From 3ba820d2e962d18e4fde47bf7926c1e7e7d81c57 Mon Sep 17 00:00:00 2001 From: lvyy Date: Tue, 24 Sep 2024 08:50:46 +0000 Subject: [PATCH] fix problem that caused sgdisk to crash when using the latest popt --- ...h-of-sgdisk-when-compiled-with-lates.patch | 28 ++++++++++++ ...ence-when-duplicating-string-argumen.patch | 43 +++++++++++++++++++ gdisk.spec | 10 +++-- 3 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 0002-Fix-failure-crash-of-sgdisk-when-compiled-with-lates.patch create mode 100644 0003-Fix-NULL-dereference-when-duplicating-string-argumen.patch diff --git a/0002-Fix-failure-crash-of-sgdisk-when-compiled-with-lates.patch b/0002-Fix-failure-crash-of-sgdisk-when-compiled-with-lates.patch new file mode 100644 index 0000000..a220660 --- /dev/null +++ b/0002-Fix-failure-crash-of-sgdisk-when-compiled-with-lates.patch @@ -0,0 +1,28 @@ +From 5d5e76d369a412bfb3d2cebb5fc0a7509cef878d Mon Sep 17 00:00:00 2001 +From: Rod Smith +Date: Fri, 15 Apr 2022 18:10:14 -0400 +Subject: [PATCH] Fix failure & crash of sgdisk when compiled with latest popt + (commit 740; presumably eventually release 1.19) + +Conflict:no +Reference:https://sourceforge.net/p/gptfdisk/code/ci/5d5e76d369a412bfb3d2cebb5fc0a7509cef878d +--- + gptcl.cc | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) + +diff --git a/gptcl.cc b/gptcl.cc +index 34c9421..0d578eb 100644 +--- a/gptcl.cc ++++ b/gptcl.cc +@@ -155,7 +155,7 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) { + } // while + + // Assume first non-option argument is the device filename.... +- device = (char*) poptGetArg(poptCon); ++ device = strdup((char*) poptGetArg(poptCon)); + poptResetContext(poptCon); + + if (device != NULL) { +-- +2.33.0 + diff --git a/0003-Fix-NULL-dereference-when-duplicating-string-argumen.patch b/0003-Fix-NULL-dereference-when-duplicating-string-argumen.patch new file mode 100644 index 0000000..f852fc8 --- /dev/null +++ b/0003-Fix-NULL-dereference-when-duplicating-string-argumen.patch @@ -0,0 +1,43 @@ +From f5de3401b974ce103ffd93af8f9d43505a04aaf9 Mon Sep 17 00:00:00 2001 +From: Damian Kurek +Date: Thu, 7 Jul 2022 03:39:16 +0000 +Subject: [PATCH] Fix NULL dereference when duplicating string argument + +poptGetArg can return NULL if there are no additional arguments, which +makes strdup dereference NULL on strlen + +Conflict:no +Reference:https://sourceforge.net/p/gptfdisk/code/ci/f5de3401b974ce103ffd93af8f9d43505a04aaf9 +--- + gptcl.cc | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/gptcl.cc b/gptcl.cc +index 0d578eb..ab95239 100644 +--- a/gptcl.cc ++++ b/gptcl.cc +@@ -155,10 +155,11 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) { + } // while + + // Assume first non-option argument is the device filename.... +- device = strdup((char*) poptGetArg(poptCon)); +- poptResetContext(poptCon); ++ device = (char*) poptGetArg(poptCon); + + if (device != NULL) { ++ device = strdup(device); ++ poptResetContext(poptCon); + JustLooking(); // reset as necessary + BeQuiet(); // Tell called functions to be less verbose & interactive + if (LoadPartitions((string) device)) { +@@ -498,6 +499,7 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) { + cerr << "Error encountered; not saving changes.\n"; + retval = 4; + } // if ++ free(device); + } // if (device != NULL) + poptFreeContext(poptCon); + return retval; +-- +2.33.0 + diff --git a/gdisk.spec b/gdisk.spec index 2782925..0a69518 100644 --- a/gdisk.spec +++ b/gdisk.spec @@ -1,13 +1,14 @@ Name: gdisk Version: 1.0.5 -Release: 6 +Release: 7 Summary: GPT fdisk(consisting of the gdisk,sgdisk,cgdisk) is a set of text-mode partitioning tools License: GPLv2 URL: http://www.rodsbooks.com/gdisk Source0: http://downloads.sourceforge.net/gptfdisk/gptfdisk-%{version}.tar.gz -Patch1: 0001-Fix-segfault-on-some-weird-data-structures.patch - +Patch0001: 0001-Fix-segfault-on-some-weird-data-structures.patch +Patch0002: 0002-Fix-failure-crash-of-sgdisk-when-compiled-with-lates.patch +Patch0003: 0003-Fix-NULL-dereference-when-duplicating-string-argumen.patch BuildRequires:ncurses-devel util-linux-devel gcc-c++ popt-devel @@ -51,6 +52,9 @@ install -Dp -m 0644 fixparts.8 %{buildroot}%{_mandir}/man8/fixparts.8 %{_mandir}/man8/* %changelog +* Tue Sep 24 2024 lvyy - 1.0.5-7 +- DESC: fix problem that caused sgdisk to crash when using the latest popt + * Fri Jul 30 2021 chenyanpanHW - 1.0.5-6 - DESC: delete -Sgit from %autosetup, and delete BuildRequires git -- Gitee