]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Applied suggestion of bug #2830643.
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Sat, 1 Aug 2009 20:32:19 +0000 (20:32 +0000)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Sat, 1 Aug 2009 20:32:19 +0000 (20:32 +0000)
log.c
util.c

diff --git a/log.c b/log.c
index 2f0bc6217ad9b845daa014fe0a0836abd7eaf98b..421dd89e3d392bca98d79de16f1d15c54fcb0ef8 100644 (file)
--- a/log.c
+++ b/log.c
@@ -1562,6 +1562,10 @@ static void getusers(const char *pwdfile, int debug)
 
    fseek(fp_usr, (off_t)0, SEEK_END);
    nreg = ftell(fp_usr);
+   if (nreg<0) {
+      printf("SARG: Cannot get the size of file %s",pwdfile);
+      exit(1);
+   }
    nreg = nreg+5000;
    fseek(fp_usr, (off_t)0, SEEK_SET);
 
@@ -1605,7 +1609,12 @@ static void gethexclude(const char *hexfile, int debug)
    }
 
    fseek(fp_ex, (off_t)0, SEEK_END);
-   nreg = ftell(fp_ex)+11;
+   nreg = ftell(fp_ex);
+   if (nreg<0) {
+      printf("SARG: Cannot get the size of file %s",hexfile);
+      exit(1);
+   }
+   nreg += 11;
    fseek(fp_ex, (off_t)0, SEEK_SET);
 
    if((excludefile=(char *) malloc(nreg))==NULL){
@@ -1647,7 +1656,12 @@ static void getuexclude(const char *uexfile, int debug)
    }
 
    fseek(fp_ex, (off_t)0, SEEK_END);
-   nreg = ftell(fp_ex)+11;
+   nreg = ftell(fp_ex);
+   if (nreg<0) {
+      printf("SARG: Cannot get the size of file %s",uexfile);
+      exit(1);
+   }
+   nreg += 11;
    fseek(fp_ex, (off_t)0, SEEK_SET);
 
    if((excludeuser=(char *) malloc(nreg))==NULL){
diff --git a/util.c b/util.c
index 4afb020141ab49a4f6113d14fe732b8c39c798bb..b3b94d60a9d9b85af15b26fe43f0b108e8580ea9 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1454,7 +1454,12 @@ void read_usertab(const char *UserTabFile)
          exit(1);
       }
       fseek(fp_usr, 0, SEEK_END);
-      nreg = ftell(fp_usr)+100;
+      nreg = ftell(fp_usr);
+      if (nreg<0) {
+         printf("SARG: Cannot get the size of file %s",UserTabFile);
+         exit(1);
+      }
+      nreg += 100;
       fseek(fp_usr, 0, SEEK_SET);
       if((userfile=(char *) malloc(nreg))==NULL){
          fprintf(stderr, "SARG ERROR: %s",text[87]);