!40 [sync] PR-37: fix problem that caused sgdisk to crash when using the latest popt

From: @openeuler-sync-bot 
Reviewed-by: @swf504 
Signed-off-by: @swf504
This commit is contained in:
openeuler-ci-bot 2024-09-27 01:14:24 +00:00 committed by Gitee
commit 0196474eca
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 78 additions and 1 deletions

View File

@ -0,0 +1,28 @@
From 5d5e76d369a412bfb3d2cebb5fc0a7509cef878d Mon Sep 17 00:00:00 2001
From: Rod Smith <rodsmith@rodsbooks.com>
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

View File

@ -0,0 +1,43 @@
From f5de3401b974ce103ffd93af8f9d43505a04aaf9 Mon Sep 17 00:00:00 2001
From: Damian Kurek <starfire24680@gmail.com>
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

View File

@ -1,6 +1,6 @@
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
@ -8,6 +8,9 @@ Source0: http://downloads.sourceforge.net/gptfdisk/gptfdisk-%{version}.tar.gz
BuildRequires:ncurses-devel util-linux-devel gcc-c++ popt-devel
Patch0001: 0001-Fix-failure-crash-of-sgdisk-when-compiled-with-lates.patch
Patch0002: 0002-Fix-NULL-dereference-when-duplicating-string-argumen.patch
%description
GPT fdisk(consisting of the gdisk,sgdisk,cgdisk) is a set of text-mode partitioning tools.
rather than on the older MBR partition tables.
@ -48,6 +51,9 @@ install -Dp -m 0644 fixparts.8 %{buildroot}%{_mandir}/man8/fixparts.8
%{_mandir}/man8/*
%changelog
* Tue Sep 24 2024 lvyy <lyunmail@163.com> - 1.0.9-2
- DESC: fix problem that caused sgdisk to crash when using the latest popt
* Thu Dec 8 2022 tangyuchen <tangyuchen5@huawei.com> - 1.0.9-1
- update to gptfdisk-1.0.9