diff options
author | dim <dim@FreeBSD.org> | 2015-06-20 19:34:50 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2015-06-20 19:34:50 +0000 |
commit | e109f99dcb6c95c84bbec22229de29a25491f7c2 (patch) | |
tree | d142d742b698973a366ae768a3f4033924e314c8 /lib/libc/sys/stack_protector.c | |
parent | 238df27d058d0d8912acf0a186d3f43289a0a2b6 (diff) | |
parent | cb167b45a82327b0d6d88e85e3d6e2e326291ee4 (diff) | |
download | FreeBSD-src-e109f99dcb6c95c84bbec22229de29a25491f7c2.zip FreeBSD-src-e109f99dcb6c95c84bbec22229de29a25491f7c2.tar.gz |
Merge ^/head r284188 through r284643.
Diffstat (limited to 'lib/libc/sys/stack_protector.c')
-rw-r--r-- | lib/libc/sys/stack_protector.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/lib/libc/sys/stack_protector.c b/lib/libc/sys/stack_protector.c index ed7d635..cd5f166 100644 --- a/lib/libc/sys/stack_protector.c +++ b/lib/libc/sys/stack_protector.c @@ -41,8 +41,8 @@ __FBSDID("$FreeBSD$"); #include <unistd.h> #include "libc_private.h" -extern int __sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, - void *newp, size_t newlen); +extern int __sysctl(const int *name, u_int namelen, void *oldp, + size_t *oldlenp, void *newp, size_t newlen); long __stack_chk_guard[8] = {0, 0, 0, 0, 0, 0, 0, 0}; static void __guard_setup(void) __attribute__((__constructor__, __used__)); @@ -54,7 +54,7 @@ void __chk_fail(void); static void __guard_setup(void) { - int mib[2]; + static const int mib[2] = { CTL_KERN, KERN_ARND }; size_t len; int error; @@ -65,12 +65,9 @@ __guard_setup(void) if (error == 0 && __stack_chk_guard[0] != 0) return; - mib[0] = CTL_KERN; - mib[1] = KERN_ARND; - len = sizeof(__stack_chk_guard); - if (__sysctl(mib, 2, __stack_chk_guard, &len, NULL, 0) == -1 || - len != sizeof(__stack_chk_guard)) { + if (__sysctl(mib, nitems(mib), __stack_chk_guard, &len, NULL, 0) == + -1 || len != sizeof(__stack_chk_guard)) { /* If sysctl was unsuccessful, use the "terminator canary". */ ((unsigned char *)(void *)__stack_chk_guard)[0] = 0; ((unsigned char *)(void *)__stack_chk_guard)[1] = 0; |