Don't copy memory for arguments if there are none
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_gdb_build--master-arm |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gdb_check--master-arm |
success
|
Test passed
|
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 |
success
|
Test passed
|
Commit Message
If amd64_windows_push_arguments is called with no arguments, then ARGS
can be NULL, and inside the passed-by-pointer block, memcpy is called
with this NULL, which is undefined behavior.
So this just disable the passed-by-pointer block if there are no
arguments.
Fixes the following ubsan error:
C:/gdb/src/gdb.git/gdb/amd64-windows-tdep.c:244:12: runtime error: null pointer passed as argument 2, which is declared to never be null
---
gdb/amd64-windows-tdep.c | 1 +
1 file changed, 1 insertion(+)
Comments
>>>>> "Hannes" == Hannes Domani <ssbssa@yahoo.de> writes:
Hannes> If amd64_windows_push_arguments is called with no arguments, then ARGS
Hannes> can be NULL, and inside the passed-by-pointer block, memcpy is called
Hannes> with this NULL, which is undefined behavior.
Hannes> So this just disable the passed-by-pointer block if there are no
Hannes> arguments.
Thanks. This is ok.
Approved-By: Tom Tromey <tom@tromey.com>
Tom
Am Montag, 28. Oktober 2024 um 20:39:36 MEZ hat Tom Tromey <tom@tromey.com> Folgendes geschrieben:
> >>>>> "Hannes" == Hannes Domani <ssbssa@yahoo.de> writes:
>
> Hannes> If amd64_windows_push_arguments is called with no arguments, then ARGS
> Hannes> can be NULL, and inside the passed-by-pointer block, memcpy is called
> Hannes> with this NULL, which is undefined behavior.
>
> Hannes> So this just disable the passed-by-pointer block if there are no
> Hannes> arguments.
>
> Thanks. This is ok.
> Approved-By: Tom Tromey <tom@tromey.com>
Pushed, thanks.
Hannes
@@ -239,6 +239,7 @@ amd64_windows_push_arguments (struct regcache *regcache, int nargs,
These arguments are replaced by pointers to a copy we are making
in inferior memory. So use a copy of the ARGS table, to avoid
modifying the original one. */
+ if (nargs > 0)
{
struct value **args1 = XALLOCAVEC (struct value *, nargs);