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

Message ID 20210519055808.11861-1-gert@greenie.muc.de
State Changes Requested
Headers show
Series [Openvpn-devel,v2] Ignore leading whitespace and comment lines for peer-fingerprint. | expand

Commit Message

Gert Doering May 18, 2021, 7:58 p.m. UTC
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.

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, 3:26 a.m. UTC | #1
Hi,

On Wed, May 19, 2021 at 1:58 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.
>
> 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..037454f7 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 = ';')

We want ==  :)

Selva

Patch

diff --git a/src/openvpn/options.c b/src/openvpn/options.c
index db460796..037454f7 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;
         }