summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2013-12-13 20:12:57 +0100
committerThomas Haller <thaller@redhat.com>2013-12-13 20:49:27 +0100
commitbb9deec9ef98ede632e69f8e5a6e017070f714a8 (patch)
tree5d963aafabe2f47c2102a67c4abd72e9610f794e
parent1f719729987ed8d445fdb841b3adc69829152be8 (diff)
downloadNetworkManager-bb9deec9ef98ede632e69f8e5a6e017070f714a8.tar.gz
core: fix NMDevice.ip6_use_tempaddr to avoid buffer overrun for zero char in config file
Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r--src/devices/nm-device.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 1c1497a4c4..c1c7c69d69 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -3432,7 +3432,6 @@ static int
ip6_use_tempaddr (void)
{
char *contents = NULL;
- gsize len = 0;
const char *group_name = "[forged_group]\n";
char *sysctl_data = NULL;
GKeyFile *keyfile;
@@ -3440,15 +3439,15 @@ ip6_use_tempaddr (void)
int tmp, ret = -1;
/* Read file contents to a string. */
- if (!g_file_get_contents ("/etc/sysctl.conf", &contents, &len, NULL))
- if (!g_file_get_contents ("/lib/sysctl.d/sysctl.conf", &contents, &len, NULL))
+ if (!g_file_get_contents ("/etc/sysctl.conf", &contents, NULL, NULL))
+ if (!g_file_get_contents ("/lib/sysctl.d/sysctl.conf", &contents, NULL, NULL))
return -1;
/* Prepend a group so that we can use GKeyFile parser. */
sysctl_data = g_strdup_printf ("%s%s", group_name, contents);
keyfile = g_key_file_new ();
- if (!g_key_file_load_from_data (keyfile, sysctl_data, len + strlen (group_name), G_KEY_FILE_NONE, NULL))
+ if (!g_key_file_load_from_data (keyfile, sysctl_data, -1, G_KEY_FILE_NONE, NULL))
goto done;
tmp = g_key_file_get_integer (keyfile, "forged_group", "net.ipv6.conf.default.use_tempaddr", &error);