From 9af00b1d73cff7acd1fd119576c547795d45d026 Mon Sep 17 00:00:00 2001 From: martynas <> Date: Sat, 28 Dec 2013 01:51:53 +0000 Subject: [PATCH] Annotate a few more bounded functions: realpath(3) needs a buffer of size at least PATH_MAX. pread(2), pwrite(2) and readlinkat(2) also take the buffer and the bound. OK theo. --- src/include/stdlib.h | 5 +++-- src/include/unistd.h | 11 +++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/include/stdlib.h b/src/include/stdlib.h index d50946a9..a2310e36 100644 --- a/src/include/stdlib.h +++ b/src/include/stdlib.h @@ -1,4 +1,4 @@ -/* $OpenBSD: stdlib.h,v 1.55 2013/12/13 20:48:39 millert Exp $ */ +/* $OpenBSD: stdlib.h,v 1.56 2013/12/28 01:51:53 martynas Exp $ */ /* $NetBSD: stdlib.h,v 1.25 1995/12/27 21:19:08 jtc Exp $ */ /*- @@ -188,7 +188,8 @@ long random(void); char *setstate(char *); void srandom(unsigned int); -char *realpath(const char *, char *); +char *realpath(const char *, char *) + __attribute__((__bounded__ (__minbytes__,2,1024))); int setkey(const char *); diff --git a/src/include/unistd.h b/src/include/unistd.h index bc621998..501f2a88 100644 --- a/src/include/unistd.h +++ b/src/include/unistd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: unistd.h,v 1.82 2013/12/04 22:58:24 deraadt Exp $ */ +/* $OpenBSD: unistd.h,v 1.83 2013/12/28 01:51:53 martynas Exp $ */ /* $NetBSD: unistd.h,v 1.26.4.1 1996/05/28 02:31:51 mrg Exp $ */ /*- @@ -436,8 +436,10 @@ pid_t getsid(pid_t); #endif #if __XPG_VISIBLE >= 500 -ssize_t pread(int, void *, size_t, off_t); -ssize_t pwrite(int, const void *, size_t, off_t); +ssize_t pread(int, void *, size_t, off_t) + __attribute__((__bounded__(__buffer__,2,3))); +ssize_t pwrite(int, const void *, size_t, off_t) + __attribute__((__bounded__(__buffer__,2,3))); int ttyname_r(int, char *, size_t) __attribute__((__bounded__(__string__,2,3))); #endif @@ -468,7 +470,8 @@ int seteuid(uid_t); int faccessat(int, const char *, int, int); int fchownat(int, const char *, uid_t, gid_t, int); int linkat(int, const char *, int, const char *, int); -ssize_t readlinkat(int, const char *, char *, size_t); +ssize_t readlinkat(int, const char *, char *, size_t) + __attribute__ ((__bounded__(__string__,3,4))); int symlinkat(const char *, int, const char *); int unlinkat(int, const char *, int); #endif