From: Frédéric Marchal Date: Sun, 15 Jul 2012 16:57:48 +0000 (+0200) Subject: Store the smartfilter log temporary file in the temporary directory X-Git-Tag: v2.3.3~37 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1caa1b3d5a236bb5faa8d4050f163a5c4f7b7c6c;p=thirdparty%2Fsarg.git Store the smartfilter log temporary file in the temporary directory I couldn't test this change as I don't have any log file with smartfilter tags. --- diff --git a/report.c b/report.c index cb0f579..e91acae 100644 --- a/report.c +++ b/report.c @@ -178,7 +178,7 @@ void gerarel(void) if(accsmart[0] != '\0') { smartfilter++; - grava_SmartFilter(outdirname,uinfo->id,accip,accdia,acchora,accurl,accsmart); + grava_SmartFilter(tmp,uinfo->id,accip,accdia,acchora,accurl,accsmart); } if(Ip2Name) { @@ -743,7 +743,10 @@ static void grava_SmartFilter(const char *dirname, const char *user, const char FILE *fp_ou; char wdirname[MAXLEN]; - sprintf(wdirname,"%s/smartfilter.int_unsort",dirname); + if (snprintf(wdirname,sizeof(wdirname),"%s/smartfilter.int_unsort",dirname)>=sizeof(wdirname)) { + debuga(_("File name too long for %s/smartfilter.int_unsort"),dirname); + exit(EXIT_FAILURE); + } if((fp_ou=MY_FOPEN(wdirname,"a"))==NULL){ debuga(_("(report) Cannot open file %s\n"),wdirname); diff --git a/smartfilter.c b/smartfilter.c index d461f70..8be425e 100644 --- a/smartfilter.c +++ b/smartfilter.c @@ -53,16 +53,16 @@ void smartfilter_report(void) ouser[0]='\0'; - if (snprintf(smart_in,sizeof(smart_in),"%s/smartfilter.int_unsort",outdirname)>=sizeof(smart_in)) { - debuga(_("File name too long: %s/smartfilter.int_unsort\n"),outdirname); + if (snprintf(smart_in,sizeof(smart_in),"%s/smartfilter.int_unsort",tmp)>=sizeof(smart_in)) { + debuga(_("File name too long: %s/smartfilter.int_unsort\n"),tmp); exit(EXIT_FAILURE); } if (snprintf(sites,sizeof(sites),"%s/sarg-sites",outdirname)>=sizeof(sites)) { debuga(_("File name too long: %s/sarg-sites\n"),outdirname); exit(EXIT_FAILURE); } - if (snprintf(smart_ou,sizeof(smart_ou),"%s/smartfilter.log",outdirname)>=sizeof(smart_ou)) { - debuga(_("File name too long: %s/smartfilter.log\n"),outdirname); + if (snprintf(smart_ou,sizeof(smart_ou),"%s/smartfilter.int_log",tmp)>=sizeof(smart_ou)) { + debuga(_("File name too long: %s/smartfilter.int_log\n"),tmp); exit(EXIT_FAILURE); } if (snprintf(report,sizeof(report),"%s/smartfilter.html",outdirname)>=sizeof(report)) {