about summary refs log tree commit diff
path: root/pkgs/tools/system/gptfdisk/popt-1-19.patch
blob: 234c664c962cdbb4d9b1506be73750c02a11ab3b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
commit 5d5e76d369a412bfb3d2cebb5fc0a7509cef878d
Author: Rod Smith <rodsmith@rodsbooks.com>
Date:   Fri Apr 15 18:10:14 2022 -0400

    Fix failure & crash of sgdisk when compiled with latest popt (commit 740; presumably eventually release 1.19)

diff --git a/NEWS b/NEWS
index c7add56..9e153fd 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,11 @@
+1.0.10 (?/??/2022):
+-------------------
+
+- Fixed problem that caused sgdisk to crash with errors about being unable
+  to read the disk's partition table when compiled with the latest popt
+  (commit 740, which is pre-release as I type; presumably version 1.19 and
+  later once released).
+
 1.0.9 (4/14/2022):
 ------------------
 
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) {
diff --git a/support.h b/support.h
index 8ba9ad1..f91f1bc 100644
--- a/support.h
+++ b/support.h
@@ -8,7 +8,7 @@
 #include <stdlib.h>
 #include <string>
 
-#define GPTFDISK_VERSION "1.0.9"
+#define GPTFDISK_VERSION "1.0.9.1"
 
 #if defined (__FreeBSD__) || defined (__FreeBSD_kernel__) || defined (__APPLE__)
 // Darwin (Mac OS) & FreeBSD: disk IOCTLs are different, and there is no lseek64

commit f5de3401b974ce103ffd93af8f9d43505a04aaf9
Author: Damian Kurek <starfire24680@gmail.com>
Date:   Thu Jul 7 03:39:16 2022 +0000

    Fix NULL dereference when duplicating string argument
    
    poptGetArg can return NULL if there are no additional arguments, which
    makes strdup dereference NULL on strlen

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;