From fc71bd8bc73f45126f678823befac6a12f0e2d63 Mon Sep 17 00:00:00 2001 From: binlingyu Date: Mon, 20 May 2024 14:51:42 +0800 Subject: [PATCH 1/5] fix memory leak (cherry picked from commit 7ccf9f11b9a5198537b351971525fbc86f8ffad8) --- fix-memory-leak.patch | 45 +++++++++++++++++++++++++++++++++++++++++++ hostname.spec | 6 +++++- 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 fix-memory-leak.patch diff --git a/fix-memory-leak.patch b/fix-memory-leak.patch new file mode 100644 index 0000000..e8a358c --- /dev/null +++ b/fix-memory-leak.patch @@ -0,0 +1,45 @@ +From 57ae819cc495ef2b3d9b23d44a3e54c2f217b75b Mon Sep 17 00:00:00 2001 +From: binlingyu +Date: Fri, 17 May 2024 09:46:54 +0800 +Subject: [PATCH] Fix memory leak + +--- + hostname.c | 13 ++++++++++--- + 1 file changed, 10 insertions(+), 3 deletions(-) + +diff --git a/hostname.c b/hostname.c +index 10c0a67..1501e9e 100644 +--- a/hostname.c ++++ b/hostname.c +@@ -261,18 +261,25 @@ show_name(enum type_t type) + switch(type) + { + case DEFAULT: +- printf("%s\n", localhost()); ++ p=localhost(); ++ printf("%s\n", p); ++ free(p); + break; + case SHORT: + p = localhost(); + *(strchrnul(p, '.')) = '\0'; + printf("%s\n", p); ++ free(p); + break; + case NIS: +- printf("%s\n", localdomain()); ++ p=localdomain(); ++ printf("%s\n", p); ++ free(p); + break; + case NIS_DEF: +- printf("%s\n", localnisdomain()); ++ p=localnisdomain(); ++ printf("%s\n", p); ++ free(p); + break; + case ALL_IPS: + case ALL_FQDNS: { +-- +2.20.1 + diff --git a/hostname.spec b/hostname.spec index 16be3df..3acd7ca 100644 --- a/hostname.spec +++ b/hostname.spec @@ -1,7 +1,7 @@ Summary: Utility to set/show the host name or domain name Name: hostname Version: 3.23 -Release: 1 +Release: 2 License: GPLv2+ URL: http://packages.qa.debian.org/h/hostname.html Source0: http://ftp.de.debian.org/debian/pool/main/h/hostname/hostname_%{version}.tar.gz @@ -9,6 +9,7 @@ Source1: https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt Source2: nis-domainname Source3: nis-domainname.service Patch1: hostname-rh.patch +Patch2: fix-memory-leak.patch BuildRequires: gcc @@ -50,6 +51,9 @@ fi %{_libexecdir}/%{name}/* %changelog +* Mon May 20 2024 binlingyu - 3.23-2 +- fix:add fix-memory-leak.patch + * Sat Oct 29 2022 zhouyihang - 3.23-1 - Type:requirement - ID:NA -- Gitee From c65a28d29ed9b71d472d15ad96bf0f86129a0ffc Mon Sep 17 00:00:00 2001 From: binlingyu Date: Mon, 20 May 2024 07:16:05 +0000 Subject: [PATCH 2/5] update hostname.spec. Signed-off-by: binlingyu (cherry picked from commit 4294445fd4339f7a5864b5522224899170a3ad5e) --- hostname.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hostname.spec b/hostname.spec index 3acd7ca..578d5f5 100644 --- a/hostname.spec +++ b/hostname.spec @@ -9,7 +9,7 @@ Source1: https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt Source2: nis-domainname Source3: nis-domainname.service Patch1: hostname-rh.patch -Patch2: fix-memory-leak.patch +Patch2: 5000-fix-memory-leak.patch BuildRequires: gcc @@ -52,7 +52,7 @@ fi %changelog * Mon May 20 2024 binlingyu - 3.23-2 -- fix:add fix-memory-leak.patch +- fix:add 5000-fix-memory-leak.patch * Sat Oct 29 2022 zhouyihang - 3.23-1 - Type:requirement -- Gitee From c240430efab161165d78a6e8a3e55217ccaa763a Mon Sep 17 00:00:00 2001 From: binlingyu Date: Mon, 20 May 2024 07:16:22 +0000 Subject: [PATCH 3/5] =?UTF-8?q?=E9=87=8D=E5=91=BD=E5=90=8D=20fix-memory-le?= =?UTF-8?q?ak.patch=20=E4=B8=BA=205000-fix-memory-leak.patch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit b2908d822c599b725fc54656d5ae5e4a20241acf) --- fix-memory-leak.patch => 5000-fix-memory-leak.patch | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename fix-memory-leak.patch => 5000-fix-memory-leak.patch (100%) diff --git a/fix-memory-leak.patch b/5000-fix-memory-leak.patch similarity index 100% rename from fix-memory-leak.patch rename to 5000-fix-memory-leak.patch -- Gitee From fc3e9a07b792e28e2aa05e91e9dd6a01ffd1d1fe Mon Sep 17 00:00:00 2001 From: binlingyu Date: Mon, 20 May 2024 08:27:35 +0000 Subject: [PATCH 4/5] update 5000-fix-memory-leak.patch. Signed-off-by: binlingyu (cherry picked from commit 25f309e4da41707bb1e2c882e4d8d314a63c15bc) --- 5000-fix-memory-leak.patch | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/5000-fix-memory-leak.patch b/5000-fix-memory-leak.patch index e8a358c..36efaac 100644 --- a/5000-fix-memory-leak.patch +++ b/5000-fix-memory-leak.patch @@ -1,17 +1,17 @@ -From 57ae819cc495ef2b3d9b23d44a3e54c2f217b75b Mon Sep 17 00:00:00 2001 +From ddacb22dac891332c759293ab6297090216b121b Mon Sep 17 00:00:00 2001 From: binlingyu -Date: Fri, 17 May 2024 09:46:54 +0800 -Subject: [PATCH] Fix memory leak +Date: Mon, 20 May 2024 16:24:12 +0800 +Subject: [PATCH] fix-memory-leak --- - hostname.c | 13 ++++++++++--- - 1 file changed, 10 insertions(+), 3 deletions(-) + hostname.c | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hostname.c b/hostname.c -index 10c0a67..1501e9e 100644 +index 5be268e..63200be 100644 --- a/hostname.c +++ b/hostname.c -@@ -261,18 +261,25 @@ show_name(enum type_t type) +@@ -262,15 +262,20 @@ show_name(enum type_t type) switch(type) { case DEFAULT: @@ -33,13 +33,6 @@ index 10c0a67..1501e9e 100644 + free(p); break; case NIS_DEF: -- printf("%s\n", localnisdomain()); -+ p=localnisdomain(); -+ printf("%s\n", p); -+ free(p); - break; - case ALL_IPS: - case ALL_FQDNS: { + printf("%s\n", localnisdomain()); -- -2.20.1 - +2.20.1 \ No newline at end of file -- Gitee From 52b7a36833c582b090e9c1f3ef02c497c77cc935 Mon Sep 17 00:00:00 2001 From: binlingyu Date: Mon, 27 May 2024 09:27:39 +0000 Subject: [PATCH 5/5] update hostname.spec. Signed-off-by: binlingyu (cherry picked from commit 45c41445a3f0d7317c2347cc8b9b57290797dbe7) --- hostname.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hostname.spec b/hostname.spec index 578d5f5..e133beb 100644 --- a/hostname.spec +++ b/hostname.spec @@ -52,7 +52,10 @@ fi %changelog * Mon May 20 2024 binlingyu - 3.23-2 -- fix:add 5000-fix-memory-leak.patch +- Type:requirement +- ID:NA +- SUG:NA +- DESC:Fix memory leak. * Sat Oct 29 2022 zhouyihang - 3.23-1 - Type:requirement -- Gitee