off-by-one bug in truss
Nicolas Thery
nthery at gmail.com
Thu Dec 20 09:58:06 PST 2007
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 @@
fsc.number = syscall;
fsc.name =
- (syscall < 0 || syscall > nsyscalls) ? NULL : syscallnames[syscall];
+ (syscall < 0 || syscall >= nsyscalls) ? NULL : syscallnames[syscall];
if (!fsc.name) {
fprintf(outfile, "-- UNKNOWN SYSCALL %d --\n", syscall);
}
Index: dfly/src/usr.bin/truss/i386-linux.c
===================================================================
--- 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);
}
More information about the Bugs
mailing list