Skip to contentSkip to conversation

Report missing endtags of inline files as warnings

PATCH In review Arne Schwabe 2 participants 4 messages Jun 29, 2015 – Jun 30, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Report missing endtags of inline files as warnings

---
 src/openvpn/options.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
src/openvpn/options.c +8 -1
index 74276d4..24efb59 100644
@@ -3703,10 +3703,15 @@ read_inline_file (struct in_src *is, const char *close_tag, struct gc_arena *gc)
   char line[OPTION_LINE_SIZE];
   struct buffer buf = alloc_buf (8*OPTION_LINE_SIZE);
   char *ret;
+  bool endtagfound = false;
+
   while (in_src_get (is, line, sizeof (line)))
     {
       if (!strncmp (line, close_tag, strlen (close_tag)))
-	break;
+	{
+	  endtagfound = true;
+	  break;
+	}
       if (!buf_safe (&buf, strlen(line)))
 	{
 	  /* Increase buffer size */
@@ -3718,6 +3723,8 @@ read_inline_file (struct in_src *is, const char *close_tag, struct gc_arena *gc)
 	}
       buf_printf (&buf, "%s", line);
     }
+  if (!endtagfound)
+    msg (M_WARN, "WARNING: Endtag %s missing", close_tag);
   ret = string_alloc (BSTR (&buf), gc);
   buf_clear (&buf);
   free_buf (&buf);
Signature · 1 line
2.3.2 (Apple Git-55)
#1 lore raw

Hi,

src/openvpn/options.c read_inline_file (struct in_src *is, const char *close_tag, struct gc_arena *gc) · line 3727

Quoted 5 lines · Arne Schwabe
src/openvpn/options.c +2 -0
 	}
       buf_printf (&buf, "%s", line);
     }
+  if (!endtagfound)
+    msg (M_WARN, "WARNING: Endtag %s missing", close_tag);

Generally speaking, ACK. I wonder whether this should be M_WARN or M_FATAL, though?

Tested, nicely reports the missing </key> in my test case, but then proceeds to "not do what the user intended"...

(Can't commit it anyway, as mid.gmane.org is not giving me URLs right now...)

gert

Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
                                                           //www.muc.de/~gert/
Gert Doering - Munich, Germany                             [email protected]...
fax: +49-89-35655025                        [email protected]...
#2 lore raw

Am 29.06.15 um 20:22 schrieb Gert Doering:

Quoted 8 lines

Hi,

src/openvpn/options.c read_inline_file (struct in_src *is, const char *close_tag, struct gc_arena *gc) · line 3727

Quoted 5 lines · Arne Schwabe
src/openvpn/options.c +2 -0
 	}
       buf_printf (&buf, "%s", line);
     }
+  if (!endtagfound)
+    msg (M_WARN, "WARNING: Endtag %s missing", close_tag);
Quoted 8 lines

Generally speaking, ACK. I wonder whether this should be M_WARN or M_FATAL, though?

Tested, nicely reports the missing </key> in my test case, but then proceeds to "not do what the user intended"...

(Can't commit it anyway, as mid.gmane.org is not giving me URLs right now...)

Maybe M_WARN for 2.3, M_FATAL for 2.4?

Arne

#3 lore raw
In reply to Arne Schwabe

ACK.

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

I've added a reference to trac #568 and made it M_FATAL / "ERROR:" for 2.4, while the release/2.3 patch went in "as is".

commit 68eecf76978a80bd5d88e944e4ed5e42bf2fd8e4 (master) commit 19475259c92b4747c4c9d3a3d025bdeb170e859c (release/2.3)

Author: Arne Schwabe
Date:   Mon Jun 29 14:46:35 2015 +0200
     Report missing endtags of inline files as warnings

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

--
kind regards,

Gert Doering