[Buildroot] [PATCH v2] package/gptfdisk: fix another runtime failure with popt 1.19
Yann E. MORIN
yann.morin.1998 at free.fr
Sat May 6 15:17:43 UTC 2023
Stefan, All,
On 2023-03-29 15:02 +0200, Stefan Agner spake thusly:
> Fix the following runtime failure raised since bump of popt to version
> 1.19 in commit 895bfba93f6e5535f2132aeea144d2cd87ebc71b:
>
> Segmentation fault (core dumped)
>
> Fix the issue by backporting a fix found in upstream git repository [0].
>
> [0] https://sourceforge.net/p/gptfdisk/code/ci/f5de3401b974ce103ffd93af8f9d43505a04aaf9/
>
> Signed-off-by: Stefan Agner <stefan at agner.ch>
> ---
> ...ence-when-duplicating-string-argumen.patch | 43 +++++++++++++++++++
> 1 file changed, 43 insertions(+)
> create mode 100644 package/gptfdisk/0003-Fix-NULL-dereference-when-duplicating-string-argumen.patch
>
> diff --git a/package/gptfdisk/0003-Fix-NULL-dereference-when-duplicating-string-argumen.patch b/package/gptfdisk/0003-Fix-NULL-dereference-when-duplicating-string-argumen.patch
> new file mode 100644
> index 0000000000..1642343d06
> --- /dev/null
> +++ b/package/gptfdisk/0003-Fix-NULL-dereference-when-duplicating-string-argumen.patch
> @@ -0,0 +1,43 @@
> +From f5de3401b974ce103ffd93af8f9d43505a04aaf9 Mon Sep 17 00:00:00 2001
> +Message-Id: <f5de3401b974ce103ffd93af8f9d43505a04aaf9.1680094621.git.stefan at agner.ch>
> +From: Damian Kurek <starfire24680 at gmail.com>
> +Date: Thu, 7 Jul 2022 03:39:16 +0000
> +Subject: [PATCH] Fix NULL dereference when duplicating string argument
> +
> +poptGetArg can return NULL if there are no additional arguments, which
> +makes strdup dereference NULL on strlen
> +
> +Signed-off-by: Stefan Agner <stefan at agner.ch>
$ make check-pacakge
package/gptfdisk/0003-Fix-NULL-dereference-when-duplicating-string-argumen.patch:0: missing Upstream in the header (http://nightly.buildroot.org/#_additional_patch_documentation)
That's a check that was added after you send your patch, so I added one:
Upstream: https://sourceforge.net/p/gptfdisk/code/ci/f5de3401b974ce103ffd93af8f9d43505a04aaf9
And of course, I borked it and pushed before I did ammend the commit...
Anyway...
Applied to master, thanks.
Regards,
Yann E. MORIN.
> +---
> + gptcl.cc | 6 ++++--
> + 1 file changed, 4 insertions(+), 2 deletions(-)
> +
> +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;
> +--
> +2.40.0
> +
> --
> 2.40.0
>
> _______________________________________________
> buildroot mailing list
> buildroot at buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
More information about the buildroot
mailing list