When is debuginfod_query_server is given an hexadecimal string as
build-id build_id_len will be zero. We were checking the size of
the build_id_bytes destination string instead of the string length
of build_id input string. Make sure the input string is not too
big or strcpy might overwrite then end of the build_id_bytes array.
Signed-off-by: Mark Wielaard <mark@klomp.org>
+2020-06-16 Mark Wielaard <mark@klomp.org>
+
+ * debuginfod-client.c (debuginfod_query_server): Replace sizeof
+ build_id_bytes check with strlen build_id check.
+
2020-06-16 Mark Wielaard <mark@klomp.org>
* debuginfod-client.c (debuginfod_query_server): Increase suffix
/* Copy lowercase hex representation of build_id into buf. */
if ((build_id_len >= MAX_BUILD_ID_BYTES) ||
(build_id_len == 0 &&
- sizeof(build_id_bytes) > MAX_BUILD_ID_BYTES*2 + 1))
+ strlen ((const char *) build_id) > MAX_BUILD_ID_BYTES*2))
return -EINVAL;
if (build_id_len == 0) /* expect clean hexadecimal */
strcpy (build_id_bytes, (const char *) build_id);