]> git.ipfire.org Git - thirdparty/fcron.git/commitdiff
bug fixed : fcrontab used to get a SIGSEGV when a string was placed
authorThibault Godouet <yo8192@users.noreply.github.com>
Sat, 10 Jun 2000 22:16:44 +0000 (22:16 +0000)
committerThibault Godouet <yo8192@users.noreply.github.com>
Sat, 10 Jun 2000 22:16:44 +0000 (22:16 +0000)
in a field which only accept a interger value

fileconf.c

index 152c7403b5454607a834d0d9e6218ec9d75127fb..d384e7b2f971bf0e59106fb2bec5aafb5c44d120 100644 (file)
@@ -22,7 +22,7 @@
  *  `LICENSE' that comes with the fcron source distribution.
  */
 
- /* $Id: fileconf.c,v 1.3 2000-05-30 19:27:26 thib Exp $ */
+ /* $Id: fileconf.c,v 1.4 2000-06-10 22:16:44 thib Exp $ */
 
 #include "fcrontab.h"
 
@@ -332,8 +332,8 @@ read_freq(char *ptr, CF *cf, int line, char *file_name)
     Alloc(cl, CL);
 
     ptr++;
-    /* get cl_remain field */
-    ptr = get_time(ptr, &(cl->cl_remain), line, file_name);
+    /* get the time before first execution */
+    ptr = get_time(ptr, &(cl->cl_nextexe), line, file_name);
 
     Skip_blanks(ptr);
 
@@ -346,9 +346,11 @@ read_freq(char *ptr, CF *cf, int line, char *file_name)
        return;
     }
 
-    if ( cl->cl_remain == 0 )
-       /* cl_remain is not specified : set it to cl_timefreq value */
-       cl->cl_remain = cl->cl_timefreq;
+    if ( cl->cl_nextexe == 0 )
+       /* time before first execution is not specified */
+       cl->cl_nextexe = cl->cl_timefreq;
+
+
 
     /* get cl_shell field ( remove trailing blanks ) */
     if ( (cl->cl_shell = get_string(ptr)) == NULL ) {
@@ -363,7 +365,7 @@ read_freq(char *ptr, CF *cf, int line, char *file_name)
 
     if ( debug_opt )
        fprintf(stderr, "  Cmd '%s', timefreq %ld, remain %ld\n",
-               cl->cl_shell, cl->cl_timefreq, cl->cl_remain);
+               cl->cl_shell, cl->cl_timefreq, cl->cl_nextexe);
 
 }
 
@@ -420,7 +422,7 @@ read_arys(char *ptr, CF *cf, int line, char *file_name)
     if (debug_opt)
        /* if debug_opt is set, we print informations in read_field function,
         *  but no end line : we print it here */
-       fprintf(stderr, " remain %ld\n", cl->cl_remain);
+       fprintf(stderr, " remain %d\n", cl->cl_remain);
 
     /* get the shell command (remove trailing blanks) */
     if ( (cl->cl_shell = get_string(ptr)) == NULL ) {
@@ -449,6 +451,9 @@ read_num(char *ptr, int *num, int max, const char **names)
     if ( isalpha(*ptr) ) {
        int i;
 
+       if ( names == NULL )
+           return NULL;
+
        /* set string to lower case */
        for ( i = 0; i < strlen(names[0]); i++ )
            *(ptr+i) = tolower( *(ptr+i) );
@@ -687,6 +692,10 @@ save_file(char *path)
         * if the syntax has changed */
        fprintf(f, "fcrontab-" FILEVERSION "\n");
 
+       /* put the time & date of saving : this is use for calcutating 
+        * the system down time. As it is a new file, we set it to 0 */
+       fprintf(f, "%d", 0);
+
        /*   mailto, */
        if ( file->cf_mailto != NULL ) {
            fprintf(f, "m");