Date: Thu, 7 Nov 2019 10:40:04 -0500 From: Phil Shafer <phil@juniper.net> To: Arnaud Ysmal <a@stacktic.org> Cc: <david@catwhisker.org>, <freebsd-current@freebsd.org>, <phil@freebsd.org> Subject: Re: Segmentation fault in netstat after r354373 -> r354373 update Message-ID: <155BBBD2-C93F-4C01-A329-7EC195091574@juniper.net> In-Reply-To: <cc5c473e58f7b727e056fad14670d823@stacktic.org> References: <cc5c473e58f7b727e056fad14670d823@stacktic.org>
next in thread | previous in thread | raw e-mail | index | archive | help
+++ b/libxo/libxo.c
@@ -8104,6 +8104,8 @@ xo_parse_args (int argc, char **argv)
cp = strrchr(xo_program, '/');
if (cp)
xo_program = ++cp;
+ else
+ cp = argv[0]; /* Reset to front of string */
/* GNU tools add an annoying ".test" as the program extension;
remove it */
size_t len = strlen(xo_program);
On 7 Nov 2019, at 10:08, Arnaud Ysmal wrote:
> Hi,
>
> I just got the same issue, it happens when argv[0] does not contain a
> / (calling uptime segfault but calling /usr/bin/uptime works).
>
> In xo_parse_args there is no check whether cp is NULL before calling
> xo_streq.
>
> I fixed it by changing this line:
> - cp = &cp[len + 1 - sizeof(gnu_ext)];
> + cp = (char *)(uintptr_t)(const char *)(&xo_program[len + 1 -
> sizeof(gnu_ext)]);
>
> Arnaud Ysmal
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?155BBBD2-C93F-4C01-A329-7EC195091574>
