]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Fix commit e473b7c if an inline file happens to have a line break exactly at buffer...
authorArne Schwabe <arne@rfc2549.org>
Mon, 27 Jul 2015 15:33:11 +0000 (17:33 +0200)
committerGert Doering <gert@greenie.muc.de>
Mon, 27 Jul 2015 18:29:50 +0000 (20:29 +0200)
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>
(cherry picked from commit d40cbf0e2601b35bfb1c0551c6f3907b5c5178ff)

src/openvpn/buffer.h
src/openvpn/options.c

index 93efb0962b3b99891f35a595f8de5d9459f4f160..d306a04acd90e5b625ccf9d03345aec545bea9de 100644 (file)
@@ -308,7 +308,10 @@ has_digit (const unsigned char* src)
 }
 
 /*
- * printf append to a buffer with overflow check
+ * printf append to a buffer with overflow check,
+ * due to usage of vsnprintf, it will leave space for
+ * a final null character and thus use only
+ * capacity - 1
  */
 bool buf_printf (struct buffer *buf, const char *format, ...)
 #ifdef __GNUC__
index 99c01873fc4227700244f82a7b2fc1b6c652f81c..007bd8cec6477b7473ee236e96dec75f4164f026 100644 (file)
@@ -3766,7 +3766,7 @@ read_inline_file (struct in_src *is, const char *close_tag, struct gc_arena *gc)
          endtagfound = true;
          break;
        }
-      if (!buf_safe (&buf, strlen(line)))
+      if (!buf_safe (&buf, strlen(line)+1))
        {
          /* Increase buffer size */
          struct buffer buf2 = alloc_buf (buf.capacity * 2);