svn commit: r254600 - head/lib/libutil

Sergey Kandaurov pluknet at freebsd.org
Wed Aug 21 19:03:16 UTC 2013


On Wed, Aug 21, 2013 at 09:21:47PM +0400, Andrey Chernov wrote:
> On 21.08.2013 20:46, Sergey Kandaurov wrote:
> >  	number = strtoumax(buf, &endptr, 0);
> >  
> > +	if (number == UINTMAX_MAX && errno == ERANGE) {
> > +		return (-1);
> > +	}
> 
> You need to reset errno before strtoumax() call (errno = 0), because any
> of previous functions may left it as ERANGE.
> 

Thanks for pointing out.
Does the patch look good?

Index: expand_number.c
===================================================================
--- expand_number.c     (revision 254600)
+++ expand_number.c     (working copy)
@@ -53,6 +53,8 @@
        unsigned shift;
        char *endptr;
 
+       errno = 0;
+
        number = strtoumax(buf, &endptr, 0);
 
        if (number == UINTMAX_MAX && errno == ERANGE) {

-------------- next part --------------
A non-text attachment was scrubbed...
Name: expand_number.diff
Type: text/x-diff
Size: 324 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/svn-src-head/attachments/20130821/393ba3e6/attachment.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/svn-src-head/attachments/20130821/393ba3e6/attachment.sig>


More information about the svn-src-head mailing list