[network-manager-openvpn/bg/inline-cert-fixes-bgo760746: 3/3] import: skip empty lines while importing inline certificates
- From: Beniamino Galvani <bgalvani src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-openvpn/bg/inline-cert-fixes-bgo760746: 3/3] import: skip empty lines while importing inline certificates
- Date: Mon, 18 Jan 2016 22:38:10 +0000 (UTC)
commit 284bd04e8e058613cc8470a817c184a94617cfe0
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.
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 d6e54d5..d624b52 100644
--- a/properties/import-export.c
+++ b/properties/import-export.c
@@ -216,6 +216,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;
@@ -239,7 +248,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;
@@ -247,18 +256,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]