[binutils-gdb] gdb: fix possible uninitialised variable use
Andrew Burgess
aburgess@sourceware.org
Tue Mar 26 12:14:55 GMT 2024
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=24df37a10f8773ad5db07dc000f694d6405e3a36
commit 24df37a10f8773ad5db07dc000f694d6405e3a36
Author: Andrew Burgess <aburgess@redhat.com>
Date: Tue Mar 26 12:05:07 2024 +0000
gdb: fix possible uninitialised variable use
After this commit:
commit 198ff6ff819c240545f9fc68b39636fd376d4ba9
Date: Tue Jan 30 15:37:23 2024 +0000
gdb/gdbserver: share x86/linux tdesc caching
a possible use of an uninitialised variable was introduced, the
'tdesc' variable in i386_linux_core_read_description might be read
without being written too if 'xcr0' was 0.
This is fixed in this commit. I've updated the function to follow the
same pattern as amd64_linux_core_read_description, if xcr0 is 0 then
we select a default xcr0 value and use that to select a tdesc.
Diff:
---
gdb/i386-linux-tdep.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c
index ed1442236e8..2e84384306d 100644
--- a/gdb/i386-linux-tdep.c
+++ b/gdb/i386-linux-tdep.c
@@ -700,17 +700,15 @@ i386_linux_core_read_description (struct gdbarch *gdbarch,
x86_xsave_layout layout;
uint64_t xcr0 = i386_linux_core_read_xsave_info (abfd, layout);
- const struct target_desc *tdesc;
- if (xcr0 != 0)
- tdesc = i386_linux_read_description (xcr0);
-
- if (tdesc != NULL)
- return tdesc;
+ if (xcr0 == 0)
+ {
+ if (bfd_get_section_by_name (abfd, ".reg-xfp") != nullptr)
+ xcr0 = X86_XSTATE_SSE_MASK;
+ else
+ xcr0 = X86_XSTATE_X87_MASK;
+ }
- if (bfd_get_section_by_name (abfd, ".reg-xfp") != NULL)
- return i386_linux_read_description (X86_XSTATE_SSE_MASK);
- else
- return i386_linux_read_description (X86_XSTATE_X87_MASK);
+ return i386_linux_read_description (xcr0);
}
/* Similar to i386_supply_fpregset, but use XSAVE extended state. */
More information about the Gdb-cvs
mailing list