From: Thibault Godouet Date: Mon, 13 Nov 2000 15:47:50 +0000 (+0000) Subject: check for empty shell command X-Git-Tag: ver2_9_4~507 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7852aea9ed2a1c686395a804478947568f7882d0;p=thirdparty%2Ffcron.git check for empty shell command --- diff --git a/conf.c b/conf.c index c6733ca..fff6697 100644 --- a/conf.c +++ b/conf.c @@ -22,7 +22,7 @@ * `LICENSE' that comes with the fcron source distribution. */ - /* $Id: conf.c,v 1.29 2000-11-10 17:36:26 thib Exp $ */ + /* $Id: conf.c,v 1.30 2000-11-13 15:47:50 thib Exp $ */ #include "fcron.h" @@ -416,8 +416,10 @@ read_file(const char *file_name, CF *cf) } /* get the owner's name */ - user = read_str(ff, buf, sizeof(buf)); - + if ( (user = read_str(ff, buf, sizeof(buf))) == NULL ) { + error("Cannot read user's name : file ignored"); + return 1; + } /* get the time & date of the saving */ /* a new file generated by fcrontab has t_save set to 0 */ @@ -443,7 +445,10 @@ read_file(const char *file_name, CF *cf) Alloc(cl, CL); while ( fread(cl, sizeof(CL), 1, ff) == 1 ) { - cl->cl_shell = read_str(ff, buf, sizeof(buf)); + if ((cl->cl_shell = read_str(ff, buf, sizeof(buf))) == NULL) { + error("Line is not valid (empty shell command) : ignored"); + continue; + } if ( is_td(cl->cl_option) ) { @@ -733,11 +738,6 @@ save_file(CF *file, char *path) } - /* then, write the number of lines to permit to check if the file - * is complete (i.e. fcron may has been interrupted during - * save process */ -/* // fprintf(f, "eof\n"); */ - fclose(f); if (file != NULL)