summaryrefslogtreecommitdiff
path: root/src/dns
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-09-21 13:09:02 +0200
committerThomas Haller <thaller@redhat.com>2018-09-21 13:12:05 +0200
commit511709c54df5ecdc96453cb8af9796a54d901aa8 (patch)
tree00f2631bf1a5cc24fc150cebae3c6ba9c5a5e41b /src/dns
parent0ce73275506e8d3156b8d3cd9ca7a1105c5dc4fb (diff)
downloadNetworkManager-511709c54df5ecdc96453cb8af9796a54d901aa8.tar.gz
dns: fix creating resolv.conf content
g_string_new_len() allocates the buffer with length bytes. Maybe it should be obvious (wasn't to me), but if a init argument is given, that is taken as containing length bytes. So, str = g_string_new_len (init, len); is more like str = g_string_new_len (NULL, len); g_string_append_len (str, init, len); and not (how I wrongly thought) str = g_string_new_len (NULL, len); g_string_append (str, init); Fixes: 95b006c244978fecec9463690477e8b64f743202
Diffstat (limited to 'src/dns')
-rw-r--r--src/dns/nm-dns-manager.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/dns/nm-dns-manager.c b/src/dns/nm-dns-manager.c
index 62ea02b755..a8dc0413d4 100644
--- a/src/dns/nm-dns-manager.c
+++ b/src/dns/nm-dns-manager.c
@@ -589,7 +589,9 @@ create_resolv_conf (char **searches,
GString *str;
gsize i;
- str = g_string_new_len ("# Generated by NetworkManager\n", 245);
+ str = g_string_new_len (NULL, 245);
+
+ g_string_append (str, "# Generated by NetworkManager\n");
if (searches && searches[0]) {
g_string_append (str, "search");