strace: Gracefully handle invalid syscall numbers.

OpenJDK 1.8 somehow manages to trigger this. Before this commit it would
just attempt to read past the end of the vector, which of course segfaulted,
which seems to imply nobody has run into this case before.
This commit is contained in:
Augustin Cavalier 2018-11-01 20:51:05 -04:00
parent ffd9d565d2
commit 49783dc8f2

View File

@ -686,7 +686,12 @@ main(int argc, const char *const *argv)
Team* team = it->second;
MemoryReader& memoryReader = team->GetMemoryReader();
int32 syscallNumber = message.post_syscall.syscall;
uint32 syscallNumber = message.post_syscall.syscall;
if (syscallNumber >= sSyscallVector.size()) {
fprintf(stderr, "%s: invalid syscall %" B_PRIu32 " attempted\n",
kCommandName, syscallNumber);
break;
}
Syscall* syscall = sSyscallVector[syscallNumber];
if (stats)