6ba8133cdd
detailed http 404 error reports. Webalizer author hinted me at this, he does not intend to update. danh@ is ok with the maintainer change. ok stehn, okan.
220 lines
8.7 KiB
Plaintext
220 lines
8.7 KiB
Plaintext
$OpenBSD: patch-preserve_c,v 1.3 2008/01/30 20:06:48 mbalmer Exp $
|
|
--- preserve.c.orig Tue Jul 3 12:19:00 2007
|
|
+++ preserve.c Wed Jan 30 13:41:34 2008
|
|
@@ -38,6 +38,7 @@
|
|
#include <ctype.h>
|
|
#include <sys/utsname.h>
|
|
#include <sys/times.h>
|
|
+#include <sys/socket.h>
|
|
|
|
/* ensure getopt */
|
|
#ifdef HAVE_GETOPT_H
|
|
@@ -203,7 +204,7 @@ int save_state()
|
|
/* Saving current run data... */
|
|
if (verbose>1)
|
|
{
|
|
- sprintf(buffer,"%02d/%02d/%04d %02d:%02d:%02d",
|
|
+ snprintf(buffer,sizeof buffer,"%02d/%02d/%04d %02d:%02d:%02d",
|
|
cur_month,cur_day,cur_year,cur_hour,cur_min,cur_sec);
|
|
printf("%s [%s]\n",msg_put_data,buffer);
|
|
}
|
|
@@ -216,25 +217,25 @@ int save_state()
|
|
if (fputs(buffer,fp)==EOF) return 1; /* error exit */
|
|
|
|
/* Current date/time */
|
|
- sprintf(buffer,"%d %d %d %d %d %d\n",
|
|
+ snprintf(buffer,sizeof(buffer),"%d %d %d %d %d %d\n",
|
|
cur_year, cur_month, cur_day, cur_hour, cur_min, cur_sec);
|
|
if (fputs(buffer,fp)==EOF) return 1; /* error exit */
|
|
|
|
/* Monthly totals for sites, urls, etc... */
|
|
- sprintf(buffer,"%lu %lu %lu %lu %lu %lu %.0f %lu %lu %lu %.0f %.0f\n",
|
|
+ snprintf(buffer,sizeof buffer,"%lu %lu %lu %lu %lu %lu %.0f %lu %lu %lu %.0f %.0f\n",
|
|
t_hit, t_file, t_site, t_url,
|
|
t_ref, t_agent, t_xfer, t_page, t_visit, t_user, t_ixfer, t_oxfer);
|
|
if (fputs(buffer,fp)==EOF) return 1; /* error exit */
|
|
|
|
/* Daily totals for sites, urls, etc... */
|
|
- sprintf(buffer,"%lu %lu %lu %d %d\n",
|
|
+ snprintf(buffer,sizeof buffer,"%lu %lu %lu %d %d\n",
|
|
dt_site, ht_hit, mh_hit, f_day, l_day);
|
|
if (fputs(buffer,fp)==EOF) return 1; /* error exit */
|
|
|
|
/* Monthly (by day) total array */
|
|
for (i=0;i<31;i++)
|
|
{
|
|
- sprintf(buffer,"%lu %lu %.0f %lu %lu %lu %.0f %.0f\n",
|
|
+ snprintf(buffer,sizeof buffer,"%lu %lu %.0f %lu %lu %lu %.0f %.0f\n",
|
|
tm_hit[i],tm_file[i],tm_xfer[i],tm_site[i],
|
|
tm_page[i],tm_visit[i],tm_ixfer[i],tm_oxfer[i]);
|
|
if (fputs(buffer,fp)==EOF) return 1; /* error exit */
|
|
@@ -243,7 +244,7 @@ int save_state()
|
|
/* Daily (by hour) total array */
|
|
for (i=0;i<24;i++)
|
|
{
|
|
- sprintf(buffer,"%lu %lu %.0f %lu %.0f %.0f\n",
|
|
+ snprintf(buffer,sizeof buffer,"%lu %lu %.0f %lu %.0f %.0f\n",
|
|
th_hit[i],th_file[i],th_xfer[i],th_page[i],th_ixfer[i],th_oxfer[i]);
|
|
if (fputs(buffer,fp)==EOF) return 1; /* error exit */
|
|
}
|
|
@@ -251,7 +252,7 @@ int save_state()
|
|
/* Response codes */
|
|
for (i=0;i<TOTAL_RC;i++)
|
|
{
|
|
- sprintf(buffer,"%lu\n",response[i].count);
|
|
+ snprintf(buffer,sizeof buffer,"%lu\n",response[i].count);
|
|
if (fputs(buffer,fp)==EOF) return 1; /* error exit */
|
|
}
|
|
|
|
@@ -263,7 +264,7 @@ int save_state()
|
|
uptr=um_htab[i];
|
|
while (uptr!=NULL)
|
|
{
|
|
- sprintf(buffer,"%s\n%d %lu %lu %.0f %lu %lu %.0f %.0f\n", uptr->string,
|
|
+ snprintf(buffer,sizeof buffer,"%s\n%d %lu %lu %.0f %lu %lu %.0f %.0f\n", uptr->string,
|
|
uptr->flag, uptr->count, uptr->files, uptr->xfer,
|
|
uptr->entry, uptr->exit,uptr->ixfer, uptr->oxfer);
|
|
if (fputs(buffer,fp)==EOF) return 1;
|
|
@@ -280,7 +281,7 @@ int save_state()
|
|
hptr=sm_htab[i];
|
|
while (hptr!=NULL)
|
|
{
|
|
- sprintf(buffer,"%s\n%d %lu %lu %.0f %lu %lu %.0f %.0f\n%s\n",
|
|
+ snprintf(buffer,sizeof buffer,"%s\n%d %lu %lu %.0f %lu %lu %.0f %.0f\n%s\n",
|
|
hptr->string,
|
|
hptr->flag,
|
|
hptr->count,
|
|
@@ -304,7 +305,7 @@ int save_state()
|
|
hptr=sd_htab[i];
|
|
while (hptr!=NULL)
|
|
{
|
|
- sprintf(buffer,"%s\n%d %lu %lu %.0f %lu %lu %.0f %.0f\n%s\n",
|
|
+ snprintf(buffer,sizeof buffer,"%s\n%d %lu %lu %.0f %lu %lu %.0f %.0f\n%s\n",
|
|
hptr->string,
|
|
hptr->flag,
|
|
hptr->count,
|
|
@@ -330,7 +331,7 @@ int save_state()
|
|
rptr=rm_htab[i];
|
|
while (rptr!=NULL)
|
|
{
|
|
- sprintf(buffer,"%s\n%d %lu\n", rptr->string,
|
|
+ snprintf(buffer,sizeof buffer,"%s\n%d %lu\n", rptr->string,
|
|
rptr->flag, rptr->count);
|
|
if (fputs(buffer,fp)==EOF) return 1; /* error exit */
|
|
rptr=rptr->next;
|
|
@@ -348,7 +349,7 @@ int save_state()
|
|
aptr=am_htab[i];
|
|
while (aptr!=NULL)
|
|
{
|
|
- sprintf(buffer,"%s\n%d %lu\n", aptr->string,
|
|
+ snprintf(buffer,sizeof buffer,"%s\n%d %lu\n", aptr->string,
|
|
aptr->flag, aptr->count);
|
|
if (fputs(buffer,fp)==EOF) return 1; /* error exit */
|
|
aptr=aptr->next;
|
|
@@ -364,7 +365,7 @@ int save_state()
|
|
sptr=sr_htab[i];
|
|
while (sptr!=NULL)
|
|
{
|
|
- sprintf(buffer,"%s\n%lu\n", sptr->string,sptr->count);
|
|
+ snprintf(buffer,sizeof buffer,"%s\n%lu\n", sptr->string,sptr->count);
|
|
if (fputs(buffer,fp)==EOF) return 1; /* error exit */
|
|
sptr=sptr->next;
|
|
}
|
|
@@ -379,7 +380,7 @@ int save_state()
|
|
iptr=im_htab[i];
|
|
while (iptr!=NULL)
|
|
{
|
|
- sprintf(buffer,"%s\n%d %lu %lu %.0f %lu %lu %.0f %.0f\n",
|
|
+ snprintf(buffer,sizeof buffer,"%s\n%d %lu %lu %.0f %lu %lu %.0f %.0f\n",
|
|
iptr->string,
|
|
iptr->flag,
|
|
iptr->count,
|
|
@@ -396,13 +397,13 @@ int save_state()
|
|
if (fputs("# End Of Table - usernames\n",fp)==EOF) return 1;
|
|
|
|
/* 404 error list */
|
|
- sprintf(buffer,"%lu\n",resp_counter); /* save total 404 counter */
|
|
+ snprintf(buffer,sizeof buffer,"%lu\n",resp_counter); /* save total 404 counter */
|
|
if (fputs(buffer,fp)==EOF) return 1; /* error exit */
|
|
|
|
if (fputs("# -notfounderrors- \n",fp)==EOF) return 1; /* error exit */
|
|
if (resp_counter>0) {
|
|
for (i=0;i<resp_counter;i++) {
|
|
- sprintf(buffer,"%s\n%lu\n",respnotfound[i].respurl,respnotfound[i].count);
|
|
+ snprintf(buffer,sizeof buffer,"%s\n%lu\n",respnotfound[i].respurl,respnotfound[i].count);
|
|
if (fputs(buffer,fp)==EOF) return 1; /* error exit */
|
|
}
|
|
}
|
|
@@ -444,7 +445,7 @@ int restore_state()
|
|
if (verbose>1) printf("%s %s\n",msg_get_data,state_fname);
|
|
|
|
/* get easy stuff */
|
|
- sprintf(tmp_buf,"# Webalizer V%s ",version);
|
|
+ snprintf(tmp_buf,sizeof tmp_buf,"# Webalizer V%s ",version);
|
|
if ((fgets(buffer,BUFSIZE,fp)) != NULL) /* Header record */
|
|
{if (strncmp(buffer,tmp_buf,17)) return 99;} /* bad magic? */
|
|
else return 1; /* error exit */
|
|
@@ -537,7 +538,7 @@ int restore_state()
|
|
while ((fgets(buffer,BUFSIZE,fp)) != NULL)
|
|
{
|
|
if (!strncmp(buffer,"# End Of Table ",15)) break;
|
|
- strncpy(tmp_buf,buffer,MAXURLH);
|
|
+ strlcpy(tmp_buf,buffer,sizeof tmp_buf);
|
|
tmp_buf[strlen(tmp_buf)-1]=0;
|
|
|
|
if ((fgets(buffer,BUFSIZE,fp)) == NULL) return 10; /* error exit */
|
|
@@ -574,7 +575,7 @@ int restore_state()
|
|
{
|
|
/* Check for end of table */
|
|
if (!strncmp(buffer,"# End Of Table ",15)) break;
|
|
- strncpy(tmp_buf,buffer,MAXHOST);
|
|
+ strlcpy(tmp_buf,buffer,sizeof tmp_buf);
|
|
tmp_buf[strlen(buffer)-1]=0;
|
|
|
|
if ((fgets(buffer,BUFSIZE,fp)) == NULL) return 8; /* error exit */
|
|
@@ -620,7 +621,7 @@ int restore_state()
|
|
{
|
|
/* Check for end of table */
|
|
if (!strncmp(buffer,"# End Of Table ",15)) break;
|
|
- strncpy(tmp_buf,buffer,MAXHOST);
|
|
+ strlcpy(tmp_buf,buffer,sizeof tmp_buf);
|
|
tmp_buf[strlen(buffer)-1]=0;
|
|
|
|
if ((fgets(buffer,BUFSIZE,fp)) == NULL) return 9; /* error exit */
|
|
@@ -664,7 +665,7 @@ int restore_state()
|
|
while ((fgets(buffer,BUFSIZE,fp)) != NULL)
|
|
{
|
|
if (!strncmp(buffer,"# End Of Table ",15)) break;
|
|
- strncpy(tmp_buf,buffer,MAXREFH);
|
|
+ strlcpy(tmp_buf,buffer,sizeof tmp_buf);
|
|
tmp_buf[strlen(buffer)-1]=0;
|
|
|
|
if ((fgets(buffer,BUFSIZE,fp)) == NULL) return 11; /* error exit */
|
|
@@ -689,7 +690,7 @@ int restore_state()
|
|
while ((fgets(buffer,BUFSIZE,fp)) != NULL)
|
|
{
|
|
if (!strncmp(buffer,"# End Of Table ",15)) break;
|
|
- strncpy(tmp_buf,buffer,MAXAGENT);
|
|
+ strlcpy(tmp_buf,buffer,sizeof tmp_buf);
|
|
tmp_buf[strlen(buffer)-1]=0;
|
|
|
|
if ((fgets(buffer,BUFSIZE,fp)) == NULL) return 12; /* error exit */
|
|
@@ -714,7 +715,7 @@ int restore_state()
|
|
while ((fgets(buffer,BUFSIZE,fp)) != NULL)
|
|
{
|
|
if (!strncmp(buffer,"# End Of Table ",15)) break;
|
|
- strncpy(tmp_buf,buffer,MAXSRCH);
|
|
+ strlcpy(tmp_buf,buffer,sizeof tmp_buf);
|
|
tmp_buf[strlen(buffer)-1]=0;
|
|
|
|
if ((fgets(buffer,BUFSIZE,fp)) == NULL) return 13; /* error exit */
|
|
@@ -739,7 +740,7 @@ int restore_state()
|
|
{
|
|
/* Check for end of table */
|
|
if (!strncmp(buffer,"# End Of Table ",15)) break;
|
|
- strncpy(tmp_buf,buffer,MAXIDENT);
|
|
+ strncpy(tmp_buf,buffer,sizeof tmp_buf);
|
|
tmp_buf[strlen(buffer)-1]=0;
|
|
|
|
if ((fgets(buffer,BUFSIZE,fp)) == NULL) return 14; /* error exit */
|