The check does only for strlen(line) space and buf_printf will only use at
most space -1 and not print the final character ('\n') in this corner.
Since a missing \n only breaks certificates at the start and end marker,
missing line breaks otherwise do not trigger this error.
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1438011191-19389-1-git-send-email-arne@rfc2549.org>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9956
Signed-off-by: Gert Doering <gert@greenie.muc.de>
... | ... |
@@ -329,7 +329,10 @@ has_digit (const unsigned char* src) |
329 | 329 |
} |
330 | 330 |
|
331 | 331 |
/* |
332 |
- * printf append to a buffer with overflow check |
|
332 |
+ * printf append to a buffer with overflow check, |
|
333 |
+ * due to usage of vsnprintf, it will leave space for |
|
334 |
+ * a final null character and thus use only |
|
335 |
+ * capacity - 1 |
|
333 | 336 |
*/ |
334 | 337 |
bool buf_printf (struct buffer *buf, const char *format, ...) |
335 | 338 |
#ifdef __GNUC__ |
... | ... |
@@ -3712,7 +3712,7 @@ read_inline_file (struct in_src *is, const char *close_tag, struct gc_arena *gc) |
3712 | 3712 |
endtagfound = true; |
3713 | 3713 |
break; |
3714 | 3714 |
} |
3715 |
- if (!buf_safe (&buf, strlen(line))) |
|
3715 |
+ if (!buf_safe (&buf, strlen(line)+1)) |
|
3716 | 3716 |
{ |
3717 | 3717 |
/* Increase buffer size */ |
3718 | 3718 |
struct buffer buf2 = alloc_buf (buf.capacity * 2); |