[Openvpn-devel,v3] Ignore leading whitespace and comment lines for peer-fingerprint.

Message ID 20210519133415.28627-1-gert@greenie.muc.de
State Accepted
Headers show
Series
  • [Openvpn-devel,v3] Ignore leading whitespace and comment lines for peer-fingerprint.
Related show

Commit Message

Gert Doering May 19, 2021, 1:34 p.m.
Inline peer-fingerprint blocks can benefit from a bit of structuring
by indentation or by putting comments ("# this is Alice's key").

v2: accept ';' and '#' as comment delimiter.  Fix tab-indent.
v3: we want ==

Signed-off-by: Gert Doering <gert@greenie.muc.de>
---
 src/openvpn/options.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Selva Nair May 19, 2021, 2:05 p.m. | #1
Hi

On Wed, May 19, 2021 at 9:35 AM Gert Doering <gert@greenie.muc.de> wrote:
>
> Inline peer-fingerprint blocks can benefit from a bit of structuring
> by indentation or by putting comments ("# this is Alice's key").
>
> v2: accept ';' and '#' as comment delimiter.  Fix tab-indent.
> v3: we want ==
>
> Signed-off-by: Gert Doering <gert@greenie.muc.de>
> ---
>  src/openvpn/options.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/src/openvpn/options.c b/src/openvpn/options.c
> index db460796..5a6f37d7 100644
> --- a/src/openvpn/options.c
> +++ b/src/openvpn/options.c
> @@ -1145,8 +1145,13 @@ parse_hash_fingerprint_multiline(const char *str, int nbytes, int msglevel,
>      const char *line;
>      while ((line = strsep(&lines, "\n")))
>      {
> -        /* skip empty lines */
> -        if (strlen(line) == 0)
> +        /* ignore leading whitespace */
> +        while(isspace(*line))
> +        {
> +            line++;
> +        }
> +        /* skip empty lines and comment lines */
> +        if (strlen(line) == 0 || *line == '#' || *line == ';')
>          {
>              continue;
>          }

I haven't tested it, but looks good to me.

Acked-by: selva.nair@gmail.com
Gert Doering May 19, 2021, 2:47 p.m. | #2
Patch has been applied to the master branch.

commit de78371ab83f7d533d65ccf966684e31b57d953f
Author: Gert Doering
Date:   Wed May 19 15:34:15 2021 +0200

     Ignore leading whitespace and comment lines for peer-fingerprint.

     Signed-off-by: Gert Doering <gert@greenie.muc.de>
     Acked-by: Selva Nair <selva.nair@gmail.com>
     Message-Id: <20210519133415.28627-1-gert@greenie.muc.de>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22404.html
     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 db460796..5a6f37d7 100644
--- a/src/openvpn/options.c
+++ b/src/openvpn/options.c
@@ -1145,8 +1145,13 @@  parse_hash_fingerprint_multiline(const char *str, int nbytes, int msglevel,
     const char *line;
     while ((line = strsep(&lines, "\n")))
     {
-        /* skip empty lines */
-        if (strlen(line) == 0)
+        /* ignore leading whitespace */
+        while(isspace(*line))
+        {
+            line++;
+        }
+        /* skip empty lines and comment lines */
+        if (strlen(line) == 0 || *line == '#' || *line == ';')
         {
             continue;
         }