[Openvpn-devel,v3] pull-filter: ignore leading "spaces" in option names

Message ID 20221130105502.662374-1-selva.nair@gmail.com
State Accepted
Headers show
Series [Openvpn-devel,v3] pull-filter: ignore leading "spaces" in option names | expand

Commit Message

Selva Nair Nov. 30, 2022, 10:55 a.m. UTC
From: Selva Nair <selva.nair@gmail.com>

It seems sometimes comma-separated pulled options have
an offending leading space. Not sure whether that is an error,
but the change here matches the behaviour of option parsing.

v2: fix typo in commit message
v3: space() --> isspace()

Signed-off-by: Selva Nair <selva.nair@gmail.com>
---
 src/openvpn/options.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Gert Doering Nov. 30, 2022, 12:35 p.m. UTC | #1
Acked-by: Gert Doering <gert@greenie.muc.de>

I thought we might not need it, but Arne says it's useful, and it's
really trivial and not adding much code.  *line is a local variable,
so it can't have side effects, and isspace(*line) is "end of string"-safe
as well.

Tested, of course, to a server that still had the extra blank

$ openvpn --pull-filter ignore auth-token ...

without the patch:

2022-11-30 13:10:41 PUSH: Received control message: 'PUSH_REPLY, auth-tokenSESS_ID'
2022-11-30 13:11:37 PUSH: Received control message: 'PUSH_REPLY, auth-tokenSESS_ID'

with the patch:

2022-11-30 13:21:02 PUSH: Received control message: 'PUSH_REPLY, auth-tokenSESS_ID'
2022-11-30 13:21:02 Pushed option removed by filter: 'auth-token SESS_ID_...
2022-11-30 13:21:59 PUSH: Received control message: 'PUSH_REPLY, auth-tokenSESS_ID'
2022-11-30 13:21:59 Pushed option removed by filter: 'auth-token SESS_ID_...


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

commit f02946ff9900a37dd36f61748173d53eca01adf9 (master)
commit 00952a6184da0a77fbabe801d842a7546058f6c2 (release/2.5)
Author: Selva Nair
Date:   Wed Nov 30 05:55:02 2022 -0500

     pull-filter: ignore leading spaces in option names

     Signed-off-by: Selva Nair <selva.nair@gmail.com>
     Acked-by: Gert Doering <gert@greenie.muc.de>
     Message-Id: <20221130105502.662374-1-selva.nair@gmail.com>
     URL: https://www.mail-archive.com/search?l=mid&q=20221130105502.662374-1-selva.nair@gmail.com
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering

Patch

diff --git a/src/openvpn/options.c b/src/openvpn/options.c
index b7b34c9c..cba99846 100644
--- a/src/openvpn/options.c
+++ b/src/openvpn/options.c
@@ -5385,6 +5385,12 @@  apply_pull_filter(const struct options *o, char *line)
         return true;
     }
 
+    /* skip leading spaces matching the behaviour of parse_line */
+    while(isspace(*line))
+    {
+        line++;
+    }
+
     for (f = o->pull_filter_list->head; f; f = f->next)
     {
         if (f->type == PUF_TYPE_ACCEPT && strncmp(line, f->pattern, f->size) == 0)