Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 872131 - sys-apps/gptfdisk is incompatible with dev-libs/popt-1.19
Summary: sys-apps/gptfdisk is incompatible with dev-libs/popt-1.19
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Marek Szuba (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-09-21 07:07 UTC by Ronald Smith
Modified: 2022-09-22 00:32 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ronald Smith 2022-09-21 07:07:17 UTC
sgdisk doesn't parse the device argument with popt-1.19. There is a fix upstream but there is no new version. So sys-apps/gptfdisk-1.0.9  needs to backport the patch:

commit f5de3401b974ce103ffd93af8f9d43505a04aaf9 (HEAD -> master, origin/master, origin/HEAD)
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;


Reproducible: Always
Comment 1 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-09-21 07:34:54 UTC
Could you include a link to the patch source? And thanks!
Comment 2 Ronald Smith 2022-09-21 08:07:45 UTC
Nope as links are not allowed by new accounts.

try this tho:

sourceforge.net/u/starfire24680/gptfdisk/ci/f5de3401b974ce103ffd93af8f9d43505a04aaf9/log/
Comment 3 Ronald Smith 2022-09-21 09:17:16 UTC
Also from carbonOS gitlab.com/carbonOS/build-meta/-/issues/104
Comment 4 Larry the Git Cow gentoo-dev 2022-09-22 00:32:45 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2dc57d72ada009425ab74d4ff46064a17d477782

commit 2dc57d72ada009425ab74d4ff46064a17d477782
Author:     Marek Szuba <marecki@gentoo.org>
AuthorDate: 2022-09-22 00:21:53 +0000
Commit:     Marek Szuba <marecki@gentoo.org>
CommitDate: 2022-09-22 00:32:39 +0000

    sys-apps/gptfdisk: fix dev-libs/popt-1.19 incompatibility
    
    Without this, starting gdisk linked against popt-1.19 fails with
    
    Problem opening (garbage) for reading! Error is 2.
    The specified file does not exist!
    
    (assuming gptfdisk has been emerged without tests; otherwise this
    does get caught by the test suite)
    
    Closes: https://bugs.gentoo.org/872131
    Signed-off-by: Marek Szuba <marecki@gentoo.org>

 .../gptfdisk/files/gptfdisk-1.0.9-popt_segv.patch  | 22 ++++++++
 sys-apps/gptfdisk/gptfdisk-1.0.9-r2.ebuild         | 61 ++++++++++++++++++++++
 2 files changed, 83 insertions(+)