Skip to contentSkip to conversation

Detect config lines that are too long and give a warning/error

PATCH In review Arne Schwabe 2 participants 2 messages Dec 10, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Detect config lines that are too long and give a warning/error

This closes Trac ticket 631

---
 src/openvpn/options.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
src/openvpn/options.c +5 -1
index 4347525..be4ba52 100644
@@ -3798,7 +3798,7 @@ read_config_file (struct options *options,
   const int max_recursive_levels = 10;
   FILE *fp;
   int line_num;
-  char line[OPTION_LINE_SIZE];
+  char line[OPTION_LINE_SIZE+1];
   char *p[MAX_PARMS];
 
   ++level;
@@ -3816,6 +3816,10 @@ read_config_file (struct options *options,
               int offset = 0;
 	      CLEAR (p);
 	      ++line_num;
+          if (strlen(line) == OPTION_LINE_SIZE)
+              msg (msglevel, "In %s:%d: Maximum optione line length (%d) exceeded, line starts with %s",
+                   file, line_num, OPTION_LINE_SIZE, line);
+
               /* Ignore UTF-8 BOM at start of stream */
               if (line_num == 1 && strncmp (line, "\xEF\xBB\xBF", 3) == 0)
                 offset = 3;
Signature · 1 line
2.5.4 (Apple Git-61)
#1 lore raw

ACK. Thanks.

Your patch has been applied to the master and release/2.3 branch.

commit 4baec3ee10b8d6826d5f076a9832a92a5cfe3676 (master) commit 305c16c28d0ce7bc48c6e0abb18653241ddb910b (release/2.3)

Author: Arne Schwabe
Date:   Thu Dec 10 13:37:10 2015 +0100
     Detect config lines that are too long and give a warning/error

     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: http://article.gmane.org/gmane.network.openvpn.devel/10723
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering