From 1f44109aba476f876b1c1deea801b54d7afe0d73 Mon Sep 17 00:00:00 2001 From: Bruno Larsen Date: Thu, 23 Sep 2021 12:05:47 -0300 Subject: [PATCH] Backport [gdb] Improve early exits for env var in debuginfod-support.c (Tom de Vries) Resolves: RHBZ 1970741 --- _gdb.spec.Patch.include | 4 ++ _gdb.spec.patch.include | 1 + _patch_order | 1 + ...-early-exit-for-empty-debuginfod-url.patch | 51 +++++++++++++++++++ gdb.spec | 4 ++ 5 files changed, 61 insertions(+) create mode 100644 gdb-rhbz1970741-early-exit-for-empty-debuginfod-url.patch diff --git a/_gdb.spec.Patch.include b/_gdb.spec.Patch.include index b8a5eae..0b2200f 100644 --- a/_gdb.spec.Patch.include +++ b/_gdb.spec.Patch.include @@ -368,3 +368,7 @@ Patch088: gdb-dont-overwrite-fsgsbase-m32.patch #(Tom de Vries) Patch089: gdb-rhbz1916516-pathstuff.cc132-internal-error.patch +#[gdb] Improve early exits for env var in debuginfod-support.c +#(Tom de Vries) +Patch090: gdb-rhbz1970741-early-exit-for-empty-debuginfod-url.patch + diff --git a/_gdb.spec.patch.include b/_gdb.spec.patch.include index dd1a19f..3f40bb5 100644 --- a/_gdb.spec.patch.include +++ b/_gdb.spec.patch.include @@ -87,3 +87,4 @@ %patch087 -p1 %patch088 -p1 %patch089 -p1 +%patch090 -p1 diff --git a/_patch_order b/_patch_order index b171f1b..d0e201a 100644 --- a/_patch_order +++ b/_patch_order @@ -87,3 +87,4 @@ gdb-rhbz1898252-loadable-section-outside-ELF-segments.patch gdb-gdb27743-psymtab-imported-unit.patch gdb-dont-overwrite-fsgsbase-m32.patch gdb-rhbz1916516-pathstuff.cc132-internal-error.patch +gdb-rhbz1970741-early-exit-for-empty-debuginfod-url.patch diff --git a/gdb-rhbz1970741-early-exit-for-empty-debuginfod-url.patch b/gdb-rhbz1970741-early-exit-for-empty-debuginfod-url.patch new file mode 100644 index 0000000..c1865c4 --- /dev/null +++ b/gdb-rhbz1970741-early-exit-for-empty-debuginfod-url.patch @@ -0,0 +1,51 @@ +From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 +From: Bruno Larsen +Date: Thu, 23 Sep 2021 11:19:09 -0300 +Subject: gdb-rhbz1970741-early-exit-for-empty-debuginfod-url.patch + +;;[gdb] Improve early exits for env var in debuginfod-support.c +;;(Tom de Vries) + +There's an early exit in libdebuginfod's debuginfod_query_server, which checks +both for: +- getenv (DEBUGINFOD_URLS_ENV_VAR) == NULL, and +- (getenv (DEBUGINFOD_URLS_ENV_VAR))[0] == '\0'. + +In debuginfod_source_query and debuginfod_debuginfo_query (which both +end up calling debuginfod_query_server) there are also early exits checking +the same env var, but those just check for NULL. + +Make the early exit tests in debuginfod-support.c match those in +libdebuginfod. + +gdb/ChangeLog: + +2020-11-18 Tom de Vries + + * debuginfod-support.c (debuginfod_source_query) + (debuginfod_debuginfo_query): Also do early exit if + "(getenv (DEBUGINFOD_URLS_ENV_VAR))[0] == '\0'". + +diff --git a/gdb/debuginfod-support.c b/gdb/debuginfod-support.c +--- a/gdb/debuginfod-support.c ++++ b/gdb/debuginfod-support.c +@@ -98,7 +98,8 @@ debuginfod_source_query (const unsigned char *build_id, + const char *srcpath, + gdb::unique_xmalloc_ptr *destname) + { +- if (getenv (DEBUGINFOD_URLS_ENV_VAR) == NULL) ++ const char *urls_env_var = getenv (DEBUGINFOD_URLS_ENV_VAR); ++ if (urls_env_var == NULL || urls_env_var[0] == '\0') + return scoped_fd (-ENOSYS); + + debuginfod_client *c = debuginfod_init (); +@@ -135,7 +136,8 @@ debuginfod_debuginfo_query (const unsigned char *build_id, + const char *filename, + gdb::unique_xmalloc_ptr *destname) + { +- if (getenv (DEBUGINFOD_URLS_ENV_VAR) == NULL) ++ const char *urls_env_var = getenv (DEBUGINFOD_URLS_ENV_VAR); ++ if (urls_env_var == NULL || urls_env_var[0] == '\0') + return scoped_fd (-ENOSYS); + + debuginfod_client *c = debuginfod_init (); diff --git a/gdb.spec b/gdb.spec index 30b5488..76baf87 100644 --- a/gdb.spec +++ b/gdb.spec @@ -1148,6 +1148,10 @@ fi %endif %changelog +* Thu Sep 23 2021 Bruno Larsen - 10.2-2 +- Backport "[gdb] Improve early exits for env var in debuginfod-support.c" + (Tom de Vries) + * Thu Sep 23 2021 Bruno Larsen - 10.2-2 - Backport "[gdb/cli] Don't assert on empty string for core-file" (Tom de Vries)