diff options
author | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2003-06-26 09:04:03 +0800 |
---|---|---|
committer | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2003-06-26 09:04:03 +0800 |
commit | bd20344d93a0b631d8d238a61a697b1fd210c9f6 (patch) | |
tree | f1f77cdd5053a61dba0fdcf746dd99b86ae56477 /mbbsd/args.c | |
parent | e9a30a5eb89c3fb99aa2025ed8069705d977e5d3 (diff) | |
download | pttbbs-bd20344d93a0b631d8d238a61a697b1fd210c9f6.tar pttbbs-bd20344d93a0b631d8d238a61a697b1fd210c9f6.tar.gz pttbbs-bd20344d93a0b631d8d238a61a697b1fd210c9f6.tar.bz2 pttbbs-bd20344d93a0b631d8d238a61a697b1fd210c9f6.tar.lz pttbbs-bd20344d93a0b631d8d238a61a697b1fd210c9f6.tar.xz pttbbs-bd20344d93a0b631d8d238a61a697b1fd210c9f6.tar.zst pttbbs-bd20344d93a0b631d8d238a61a697b1fd210c9f6.zip |
code clean up
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@969 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/args.c')
-rw-r--r-- | mbbsd/args.c | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/mbbsd/args.c b/mbbsd/args.c index 1d128673..bf36827b 100644 --- a/mbbsd/args.c +++ b/mbbsd/args.c @@ -1,4 +1,4 @@ -/* $Id: args.c,v 1.7 2002/07/22 19:02:00 in2 Exp $ */ +/* $Id: args.c,v 1.8 2003/06/26 01:04:03 kcwu Exp $ */ #include "bbs.h" #ifdef HAVE_SETPROCTITLE @@ -40,19 +40,13 @@ initsetproctitle(int argc, char **argv, char **envp) static void do_setproctitle(const char *cmdline) { - char buf[256], *p; - int i; + int len; - strncpy(buf, cmdline, 256); - buf[255] = '\0'; - i = strlen(buf); - if (i > LastArgv - Argv[0] - 2) { - i = LastArgv - Argv[0] - 2; - } - strlcpy(Argv[0], buf, sizeof(buf)); - p = &Argv[0][i]; - while (p < LastArgv) - *p++ = '\0'; + len = strlen(cmdline) + 1; // +1 for '\0' + if(len > LastArgv - Argv[0] - 2) // 2 ?? + len = LastArgv - Argv[0] - 2; + memset(Argv[0], 0, LastArgv-Argv[0]); + strlcpy(Argv[0], cmdline, len); Argv[1] = NULL; } |