summaryrefslogtreecommitdiffstats
path: root/contrib/sendmail/smrsh/smrsh.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/sendmail/smrsh/smrsh.c')
-rw-r--r--contrib/sendmail/smrsh/smrsh.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/contrib/sendmail/smrsh/smrsh.c b/contrib/sendmail/smrsh/smrsh.c
index 9a9bc21..bfcfcbe 100644
--- a/contrib/sendmail/smrsh/smrsh.c
+++ b/contrib/sendmail/smrsh/smrsh.c
@@ -20,7 +20,7 @@ SM_IDSTR(copyright,
Copyright (c) 1993\n\
The Regents of the University of California. All rights reserved.\n")
-SM_IDSTR(id, "@(#)$Id: smrsh.c,v 8.58.2.2 2002/09/24 21:40:05 ca Exp $")
+SM_IDSTR(id, "@(#)$Id: smrsh.c,v 8.58.2.5 2003/12/15 17:09:39 ca Exp $")
/*
** SMRSH -- sendmail restricted shell
@@ -118,8 +118,9 @@ addcmd(s, cmd, len)
if (s == NULL || *s == '\0')
return;
+ /* enough space for s (len) and CMDDIR + "/" and '\0'? */
if (sizeof newcmdbuf - strlen(newcmdbuf) <=
- len + (cmd ? (strlen(CMDDIR) + 1) : 0))
+ len + 1 + (cmd ? (strlen(CMDDIR) + 1) : 0))
{
(void)sm_io_fprintf(smioerr, SM_TIME_DEFAULT,
"%s: command too long: %s\n", prg, par);
@@ -130,7 +131,7 @@ addcmd(s, cmd, len)
}
if (cmd)
(void) sm_strlcat2(newcmdbuf, CMDDIR, "/", sizeof newcmdbuf);
- (void) sm_strlcat(newcmdbuf, s, sizeof newcmdbuf);
+ (void) strncat(newcmdbuf, s, len);
}
int
@@ -423,7 +424,8 @@ main(argc, argv)
#ifdef DEBUG
(void) sm_io_fprintf(smioout, SM_TIME_DEFAULT, "%s\n", newcmdbuf);
#endif /* DEBUG */
- (void) execle("/bin/sh", "/bin/sh", "-c", newcmdbuf, NULL, newenv);
+ (void) execle("/bin/sh", "/bin/sh", "-c", newcmdbuf,
+ (char *)NULL, newenv);
save_errno = errno;
#ifndef DEBUG
syslog(LOG_CRIT, "Cannot exec /bin/sh: %s", sm_errstring(errno));
OpenPOWER on IntegriCloud