2008-08-12 Dan Williams <dcbw@redhat.com>

* system-settings/plugins/ifcfg-fedora/shvar.c
	  system-settings/plugins/ifcfg-fedora/shvar.c
		- Fix double-free caused by svSetValue() followed by svCloseFile()



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3940 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Dan Williams 2008-08-12 17:47:21 +00:00
parent 7c8afe56a5
commit 1cb8b4a101
3 changed files with 13 additions and 11 deletions

View file

@ -1,3 +1,9 @@
2008-08-12 Dan Williams <dcbw@redhat.com>
* 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 <tambet@gmail.com>
* Makefile.am: Fix distcheck.

View file

@ -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);

View file

@ -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 */