}
#endif
- sprintf(csort,"sort -n -T \"%s\" -t \"\t\" -r -k 2,2 -o \"%s\" \"%s\"", TempDir, top1, top2);
+ if (snprintf(csort,sizeof(csort),"sort -n -T \"%s\" -t \"\t\" -r -k 2,2 -o \"%s\" \"%s\"", TempDir, top1, top2)>=sizeof(csort)) {
+ debuga(_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),top2,top1);
+ exit(EXIT_FAILURE);
+ }
cstatus=system(csort);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
fclose(fp_ip);
fclose(fp_ip2);
- sprintf(csort,"sort -n -t \"\t\" -T \"%s\" -k 1,1 -k 2,2 -o \"%s\" \"%s\"",tmp,tmp3,tmp2);
+ if (snprintf(csort,sizeof(csort),"sort -n -t \"\t\" -T \"%s\" -k 1,1 -k 2,2 -o \"%s\" \"%s\"",tmp,tmp3,tmp2)>=sizeof(csort)) {
+ debuga(_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),tmp2,tmp3);
+ exit(EXIT_FAILURE);
+ }
cstatus=system(csort);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
}
if(DataFile[0] == '\0' && (ReportType & REPORT_TYPE_DENIED) != 0) {
- sprintf(csort,"sort -T \"%s\" -t \"\t\" -k 3,3 -k 5,5 -o \"%s\" \"%s\"",tmp,denied_sort,denied_unsort);
+ if (snprintf(csort,sizeof(csort),"sort -T \"%s\" -t \"\t\" -k 3,3 -k 5,5 -o \"%s\" \"%s\"",tmp,denied_sort,denied_unsort)>=sizeof(csort)) {
+ debuga(_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),denied_unsort,denied_sort);
+ exit(EXIT_FAILURE);
+ }
cstatus=system(csort);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
fclose(tmp);
longline_destroy(&line);
- sprintf(cmd,"sort -t \"\t\" -r -k 1,1 -k 2,2 -o \"%s\" \"%s\"",template2,template1);
+ if (snprintf(cmd,sizeof(cmd),"sort -t \"\t\" -r -k 1,1 -k 2,2 -o \"%s\" \"%s\"",template2,template1)>=sizeof(cmd)) {
+ debuga(_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),template1,template2);
+ exit(EXIT_FAILURE);
+ }
cstatus=system(cmd);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
sprintf(general2,"%s/sarg-general2",outdirname);
sprintf(report,"%s/siteuser.html",outdirname);
- sprintf(csort,"sort -t \"\t\" -k 4,4 -k 1,1 -o \"%s\" \"%s\"",general2,general);
+ if (snprintf(csort,sizeof(csort),"sort -t \"\t\" -k 4,4 -k 1,1 -o \"%s\" \"%s\"",general2,general)>=sizeof(csort)) {
+ debuga(_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),general,general2);
+ exit(EXIT_FAILURE);
+ }
cstatus=system(csort);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
debuga(_("Sorting file: %s\n"),arqou);
}
- sprintf(csort,"sort -n -T \"%s\" -t \"\t\" %s -k %s -k %s -k %s -o \"%s\" \"%s\"",tmp,order,field1,field2,field3,arqou,arqin);
+ if (snprintf(csort,sizeof(csort),"sort -n -T \"%s\" -t \"\t\" %s -k %s -k %s -k %s -o \"%s\" \"%s\"",tmp,order,field1,field2,field3,arqou,arqin)>=sizeof(csort)) {
+ debuga(_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),arqin,arqou);
+ exit(EXIT_FAILURE);
+ }
cstatus=system(csort);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
debuga(_("Sorting file: %s\n"),guard_ou);
}
- sprintf(tmp6,"sort -t \"\t\" -k 1,1 -k 2,2 -k 4,4 \"%s\" -o \"%s\"",guard_in, guard_ou);
+ if (snprintf(tmp6,sizeof(tmp6),"sort -t \"\t\" -k 1,1 -k 2,2 -k 4,4 \"%s\" -o \"%s\"",guard_in, guard_ou)>=sizeof(tmp6)) {
+ debuga(_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),guard_in,guard_ou);
+ exit(EXIT_FAILURE);
+ }
cstatus=system(tmp6);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
else
sprintf(report,"%s/topsites.html",outdirname);
- sprintf(csort,"sort -t \"\t\" -k 4,4 -o \"%s\" \"%s\"",general2,general);
+ if (snprintf(csort,sizeof(csort),"sort -t \"\t\" -k 4,4 -o \"%s\" \"%s\"",general2,general)>=sizeof(csort)) {
+ debuga(_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),general,general2);
+ exit(EXIT_FAILURE);
+ }
cstatus=system(csort);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
sortt="";
}
- sprintf(csort,"sort -t \"\t\" %s -n %s -o \"%s\" \"%s\"",sortt,sortf,sites,general3);
+ if (snprintf(csort,sizeof(csort),"sort -t \"\t\" %s -n %s -o \"%s\" \"%s\"",sortt,sortf,sites,general3)>=sizeof(csort)) {
+ debuga(_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),general3,sites);
+ exit(EXIT_FAILURE);
+ }
cstatus=system(csort);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
}
snprintf(top1,sizeof(top1),"%s/top",outdirname);
- sprintf(csort,"sort -T \"%s\" -t \"\t\" %s %s -o \"%s\" \"%s\"", tmp, order, sfield, top1, top2);
+ if (snprintf(csort,sizeof(csort),"sort -T \"%s\" -t \"\t\" %s %s -o \"%s\" \"%s\"", tmp, order, sfield, top1, top2)>=sizeof(csort)) {
+ debuga(_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),top2,top1);
+ exit(EXIT_FAILURE);
+ }
cstatus=system(csort);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
debuga(_("Sorting file: %s\n"),tmp2);
}
- sprintf(csort,"sort -n -t \"\t\" -k 3,3 -k 2,2 -k 1,1 -o \"%s\" \"%s\"",tmp2,tmp3);
+ if (snprintf(csort,sizeof(csort),"sort -n -t \"\t\" -k 3,3 -k 2,2 -k 1,1 -o \"%s\" \"%s\"",tmp2,tmp3)>=sizeof(csort)) {
+ debuga(_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),tmp2,tmp3);
+ exit(EXIT_FAILURE);
+ }
cstatus=system(csort);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
fputs("</table>\n",fp_ht);
fclose(fp_in);
- sprintf(csort,"sort -t \"\t\" -k 2,2 -o \"%s\" \"%s\"",tmp3,tmp2);
+ if (snprintf(csort,sizeof(csort),"sort -t \"\t\" -k 2,2 -o \"%s\" \"%s\"",tmp3,tmp2)>=sizeof(csort)) {
+ debuga(_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),tmp2,tmp3);
+ exit(EXIT_FAILURE);
+ }
cstatus=system(csort);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
exit(EXIT_FAILURE);
}
- sprintf(csort,"sort -n -r -k 1,1 -o \"%s\" \"%s\"",tmp3,tmp2);
+ if (snprintf(csort,sizeof(csort),"sort -n -r -k 1,1 -o \"%s\" \"%s\"",tmp3,tmp2)>=sizeof(csort)) {
+ debuga(_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),tmp2,tmp3);
+ exit(EXIT_FAILURE);
+ }
cstatus=system(csort);
if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));