1commit 5d5e76d369a412bfb3d2cebb5fc0a7509cef878d
2Author: Rod Smith <rodsmith@rodsbooks.com>
3Date: Fri Apr 15 18:10:14 2022 -0400
4
5 Fix failure & crash of sgdisk when compiled with latest popt (commit 740; presumably eventually release 1.19)
6
7diff --git a/NEWS b/NEWS
8index c7add56..9e153fd 100644
9--- a/NEWS
10+++ b/NEWS
11@@ -1,3 +1,11 @@
12+1.0.10 (?/??/2022):
13+-------------------
14+
15+- Fixed problem that caused sgdisk to crash with errors about being unable
16+ to read the disk's partition table when compiled with the latest popt
17+ (commit 740, which is pre-release as I type; presumably version 1.19 and
18+ later once released).
19+
20 1.0.9 (4/14/2022):
21 ------------------
22
23diff --git a/gptcl.cc b/gptcl.cc
24index 34c9421..0d578eb 100644
25--- a/gptcl.cc
26+++ b/gptcl.cc
27@@ -155,7 +155,7 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) {
28 } // while
29
30 // Assume first non-option argument is the device filename....
31- device = (char*) poptGetArg(poptCon);
32+ device = strdup((char*) poptGetArg(poptCon));
33 poptResetContext(poptCon);
34
35 if (device != NULL) {
36diff --git a/support.h b/support.h
37index 8ba9ad1..f91f1bc 100644
38--- a/support.h
39+++ b/support.h
40@@ -8,7 +8,7 @@
41 #include <stdlib.h>
42 #include <string>
43
44-#define GPTFDISK_VERSION "1.0.9"
45+#define GPTFDISK_VERSION "1.0.9.1"
46
47 #if defined (__FreeBSD__) || defined (__FreeBSD_kernel__) || defined (__APPLE__)
48 // Darwin (Mac OS) & FreeBSD: disk IOCTLs are different, and there is no lseek64
49
50commit f5de3401b974ce103ffd93af8f9d43505a04aaf9
51Author: Damian Kurek <starfire24680@gmail.com>
52Date: Thu Jul 7 03:39:16 2022 +0000
53
54 Fix NULL dereference when duplicating string argument
55
56 poptGetArg can return NULL if there are no additional arguments, which
57 makes strdup dereference NULL on strlen
58
59diff --git a/gptcl.cc b/gptcl.cc
60index 0d578eb..ab95239 100644
61--- a/gptcl.cc
62+++ b/gptcl.cc
63@@ -155,10 +155,11 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) {
64 } // while
65
66 // Assume first non-option argument is the device filename....
67- device = strdup((char*) poptGetArg(poptCon));
68- poptResetContext(poptCon);
69+ device = (char*) poptGetArg(poptCon);
70
71 if (device != NULL) {
72+ device = strdup(device);
73+ poptResetContext(poptCon);
74 JustLooking(); // reset as necessary
75 BeQuiet(); // Tell called functions to be less verbose & interactive
76 if (LoadPartitions((string) device)) {
77@@ -498,6 +499,7 @@ int GPTDataCL::DoOptions(int argc, char* argv[]) {
78 cerr << "Error encountered; not saving changes.\n";
79 retval = 4;
80 } // if
81+ free(device);
82 } // if (device != NULL)
83 poptFreeContext(poptCon);
84 return retval;