Commit 3c839f44 by Ondrej Kozina Committed by Milan Broz

luks2: fix off-by-one error in uint64 validation

parent 304bdd7d
......@@ -184,7 +184,6 @@ uint32_t json_object_get_uint32(json_object *jobj)
}
/* jobj has to be json_type_string and numbered */
/* FIXME: sscanf() instead? */
static json_bool json_str_to_uint64(json_object *jobj, uint64_t *value)
{
char *endptr;
......@@ -192,7 +191,7 @@ static json_bool json_str_to_uint64(json_object *jobj, uint64_t *value)
errno = 0;
tmp = strtoull(json_object_get_string(jobj), &endptr, 10);
if (*endptr || errno || tmp >= UINT64_MAX) {
if (*endptr || errno || tmp > UINT64_MAX) {
log_dbg("Failed to parse uint64_t type from string %s.",
json_object_get_string(jobj));
*value = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment