recipes: networking/ineutils: Apply patches from Debian in order to refresh this...
[dragora.git] / patches / inetutils / 0026-src-hostname.c-parse_file-Free-name-and-allocate-one.patch
blobfc332c921d113a45a292389d9bfd6f985bf4b51a
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
5 extra byte for it.
7 ---
8 ChangeLog | 5 +++++
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
14 --- a/ChangeLog
15 +++ b/ChangeLog
16 @@ -1,3 +1,8 @@
17 +2017-07-10 Omer Anson <oaanson@gmail.com> (tiny change)
19 + * src/hostname.c (parse_file): Free name and allocate one extra
20 + byte for it.
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
27 --- a/src/hostname.c
28 +++ b/src/hostname.c
29 @@ -410,9 +410,11 @@ parse_file (const char *const file_name)
31 if (buffer[0] != '#')
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)
37 break;
38 + free (name);
39 + name = NULL;
42 while (feof (file) == 0);
43 --
44 2.26.0.292.g33ef6b2f38