From 511709c54df5ecdc96453cb8af9796a54d901aa8 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 21 Sep 2018 13:09:02 +0200 Subject: [PATCH] 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 --- src/dns/nm-dns-manager.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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");