From 77e0d2dccc2487923325571f02cba5c377d5bb9a Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Mon, 2 Mar 2015 02:13:03 +0000 Subject: [PATCH] tests/uid16: skip if real uid is larger than 16bit * tests/uid16.c (main): Skip if the uid returned by getuid matches /proc/sys/kernel/overflowuid. --- tests/uid16.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/uid16.c b/tests/uid16.c index be5cec6d..a2006d7f 100644 --- a/tests/uid16.c +++ b/tests/uid16.c @@ -4,6 +4,7 @@ #include #include #include +#include #include int @@ -38,6 +39,21 @@ main(void) int *list = 0; uid = syscall(__NR_getuid); + + (void) close(0); + if (open("/proc/sys/kernel/overflowuid", O_RDONLY) == 0) { + /* we trust the kernel */ + char buf[sizeof(int)*3]; + int n = read(0, buf, sizeof(buf) - 1); + if (n) { + buf[n] = '\0'; + n = atoi(buf); + if (uid == n) + return 77; + } + close(0); + } + assert(syscall(__NR_setuid, uid) == 0); { /*