forked from osmocom/wireshark
Check for signs in unsigned numbers and fail if we see one.
-1 is not an unsigned number. For that matter, neither is +1; "unsigned" means "without a sign", and they both have signs. ANSI C's strto{whatever} routines - even the ones that supposedly are for "unsigned" values - and the GLib routines modeled after them allow a leading sign, so we have to check ourselves. Change-Id: Ia0584bbf83394185cde88eec48efcdfa316f1c92 Reviewed-on: https://code.wireshark.org/review/17511 Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
parent
4adf7f2be5
commit
97103d40e3
|
@ -53,6 +53,13 @@ gboolean ws_strtou64(const gchar* str, guint64* cint)
|
|||
gchar* endptr;
|
||||
guint64 val;
|
||||
|
||||
if (str[0] == '-' || str[0] == '+') {
|
||||
/*
|
||||
* Unsigned numbers don't have a sign.
|
||||
*/
|
||||
errno = EINVAL;
|
||||
return FALSE;
|
||||
}
|
||||
errno = 0;
|
||||
val = g_ascii_strtoull(str, &endptr, 10);
|
||||
if ((val == 0 && endptr == str) || (*endptr != 0)) {
|
||||
|
|
Loading…
Reference in New Issue