apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Jagielski <...@jaguNET.com>
Subject "invalid characters" during overflow - ap_strtol and apr_strtoi64
Date Mon, 19 Aug 2002 21:57:31 GMT
Topic for discussion... Consider an overflow condition. Before the recent
patch, ap_strtol would continue checking each digit in the input until
it either hit a "non-correct" character (one that doesn't make sense in
the base) or the end of the string. Thus, on overflow, errno would
mark the overflow, and the correct limit would be set, but endptr
would point to '\0' (assuming just a big number). This was not the
case in apr_strtoi64. They are now consistant, but which is the more
"correct" case? Should endptr just make sense when there's an incorrect
character, or should a digit that would cause an overflow be considered
an incorrect/invalid character?

True, this is a weird boundary condition, but which makes more sense?
The BSD impl's I've seen all do the former (endptr is just for chars
that aren't "digits" to the base) and I'm leaning toward that
understanding, just for compatibility.

So the proposal: should ap_strtol and apr_strtoi64 be BSD compliant with
the handling of endptr for over/underflows? This appears to be
implied by ANSI as well.
   Jim Jagielski   [|]   jim@jaguNET.com   [|]   http://www.jaguNET.com/
      "A society that will trade a little liberty for a little order
             will lose both and deserve neither" - T.Jefferson

View raw message