summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-08-06 23:05:00 -0400
committerIan Moffett <ian@osmora.org>2025-08-06 23:05:00 -0400
commit9de636933536756970fb2da41030dc4c5afd83b9 (patch)
tree3ef5ee01502108ea216b389707028e380127cb8d /sys
parent3e1379d84c4502a380cad375b93a7cf36ab2c02e (diff)
kernel: sysctl: Set 'oldlenp' to NULL if needed
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_sysctl.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c
index fc8feec..6df5a8d 100644
--- a/sys/kern/kern_sysctl.c
+++ b/sys/kern/kern_sysctl.c
@@ -95,9 +95,10 @@ do_sysctl(struct sysctl_args *args)
size_t name_len = 1, oldlenp = 0;
int *name = NULL;
void *oldp = NULL, *newp = NULL;
- int retval = 0;
+ int retval = 0, have_oldlen = 0;
if (args->oldlenp != NULL) {
+ have_oldlen = 1;
name_len = args->nlen;
retval = copyin(args->oldlenp, &oldlenp, sizeof(oldlenp));
if (retval != 0) {
@@ -135,7 +136,7 @@ do_sysctl(struct sysctl_args *args)
new_args.name = name;
new_args.nlen = name_len;
new_args.oldp = oldp;
- new_args.oldlenp = &oldlenp;
+ new_args.oldlenp = (have_oldlen) ? &oldlenp : NULL;
new_args.newp = newp;
new_args.newlen = args->newlen;