From 0e857c82883cff04ccc8868762c78b0e94ccde91 Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Fri, 5 Feb 2021 17:47:07 +0100 Subject: [gdb/breakpoints] Fix segfault for catch syscall -1 Using a hello world a.out, I run into a segfault: ... $ gcc hello.c $ gdb -batch a.out -ex "catch syscall -1" -ex r Catchpoint 1 (syscall -1) Aborted (core dumped) ... Fix this by erroring out if a negative syscall number is used in the catch syscall command. Tested on x86_64-linux. gdb/ChangeLog: 2021-02-05 Tom de Vries PR breakpoints/27313 * break-catch-syscall.c (catch_syscall_split_args): Reject negative syscall numbers. gdb/testsuite/ChangeLog: 2021-02-05 Tom de Vries PR breakpoints/27313 * gdb.base/catch-syscall.exp: Check that "catch syscall -1" is rejected. --- gdb/break-catch-syscall.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'gdb/break-catch-syscall.c') diff --git a/gdb/break-catch-syscall.c b/gdb/break-catch-syscall.c index 9772ac0..7335377 100644 --- a/gdb/break-catch-syscall.c +++ b/gdb/break-catch-syscall.c @@ -390,6 +390,8 @@ catch_syscall_split_args (const char *arg) syscall_number = (int) strtol (cur_name, &endptr, 0); if (*endptr == '\0') { + if (syscall_number < 0) + error (_("Unknown syscall number '%d'."), syscall_number); get_syscall_by_number (gdbarch, syscall_number, &s); result.push_back (s.number); } -- cgit v1.1