diff --git a/ChangeLog b/ChangeLog index 96556157e2..7c41fdfd4b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-08-12 Dan Williams + + * system-settings/plugins/ifcfg-fedora/shvar.c + system-settings/plugins/ifcfg-fedora/shvar.c + - Fix double-free caused by svSetValue() followed by svCloseFile() + 2008-08-12 Tambet Ingo * Makefile.am: Fix distcheck. diff --git a/system-settings/plugins/ifcfg-fedora/shvar.c b/system-settings/plugins/ifcfg-fedora/shvar.c index 67b3019d48..5ecae90fcd 100644 --- a/system-settings/plugins/ifcfg-fedora/shvar.c +++ b/system-settings/plugins/ifcfg-fedora/shvar.c @@ -121,9 +121,13 @@ unescape(char *s) { len = strlen(s); if ((s[0] == '"' || s[0] == '\'') && s[0] == s[len-1]) { i = len - 2; - memmove(s, s+1, i); - s[i+1] = '\0'; - len = i; + if (i == 0) + s[0] = '\0'; + else { + memmove(s, s+1, i); + s[i+1] = '\0'; + len = i; + } } for (i = 0; i < len; i++) { if (s[i] == '\\') { @@ -291,7 +295,6 @@ svSetValue(shvarFile *s, const char *key, const char *value) /* change/append line to get key= */ if (s->current) s->current->data = keyValue; else s->lineList = g_list_append(s->lineList, keyValue); - s->freeList = g_list_append(s->freeList, keyValue); s->modified = 1; } else if (val1) { /* delete line */ @@ -307,7 +310,6 @@ svSetValue(shvarFile *s, const char *key, const char *value) if (val2 && !strcmp(val2, newval)) goto end; /* append line */ s->lineList = g_list_append(s->lineList, keyValue); - s->freeList = g_list_append(s->freeList, keyValue); s->modified = 1; goto end; } @@ -326,7 +328,6 @@ svSetValue(shvarFile *s, const char *key, const char *value) /* change line */ if (s->current) s->current->data = keyValue; else s->lineList = g_list_append(s->lineList, keyValue); - s->freeList = g_list_append(s->freeList, keyValue); s->modified = 1; } @@ -387,11 +388,7 @@ svCloseFile(shvarFile *s) if (s->fd != -1) close(s->fd); g_free(s->arena); - for (s->current = s->freeList; s->current; s->current = s->current->next) { - g_free(s->current->data); - } g_free(s->fileName); - g_list_free(s->freeList); g_list_foreach (s->lineList, (GFunc) g_free, NULL); g_list_free(s->lineList); /* implicitly frees s->current */ g_free(s); diff --git a/system-settings/plugins/ifcfg-fedora/shvar.h b/system-settings/plugins/ifcfg-fedora/shvar.h index 00e1a8e59f..e01b08d4ae 100644 --- a/system-settings/plugins/ifcfg-fedora/shvar.h +++ b/system-settings/plugins/ifcfg-fedora/shvar.h @@ -42,7 +42,6 @@ struct _shvarFile { int fd; /* read-only */ char *arena; /* ignore */ GList *lineList; /* read-only */ - GList *freeList; /* ignore */ GList *current; /* set implicitly or explicitly, points to element of lineList */ shvarFile *parent; /* set explicitly */