From: Hans Petter Selasky <hps@selasky.org>
To: libc-alpha@sourceware.org
Subject: argp_help() causes segmentation fault (v4l-utils - dvbv5-scan)
Date: Thu, 9 Apr 2020 23:12:07 +0200 [thread overview]
Message-ID: <1d1c81d1-23cd-9a02-a059-a66c7146b396@selasky.org> (raw)
In-Reply-To: <22128b83-2388-561f-7c26-8d097d6ca909@selasky.org>
[-- Attachment #1: Type: text/plain, Size: 1242 bytes --]
Dear GNU libc people,
I'm a FreeBSD developer and we have a port of some of your glibc code. I
recently found a bug, which I'm not sure if you've fixed.
The fix for FreeBSD is here:
https://svnweb.freebsd.org/changeset/ports/531220
> Log:
> Fix segmentation fault when showing help text.
> Found when running dvbv5-scan (part of coming v4l-utils upgrade).
>
> Backtrace:
> #0 hol_entry_help (entry=0x8007e0000, state=0x0, stream=0x8007d3000,
> hhstate=0x7fffffffe5d8) at argp-help.c:1164
> #1 hol_help (hol=0x8007df000, state=0x0, stream=0x8007d3000) at argp-help.c:1230
> #2 _help (argp=0x7fffffffe750, state=0x0, stream=0x8004fca20, flags=634,
> name=0x2018ce "dvbv5-scan") at argp-help.c:1675
> #3 argp_help (argp=0x7fffffffe750, stream=0x8004fca20, flags=634,
> name=0x2018ce "dvbv5-scan") at argp-help.c:1707
>
It turns out the argp_help invoke _help with a NULL state. In some cases
the state may be used when printing the help message, for example when
running dvbv5-scan w/o any arguments in FreeBSD.
Fix this by creating a dummy argp_state structure on the stack, and fill
in the used arguments.
I hope my fix is right. At least it fixes the issue for me.
Thank you!
--HPS
[-- Attachment #2: patch-argp-help.c --]
[-- Type: text/x-csrc, Size: 441 bytes --]
--- argp-help.c.orig 2020-04-09 17:39:48 UTC
+++ argp-help.c
@@ -1704,7 +1704,10 @@ Try `%s --help' or `%s --usage' for more information.\
void __argp_help (const struct argp *argp, FILE *stream,
unsigned flags, char *name)
{
- _help (argp, 0, stream, flags, name);
+ struct argp_state state = {
+ .root_argp = argp,
+ };
+ _help (argp, &state, stream, flags, name);
}
#ifdef weak_alias
weak_alias (__argp_help, argp_help)
next parent reply other threads:[~2020-04-09 21:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <22128b83-2388-561f-7c26-8d097d6ca909@selasky.org>
2020-04-09 21:12 ` Hans Petter Selasky [this message]
2020-04-09 21:32 ` Carlos O'Donell
2020-04-10 11:12 ` Hans Petter Selasky
2020-04-10 13:55 ` Florian Weimer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1d1c81d1-23cd-9a02-a059-a66c7146b396@selasky.org \
--to=hps@selasky.org \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).