summary refs log tree commit diff
diff options
context:
space:
mode:
authorAndrew Marshall <andrew@johnandrewmarshall.com>2023-03-13 16:48:21 -0400
committerEmery Hemingway <ehmry@posteo.net>2023-04-05 15:09:02 +0000
commitd179bf5a96a57a68dcca548c992b5e9b5ee5818f (patch)
treef48b18cb4e980ddcef3ef01a45dd5119a4291038
parent5cdf84485cf0da6b4cd05ee071e070fc33ea3761 (diff)
downloadnixpkgs-d179bf5a96a57a68dcca548c992b5e9b5ee5818f.tar
nixpkgs-d179bf5a96a57a68dcca548c992b5e9b5ee5818f.tar.gz
nixpkgs-d179bf5a96a57a68dcca548c992b5e9b5ee5818f.tar.bz2
nixpkgs-d179bf5a96a57a68dcca548c992b5e9b5ee5818f.tar.lz
nixpkgs-d179bf5a96a57a68dcca548c992b5e9b5ee5818f.tar.xz
nixpkgs-d179bf5a96a57a68dcca548c992b5e9b5ee5818f.tar.zst
nixpkgs-d179bf5a96a57a68dcca548c992b5e9b5ee5818f.zip
gptfdisk: Backport upstream fix for popt 1.19
Existing patch in nixpkgs causes segfault, see
https://github.com/NixOS/nixpkgs/issues/219775. This replaces that with
cherry-picks from upstream. Tested basic behavior (`sgdisk --version ;
sgdisk /dev/sda1`) and both seem to work okay.
-rw-r--r--pkgs/tools/system/gptfdisk/default.nix1
-rw-r--r--pkgs/tools/system/gptfdisk/popt-1-19.patch71
2 files changed, 71 insertions, 1 deletions
diff --git a/pkgs/tools/system/gptfdisk/default.nix b/pkgs/tools/system/gptfdisk/default.nix
index dbce7316303..ea6b12ac5eb 100644
--- a/pkgs/tools/system/gptfdisk/default.nix
+++ b/pkgs/tools/system/gptfdisk/default.nix
@@ -13,7 +13,6 @@ stdenv.mkDerivation rec {
 
   patches = [
     # issues with popt 1.19 (from upstream but not yet released):
-    # https://sourceforge.net/p/gptfdisk/code/ci/5d5e76d369a412bfb3d2cebb5fc0a7509cef878d/
     # https://github.com/rpm-software-management/popt/issues/80
     ./popt-1-19.patch
 
diff --git a/pkgs/tools/system/gptfdisk/popt-1-19.patch b/pkgs/tools/system/gptfdisk/popt-1-19.patch
index ae971362cdd..234c664c962 100644
--- a/pkgs/tools/system/gptfdisk/popt-1-19.patch
+++ b/pkgs/tools/system/gptfdisk/popt-1-19.patch
@@ -1,3 +1,25 @@
+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
@@ -11,3 +33,52 @@ index 34c9421..0d578eb 100644
     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;