From: Frédéric Marchal Date: Sat, 1 Aug 2009 20:32:19 +0000 (+0000) Subject: Applied suggestion of bug #2830643. X-Git-Tag: v2_2_6~46 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5355d243d0b09004c9724d69a29a8c9c508af1ae;p=thirdparty%2Fsarg.git Applied suggestion of bug #2830643. --- diff --git a/log.c b/log.c index 2f0bc62..421dd89 100644 --- 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 4afb020..b3b94d6 100644 --- 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]);