NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: lib/49429: Import strtonum(3)



The following reply was made to PR lib/49429; it has been noted by GNATS.

From: "Kamil Rytarowski" <n54%gmx.com@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: christos%netbsd.org@localhost
Subject: Re: lib/49429: Import strtonum(3)
Date: Sat, 27 Dec 2014 02:26:35 +0100

 Hello!
 
 Thank you very much!
 
 Your solution looks reasonable, but I have few notes:
 1) the function for (lo > hi) behaves in unpredicted way, I suggest set errno immediatetely to EINVAL and return 0 (special case)
 2) assume correct reults so for check of invalid results use __prefict_false()
 
 if (__predict_false(lo > hi)) {
 errno = EINVAL;  
 return 0;
 }
 
 3) the example strtoi("foo", NULL, 0, 10, 20, NULL); makes NULL pointer dereference
 4) do we really want ENOSUP this way?
 5) if base is not supported then we can unexpectedly abuse errno from EINVAL and change return value from 0 to lo/hi
 
 
 I'm upset for __OPENBSD_SOURCE, please don't do it!
 
 What do you think of libobcompat (OpenBSD compat layer) in src/external (and in some appropriate place in pkgsrc), on top of libnbcompat, with inline OpenBSD-specific functions. These functions will be promised that they are NOT supported by us and they forbidden in our own code. The compat layer will be used only to ease having external code in the base (OpenSSH, tmux...).
 
 One of the functions, next to strtonum(3) will be explicit_bzero(3).
 
 In all other places, where the code is not external we will switch to strtoi(3)/strtou(3).
 


Home | Main Index | Thread Index | Old Index