Last active
January 16, 2019 22:34
-
-
Save seisvelas/f8a9faf45ec3a38b88e2361d3b88ee43 to your computer and use it in GitHub Desktop.
Test for possible bug in Torsocks getdent_fix branch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <dirent.h> | |
#include <fcntl.h> | |
#include <stdio.h> | |
#include <unistd.h> | |
#include <stdlib.h> | |
#include <sys/stat.h> | |
#include <sys/syscall.h> | |
#define handle_error(msg) \ | |
do { perror(msg); exit(EXIT_FAILURE); } while (0) | |
struct linux_dirent64 { | |
long d_ino; | |
off_t d_off; | |
unsigned short d_reclen; | |
char d_name[]; | |
}; | |
#define BUF_SIZE 1024 | |
int | |
main(int argc, char * argv[]) { | |
int fd, nread; | |
char buf[BUF_SIZE]; | |
struct linux_dirent64 * d; | |
int bpos; | |
char d_type; | |
fd = open(argc > 1 ? argv[1] : ".", O_RDONLY | O_DIRECTORY); | |
nread = syscall(SYS_getdents64, fd, buf, BUF_SIZE); | |
exit(EXIT_SUCCESS); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment