summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2018-04-25 11:15:59 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2018-04-25 11:15:59 +0000
commitf27446c980336f27ac50b6765c323462a512c605 (patch)
tree1e03f00761d5f70f6f251b6e9a04c32adec99e4b /sys
parentb73fa8cf8f1c07640fda852104ee5cb5d57d171e (diff)
use size_t for the size of buffers and strings, not int.
sprinkle some bounded attributes while here. ok deraadt@
Diffstat (limited to 'sys')
-rw-r--r--sys/lib/libkern/getsn.c9
-rw-r--r--sys/lib/libkern/libkern.h5
2 files changed, 8 insertions, 6 deletions
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 <sys/systm.h>
#include <dev/cons.h>
-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);