[network-manager-openvpn/nm-1-0: 3/4] import: skip empty lines while importing inline certificates



commit ff54cd58409fc1d62b83df529b39a7991398b200
Author: Beniamino Galvani <bgalvani redhat com>
Date:   Mon Jan 18 16:39:52 2016 +0100

    import: skip empty lines while importing inline certificates
    
    Skip empty lines between tags and certificates.
    
    (cherry picked from commit 887c44b48171149312c45f6406077d34487c8e66)

 properties/import-export.c |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)
---
diff --git a/properties/import-export.c b/properties/import-export.c
index e63cb81..a375ea4 100644
--- a/properties/import-export.c
+++ b/properties/import-export.c
@@ -188,6 +188,15 @@ handle_blob_item (const char ***line,
        GString *in_file = NULL;
        const char **p;
 
+#define NEXT_LINE \
+       G_STMT_START { \
+               do { \
+                       p++; \
+                       if (!*p) \
+                               goto finish; \
+               } while (!*p[0]); \
+       } G_STMT_END
+
        if (!strcmp (key, NM_OPENVPN_KEY_CA)) {
                start_tag = CA_BLOB_START_TAG;
                end_tag = CA_BLOB_END_TAG;
@@ -211,7 +220,7 @@ handle_blob_item (const char ***line,
        p = *line;
        if (strncmp (*p, start_tag, strlen (start_tag)))
                goto finish;
-       p++;
+       NEXT_LINE;
 
        if (blob_mark_start2 && !strcmp (*p, blob_mark_start2)) {
                blob_mark_start = blob_mark_start2;
@@ -219,18 +228,18 @@ handle_blob_item (const char ***line,
        } else if (strcmp (*p, blob_mark_start))
                goto finish;
 
-       p++;
-
+       NEXT_LINE;
        in_file = g_string_new (NULL);
 
        while (*p && strcmp (*p, blob_mark_end)) {
                g_string_append (in_file, *p);
                g_string_append_c (in_file, '\n');
-               p++;
+               NEXT_LINE;
        }
-       if (!*p || strncmp (*(p+1), end_tag, strlen (end_tag)))
+
+       NEXT_LINE;
+       if (strncmp (*p, end_tag, strlen (end_tag)))
                goto finish;
-       p++;
 
        /* Construct file name to write the data in */
        filename = g_strdup_printf ("%s-%s.pem", name, key);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]