NetBSD Problem Report #49632

From www@NetBSD.org  Mon Feb  2 23:56:01 2015
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id E12B7A6567
	for <gnats-bugs@gnats.NetBSD.org>; Mon,  2 Feb 2015 23:56:01 +0000 (UTC)
Message-Id: <20150202235600.987D5A65C4@mollari.NetBSD.org>
Date: Mon,  2 Feb 2015 23:56:00 +0000 (UTC)
From: n54@gmx.com
Reply-To: n54@gmx.com
To: gnats-bugs@NetBSD.org
Subject: t_strtol improper check of endptr
X-Send-Pr-Version: www-1.0

>Number:         49632
>Category:       lib
>Synopsis:       t_strtol improper check of endptr
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pgoyette
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Feb 03 00:00:00 +0000 2015
>Closed-Date:    Wed Jun 01 01:12:48 +0000 2016
>Last-Modified:  Sat Aug 26 16:40:01 +0000 2017
>Originator:     Kamil Rytarowski
>Release:        current
>Organization:
>Environment:
NetBSD chieftec 7.99.1 NetBSD 7.99.1 (GENERIC) #0: Fri Nov  7 22:04:53 CET 2014  kamil@chieftec:/tmp/netbsd-tmp/sys/arch/amd64/compile/GENERIC amd64

>Description:
t_strtol tests improperly check for valid endptr.
If provided endptr from test matrix is NULL then it skips checking for proper endptr.

After fixing it, fix 3 tests.

See patch for details.
>How-To-Repeat:
N/A
>Fix:
commit a21d6cf264a73d6549b9c6f011f99bc9f9a93b72
Author: Kamil Rytarowski <n54@gmx.com>
Date:   Mon Feb 2 23:09:28 2015 +0000

    t_strtol fix

diff --git a/lib/libc/stdlib/t_strtol.c b/lib/libc/stdlib/t_strtol.c
index 5a0c6d0..e6165b2 100644
--- a/lib/libc/stdlib/t_strtol.c
+++ b/lib/libc/stdlib/t_strtol.c
@@ -59,7 +59,8 @@ check(struct test *t, long int li, long long int lli, char *end)
 		atf_tc_fail_nonfatal("strtoll(%s, NULL, %d) failed "
 		    "(rv = %lld)", t->str, t->base, lli);

-	if (t->end != NULL && strcmp(t->end, end) != 0)
+	if ((t->end != NULL && strcmp(t->end, end) != 0) ||
+	    (t->end == NULL && *end != '\0'))
 		atf_tc_fail_nonfatal("invalid end pointer ('%s') from "
 		    "strtol(%s, &end, %d)", end, t->str, t->base);
 }
@@ -89,8 +90,8 @@ ATF_TC_BODY(strtol_base, tc)
 		{ "12579781",			 123456789, 14, NULL	},
 		{ "AC89BC9",			 123456789, 15, NULL	},
 		{ "75BCD15",			 123456789, 16, NULL	},
-		{ "123456789",			    342391,  8, NULL	},
-		{ "0123456789",			    342391,  0, NULL	},
+		{ "1234567",			    342391,  8, NULL	},
+		{ "01234567",			    342391,  0, NULL	},
 		{ "0123456789",			 123456789, 10, NULL	},
 		{ "0x75bcd15",		         123456789,  0, NULL	},
 	};
@@ -121,7 +122,7 @@ ATF_TC_BODY(strtol_case, tc)
 		{ "abcd",	0xabcd, 16, NULL	},
 		{ "     dcba",	0xdcba, 16, NULL	},
 		{ "abcd dcba",	0xabcd, 16, " dcba"	},
-		{ "abc0x123",	0xabc0, 16, NULL	},
+		{ "abc0x123",	0xabc0, 16, "x123"	},
 		{ "abcd\0x123",	0xabcd, 16, "\0x123"	},
 		{ "ABCD",	0xabcd, 16, NULL	},
 		{ "aBcD",	0xabcd, 16, NULL	},

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: lib-bug-people->pgoyette
Responsible-Changed-By: pgoyette@NetBSD.org
Responsible-Changed-When: Wed, 01 Jun 2016 01:12:48 +0000
Responsible-Changed-Why:
I handled it.


State-Changed-From-To: open->closed
State-Changed-By: pgoyette@NetBSD.org
State-Changed-When: Wed, 01 Jun 2016 01:12:48 +0000
State-Changed-Why:
Fix applied.


From: "Paul Goyette" <pgoyette@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/49632 CVS commit: src/tests/lib/libc/stdlib
Date: Wed, 1 Jun 2016 01:12:03 +0000

 Module Name:	src
 Committed By:	pgoyette
 Date:		Wed Jun  1 01:12:03 UTC 2016

 Modified Files:
 	src/tests/lib/libc/stdlib: t_strtol.c

 Log Message:
 Fix testing of returned entptr, and fix three affected tests.

 From kamil@ via PR lib/49632


 To generate a diff of this commit:
 cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libc/stdlib/t_strtol.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Soren Jacobsen" <snj@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/49632 CVS commit: [netbsd-6] src
Date: Sat, 26 Aug 2017 16:36:19 +0000

 Module Name:	src
 Committed By:	snj
 Date:		Sat Aug 26 16:36:19 UTC 2017

 Modified Files:
 	src/common/lib/libc/stdlib [netbsd-6]: _strtol.h _strtoul.h
 	src/tests/lib/libc/stdlib [netbsd-6]: t_strtol.c

 Log Message:
 Pull up following revision(s) (requested by joerg in ticket #1460):
 	common/lib/libc/stdlib/_strtol.h: 1.11 via patch
 	common/lib/libc/stdlib/_strtoul.h: 1.11 via patch
 	tests/lib/libc/stdlib/t_strtol.c: 1.6-1.7
 Fix testing of returned entptr, and fix three affected tests.
 From kamil@ via PR lib/49632
 --
 Fix ISO C compliance: strtol of "0xX" should give the largest valid
 numeric prefix, which is 0.


 To generate a diff of this commit:
 cvs rdiff -u -r1.2 -r1.2.8.1 src/common/lib/libc/stdlib/_strtol.h
 cvs rdiff -u -r1.1.22.1 -r1.1.22.2 src/common/lib/libc/stdlib/_strtoul.h
 cvs rdiff -u -r1.5 -r1.5.6.1 src/tests/lib/libc/stdlib/t_strtol.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.