From: Martin Mares Date: Wed, 18 Jul 2012 16:46:09 +0000 (+0200) Subject: setproctitle: Copy all arguments in setproctitle_init() X-Git-Tag: v5.99~133 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=63d7c945746d3dc7c98928883213603711c0b0b3;p=libucw.git setproctitle: Copy all arguments in setproctitle_init() Otherwise, values of command-line arguments, which are not explicitly copied, can be corrupted by setproctitle(). --- 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