From 1e64043f43a087e210d5a2447b625d54b100fbfb Mon Sep 17 00:00:00 2001 From: delphij Date: Thu, 28 May 2009 00:38:24 +0000 Subject: [PATCH] Correct off-by-one issue in truss(1) which happens when system call number is nsyscalls. PR: bin/134916 Submitted by: Steven Hartland MFC after: 2 weeks --- usr.bin/truss/amd64-fbsd.c | 2 +- usr.bin/truss/amd64-fbsd32.c | 2 +- usr.bin/truss/amd64-linux32.c | 2 +- usr.bin/truss/i386-fbsd.c | 2 +- usr.bin/truss/i386-linux.c | 2 +- usr.bin/truss/ia64-fbsd.c | 2 +- usr.bin/truss/mips-fbsd.c | 2 +- usr.bin/truss/powerpc-fbsd.c | 2 +- usr.bin/truss/sparc64-fbsd.c | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/usr.bin/truss/amd64-fbsd.c b/usr.bin/truss/amd64-fbsd.c index f7c949ac697c..bfd39c2f5415 100644 --- a/usr.bin/truss/amd64-fbsd.c +++ b/usr.bin/truss/amd64-fbsd.c @@ -142,7 +142,7 @@ amd64_syscall_entry(struct trussinfo *trussinfo, int nargs) { fsc.number = syscall_num; fsc.name = - (syscall_num < 0 || syscall_num > nsyscalls) ? NULL : syscallnames[syscall_num]; + (syscall_num < 0 || syscall_num >= nsyscalls) ? NULL : syscallnames[syscall_num]; if (!fsc.name) { fprintf(trussinfo->outfile, "-- UNKNOWN SYSCALL %d --\n", syscall_num); } diff --git a/usr.bin/truss/amd64-fbsd32.c b/usr.bin/truss/amd64-fbsd32.c index 9b0eb28e7fa8..eab841c96e83 100644 --- a/usr.bin/truss/amd64-fbsd32.c +++ b/usr.bin/truss/amd64-fbsd32.c @@ -152,7 +152,7 @@ amd64_fbsd32_syscall_entry(struct trussinfo *trussinfo, int nargs) { fsc.number = syscall_num; fsc.name = - (syscall_num < 0 || syscall_num > nsyscalls) ? NULL : + (syscall_num < 0 || syscall_num >= nsyscalls) ? NULL : freebsd32_syscallnames[syscall_num]; if (!fsc.name) { fprintf(trussinfo->outfile, "-- UNKNOWN SYSCALL %d --\n", syscall_num); diff --git a/usr.bin/truss/amd64-linux32.c b/usr.bin/truss/amd64-linux32.c index 7d88c8d56890..5e9d012805be 100644 --- a/usr.bin/truss/amd64-linux32.c +++ b/usr.bin/truss/amd64-linux32.c @@ -124,7 +124,7 @@ amd64_linux32_syscall_entry(struct trussinfo *trussinfo, int nargs) { fsc.number = syscall_num; fsc.name = - (syscall_num < 0 || syscall_num > nsyscalls) ? NULL : linux32_syscallnames[syscall_num]; + (syscall_num < 0 || syscall_num >= nsyscalls) ? NULL : linux32_syscallnames[syscall_num]; if (!fsc.name) { fprintf(trussinfo->outfile, "-- UNKNOWN SYSCALL %d --\n", syscall_num); } diff --git a/usr.bin/truss/i386-fbsd.c b/usr.bin/truss/i386-fbsd.c index 6f774b2a4c7b..8500f32bf48e 100644 --- a/usr.bin/truss/i386-fbsd.c +++ b/usr.bin/truss/i386-fbsd.c @@ -147,7 +147,7 @@ i386_syscall_entry(struct trussinfo *trussinfo, int nargs) { fsc.number = syscall_num; fsc.name = - (syscall_num < 0 || syscall_num > nsyscalls) ? NULL : syscallnames[syscall_num]; + (syscall_num < 0 || syscall_num >= nsyscalls) ? NULL : syscallnames[syscall_num]; if (!fsc.name) { fprintf(trussinfo->outfile, "-- UNKNOWN SYSCALL %d --\n", syscall_num); } diff --git a/usr.bin/truss/i386-linux.c b/usr.bin/truss/i386-linux.c index 2bd6e7b64bde..cf4c1c0a3e3a 100644 --- a/usr.bin/truss/i386-linux.c +++ b/usr.bin/truss/i386-linux.c @@ -124,7 +124,7 @@ i386_linux_syscall_entry(struct trussinfo *trussinfo, int nargs) { fsc.number = syscall_num; fsc.name = - (syscall_num < 0 || syscall_num > nsyscalls) ? NULL : linux_syscallnames[syscall_num]; + (syscall_num < 0 || syscall_num >= nsyscalls) ? NULL : linux_syscallnames[syscall_num]; if (!fsc.name) { fprintf(trussinfo->outfile, "-- UNKNOWN SYSCALL %d --\n", syscall_num); } diff --git a/usr.bin/truss/ia64-fbsd.c b/usr.bin/truss/ia64-fbsd.c index 8c8221826f5e..dae111653704 100644 --- a/usr.bin/truss/ia64-fbsd.c +++ b/usr.bin/truss/ia64-fbsd.c @@ -135,7 +135,7 @@ ia64_syscall_entry(struct trussinfo *trussinfo, int nargs) { syscall_num = (int)*parm_offset++; fsc.number = syscall_num; - fsc.name = (syscall_num < 0 || syscall_num > nsyscalls) + fsc.name = (syscall_num < 0 || syscall_num >= nsyscalls) ? NULL : syscallnames[syscall_num]; if (!fsc.name) { fprintf(trussinfo->outfile, "-- UNKNOWN SYSCALL %d --\n", syscall_num); diff --git a/usr.bin/truss/mips-fbsd.c b/usr.bin/truss/mips-fbsd.c index 342883cc66d7..0ef4ac9e9b12 100644 --- a/usr.bin/truss/mips-fbsd.c +++ b/usr.bin/truss/mips-fbsd.c @@ -139,7 +139,7 @@ mips_syscall_entry(struct trussinfo *trussinfo, int nargs) { fsc.number = syscall_num; fsc.name = - (syscall_num < 0 || syscall_num > nsyscalls) ? NULL : syscallnames[syscall_num]; + (syscall_num < 0 || syscall_num >= nsyscalls) ? NULL : syscallnames[syscall_num]; if (!fsc.name) { fprintf(trussinfo->outfile, "-- UNKNOWN SYSCALL %d --\n", syscall_num); } diff --git a/usr.bin/truss/powerpc-fbsd.c b/usr.bin/truss/powerpc-fbsd.c index 43f7c9eece98..8de66eef5bf2 100644 --- a/usr.bin/truss/powerpc-fbsd.c +++ b/usr.bin/truss/powerpc-fbsd.c @@ -149,7 +149,7 @@ powerpc_syscall_entry(struct trussinfo *trussinfo, int nargs) { fsc.number = syscall_num; fsc.name = - (syscall_num < 0 || syscall_num > nsyscalls) ? NULL : syscallnames[syscall_num]; + (syscall_num < 0 || syscall_num >= nsyscalls) ? NULL : syscallnames[syscall_num]; if (!fsc.name) { fprintf(trussinfo->outfile, "-- UNKNOWN SYSCALL %d --\n", syscall_num); } diff --git a/usr.bin/truss/sparc64-fbsd.c b/usr.bin/truss/sparc64-fbsd.c index 787774319430..d06e6b0c60d5 100644 --- a/usr.bin/truss/sparc64-fbsd.c +++ b/usr.bin/truss/sparc64-fbsd.c @@ -145,7 +145,7 @@ sparc64_syscall_entry(struct trussinfo *trussinfo, int nargs) { fsc.number = syscall_num; fsc.name = - (syscall_num < 0 || syscall_num > nsyscalls) ? NULL : syscallnames[syscall_num]; + (syscall_num < 0 || syscall_num >= nsyscalls) ? NULL : syscallnames[syscall_num]; if (!fsc.name) { fprintf(trussinfo->outfile, "-- UNKNOWN SYSCALL %d --\n", syscall_num); }