]> git.ipfire.org Git - thirdparty/fcron.git/commitdiff
check for empty shell command
authorThibault Godouet <yo8192@users.noreply.github.com>
Mon, 13 Nov 2000 15:47:50 +0000 (15:47 +0000)
committerThibault Godouet <yo8192@users.noreply.github.com>
Mon, 13 Nov 2000 15:47:50 +0000 (15:47 +0000)
conf.c

diff --git a/conf.c b/conf.c
index c6733caf54679b6e8b9d429bc5ad1bf574a19ff0..fff66974b0c7180f9ec146a649f0e04de5908b79 100644 (file)
--- 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)