main/gptfdisk: Fix null dereference and enable tests

This commit is contained in:
Damian Kurek 2022-07-07 00:32:39 +02:00 committed by alice
parent fcf58b92f2
commit a375ef4c2a
2 changed files with 45 additions and 2 deletions

View File

@ -0,0 +1,38 @@
From fb181ca613329886f017bbf0129108eafd01fe0f Mon Sep 17 00:00:00 2001
From: Damian Kurek <starfire24680@gmail.com>
Date: Wed, 6 Jul 2022 22:23:58 +0000
Subject: [PATCH 1/1] Fix NULL dereference when duplicating string argument
---
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.35.1

View File

@ -1,11 +1,10 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=gptfdisk
pkgver=1.0.9
pkgrel=1
pkgrel=2
pkgdesc="Text-mode partitioning tool that works on Globally Unique Identifier (GUID) Partition Table (GPT) disks"
arch="all"
url="https://www.rodsbooks.com/gdisk"
options="!check" # No test suite.
license="GPL-2.0-or-later"
makedepends="ncurses-dev e2fsprogs-dev popt-dev linux-headers"
subpackages="$pkgname-doc sgdisk"
@ -13,6 +12,7 @@ source="https://downloads.sourceforge.net/project/gptfdisk/gptfdisk/$pkgver/gptf
fix-wrong-include.patch
0001-Fix-failure-crash-of-sgdisk-when-compiled-with-lates.patch
0002-Updated-guid.cc-to-deal-with-minor-change-in-libuuid.patch
0003-Fix-NULL-dereference-when-duplicating-string-argumen.patch
"
# secfixes:
# 1.0.6-r0:
@ -31,6 +31,10 @@ package() {
done
}
check() {
sh "$builddir"/gdisk_test.sh
}
sgdisk() {
pkgdesc="Command-line GUID partition table (GPT) manipulator"
mkdir -p "$subpkgdir"/usr/bin
@ -42,4 +46,5 @@ c2489ac7e196cb53b9fdb18d0e421571eca43c366de8922c5c7f550aadf192558e7af69b181c3074
9b64c0e565137b4d4275bd6e8b050f98a73ff5593093b54d43736e6aabd24abf6e35d88ea27be17c5fee70aada4ad05a70fe5af3523212aad114f05aaf82356f fix-wrong-include.patch
ebd680343cd7f559503156984f056f4b49cc3581c8c7f623c66c10bb79e1dd7ee9e217cbd0479ebe3b7bce3b34b85428bc3525aa354b76789e9bcbaf1000a889 0001-Fix-failure-crash-of-sgdisk-when-compiled-with-lates.patch
fd2747714f854a2abaa5cbd113a9bf9eea3d8ee6c46e47dbe3246c9d3bebb621a2a7bc623827f6f44870133eb09b5b991ea73d03755fa0e2b9d73c5cea821f33 0002-Updated-guid.cc-to-deal-with-minor-change-in-libuuid.patch
f1d3b1d43490665dbe2b024027b12803ec73698dc232335fd87813ffb940202032c8f47c3410190a00d16382a2ceb35effc1f825ca87f6a0cd3dad564bb751af 0003-Fix-NULL-dereference-when-duplicating-string-argumen.patch
"