summaryrefslogtreecommitdiffstats
path: root/usr.sbin/jls
diff options
context:
space:
mode:
authorbz <bz@FreeBSD.org>2008-12-11 01:04:25 +0000
committerbz <bz@FreeBSD.org>2008-12-11 01:04:25 +0000
commite65de9d9824d3b5379b9f57139d753a1d566f921 (patch)
treee15a64ee7912abf77ac2429c1e74f032748f52b5 /usr.sbin/jls
parentda8c897826760d083248a5fc96e280066909c8b7 (diff)
downloadFreeBSD-src-e65de9d9824d3b5379b9f57139d753a1d566f921.zip
FreeBSD-src-e65de9d9824d3b5379b9f57139d753a1d566f921.tar.gz
Correctly check the number of prison states to not access anything
outside the prison_states array. When checking if there is a name configured for the prison, check the first character to not be '\0' instead of checking if the char array is present, which it always is. Note, that this is different for the *jailname in the syscall. Found with: Coverity Prevent(tm) CID: 4156, 4155 MFC after: 4 weeks (just that I get the mail)
Diffstat (limited to 'usr.sbin/jls')
-rw-r--r--usr.sbin/jls/jls.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/usr.sbin/jls/jls.c b/usr.sbin/jls/jls.c
index 4488c31..5853abc 100644
--- a/usr.sbin/jls/jls.c
+++ b/usr.sbin/jls/jls.c
@@ -86,7 +86,7 @@ char *print_xprison_v3(void *p, char *end, unsigned flags)
errx(1, "Invalid length for jail");
xp = (struct xprison *)p;
- if (xp->pr_state < 0 || xp->pr_state > (int)
+ if (xp->pr_state < 0 || xp->pr_state >= (int)
((sizeof(prison_states) / sizeof(struct prison_state))))
state = "(bogus)";
else
@@ -110,7 +110,7 @@ char *print_xprison_v3(void *p, char *end, unsigned flags)
/* Jail state and name. */
if (flags & FLAG_V)
printf("%6s %-29.29s %.74s\n",
- "", (xp->pr_name != NULL) ? xp->pr_name : "", state);
+ "", (xp->pr_name[0] != '\0') ? xp->pr_name : "", state);
/* cpusetid. */
if (flags & FLAG_V)
OpenPOWER on IntegriCloud