FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian KDE

 
 
LinkBack Thread Tools
 
Old 05-07-2010, 11:49 PM
David Cantrell
 
Default Advance line pointer & don't strdup(val) on error in readNetInfo

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@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 

Thread Tools




All times are GMT. The time now is 10:08 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org