aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2009-04-08 04:46:34 -0400
committerMike Frysinger <vapier@gentoo.org>2009-04-08 04:46:34 -0400
commit4d60bd19491cbe249e09f368be0879429227db49 (patch)
tree58edef21f88b9937ef55f26de5d4019a440fe5a6
parentlibsandbox: symbols.h does not care about wrapper files (diff)
downloadsandbox-4d60bd19491cbe249e09f368be0879429227db49.tar.gz
sandbox-4d60bd19491cbe249e09f368be0879429227db49.tar.bz2
sandbox-4d60bd19491cbe249e09f368be0879429227db49.zip
libsandbox: test for ERANGE like ENAMETOOLONG
Some arches (like ia64) return ERANGE for too long path names, so accept that as the same way we accept ENAMETOOLONG. The BSDs also seem to do this, so they'll get fixed as well. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
-rw-r--r--libsandbox/libsandbox.c8
-rw-r--r--libsandbox/libsandbox.h2
-rwxr-xr-xtests/script-5.sh1
3 files changed, 7 insertions, 4 deletions
diff --git a/libsandbox/libsandbox.c b/libsandbox/libsandbox.c
index 6c405aa..03a2069 100644
--- a/libsandbox/libsandbox.c
+++ b/libsandbox/libsandbox.c
@@ -163,7 +163,7 @@ int canonicalize(const char *path, char *resolved_path)
* an absolute path
*/
- if (ENAMETOOLONG == errno)
+ if (errno_is_too_long())
return -1;
if (NULL == egetcwd(resolved_path, SB_PATH_MAX - 2))
@@ -172,7 +172,7 @@ int canonicalize(const char *path, char *resolved_path)
snprintf(resolved_path + len, SB_PATH_MAX - len, "/%s", path);
if (NULL == erealpath(resolved_path, resolved_path)) {
- if (errno == ENAMETOOLONG) {
+ if (errno_is_too_long()) {
/* The resolved path is too long for the buffer to hold */
return -1;
} else {
@@ -916,7 +916,7 @@ static int check_syscall(sbcontext_t *sbcontext, int sb_nr, const char *func,
/* The path is too long to be canonicalized, so just warn and let the
* function handle it (see bugs #21766 #94630 #101728 #227947)
*/
- if (ENAMETOOLONG == errno) {
+ if (errno_is_too_long()) {
free(absolute_path);
free(resolved_path);
return 2;
@@ -983,7 +983,7 @@ bool before_syscall(int dirfd, int sb_nr, const char *func, const char *file, in
ssize_t ret = readlink(at_file_buf, at_file_buf, at_len);
if (ret == -1) {
/* see comments at end of check_syscall() */
- if (errno == ENAMETOOLONG) {
+ if (errno_is_too_long()) {
restore_errno();
return true;
}
diff --git a/libsandbox/libsandbox.h b/libsandbox/libsandbox.h
index 439e9b2..28154c5 100644
--- a/libsandbox/libsandbox.h
+++ b/libsandbox/libsandbox.h
@@ -69,6 +69,8 @@ __attribute__((noreturn)) void sb_abort(void);
char *erealpath(const char *, char *);
char *egetcwd(char *, size_t);
int canonicalize(const char *, char *);
+/* most linux systems use ENAMETOOLONG, but some (ia64) use ERANGE, as do some BSDs */
+#define errno_is_too_long() (errno == ENAMETOOLONG || errno == ERANGE)
#include "sbutil.h"
diff --git a/tests/script-5.sh b/tests/script-5.sh
index 4b7d4fd..9f3e4bc 100755
--- a/tests/script-5.sh
+++ b/tests/script-5.sh
@@ -4,6 +4,7 @@
[ "${at_xfail}" = "yes" ] && exit 77 # see script-0
addwrite $PWD
+mkdir foo && cd foo || exit 1
getcwd-gnulib_tst
case $? in
0|1|2) exit 0;; # test may exit with these values