db-move: moved xdg-desktop-portal-gnome from [testing] to [extra] (x86_64)
[arch-packages.git] / gptfdisk / repos / extra-x86_64 / popt-1.19-follow-up.patch
blob3cee7cc3597afc79ba317fbf1651291c756f5840
1 From f5de3401b974ce103ffd93af8f9d43505a04aaf9 Mon Sep 17 00:00:00 2001
2 From: Damian Kurek <starfire24680@gmail.com>
3 Date: Thu, 7 Jul 2022 03:39:16 +0000
4 Subject: [PATCH] Fix NULL dereference when duplicating string argument
6 poptGetArg can return NULL if there are no additional arguments, which
7 makes strdup dereference NULL on strlen
8 ---
9 gptcl.cc | 6 ++++--
10 1 file changed, 4 insertions(+), 2 deletions(-)
12 diff --git a/gptcl.cc b/gptcl.cc
13 index 0d578eb..ab95239 100644
14 --- a/gptcl.cc
15 +++ b/gptcl.cc
16 @@ -155,10 +155,11 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) {
17 } // while
19 // Assume first non-option argument is the device filename....
20 - device = strdup((char*) poptGetArg(poptCon));
21 - poptResetContext(poptCon);
22 + device = (char*) poptGetArg(poptCon);
24 if (device != NULL) {
25 + device = strdup(device);
26 + poptResetContext(poptCon);
27 JustLooking(); // reset as necessary
28 BeQuiet(); // Tell called functions to be less verbose & interactive
29 if (LoadPartitions((string) device)) {
30 @@ -498,6 +499,7 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) {
31 cerr << "Error encountered; not saving changes.\n";
32 retval = 4;
33 } // if
34 + free(device);
35 } // if (device != NULL)
36 poptFreeContext(poptCon);
37 return retval;