From 844b9d981fee26b46dcaaeefda7eecd864b5ffca Mon Sep 17 00:00:00 2001 From: riastradh Date: Fri, 4 Nov 2016 20:14:31 +0000 Subject: Distinguish invalid syntax from trailing garbage cases. Clarify. --- lib/libc/stdlib/strtol.3 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/libc/stdlib') diff --git a/lib/libc/stdlib/strtol.3 b/lib/libc/stdlib/strtol.3 index 66b4b0bb9ad..b7065051f07 100644 --- a/lib/libc/stdlib/strtol.3 +++ b/lib/libc/stdlib/strtol.3 @@ -1,4 +1,4 @@ -.\" $NetBSD: strtol.3,v 1.35 2015/11/13 16:00:32 christos Exp $ +.\" $NetBSD: strtol.3,v 1.36 2016/11/04 20:14:31 riastradh Exp $ .\" .\" Copyright (c) 1990, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -225,8 +225,10 @@ long lval; errno = 0; lval = strtol(buf, \*[Am]ep, 10); -if (buf[0] == '\e0' || *ep != '\e0') +if (ep == buf) goto not_a_number; +if (*ep != '\e0') + goto trailing_garbage; if (errno == ERANGE \*[Am]\*[Am] (lval == LONG_MAX || lval == LONG_MIN)) goto out_of_range; .Ed -- cgit