* limitations under the License.
*/
#include <ctype.h>
+#include <errno.h>
+#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char *newline, *sep;
begin = strtoull(cursor, &sep, 16);
- if (*sep != ' ' || (sep == cursor && begin == 0))
+ if (begin == 0 || *sep != ' ' || (begin == ULLONG_MAX && errno == ERANGE))
continue;
cursor = sep;
while (*cursor && isspace(*cursor)) cursor++;
len = strtoull(cursor, &sep, 16);
- if (*sep != ' ' || (sep == cursor && begin == 0))
+ if (*sep != ' ' ||
+ (sep == cursor && len == 0) ||
+ (len == ULLONG_MAX && errno == ERANGE))
continue;
cursor = sep;
while (*cursor && isspace(*cursor)) cursor++;