diff --git a/0001-Fix-NULL-dereference-when-duplicating-string-argumen.patch b/0001-Fix-NULL-dereference-when-duplicating-string-argumen.patch new file mode 100644 index 0000000000000000000000000000000000000000..1a36587fb502ee6924ece7ae98462a23c815384e --- /dev/null +++ b/0001-Fix-NULL-dereference-when-duplicating-string-argumen.patch @@ -0,0 +1,38 @@ +From f5de3401b974ce103ffd93af8f9d43505a04aaf9 +From: Damian Kurek +Date: Thu Jul 7 03:39:16 2022 +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 +--- + gptcl.cc | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/gptcl.cc b/gptcl.cc +index 34c9421..ab95239 100644 +--- a/gptcl.cc ++++ b/gptcl.cc +@@ -156,9 +156,10 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) { + + // Assume first non-option argument is the device filename.... + device = (char*) poptGetArg(poptCon); +- poptResetContext(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.27.0 + diff --git a/gdisk.spec b/gdisk.spec index bc7cbe4ffe3084a20666cbbb1e27ec03a7aac6c3..e64104c1bad560df6044dc39bcd6f34cbcba4d12 100644 --- a/gdisk.spec +++ b/gdisk.spec @@ -1,11 +1,13 @@ Name: gdisk Version: 1.0.9 -Release: 1 +Release: 2 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-NULL-dereference-when-duplicating-string-argumen.patch + BuildRequires:ncurses-devel util-linux-devel gcc-c++ popt-devel %description @@ -48,6 +50,9 @@ install -Dp -m 0644 fixparts.8 %{buildroot}%{_mandir}/man8/fixparts.8 %{_mandir}/man8/* %changelog +* Fri Jun 28 2024 kouwenqi - 1.0.9-2 +- Fix NULL dereference when duplicating string argument + * Thu Dec 8 2022 tangyuchen - 1.0.9-1 - update to gptfdisk-1.0.9