diff options
author | Mark Wielaard <mark@klomp.org> | 2020-06-17 00:03:37 +0200 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2020-06-24 16:37:35 +0200 |
commit | 90808ed559792a70b79c39183b88df09234866cf (patch) | |
tree | 11b58512a75963316023b3daec1207bd4b8ae1fd | |
parent | 6b677bf8e3b0b92fb0ddb2c6a408b0c7759acf1d (diff) | |
download | elfutils-90808ed559792a70b79c39183b88df09234866cf.tar.gz |
debuginfod: Fix build_id hexadecimal length check.
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>
-rw-r--r-- | debuginfod/ChangeLog | 5 | ||||
-rw-r--r-- | debuginfod/debuginfod-client.c | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/debuginfod/ChangeLog b/debuginfod/ChangeLog index 9ff2e111..d6bbfac8 100644 --- a/debuginfod/ChangeLog +++ b/debuginfod/ChangeLog @@ -1,5 +1,10 @@ 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 array and prepare having to escape 1 character with 2. diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c index e9c2ca83..7b53cb31 100644 --- a/debuginfod/debuginfod-client.c +++ b/debuginfod/debuginfod-client.c @@ -496,7 +496,7 @@ debuginfod_query_server (debuginfod_client *c, /* 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); |