diff options
| author | Mark Wielaard <mark@klomp.org> | 2020-06-16 23:56:45 +0200 |
|---|---|---|
| committer | Mark Wielaard <mark@klomp.org> | 2020-06-24 16:37:35 +0200 |
| commit | 6b677bf8e3b0b92fb0ddb2c6a408b0c7759acf1d (patch) | |
| tree | 6707cfae04502a2eebdcddc2e5f4beac55fc4c9e | |
| parent | a7c5e3004bb5ddc3759c5993334003a1bfb7e704 (diff) | |
| download | platform_external_elfutils-6b677bf8e3b0b92fb0ddb2c6a408b0c7759acf1d.tar.gz platform_external_elfutils-6b677bf8e3b0b92fb0ddb2c6a408b0c7759acf1d.tar.bz2 platform_external_elfutils-6b677bf8e3b0b92fb0ddb2c6a408b0c7759acf1d.zip | |
debuginfod: Make sure suffix can place zero terminator when copying filename
We need to make sure that we can always place a zero terminator at
the end of suffix when we are copying the filename. So add one more
char to the suffix array. And make sure that we can always add an
extra escape character when we need to escape the current character.
Signed-off-by: Mark Wielaard <mark@klomp.org>
| -rw-r--r-- | debuginfod/ChangeLog | 5 | ||||
| -rw-r--r-- | debuginfod/debuginfod-client.c | 4 |
2 files changed, 7 insertions, 2 deletions
diff --git a/debuginfod/ChangeLog b/debuginfod/ChangeLog index 66511a3f..9ff2e111 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): Increase suffix + array and prepare having to escape 1 character with 2. + +2020-06-16 Mark Wielaard <mark@klomp.org> + * debuginfod-client.c (debuginfod_clean_cache): Handle failing fopen (interval_path). diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c index 0cfc6dfc..e9c2ca83 100644 --- a/debuginfod/debuginfod-client.c +++ b/debuginfod/debuginfod-client.c @@ -474,7 +474,7 @@ debuginfod_query_server (debuginfod_client *c, char *target_cache_dir = NULL; char *target_cache_path = NULL; char *target_cache_tmppath = NULL; - char suffix[PATH_MAX]; + char suffix[PATH_MAX + 1]; /* +1 for zero terminator. */ char build_id_bytes[MAX_BUILD_ID_BYTES * 2 + 1]; int rc; @@ -511,7 +511,7 @@ debuginfod_query_server (debuginfod_client *c, /* copy the filename to suffix, s,/,#,g */ unsigned q = 0; - for (unsigned fi=0; q < PATH_MAX-1; fi++) + for (unsigned fi=0; q < PATH_MAX-2; fi++) /* -2, escape is 2 chars. */ switch (filename[fi]) { case '\0': |
