Skip to contentSkip to conversation

When parsing "--setenv opt xx .." make sure a third parameter is present

PATCH In review Selva Nair 2 participants 2 messages Nov 30, 2016

lore
Share & tools
lore

Selva Nair

author
#0 lore raw

PATCH 1/1 When parsing "--setenv opt xx .." make sure a third parameter is present

When no parameters are present, set it to "setenv opt" to trigger a descriptive error message. And, thus get rid of the pesky NULL pointer dereferencing.

Resolves Trac 779

---
 src/openvpn/options.c | 2 ++
 1 file changed, 2 insertions(+)
src/openvpn/options.c +2 -0
index c540e05..d4ee340 100644
@@ -4425,6 +4425,8 @@ add_option (struct options *options,
    */
   if (streq (p[0], "setenv") && p[1] && streq (p[1], "opt") && !(permission_mask & OPT_P_PULL_MODE))
     {
+      if (!p[2])
+        p[2] = "setenv opt"; /* will trigger an error that includes setenv opt */
       p += 2;
       msglevel_fc = M_WARN;
     }
Signature · 1 line
2.1.4
#1 lore raw

[Openvpn-devel] [PATCH applied] Re: When parsing '--setenv opt xx ..' make sure a third parameter is present

ACK, thanks.

(I thought "just checking for ...&& p[2] && ..." would be nicer, but then it falls through and just silently setenv-s "opt" to "empty", which is not the intent...)

I have changed the reference to the Trac ticket to the newly-agreed-upon (yesterday on IRC) standard format, which is

Trac: #799

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

commit 997795353916ffcb413a2da02dc7f210fd621954 (master) commit 290cc3f8d50435a6ed5f2cb1ecd9056dadcc4783 (release/2.3)

Author: Selva Nair
Date:   Tue Nov 29 20:53:14 2016 -0500
     When parsing '--setenv opt xx ..' make sure a third parameter is present

     Signed-off-by: Selva Nair <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg13311.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering