Check for truncated registers in process_g_packet
authorLionel Flandrin <lionel@svkt.org>
Tue, 8 Nov 2016 10:27:36 +0000 (10:27 +0000)
committerPedro Alves <palves@redhat.com>
Tue, 8 Nov 2016 10:27:36 +0000 (10:27 +0000)
commit9dc193c3be85aafa60ceff57d3b0430af607b4ce
treed900edb55d55df5315db1db846c6ac9dd16fde49
parentec7b600bf1410f6bda239666fac258a605dc3f43
Check for truncated registers in process_g_packet

While investigating an unrelated issue in remote.c I noticed that the
bound checking for 'g' packets was bogus:

The previous code would only check that the first byte of the register
was within bounds before passing the buffer to regcache_raw_supply.
If it turned out that the register in the 'g' packet was incomplete
then regcache_raw_supply would proceed to memcpy out-of-bounds.

Since the buffer is allocated with alloca it's relatively unlikely to
crash (you just end up dumping gdb's stack into the cache) but it's
still a bit messy.

I changed this logic to check for truncated registers and raise an
error if one is encountered.  Hopefully it should make debugging
remote stubs a bit easier.

gdb/ChangeLog:
2016-11-08  Lionel Flandrin  <lionel@svkt.org>

* remote.c (process_g_packet): Detect truncated registers in 'g'
packets and raise an error.
gdb/ChangeLog
gdb/remote.c
This page took 0.025009 seconds and 4 git commands to generate.