From: Timo Sirainen Date: Mon, 23 Feb 2009 18:18:17 +0000 (-0500) Subject: deliver -p: Expand relative paths before chdir()ing. X-Git-Tag: 1.2.beta2~61 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6121f4f22dd6f2ac63b567ffc9e449e2eeb649c4;p=thirdparty%2Fdovecot%2Fcore.git deliver -p: Expand relative paths before chdir()ing. --HG-- branch : HEAD --- diff --git a/src/deliver/deliver.c b/src/deliver/deliver.c index 042c3ac31a..24393c36b7 100644 --- a/src/deliver/deliver.c +++ b/src/deliver/deliver.c @@ -828,6 +828,7 @@ int main(int argc, char *argv[]) struct mailbox_transaction_context *t; struct mailbox_header_lookup_ctx *headers_ctx; struct mail *mail; + char cwd[PATH_MAX]; uid_t process_euid; bool stderr_rejection = FALSE; bool keep_environment = FALSE; @@ -893,6 +894,12 @@ int main(int argc, char *argv[]) if (i == argc) i_fatal_status(EX_USAGE, "Missing -p argument"); path = argv[i]; + if (*path != '/') { + /* expand relative paths before we chdir */ + if (getcwd(cwd, sizeof(cwd)) == NULL) + i_fatal("getcwd() failed: %m"); + path = t_strconcat(cwd, "/", path, NULL); + } } else if (strcmp(argv[i], "-e") == 0) { stderr_rejection = TRUE; } else if (strcmp(argv[i], "-c") == 0) {