old_sysctl: fix null dereference when oldlenp == NULL.
This commit is contained in:
parent
0ed4057082
commit
ebfab35576
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kern_sysctl.c,v 1.185 2005/08/07 04:54:07 yamt Exp $ */
|
||||
/* $NetBSD: kern_sysctl.c,v 1.186 2005/08/21 13:14:54 yamt Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
|
@ -75,7 +75,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_sysctl.c,v 1.185 2005/08/07 04:54:07 yamt Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_sysctl.c,v 1.186 2005/08/21 13:14:54 yamt Exp $");
|
||||
|
||||
#include "opt_defcorename.h"
|
||||
#include "opt_insecure.h"
|
||||
|
@ -2545,17 +2545,27 @@ old_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp,
|
|||
void *newp, size_t newlen, struct lwp *l)
|
||||
{
|
||||
int error;
|
||||
size_t savelen = *oldlenp;
|
||||
size_t oldlen = 0;
|
||||
size_t savelen;
|
||||
|
||||
if (oldlenp) {
|
||||
oldlen = *oldlenp;
|
||||
}
|
||||
savelen = oldlen;
|
||||
|
||||
error = sysctl_lock(l, oldp, savelen);
|
||||
if (error)
|
||||
return (error);
|
||||
error = sysctl_dispatch(name, namelen, oldp, oldlenp,
|
||||
error = sysctl_dispatch(name, namelen, oldp, &oldlen,
|
||||
newp, newlen, name, l, NULL);
|
||||
sysctl_unlock(l);
|
||||
if (error == 0 && oldp != NULL && savelen < *oldlenp)
|
||||
if (error == 0 && oldp != NULL && savelen < oldlen)
|
||||
error = ENOMEM;
|
||||
|
||||
if (oldlenp) {
|
||||
*oldlenp = oldlen;
|
||||
}
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue