Per the notes for strtoul, since 0 or ULONG_MAX is a legitimate return
value, errno must be cleared before the call so an error can be checked
after the call by testing errno.
Issue: 7126
{
unsigned long gid = 0;
char *endptr = NULL;
+ errno = 0;
gid = strtoul(rawstr, &endptr, 10);
- if (endptr == NULL || *endptr != '\0') {
+ if (errno == ERANGE || endptr == NULL || *endptr != '\0') {
SCLogError("invalid character as arg "
"to gid keyword");
goto error;
UtRegisterTest("GidTestParse02", GidTestParse02);
UtRegisterTest("GidTestParse03", GidTestParse03);
}
-#endif /* UNITTESTS */
\ No newline at end of file
+#endif /* UNITTESTS */
{
unsigned long rev = 0;
char *endptr = NULL;
+ errno = 0;
rev = strtoul(rawstr, &endptr, 10);
- if (endptr == NULL || *endptr != '\0') {
+ if (errno == ERANGE || endptr == NULL || *endptr != '\0') {
SCLogError("invalid character as arg "
"to rev keyword");
goto error;
error:
return -1;
-}
\ No newline at end of file
+ }
{
unsigned long id = 0;
char *endptr = NULL;
+ errno = 0;
id = strtoul(sidstr, &endptr, 10);
- if (endptr == NULL || *endptr != '\0') {
+ if (errno == ERANGE || endptr == NULL || *endptr != '\0') {
SCLogError("invalid character as arg "
"to sid keyword");
goto error;
UtRegisterTest("SidTestParse03", SidTestParse03);
UtRegisterTest("SidTestParse04", SidTestParse04);
}
-#endif /* UNITTESTS */
\ No newline at end of file
+#endif /* UNITTESTS */