Bug #891
closedoff-by-one bug in truss
0%
Description
truss cores dump while handling a syscall that is one past the last
syscall known to it. This happens typically after adding a new
syscall to the kernel and before rebuilding truss.
The following patch fixes this.
Index: dfly/src/usr.bin/truss/i386-fbsd.c
===================================================================
--- dfly.orig/src/usr.bin/truss/i386-fbsd.c 2003-11-04 16:34:41.000000000 0100
++ dfly/src/usr.bin/truss/i386-fbsd.c 2007-12-20 18:30:30.000000000 +0100@ -157,7 +157,7
@
===================================================================
--- dfly.orig/src/usr.bin/truss/i386-linux.c 2003-11-04 16:34:41.000000000 0100
++ dfly/src/usr.bin/truss/i386-linux.c 2007-12-20 18:31:19.000000000 +0100@ -116,7 +116,7
@
lsc.number = syscall;
lsc.name =
- (syscall < 0 || syscall > nsyscalls) ? NULL : linux_syscallnames[syscall];
+ (syscall < 0 || syscall >= nsyscalls) ? NULL : linux_syscallnames[syscall];
if (!lsc.name) {
fprintf (outfile, "-- UNKNOWN SYSCALL %d\n", syscall);
}