diff options
author | Cristian Cadar <c.cadar@imperial.ac.uk> | 2013-10-20 02:51:24 -0700 |
---|---|---|
committer | Cristian Cadar <c.cadar@imperial.ac.uk> | 2013-10-20 02:51:24 -0700 |
commit | 631e2f6f9ffcb9ad345220426ec080bd74e10cf3 (patch) | |
tree | ffefd33d24db2cf9a87161983c9ecbed55e6870c | |
parent | a07ac98574e93f196b3bfdacaceceb4b5a806e13 (diff) | |
parent | 45bc57b046f4afdb4737dafd42ea8e2d5ed05c95 (diff) | |
download | klee-631e2f6f9ffcb9ad345220426ec080bd74e10cf3.tar.gz |
Merge pull request #47 from 251/stubs_path_max
Simplified implementation of canonicalize_file_name(). Addresses #46.
-rw-r--r-- | runtime/POSIX/stubs.c | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/runtime/POSIX/stubs.c b/runtime/POSIX/stubs.c index 7a424d05..99e2e768 100644 --- a/runtime/POSIX/stubs.c +++ b/runtime/POSIX/stubs.c @@ -7,19 +7,21 @@ // //===----------------------------------------------------------------------===// -#include <string.h> -#include <stdio.h> +#define _XOPEN_SOURCE 700 + #include <errno.h> +#include <limits.h> #include <signal.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> #include <time.h> +#include <unistd.h> #include <utime.h> #include <utmp.h> -#include <unistd.h> -#include <limits.h> -#include <stdlib.h> #include <sys/mman.h> -#include <sys/stat.h> #include <sys/resource.h> +#include <sys/stat.h> #include <sys/times.h> #include <sys/types.h> #include <sys/wait.h> @@ -31,20 +33,20 @@ void klee_warning_once(const char*); /* Silent ignore */ -int __syscall_rt_sigaction(int signum, const struct sigaction *act, +int __syscall_rt_sigaction(int signum, const struct sigaction *act, struct sigaction *oldact, size_t _something) __attribute__((weak)); -int __syscall_rt_sigaction(int signum, const struct sigaction *act, +int __syscall_rt_sigaction(int signum, const struct sigaction *act, struct sigaction *oldact, size_t _something) { klee_warning_once("silently ignoring"); return 0; } -int sigaction(int signum, const struct sigaction *act, +int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact) __attribute__((weak)); -int sigaction(int signum, const struct sigaction *act, +int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact) { klee_warning_once("silently ignoring"); return 0; @@ -122,21 +124,21 @@ int link(const char *oldpath, const char *newpath) __attribute__((weak)); int link(const char *oldpath, const char *newpath) { klee_warning("ignoring (EPERM)"); errno = EPERM; - return -1; + return -1; } int symlink(const char *oldpath, const char *newpath) __attribute__((weak)); int symlink(const char *oldpath, const char *newpath) { klee_warning("ignoring (EPERM)"); errno = EPERM; - return -1; + return -1; } int rename(const char *oldpath, const char *newpath) __attribute__((weak)); int rename(const char *oldpath, const char *newpath) { klee_warning("ignoring (EPERM)"); errno = EPERM; - return -1; + return -1; } int nanosleep(const struct timespec *req, struct timespec *rem) __attribute__((weak)); @@ -246,17 +248,13 @@ unsigned int gnu_dev_minor(unsigned long long int __dev) { unsigned long long int gnu_dev_makedev(unsigned int __major, unsigned int __minor) __attribute__((weak)); unsigned long long int gnu_dev_makedev(unsigned int __major, unsigned int __minor) { return ((__minor & 0xff) | ((__major & 0xfff) << 8) - | (((unsigned long long int) (__minor & ~0xff)) << 12) - | (((unsigned long long int) (__major & ~0xfff)) << 32)); + | (((unsigned long long int) (__minor & ~0xff)) << 12) + | (((unsigned long long int) (__major & ~0xfff)) << 32)); } char *canonicalize_file_name (const char *name) __attribute__((weak)); char *canonicalize_file_name (const char *name) { - char *res = malloc(PATH_MAX); - char *rp_res = realpath(name, res); - if (!rp_res) - free(res); - return rp_res; + return realpath(name, NULL); } int getloadavg(double loadavg[], int nelem) __attribute__((weak)); |