From f27446c980336f27ac50b6765c323462a512c605 Mon Sep 17 00:00:00 2001 From: David Gwynne Date: Wed, 25 Apr 2018 11:15:59 +0000 Subject: use size_t for the size of buffers and strings, not int. sprinkle some bounded attributes while here. ok deraadt@ --- sys/lib/libkern/getsn.c | 9 +++++---- sys/lib/libkern/libkern.h | 5 +++-- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'sys') diff --git a/sys/lib/libkern/getsn.c b/sys/lib/libkern/getsn.c index 3bb3f218ad7..4342c1024a6 100644 --- a/sys/lib/libkern/getsn.c +++ b/sys/lib/libkern/getsn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getsn.c,v 1.6 2012/12/05 23:20:22 deraadt Exp $ */ +/* $OpenBSD: getsn.c,v 1.7 2018/04/25 11:15:58 dlg Exp $ */ /* * Copyright (c) 1996 Theo de Raadt @@ -29,10 +29,11 @@ #include #include -int -getsn(char *cp, int size) +size_t +getsn(char *cp, size_t size) { - int len = 0, c; + size_t len = 0; + int c; char *lp = cp; while (1) { diff --git a/sys/lib/libkern/libkern.h b/sys/lib/libkern/libkern.h index d743920ea0b..db020a8ed03 100644 --- a/sys/lib/libkern/libkern.h +++ b/sys/lib/libkern/libkern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: libkern.h,v 1.34 2014/07/13 23:49:40 uebayasi Exp $ */ +/* $OpenBSD: libkern.h,v 1.35 2018/04/25 11:15:58 dlg Exp $ */ /* $NetBSD: libkern.h,v 1.7 1996/03/14 18:52:08 christos Exp $ */ /*- @@ -183,7 +183,8 @@ size_t strlcat(char *, const char *, size_t) int strcmp(const char *, const char *); int strncmp(const char *, const char *, size_t); int strncasecmp(const char *, const char *, size_t); -int getsn(char *, int); +size_t getsn(char *, size_t) + __attribute__ ((__bounded__(__string__,1,2))); char *strchr(const char *, int); char *strrchr(const char *, int); int timingsafe_bcmp(const void *, const void *, size_t); -- cgit v1.2.3