GNU bug report logs - #18680
[PATCH] Check if argv[0] is NULL in scm_boot_guile to avoid segfault

Previous Next

Package: guile;

Reported by: Nala Ginrut <nalaginrut <at> gmail.com>

Date: Fri, 10 Oct 2014 16:30:02 UTC

Severity: normal

Tags: patch

Done: Mark H Weaver <mhw <at> netris.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 18680 in the body.
You can then email your comments to 18680 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guile <at> gnu.org:
bug#18680; Package guile. (Fri, 10 Oct 2014 16:30:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Nala Ginrut <nalaginrut <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-guile <at> gnu.org. (Fri, 10 Oct 2014 16:30:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Nala Ginrut <nalaginrut <at> gmail.com>
To: guile-devel <guile-devel <at> gnu.org>, Eli Zaretskii <eliz <at> gnu.org>,
 Andy Wingo <wingo <at> pobox.com>, 
 bug-guile <at> gnu.org, Mark H Weaver <mhw <at> netris.org>
Subject: [PATCH] Check if argv[0] is NULL in scm_boot_guile to avoid segfault
Date: Sat, 11 Oct 2014 00:15:25 +0800
[Message part 1 (text/plain, inline)]
This patch is for master branch, but the bug also appears in the
current stable-2.0 I think.

With the recent patch from Eli Zaretskii, there'd be one more step for argv[0]:
scm_i_mirror_backslashes (argv[0]);

But this cause my program segfault, since I have such line:
scm_boot_guile(0, {NULL}, &guilemain, NULL);

According to C11, it's allowed[1].
argv[argc] should be NULL.
If the value of argc is greater than zero, the string pointed to by argv[0]
represents the program name. But if argc is zero, argv[0] will be NULL, so
we have to check it first to avoid segfault.

Attached patch fixed this.

[1] http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf
[0001-Check-argv-0-if-it-s-NULL-in-scm_boot_guile.patch (text/x-patch, attachment)]

Reply sent to Mark H Weaver <mhw <at> netris.org>:
You have taken responsibility. (Sat, 11 Oct 2014 17:07:02 GMT) Full text and rfc822 format available.

Notification sent to Nala Ginrut <nalaginrut <at> gmail.com>:
bug acknowledged by developer. (Sat, 11 Oct 2014 17:07:03 GMT) Full text and rfc822 format available.

Message #10 received at 18680-done <at> debbugs.gnu.org (full text, mbox):

From: Mark H Weaver <mhw <at> netris.org>
To: Nala Ginrut <nalaginrut <at> gmail.com>
Cc: 18680-done <at> debbugs.gnu.org, Andy Wingo <wingo <at> pobox.com>,
 Eli Zaretskii <eliz <at> gnu.org>, guile-devel <at> gnu.org
Subject: Re: [PATCH] Check if argv[0] is NULL in scm_boot_guile to avoid
 segfault
Date: Sat, 11 Oct 2014 13:05:45 -0400
Nala Ginrut <nalaginrut <at> gmail.com> writes:

> This patch is for master branch, but the bug also appears in the
> current stable-2.0 I think.
>
> With the recent patch from Eli Zaretskii, there'd be one more step for argv[0]:
> scm_i_mirror_backslashes (argv[0]);
>
> But this cause my program segfault, since I have such line:
> scm_boot_guile(0, {NULL}, &guilemain, NULL);
>
> According to C11, it's allowed[1].
> argv[argc] should be NULL.
> If the value of argc is greater than zero, the string pointed to by argv[0]
> represents the program name. But if argc is zero, argv[0] will be NULL, so
> we have to check it first to avoid segfault.

Fixed in b9ace68613395fda26f3f3d7dc2ac9bc52cd7f2a on the stable-2.0
branch.  It'll go into master on the next merge.

     Thanks,
       Mark




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 09 Nov 2014 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 10 years and 220 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.