forked from OSchip/llvm-project
[sanitizer] Fix array sizes used for path in tests
llvm-svn: 324022
This commit is contained in:
parent
b7043222bf
commit
b2a27efdc0
|
@ -8,26 +8,20 @@
|
|||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#define LEN PATH_MAX
|
||||
#else
|
||||
#define LEN NAME_MAX
|
||||
#endif
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
char symlink_path[LEN];
|
||||
char symlink_path[PATH_MAX];
|
||||
snprintf(symlink_path, sizeof(symlink_path), "%s_%d.symlink", argv[0],
|
||||
getpid());
|
||||
int res = symlink(argv[0], symlink_path);
|
||||
assert(!res);
|
||||
|
||||
char readlink_path[LEN];
|
||||
char readlink_path[PATH_MAX];
|
||||
ssize_t res2 = readlink(symlink_path, readlink_path, sizeof(readlink_path));
|
||||
assert(res2 >= 0);
|
||||
readlink_path[res2] = '\0';
|
||||
assert(!strcmp(readlink_path, argv[0]));
|
||||
|
||||
char readlinkat_path[LEN];
|
||||
char readlinkat_path[PATH_MAX];
|
||||
res2 = readlinkat(AT_FDCWD, symlink_path, readlinkat_path,
|
||||
sizeof(readlink_path));
|
||||
assert(res2 >= 0);
|
||||
|
|
|
@ -7,20 +7,14 @@
|
|||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#define LEN PATH_MAX
|
||||
#else
|
||||
#define LEN NAME_MAX
|
||||
#endif
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
char symlink_path[LEN];
|
||||
char symlink_path[PATH_MAX];
|
||||
snprintf(symlink_path, sizeof(symlink_path), "%s_%d.symlink", argv[0],
|
||||
getpid());
|
||||
int res = symlink(argv[0], symlink_path);
|
||||
assert(!res);
|
||||
|
||||
char readlinkat_path[LEN];
|
||||
char readlinkat_path[PATH_MAX];
|
||||
int res2 = readlinkat(AT_FDCWD, symlink_path, readlinkat_path,
|
||||
sizeof(readlinkat_path));
|
||||
assert(res2 >= 0);
|
||||
|
|
Loading…
Reference in New Issue