This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] stdlib/tst-qsort2.c: Fix off-by-one argc interpretation error
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: "Maciej W. Rozycki" <macro at codesourcery dot com>
- Cc: libc-alpha at sourceware dot org
- Date: Sat, 5 Oct 2013 07:51:21 +0200
- Subject: Re: [PATCH] stdlib/tst-qsort2.c: Fix off-by-one argc interpretation error
- Authentication-results: sourceware.org; auth=none
- References: <alpine dot DEB dot 1 dot 10 dot 1310050020010 dot 6696 at tp dot orcam dot me dot uk>
On Sat, Oct 05, 2013 at 12:27:00AM +0100, Maciej W. Rozycki wrote:
> Hi,
>
> This fixes an off-by-one argc interpretation error (argv[0] is included
> in the count) in stdlib/tst-qsort2.c causing a segfault if the program is
> called with one command-line argument only (argv[2] is NULL in that case).
>
> The issue doesn't trigger in regular testing as the test case is invoked
> without arguments in the test suite, but that doesn't mean the bug is good
> to have. OK to apply?
>
Looks obvious for me.
> 2013-10-04 Maciej W. Rozycki <macro@codesourcery.com>
>
> * stdlib/tst-qsort2.c (main): Fix off-by-one argc interpretation
> error.
>
> Maciej
>
> glibc-tst-qsort2-argc.diff
> Index: glibc-fsf-trunk-quilt/stdlib/tst-qsort2.c
> ===================================================================
> --- glibc-fsf-trunk-quilt.orig/stdlib/tst-qsort2.c 2012-11-21 23:51:44.000000000 +0000
> +++ glibc-fsf-trunk-quilt/stdlib/tst-qsort2.c 2013-10-04 16:04:38.369106557 +0100
> @@ -70,7 +70,7 @@ int
> main (int argc, char **argv)
> {
> int ret = 0;
> - if (argc >= 2)
> + if (argc >= 3)
> ret |= test (atoi (argv[1]), atoi (argv[2]));
> else
> {