summaryrefslogtreecommitdiffstats
path: root/usr.sbin/cron/crontab.c
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>1996-11-01 23:27:28 +0000
committermillert <millert@openbsd.org>1996-11-01 23:27:28 +0000
commitbac4f837ee024e37c804b607507b2360e2f39c77 (patch)
treed4683b5672c804612e83cf49c4295d48034239ac /usr.sbin/cron/crontab.c
parentargument type nit (diff)
downloadwireguard-openbsd-bac4f837ee024e37c804b607507b2360e2f39c77.tar.xz
wireguard-openbsd-bac4f837ee024e37c804b607507b2360e2f39c77.zip
Check malloc/strdup ret val and deal.
Diffstat (limited to 'usr.sbin/cron/crontab.c')
-rw-r--r--usr.sbin/cron/crontab.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/usr.sbin/cron/crontab.c b/usr.sbin/cron/crontab.c
index 561e11edf81..e485e33f7fe 100644
--- a/usr.sbin/cron/crontab.c
+++ b/usr.sbin/cron/crontab.c
@@ -16,7 +16,7 @@
*/
#if !defined(lint) && !defined(LINT)
-static char rcsid[] = "$Id: crontab.c,v 1.5 1996/10/31 03:10:55 millert Exp $";
+static char rcsid[] = "$Id: crontab.c,v 1.6 1996/11/01 23:27:30 millert Exp $";
#endif
/* crontab - install and manage per-user crontab files
@@ -321,7 +321,7 @@ edit_cmd() {
}
um = umask(077);
- (void) sprintf(Filename, "/tmp/crontab.XXXXXXXX");
+ (void) sprintf(Filename, "/tmp/crontab.XXXXXXXXXX");
if ((t = mkstemp(Filename)) == -1) {
perror(Filename);
(void) umask(um);
@@ -505,6 +505,11 @@ replace_cmd() {
time_t now = time(NULL);
char **envp = env_init();
+ if (envp == NULL) {
+ fprintf(stderr, "%s: Cannot allocate memory.\n", ProgramName);
+ return (-2);
+ }
+
(void) sprintf(n, "tmp.%d", Pid);
(void) sprintf(tn, CRON_TAB(n));
if (!(tmp = fopen(tn, "w+"))) {