Coverity CID 1774, 1773: Don't leak open file descriptors or leave temp
file turds on error.
This commit is contained in:
parent
d67db6407e
commit
313c1811bf
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: crontab.c,v 1.26 2005/03/16 02:53:55 xtraeme Exp $ */
|
||||
/* $NetBSD: crontab.c,v 1.27 2006/04/25 18:02:02 christos Exp $ */
|
||||
|
||||
/* Copyright 1988,1990,1993,1994 by Paul Vixie
|
||||
* All rights reserved
|
||||
|
@ -22,7 +22,7 @@
|
|||
#if 0
|
||||
static char rcsid[] = "Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp";
|
||||
#else
|
||||
__RCSID("$NetBSD: crontab.c,v 1.26 2005/03/16 02:53:55 xtraeme Exp $");
|
||||
__RCSID("$NetBSD: crontab.c,v 1.27 2006/04/25 18:02:02 christos Exp $");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -562,12 +562,14 @@ replace_cmd(void) {
|
|||
if (fstat(fileno(NewCrontab), &statbuf)) {
|
||||
fprintf(stderr, "%s: error stat'ing crontab input: %s\n",
|
||||
ProgramName, strerror(errno));
|
||||
fclose(tmp); unlink(tn);
|
||||
return(-2);
|
||||
}
|
||||
if (statbuf.st_size > maxtabsize) {
|
||||
fprintf(stderr,
|
||||
"%s: %ld bytes is larger than the maximum size of %ld bytes\n",
|
||||
ProgramName, (long) statbuf.st_size, (long) maxtabsize);
|
||||
fclose(tmp); unlink(tn);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
|
@ -578,7 +580,7 @@ replace_cmd(void) {
|
|||
fprintf(tmp, "# DO NOT EDIT THIS FILE - edit the master and reinstall.\n");
|
||||
fprintf(tmp, "# (%s installed on %-24.24s)\n", Filename, ctime(&now));
|
||||
fprintf(tmp, "# (Cron version -- %s)\n",
|
||||
"$NetBSD: crontab.c,v 1.26 2005/03/16 02:53:55 xtraeme Exp $");
|
||||
"$NetBSD: crontab.c,v 1.27 2006/04/25 18:02:02 christos Exp $");
|
||||
|
||||
/* copy the crontab to the tmp
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue