fixes in setproctitle to avoid problems with titles longer than
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Tue, 1 Oct 1985 13:06:04 +0000 (05:06 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Tue, 1 Oct 1985 13:06:04 +0000 (05:06 -0800)
argv + env

SCCS-vsn: usr.sbin/sendmail/src/conf.c 5.10
SCCS-vsn: usr.sbin/sendmail/src/version.c 5.27

usr/src/usr.sbin/sendmail/src/conf.c
usr/src/usr.sbin/sendmail/src/version.c

index 642aa29..8acab99 100644 (file)
@@ -9,7 +9,7 @@
 */
 
 #ifndef lint
 */
 
 #ifndef lint
-static char    SccsId[] = "@(#)conf.c  5.9 (Berkeley) %G%";
+static char    SccsId[] = "@(#)conf.c  5.10 (Berkeley) %G%";
 #endif not lint
 
 # include <pwd.h>
 #endif not lint
 
 # include <pwd.h>
@@ -644,18 +644,25 @@ setproctitle(fmt, a, b, c)
 {
 # ifdef SETPROCTITLE
        register char *p;
 {
 # ifdef SETPROCTITLE
        register char *p;
+       register int i;
        extern char **Argv;
        extern char *LastArgv;
        extern char **Argv;
        extern char *LastArgv;
+       char buf[MAXLINE];
 
 
-       p = Argv[0];
+       (void) sprintf(buf, fmt, a, b, c);
 
        /* make ps print "(sendmail)" */
 
        /* make ps print "(sendmail)" */
+       p = Argv[0];
        *p++ = '-';
 
        *p++ = '-';
 
-       (void) sprintf(p, fmt, a, b, c);
-       p += strlen(p);
-
-       /* avoid confusing ps */
+       i = strlen(buf);
+       if (i > LastArgv - p - 2)
+       {
+               i = LastArgv - p - 2;
+               buf[i] = '\0';
+       }
+       (void) strcpy(p, buf);
+       p += i;
        while (p < LastArgv)
                *p++ = ' ';
 # endif SETPROCTITLE
        while (p < LastArgv)
                *p++ = ' ';
 # endif SETPROCTITLE
index d568e00..6c7280d 100644 (file)
@@ -9,7 +9,7 @@
 */
 
 #ifndef lint
 */
 
 #ifndef lint
-static char    SccsId[] = "@(#)version.c       5.26 (Berkeley) %G%";
+static char    SccsId[] = "@(#)version.c       5.27 (Berkeley) %G%";
 #endif not lint
 
 #endif not lint
 
-char   Version[] = "5.26";
+char   Version[] = "5.27";