From 63d7c945746d3dc7c98928883213603711c0b0b3 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Wed, 18 Jul 2012 18:46:09 +0200 Subject: [PATCH] setproctitle: Copy all arguments in setproctitle_init() Otherwise, values of command-line arguments, which are not explicitly copied, can be corrupted by setproctitle(). --- ucw/process.h | 1 + ucw/proctitle.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ucw/process.h b/ucw/process.h index 2c780237..b995cf57 100644 --- a/ucw/process.h +++ b/ucw/process.h @@ -12,6 +12,7 @@ /* proctitle.c */ +// Must be called before parsing of arguments void setproctitle_init(int argc, char **argv); void setproctitle(const char *msg, ...) FORMAT_CHECK(printf,1,2); char *getproctitle(void); diff --git a/ucw/proctitle.c b/ucw/proctitle.c index 8810b0bf..82a0b8ed 100644 --- a/ucw/proctitle.c +++ b/ucw/proctitle.c @@ -53,8 +53,12 @@ setproctitle_init(int argc, char **argv) if (spt_end+1 == oldenv[i]) spt_end = oldenv[i] + strlen(oldenv[i]); + /* Copy all arguments */ + for (i=0; i