From 3f376b0849a3d7e59ed23ac6dba2b729fc2c7589 Mon Sep 17 00:00:00 2001 From: dlg Date: Wed, 14 Jun 2017 03:00:40 +0000 Subject: [PATCH] tweak sysctl_string and sysctl_tstring to use size_t for lengths, not int theyre both wrappers around sysctl__string, which is where half the fix is too. --- sys/kern/kern_sysctl.c | 11 ++++++----- sys/sys/sysctl.h | 8 ++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index 13024bf6ecb..16d1d279036 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sysctl.c,v 1.327 2017/06/13 06:16:31 dlg Exp $ */ +/* $OpenBSD: kern_sysctl.c,v 1.328 2017/06/14 03:00:40 dlg Exp $ */ /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */ /*- @@ -928,23 +928,24 @@ sysctl_rdquad(void *oldp, size_t *oldlenp, void *newp, int64_t val) */ int sysctl_string(void *oldp, size_t *oldlenp, void *newp, size_t newlen, char *str, - int maxlen) + size_t maxlen) { return sysctl__string(oldp, oldlenp, newp, newlen, str, maxlen, 0); } int sysctl_tstring(void *oldp, size_t *oldlenp, void *newp, size_t newlen, - char *str, int maxlen) + char *str, size_t maxlen) { return sysctl__string(oldp, oldlenp, newp, newlen, str, maxlen, 1); } int sysctl__string(void *oldp, size_t *oldlenp, void *newp, size_t newlen, - char *str, int maxlen, int trunc) + char *str, size_t maxlen, int trunc) { - int len, error = 0; + size_t len; + int error = 0; len = strlen(str) + 1; if (oldp && *oldlenp < len) { diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h index 78155712a2e..ba0a03e416f 100644 --- a/sys/sys/sysctl.h +++ b/sys/sys/sysctl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sysctl.h,v 1.173 2017/06/13 06:16:31 dlg Exp $ */ +/* $OpenBSD: sysctl.h,v 1.174 2017/06/14 03:00:40 dlg Exp $ */ /* $NetBSD: sysctl.h,v 1.16 1996/04/09 20:55:36 cgd Exp $ */ /* @@ -928,9 +928,9 @@ int sysctl_rdint(void *, size_t *, void *, int); int sysctl_int_arr(int **, int *, u_int, void *, size_t *, void *, size_t); int sysctl_quad(void *, size_t *, void *, size_t, int64_t *); int sysctl_rdquad(void *, size_t *, void *, int64_t); -int sysctl_string(void *, size_t *, void *, size_t, char *, int); -int sysctl_tstring(void *, size_t *, void *, size_t, char *, int); -int sysctl__string(void *, size_t *, void *, size_t, char *, int, int); +int sysctl_string(void *, size_t *, void *, size_t, char *, size_t); +int sysctl_tstring(void *, size_t *, void *, size_t, char *, size_t); +int sysctl__string(void *, size_t *, void *, size_t, char *, size_t, int); int sysctl_rdstring(void *, size_t *, void *, const char *); int sysctl_rdstruct(void *, size_t *, void *, const void *, size_t); int sysctl_struct(void *, size_t *, void *, size_t, void *, size_t); -- 2.20.1