[PATCH 2/5] Advance line pointer & don't strdup(val) on error in readNetInfo

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

 



Fix two issues in the readNetInfo() change.  First, if the line lacks an
equal sign, increment the line pointer to the next line before
continuing.  Second, if g_shell_unquote() errors, we do not want to
strdup(val) on the basis of the field, just ignore the line entirely,
log it, and continue.

Related: rhbz#522064
---
 loader/loader.c |   75 ++++++++++++++++++++++++++++---------------------------
 1 files changed, 38 insertions(+), 37 deletions(-)

diff --git a/loader/loader.c b/loader/loader.c
index a573b23..370f15b 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -674,6 +674,7 @@ static void readNetInfo(struct loaderData_s ** ld) {
 
         if (!strstr(tmp, "=")) {
             g_free(tmp);
+            line++;
             continue;
         }
 
@@ -688,44 +689,44 @@ static void readNetInfo(struct loaderData_s ** ld) {
                            "error reading %s from %s (line=%s): %s",
                            pair[0], cfgfile, tmp, e->message);
                 g_error_free(e);
-            }
-
-            if (!g_strcmp0(pair[0], "IPADDR")) {
-                loaderData->ipv4 = strdup(val);
-            } else if (!g_strcmp0(pair[0], "NETMASK")) {
-                loaderData->netmask = strdup(val);
-            } else if (!g_strcmp0(pair[0], "GATEWAY")) {
-                loaderData->gateway = strdup(val);
-            } else if (!g_strcmp0(pair[0], "DNS")) {
-                loaderData->dns = strdup(val);
-            } else if (!g_strcmp0(pair[0], "MTU")) {
-                errno = 0;
-                loaderData->mtu = strtol(val, NULL, 10);
-
-                if ((errno == ERANGE && (loaderData->mtu == LONG_MIN ||
-                                         loaderData->mtu == LONG_MAX)) ||
-                    (errno != 0 && loaderData->mtu == 0)) {
-                    logMessage(ERROR, "%s: %d: %m", __func__, __LINE__);
-                    abort();
+            } else {
+                if (!g_strcmp0(pair[0], "IPADDR")) {
+                    loaderData->ipv4 = strdup(val);
+                } else if (!g_strcmp0(pair[0], "NETMASK")) {
+                    loaderData->netmask = strdup(val);
+                } else if (!g_strcmp0(pair[0], "GATEWAY")) {
+                    loaderData->gateway = strdup(val);
+                } else if (!g_strcmp0(pair[0], "DNS")) {
+                    loaderData->dns = strdup(val);
+                } else if (!g_strcmp0(pair[0], "MTU")) {
+                    errno = 0;
+                    loaderData->mtu = strtol(val, NULL, 10);
+
+                    if ((errno == ERANGE && (loaderData->mtu == LONG_MIN ||
+                                             loaderData->mtu == LONG_MAX)) ||
+                        (errno != 0 && loaderData->mtu == 0)) {
+                        logMessage(ERROR, "%s: %d: %m", __func__, __LINE__);
+                        abort();
+                    }
+                } else if (!g_strcmp0(pair[0], "PEERID")) {
+                    loaderData->peerid = strdup(val);
+                } else if (!g_strcmp0(pair[0], "SUBCHANNELS")) {
+                    loaderData->subchannels = strdup(val);
+                } else if (!g_strcmp0(pair[0], "PORTNAME")) {
+                    loaderData->portname = strdup(val);
+                } else if (!g_strcmp0(pair[0], "NETTYPE")) {
+                    loaderData->nettype = strdup(val);
+                } else if (!g_strcmp0(pair[0], "CTCPROT")) {
+                    loaderData->ctcprot = strdup(val);
+                } else if (!g_strcmp0(pair[0], "LAYER2")) {
+                    loaderData->layer2 = strdup(val);
+                } else if (!g_strcmp0(pair[0], "PORTNO")) {
+                    loaderData->portno = strdup(val);
+                } else if (!g_strcmp0(pair[0], "MACADDR")) {
+                    loaderData->macaddr = strdup(val);
+                } else if (!g_strcmp0(pair[0], "HOSTNAME")) {
+                    loaderData->hostname = strdup(val);
                 }
-            } else if (!g_strcmp0(pair[0], "PEERID")) {
-                loaderData->peerid = strdup(val);
-            } else if (!g_strcmp0(pair[0], "SUBCHANNELS")) {
-                loaderData->subchannels = strdup(val);
-            } else if (!g_strcmp0(pair[0], "PORTNAME")) {
-                loaderData->portname = strdup(val);
-            } else if (!g_strcmp0(pair[0], "NETTYPE")) {
-                loaderData->nettype = strdup(val);
-            } else if (!g_strcmp0(pair[0], "CTCPROT")) {
-                loaderData->ctcprot = strdup(val);
-            } else if (!g_strcmp0(pair[0], "LAYER2")) {
-                loaderData->layer2 = strdup(val);
-            } else if (!g_strcmp0(pair[0], "PORTNO")) {
-                loaderData->portno = strdup(val);
-            } else if (!g_strcmp0(pair[0], "MACADDR")) {
-                loaderData->macaddr = strdup(val);
-            } else if (!g_strcmp0(pair[0], "HOSTNAME")) {
-                loaderData->hostname = strdup(val);
             }
 
             g_free(val);
-- 
1.6.6.1

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux