diff options
author | 2002-08-05 14:49:26 +0000 | |
---|---|---|
committer | 2002-08-05 14:49:26 +0000 | |
commit | e87d4d8fca6d663c1e2878fe35d0920beb816e41 (patch) | |
tree | 7ace511ac69fb6ee8491b2ecbad29bfadc951253 | |
parent | different translation for lstat (diff) | |
download | wireguard-openbsd-e87d4d8fca6d663c1e2878fe35d0920beb816e41.tar.xz wireguard-openbsd-e87d4d8fca6d663c1e2878fe35d0920beb816e41.zip |
increase buffer size for getstring, useful for execve arguments.
intercept_filename deals better with symlinked last component lookups.
change some translations to use unlinkname.
-rw-r--r-- | bin/systrace/intercept.c | 19 | ||||
-rw-r--r-- | bin/systrace/register.c | 7 |
2 files changed, 18 insertions, 8 deletions
diff --git a/bin/systrace/intercept.c b/bin/systrace/intercept.c index c450fa0ed9c..373f6050aeb 100644 --- a/bin/systrace/intercept.c +++ b/bin/systrace/intercept.c @@ -1,4 +1,4 @@ -/* $OpenBSD: intercept.c,v 1.24 2002/08/04 04:15:50 provos Exp $ */ +/* $OpenBSD: intercept.c,v 1.25 2002/08/05 14:49:26 provos Exp $ */ /* * Copyright 2002 Niels Provos <provos@citi.umich.edu> * All rights reserved. @@ -486,7 +486,7 @@ intercept_replace(int fd, pid_t pid, struct intercept_replace *repl) char * intercept_get_string(int fd, pid_t pid, void *addr) { - static char name[_POSIX2_LINE_MAX]; + static char name[8192]; int off = 0, done = 0, stride; stride = 32; @@ -546,8 +546,15 @@ intercept_filename(int fd, pid_t pid, void *addr, int userp) static char rcwd[2*MAXPATHLEN]; int failed = 0; - if (userp == ICLINK_NOLAST) - goto nolast; + if (userp == ICLINK_NOLAST) { + char *file = basename(cwd); + + /* Check if the last component has special meaning */ + if (strcmp(file, ".") == 0 || strcmp(file, "..") == 0) + userp = ICLINK_ALL; + else + goto nolast; + } /* If realpath fails then the filename does not exist, * or we are supposed to not resolve the last component */ @@ -574,7 +581,9 @@ intercept_filename(int fd, pid_t pid, void *addr, int userp) failed = 1; goto out; } - if (strlcat(rcwd, "/", sizeof(rcwd)) >= sizeof(rcwd)) + /* If path is not "/" append a "/" */ + if (strlen(rcwd) > 1 && + strlcat(rcwd, "/", sizeof(rcwd)) >= sizeof(rcwd)) goto error; if (strlcat(rcwd, file, sizeof(rcwd)) >= sizeof(rcwd)) goto error; diff --git a/bin/systrace/register.c b/bin/systrace/register.c index eab911dc60b..222d33560d2 100644 --- a/bin/systrace/register.c +++ b/bin/systrace/register.c @@ -1,4 +1,4 @@ -/* $OpenBSD: register.c,v 1.10 2002/08/05 14:26:07 provos Exp $ */ +/* $OpenBSD: register.c,v 1.11 2002/08/05 14:49:27 provos Exp $ */ /* * Copyright 2002 Niels Provos <provos@citi.umich.edu> * All rights reserved. @@ -102,7 +102,8 @@ systrace_initcb(void) intercept_register_translation("native", "fchmod", 0, &fdt); intercept_register_translation("native", "fchmod", 1, &modeflags); X(intercept_register_sccb("native", "readlink", trans_cb, NULL)); - tl = intercept_register_translink("native", "readlink", 0); + tl = intercept_register_translation("native", "readlink", 0, + &ic_translate_unlinkname); alias = systrace_new_alias("native", "readlink", "native", "fsread"); systrace_alias_add_trans(alias, tl); @@ -129,7 +130,7 @@ systrace_initcb(void) intercept_register_transfn("native", "rename", 1); X(intercept_register_sccb("native", "symlink", trans_cb, NULL)); intercept_register_transstring("native", "symlink", 0); - intercept_register_translink("native", "symlink", 1); + intercept_register_transfn("native", "symlink", 1); X(intercept_register_sccb("native", "link", trans_cb, NULL)); intercept_register_transfn("native", "link", 0); intercept_register_transfn("native", "link", 1); |