1 From cfbc55d15ae84e43e5c5b71b5ecde2555f1b1ac8 Mon Sep 17 00:00:00 2001
2 From: "Alfred M. Szmidt" <ams@gnu.org>
3 Date: Mon, 10 Jul 2017 20:14:58 +0000
4 Subject: [PATCH 26/60] src/hostname.c (parse_file): Free name and allocate one
9 src/hostname.c | 6 ++++--
10 2 files changed, 9 insertions(+), 2 deletions(-)
12 diff --git a/ChangeLog b/ChangeLog
13 index 289a6e9f..64e8dad8 100644
17 +2017-07-10 Omer Anson <oaanson@gmail.com> (tiny change)
19 + * src/hostname.c (parse_file): Free name and allocate one extra
22 2017-07-10 Omer Anson <oaanson@gmail.com> (tiny change)
24 * src/hostname.c (set_name): Handle case when hostname_new is
25 diff --git a/src/hostname.c b/src/hostname.c
26 index d1f584f8..e340f8fd 100644
29 @@ -410,9 +410,11 @@ parse_file (const char *const file_name)
33 - name = (char *) xmalloc (sizeof (char) * nread);
34 - if (sscanf (buffer, "%s", name) == 1)
35 + name = (char *) xmalloc (sizeof (char) * (nread + 1));
36 + if (sscanf (buffer, "%s", name) == 1)
42 while (feof (file) == 0);
44 2.26.0.292.g33ef6b2f38