Move check of strp for NULL to the top of the function, if it's NULL
release the lock and exit. It could be argued that we only ever call the function with strp being valid so the test isn't needed, but that requires the caller not to change, or be altered/broken. Fixes Coverity CID 2357, strp deferenced before NULL check.
This commit is contained in:
parent
3b6dcb2526
commit
998afe8b1c
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kern_systrace.c,v 1.51 2006/03/01 12:38:21 yamt Exp $ */
|
||||
/* $NetBSD: kern_systrace.c,v 1.52 2006/03/18 17:44:13 chris Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 2002, 2003 Niels Provos <provos@citi.umich.edu>
|
||||
|
@ -31,7 +31,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_systrace.c,v 1.51 2006/03/01 12:38:21 yamt Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_systrace.c,v 1.52 2006/03/18 17:44:13 chris Exp $");
|
||||
|
||||
#include "opt_systrace.h"
|
||||
|
||||
|
@ -1461,6 +1461,11 @@ systrace_scriptname(struct proc *p, char *dst)
|
|||
|
||||
systrace_lock();
|
||||
strp = p->p_systrace;
|
||||
if (strp == NULL) {
|
||||
systrace_unlock();
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
fst = strp->parent;
|
||||
|
||||
SYSTRACE_LOCK(fst, curlwp);
|
||||
|
@ -1473,16 +1478,14 @@ systrace_scriptname(struct proc *p, char *dst)
|
|||
goto out;
|
||||
}
|
||||
|
||||
if (strp != NULL) {
|
||||
if (strp->scriptname[0] == '\0') {
|
||||
error = ENOENT;
|
||||
goto out;
|
||||
}
|
||||
|
||||
strlcpy(dst, strp->scriptname, MAXPATHLEN);
|
||||
strp->isscript = 1;
|
||||
if (strp->scriptname[0] == '\0') {
|
||||
error = ENOENT;
|
||||
goto out;
|
||||
}
|
||||
|
||||
strlcpy(dst, strp->scriptname, MAXPATHLEN);
|
||||
strp->isscript = 1;
|
||||
|
||||
out:
|
||||
strp->scriptname[0] = '\0';
|
||||
SYSTRACE_UNLOCK(fst, curlwp);
|
||||
|
|
Loading…
Reference in New Issue