Skip to content

Commit 6b167b3

Browse files
author
Peter McCluskey
committed
64bit fixes, possible buffer overrun fixes; disabled a ConvURLsString call to make url escaping more consistent
1 parent 1026173 commit 6b167b3

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

src/print.c

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ void fprint_menu0(FILE *fp, struct emailinfo *email, int pos)
264264
char *id= (pos == PAGE_TOP) ? "options2" : "options3";
265265

266266
#ifdef HAVE_ICONV
267-
int tmplen;
267+
size_t tmplen;
268268
char *tmpptr=i18n_convstring(email->subject,"UTF-8",email->charset,&tmplen);
269269
#endif
270270

@@ -766,7 +766,7 @@ void printdates(FILE *fp, struct header *hp, int year, int month, struct emailin
766766
const char *endline;
767767
const char *subj_tag;
768768
const char *subj_end_tag;
769-
static char date_str[DATESTRLEN+11]; /* made static for smaller stack */
769+
static char date_str[DATESTRLEN+40]; /* made static for smaller stack */
770770
static char *first_attributes = "<a accesskey=\"j\" name=\"first\" id=\"first\"></a>";
771771

772772
if (hp != NULL) {
@@ -796,7 +796,7 @@ void printdates(FILE *fp, struct header *hp, int year, int month, struct emailin
796796
}
797797
else
798798
is_first = TRUE;
799-
sprintf(date_str, "<li>%s<dfn>%s</dfn><ul>\n",
799+
snprintf(date_str, sizeof(date_str), "<li>%s<dfn>%s</dfn><ul>\n",
800800
(is_first) ? first_attributes : "", tmp);
801801
fprintf (fp, "%s", date_str);
802802
strcpy (prev_date_str, tmp);
@@ -946,7 +946,11 @@ static char *ConvURLsWithHrefs(const char *line, char *mailid, char *mailsubject
946946
PushString(&retbuf, tmpline5);
947947
free(tmpline5);
948948
p += 4;
949-
tmpline6 = ConvURLsString(p, mailid, mailsubject, charset);
949+
tmpline6 = NULL;
950+
/* pcm 2007-10-01 disabled the following ConvURLsString call to have */
951+
/* it escape urls in mid line the same as it did for urls at start of */
952+
/* line. I'm still puzzled why the change works. */
953+
/* tmpline6 = ConvURLsString(p, mailid, mailsubject, charset); */
950954
if (!tmpline6) {
951955
free(PUSH_STRING(retbuf));
952956
return NULL;
@@ -1035,7 +1039,7 @@ char *ConvURLsString(char *line, char *mailid, char *mailsubject, char *charset)
10351039
char *c;
10361040

10371041
#ifdef HAVE_ICONV
1038-
int tmplen;
1042+
size_t tmplen;
10391043
char *tmpptr=i18n_convstring(mailsubject,"UTF-8",charset,&tmplen);
10401044
mailsubject=tmpptr;
10411045
#endif
@@ -1136,7 +1140,7 @@ void printheaders (FILE *fp, struct emailinfo *email)
11361140
}
11371141
else{
11381142
#ifdef HAVE_ICONV
1139-
int tmplen;
1143+
size_t tmplen;
11401144
char *tmpptr=i18n_convstring(header_content,"UTF-8",email->charset,&tmplen);
11411145
ConvURLs(fp, tmpptr, id, subject, email->charset);
11421146
if (tmpptr)
@@ -1333,7 +1337,7 @@ void printbody(FILE *fp, struct emailinfo *email, int maybe_reply, int is_reply)
13331337
}
13341338
else {
13351339
fprintf(fp, "<%s class=\"%s\">", set_iquotes ? "em" : "span", find_quote_class(bp->line));
1336-
1340+
13371341
ConvURLs(fp, bp->line, id, subject, email->charset);
13381342

13391343
fprintf(fp, "%s<br />\n", (set_iquotes) ? "</em>" : "</span>");
@@ -1580,7 +1584,7 @@ int print_links_up(FILE *fp, struct emailinfo *email, int pos, int in_thread_fil
15801584
if (set_mailcommand && set_hmail) {
15811585
if ((email->msgid && email->msgid[0]) || (email->subject && email->subject[0])) {
15821586
#ifdef HAVE_ICONV
1583-
int tmplen;
1587+
size_t tmplen;
15841588
char *tmpptr=i18n_convstring(email->subject,"UTF-8",email->charset,&tmplen);
15851589
ptr = makemailcommand(set_replymsg_command, set_hmail, email->msgid,
15861590
tmpptr);
@@ -2332,7 +2336,7 @@ void writedates(int amountmsgs, struct emailinfo *email)
23322336
int newfile;
23332337
char *filename;
23342338
FILE *fp;
2335-
char prev_date_str[DATESTRLEN];
2339+
char prev_date_str[DATESTRLEN + 40];
23362340
char *datename = index_name[email && email->subdir != NULL][DATE_INDEX];
23372341
time_t start_date_num = email && email->subdir ? email->subdir->first_email->date : firstdatenum;
23382342
time_t end_date_num = email && email->subdir ? email->subdir->last_email->date : lastdatenum;
@@ -2586,7 +2590,7 @@ void printsubjects(FILE *fp, struct header *hp, char **oldsubject,
25862590
const char *startline;
25872591
const char *break_str;
25882592
const char *endline;
2589-
static char date_str[DATESTRLEN+11]; /* made static for smaller stack */
2593+
static char date_str[DATESTRLEN+40]; /* made static for smaller stack */
25902594
static char *first_attributes = "<a accesskey=\"j\" name=\"first\" id=\"first\"></a>";
25912595

25922596
if (hp != NULL) {
@@ -2626,7 +2630,7 @@ void printsubjects(FILE *fp, struct header *hp, char **oldsubject,
26262630
else {
26272631
startline = "<li>";
26282632
break_str = "";
2629-
sprintf(date_str, "<em>(%s)</em>", getindexdatestr(hp->data->date));
2633+
snprintf(date_str, sizeof(date_str), "<em>(%s)</em>", getindexdatestr(hp->data->date));
26302634
endline = "</li>";
26312635
}
26322636
fprintf(fp,
@@ -2733,7 +2737,7 @@ void printauthors(FILE *fp, struct header *hp, char **oldname,
27332737
const char *startline;
27342738
const char *break_str;
27352739
const char *endline;
2736-
static char date_str[DATESTRLEN+11]; /* made static for smaller stack */
2740+
static char date_str[DATESTRLEN+40]; /* made static for smaller stack */
27372741
static char *first_attributes = "<a accesskey=\"j\" name=\"first\" id=\"first\"></a>";
27382742

27392743
if (hp != NULL) {
@@ -2781,7 +2785,7 @@ void printauthors(FILE *fp, struct header *hp, char **oldname,
27812785
else {
27822786
startline = "<li>";
27832787
break_str = "&nbsp;";
2784-
sprintf(date_str, "<em>(%s)</em>", getindexdatestr(hp->data->date));
2788+
snprintf(date_str, sizeof(date_str), "<em>(%s)</em>", getindexdatestr(hp->data->date));
27852789
endline = "</li>";
27862790
}
27872791
fprintf(fp,"%s%s%s</a>%s<a name=\"%d\" id=\"%d\">%s</a>%s\n",
@@ -3055,7 +3059,7 @@ static void printmonths(FILE *fp, char *summary_filename, int amountmsgs)
30553059
switch (j) {
30563060
case DATE_INDEX:
30573061
{
3058-
char prev_date_str[DATESTRLEN];
3062+
char prev_date_str[DATESTRLEN + 40];
30593063
prev_date_str[0] = '\0';
30603064
printdates(fp1, datelist, y, m, NULL, prev_date_str);
30613065
if (*prev_date_str) /* close the previous date item */

0 commit comments

Comments
 (0)