From 2695b63fbe6c6a2206a2637137c6cd654f69943a Mon Sep 17 00:00:00 2001 From: Eduardo Chappa Date: Sun, 26 Jul 2015 23:36:30 -0600 Subject: [PATCH] * Clear even more warnings from clang 3.5 and MAC OSX. --- alpine/adrbkcmd.c | 2 +- alpine/colorconf.c | 4 +-- alpine/flagmaint.c | 2 +- alpine/folder.c | 18 ++++++------- alpine/imap.c | 2 +- alpine/mailcmd.c | 64 +++++++++++++++++++++++---------------------- alpine/mailpart.c | 2 +- alpine/mailview.c | 8 +++--- alpine/newmail.c | 2 +- alpine/osdep/debuging.c | 10 +++---- alpine/osdep/fltrname.c | 7 ++--- alpine/status.c | 4 +-- alpine/takeaddr.c | 22 +++++++++------- pico/attach.c | 6 ++--- pico/browse.c | 2 +- pico/file.c | 4 +-- pith/conf.c | 2 +- pith/context.c | 10 +++---- pith/filter.c | 2 +- pith/help.c | 2 +- pith/init.c | 4 +-- pith/mailcmd.c | 16 ++++++------ pith/mailindx.c | 6 ++--- pith/mimedesc.c | 7 ++--- pith/news.c | 10 +++---- pith/pine.hlp | 2 +- pith/reply.c | 37 ++++++++++++++------------ pith/save.c | 27 ++++++++++--------- pith/send.c | 13 ++++----- pith/stream.c | 6 ++--- web/src/alpined.d/alpined.c | 27 ++++++++++++------- web/src/alpined.d/wpcomm.c | 2 +- 32 files changed, 175 insertions(+), 157 deletions(-) diff --git a/alpine/adrbkcmd.c b/alpine/adrbkcmd.c index 8c0c0d6..2bd8dbd 100644 --- a/alpine/adrbkcmd.c +++ b/alpine/adrbkcmd.c @@ -7290,7 +7290,7 @@ prep_ldap_for_viewing(struct pine *ps, LDAP_CHOOSE_S *winning_e, SourceType srct */ snprintf(obuf, sizeof(obuf), "%c%c%c%s%s%c%c%c%c", TAG_EMBED, TAG_HANDLE, - strlen(buf), buf, vals[i]->bv_val, + (int) strlen(buf), buf, vals[i]->bv_val, TAG_EMBED, TAG_BOLDOFF, TAG_EMBED, TAG_INVOFF); obuf[sizeof(obuf)-1] = '\0'; diff --git a/alpine/colorconf.c b/alpine/colorconf.c index 8325048..e306583 100644 --- a/alpine/colorconf.c +++ b/alpine/colorconf.c @@ -2708,7 +2708,7 @@ color_edit_screen(struct pine *ps, CONF_S **cl) name[0] = '\0'; if(is_general){ p = srchstr(vtmp->name, "-foreground-color"); - snprintf(name, sizeof(name), "%.*s", p ? MIN(p - vtmp->name, 30) : 30, vtmp->name); + snprintf(name, sizeof(name), "%.*s", p ? (int) MIN(p - vtmp->name, 30) : 30, vtmp->name); name[sizeof(name)-1] = '\0'; if(islower((unsigned char)name[0])) name[0] = toupper((unsigned char)name[0]); @@ -2716,7 +2716,7 @@ color_edit_screen(struct pine *ps, CONF_S **cl) else if(is_index){ p = srchstr(vtmp->name, "-foreground-color"); snprintf(name, sizeof(name), "%.*s Symbol", - p ? MIN(p - vtmp->name, 30) : 30, vtmp->name); + p ? (int) MIN(p - vtmp->name, 30) : 30, vtmp->name); name[sizeof(name)-1] = '\0'; if(islower((unsigned char)name[0])) name[0] = toupper((unsigned char)name[0]); diff --git a/alpine/flagmaint.c b/alpine/flagmaint.c index 6112979..2e5864d 100644 --- a/alpine/flagmaint.c +++ b/alpine/flagmaint.c @@ -126,7 +126,7 @@ try_again: ctmpa->valoffset = 0; snprintf(tmp, sizeof(tmp), "%*.*s--- %.*s", offset, offset, "", - lv+lc+strlen(spacer), repeat_char(lv+lc+strlen(spacer), '-')); + (int)(lv+lc+strlen(spacer)), repeat_char(lv+lc+strlen(spacer), '-')); tmp[sizeof(tmp)-1] = '\0'; ctmpa->value = cpystr(tmp); diff --git a/alpine/folder.c b/alpine/folder.c index 724bf13..34da788 100644 --- a/alpine/folder.c +++ b/alpine/folder.c @@ -1165,8 +1165,8 @@ exit_collection_add(struct headerentry *he, void (*redraw_pico)(void), int allow strncpy(tmp, server, sizeof(tmp)-1); tmp[sizeof(tmp)-1] = '\0'; } - else /* add them */ - snprintf(tmp, sizeof(tmp), "{%.*s}", sizeof(tmp)-3, server); + else /* add them */ /* sizeof(tmp) == MAILTMPLEN */ + snprintf(tmp, sizeof(tmp), "{%.*s}", MAILTMPLEN-3, server); if(mail_valid_net_parse(tmp, &mb)){ /* news? verify namespace */ if(!struncmp(mb.service, "nntp", 4) && strncmp(path, "#news.", 6)) @@ -3571,14 +3571,14 @@ folder_lister_fullname(FSTATE_S *fs, char *name) if(fs->context->dir->ref){ snprintf(tmp, sizeof(tmp), "%.*s%.*s", - sizeof(tmp)/2, + MAILTMPLEN, /* MAILTMPLEN == sizeof(tmp)/2 */ ((fs->relative_path || (fs->context->use & CNTXT_SAVEDFLT)) && (p = strstr(fs->context->context, "%s")) && !*(p+2) && !strncmp(fs->context->dir->ref, fs->context->context, p - fs->context->context)) ? fs->context->dir->ref + (p - fs->context->context) : fs->context->dir->ref, - sizeof(tmp)/2, name); + MAILTMPLEN, name); tmp[sizeof(tmp)-1] = '\0'; } @@ -3591,13 +3591,13 @@ folder_lister_fullname(FSTATE_S *fs, char *name) && !fs->relative_path && !(fs->context->use & CNTXT_SAVEDFLT)){ /* if it's in the primary collection, the names relative */ - if(fs->context->dir->ref){ + if(fs->context->dir->ref){ /* MAILTMPLEN = sizeof(tmp)/2 */ if(IS_REMOTE(fs->context->context) && (p = strrindex(fs->context->context, '}'))){ snprintf(tmp2, sizeof(tmp2), "%.*s%.*s", - MIN(p - fs->context->context + 1, sizeof(tmp2)/2), + (int) MIN(p - fs->context->context + 1, sizeof(tmp)/2), fs->context->context, - sizeof(tmp2)/2, tmp); + MAILTMPLEN, tmp); tmp2[sizeof(tmp2)-1] = '\0'; } else @@ -5056,7 +5056,7 @@ group_subscription(char *folder, size_t len, CONTEXT_S *cntxt) char tmp[MAILTMPLEN]; snprintf(tmp, sizeof(tmp), "%s%.*s*", (rc == 11) ? "" : "*", - sizeof(tmp)-3, folder); + MAILTMPLEN-3, folder); tmp[sizeof(tmp)-1] = '\0'; build_folder_list(NULL, &subscribe_cntxt, tmp, NULL, BFL_NONE); subscribe_cntxt.dir->status &= ~(CNTXT_PARTFIND|CNTXT_NOFIND); @@ -6027,7 +6027,7 @@ scan_scan_folder(MAILSTREAM *stream, CONTEXT_S *context, FOLDER_S *f, char *patt if((p = strstr(context->context, "%s")) != NULL){ if(!*(p+2)){ - snprintf(tmp, sizeof(tmp), "%.*s", MIN(p - context->context, sizeof(tmp)-1), + snprintf(tmp, sizeof(tmp), "%.*s", (int) MIN(p - context->context, sizeof(tmp)-1), context->context); tmp[sizeof(tmp)-1] = '\0'; ref = tmp; diff --git a/alpine/imap.c b/alpine/imap.c index f4cccfc..546a8ae 100644 --- a/alpine/imap.c +++ b/alpine/imap.c @@ -168,7 +168,7 @@ mm_notify(MAILSTREAM *stream, char *string, long int errflg) snprintf(ps_global->last_error, sizeof(ps_global->last_error), "%s : %.*s", (stream && stream->mailbox) ? stream->mailbox : "-no folder-", - MIN(MAX_SCREEN_COLS, sizeof(ps_global->last_error)-70), + (int) MIN(MAX_SCREEN_COLS, sizeof(ps_global->last_error)-70), string); ps_global->last_error[ps_global->ttyo ? ps_global->ttyo->screen_cols : sizeof(ps_global->last_error)-1] = '\0'; diff --git a/alpine/mailcmd.c b/alpine/mailcmd.c index eb50639..37d54eb 100644 --- a/alpine/mailcmd.c +++ b/alpine/mailcmd.c @@ -1058,7 +1058,9 @@ nfolder: break; } - {char *front, type[80], cnt[80], fbuf[MAX_SCREEN_COLS/2+1]; + { +#define CNTLEN 80 + char *front, type[80], cnt[CNTLEN], fbuf[MAX_SCREEN_COLS/2+1]; int rbspace, avail, need, take_back; /* @@ -1074,7 +1076,7 @@ nfolder: ? "Incoming folder" : "news group", sizeof(type)); type[sizeof(type)-1] = '\0'; - snprintf(cnt, sizeof(cnt), " (%.*s %s)", sizeof(cnt)-20, + snprintf(cnt, sizeof(cnt), " (%.*s %s)", CNTLEN-20, recent_cnt ? long2string(recent_cnt) : "some", F_ON(F_TAB_USES_UNSEEN, ps_global) ? "unseen" : "recent"); @@ -1106,16 +1108,16 @@ nfolder: cnt[0] = '\0'; } } - + /* MAX_SCREEN_COLS+1 = sizeof(prompt) */ snprintf(prompt, sizeof(prompt), "%.*s %.*s \"%.*s\"%.*s? ", - sizeof(prompt)/8, front, - sizeof(prompt)/8, type, - sizeof(prompt)/2, + (MAX_SCREEN_COLS+1)/8, front, + (MAX_SCREEN_COLS+1)/8, type, + (MAX_SCREEN_COLS+1)/2, short_str(nextfolder, fbuf, sizeof(fbuf), strlen(nextfolder) - ((need>avail) ? (need-avail) : 0), MidDots), - sizeof(prompt)/8, cnt); + (MAX_SCREEN_COLS+1)/8, cnt); prompt[sizeof(prompt)-1] = '\0'; } @@ -1273,9 +1275,9 @@ get_out: del_count++; if(del_count > 0L){ - state->mangled_footer = 1; + state->mangled_footer = 1; /* MAX_SCREEN_COLS+1 = sizeof(prompt) */ snprintf(prompt, sizeof(prompt), "UNexclude %ld message%s in %.*s", del_count, - plural(del_count), sizeof(prompt)-40, + plural(del_count), MAX_SCREEN_COLS+1-40, pretty_fn(state->cur_folder)); prompt[sizeof(prompt)-1] = '\0'; if(F_ON(F_FULL_AUTO_EXPUNGE, state) @@ -1773,7 +1775,7 @@ go_again: l = strlen(kw->kw)+2; fp->comment = (char *) fs_get((l+1) * sizeof(char)); - snprintf(fp->comment, l+1, "(%.*s)", strlen(kw->kw), kw->kw); + snprintf(fp->comment, l+1, "(%.*s)", (int) strlen(kw->kw), kw->kw); fp->comment[l] = '\0'; } @@ -3260,9 +3262,9 @@ cmd_expunge(struct pine *state, MAILSTREAM *stream, MSGNO_S *msgmap, int agg) if(!MCMD_ISAGG(agg)) del_count = count_flagged(stream, F_DEL); if(del_count > 0L){ - state->mangled_footer = 1; + state->mangled_footer = 1; /* MAX_SCREEN_COLS+1 = sizeof(prompt) */ snprintf(prompt, sizeof(prompt), "Exclude %ld message%s from %.*s", del_count, - plural(del_count), sizeof(prompt)-40, + plural(del_count), MAX_SCREEN_COLS+1-40, pretty_fn(state->cur_folder)); prompt[sizeof(prompt)-1] = '\0'; if(F_ON(F_FULL_AUTO_EXPUNGE, state) @@ -3316,9 +3318,9 @@ cmd_expunge(struct pine *state, MAILSTREAM *stream, MSGNO_S *msgmap, int agg) if(del_count != 0){ int ret; unsigned char *fname = folder_name_decoded((unsigned char *)state->cur_folder); - + /* MAX_SCREEN_COLS+1 = sizeof(prompt) */ snprintf(prompt, sizeof(prompt), "Expunge %ld message%s from %.*s", del_count, - plural(del_count), sizeof(prompt)-40, + plural(del_count), MAX_SCREEN_COLS+1-40, pretty_fn((char *) fname)); if(fname) fs_give((void **)&fname); prompt[sizeof(prompt)-1] = '\0'; @@ -3906,8 +3908,8 @@ cmd_export(struct pine *state, MSGNO_S *msgmap, int qline, int aopt) lfile[0] = '\0'; (void) get_filename_parameter(lfile, sizeof(lfile), a->body, NULL); - if(lfile[0] == '\0'){ - snprintf(lfile, sizeof(lfile), "part_%.*s", sizeof(lfile)-6, + if(lfile[0] == '\0'){ /* MAXPATH + 1 = sizeof(lfile) */ + snprintf(lfile, sizeof(lfile), "part_%.*s", MAXPATH+1-6, a->number ? a->number : "?"); lfile[sizeof(lfile)-1] = '\0'; } @@ -4478,7 +4480,7 @@ get_export_filename(struct pine *ps, char *filename, char *deefault, * Just building the directory name in dir2, * full_filename is overloaded. */ - snprintf(full_filename, len, "%.*s", MIN(fn-tmp,len-1), tmp); + snprintf(full_filename, len, "%.*s", (int) MIN(fn-tmp,len-1), tmp); full_filename[len-1] = '\0'; strncpy(postcolon, full_filename, sizeof(postcolon)-1); postcolon[sizeof(postcolon)-1] = '\0'; @@ -5545,9 +5547,9 @@ broach_folder(int qline, int allow_list, int *notrealinbox, CONTEXT_S **context) ? ps_global->last_unambig_folder : ((tc->last_folder[0]) ? tc->last_folder : NULL); - if(last_folder){ + if(last_folder){ /* MAXPATH + 1 = sizeof(expanded) */ unsigned char *fname = folder_name_decoded((unsigned char *)last_folder); - snprintf(expanded, sizeof(expanded), " [%.*s]", sizeof(expanded)-5, + snprintf(expanded, sizeof(expanded), " [%.*s]", MAXPATH+1-5, fname ? (char *) fname : last_folder); if(fname) fs_give((void **)&fname); } @@ -5557,35 +5559,35 @@ broach_folder(int qline, int allow_list, int *notrealinbox, CONTEXT_S **context) expanded[sizeof(expanded)-1] = '\0'; /* only show collection number if more than one available */ - if(ps_global->context_list->next) + if(ps_global->context_list->next) /* MAX_SCREEN_COLS+1 == sizeof(prompt) */ snprintf(prompt, sizeof(prompt), "GOTO %s in <%s> %.*s%s: ", NEWS_TEST(tc) ? "news group" : "folder", - tc->nickname, sizeof(prompt)-50, expanded, + tc->nickname, MAX_SCREEN_COLS+1-50, expanded, *expanded ? " " : ""); - else - snprintf(prompt, sizeof(prompt), "GOTO folder %.*s%s: ", sizeof(prompt)-20, expanded, + else /* MAX_SCREEN_COLS+1 == sizeof(prompt) */ + snprintf(prompt, sizeof(prompt), "GOTO folder %.*s%s: ", MAX_SCREEN_COLS+1-20, expanded, *expanded ? " " : ""); prompt[sizeof(prompt)-1] = '\0'; if(utf8_width(prompt) > MAXPROMPT){ - if(ps_global->context_list->next) + if(ps_global->context_list->next) /* MAX_SCREEN_COLS+1 == sizeof(prompt) */ snprintf(prompt, sizeof(prompt), "GOTO <%s> %.*s%s: ", - tc->nickname, sizeof(prompt)-50, expanded, + tc->nickname, MAX_SCREEN_COLS+1-50, expanded, *expanded ? " " : ""); - else - snprintf(prompt, sizeof(prompt), "GOTO %.*s%s: ", sizeof(prompt)-20, expanded, + else /* MAX_SCREEN_COLS+1 == sizeof(prompt) */ + snprintf(prompt, sizeof(prompt), "GOTO %.*s%s: ", MAX_SCREEN_COLS+1-20, expanded, *expanded ? " " : ""); prompt[sizeof(prompt)-1] = '\0'; if(utf8_width(prompt) > MAXPROMPT){ - if(ps_global->context_list->next) + if(ps_global->context_list->next) /* MAX_SCREEN_COLS+1 == sizeof(prompt) */ snprintf(prompt, sizeof(prompt), "<%s> %.*s%s: ", - tc->nickname, sizeof(prompt)-50, expanded, + tc->nickname, MAX_SCREEN_COLS+1-50, expanded, *expanded ? " " : ""); - else - snprintf(prompt, sizeof(prompt), "%.*s%s: ", sizeof(prompt)-20, expanded, + else /* MAX_SCREEN_COLS+1 == sizeof(prompt) */ + snprintf(prompt, sizeof(prompt), "%.*s%s: ", MAX_SCREEN_COLS+1-20, expanded, *expanded ? " " : ""); prompt[sizeof(prompt)-1] = '\0'; diff --git a/alpine/mailpart.c b/alpine/mailpart.c index 462c02e..615c728 100644 --- a/alpine/mailpart.c +++ b/alpine/mailpart.c @@ -2803,7 +2803,7 @@ display_vcard_att(long int msgno, ATTACH_S *a, int flags) begins++; snprintf(tmp, sizeof(tmp), " %-*.*s : ", indent - 5, - MIN(p - *ll, sizeof(tmp)-5), *ll); + (int) MIN(p - *ll, sizeof(tmp)-5), *ll); tmp[sizeof(tmp)-1] = '\0'; so_puts(in_store, tmp); p++; diff --git a/alpine/mailview.c b/alpine/mailview.c index 4d90af0..fdccf2c 100644 --- a/alpine/mailview.c +++ b/alpine/mailview.c @@ -849,13 +849,13 @@ scroll_handle_prompt(HANDLE_S *handle, int force) if(handle->type == URL && !struncmp(handle->h.url.path, "mailto:", 7)) snprintf(prompt, sizeof(prompt), "Compose mail to \"%.*s%s\" ? ", - MIN(MAX(0,sc - 25), sizeof(prompt)-50), handle->h.url.path+7, + (int) MIN(MAX(0,sc - 25), sizeof(prompt)-50), handle->h.url.path+7, (strlen(handle->h.url.path+7) > MAX(0,sc-25)) ? "..." : ""); else snprintf(prompt, sizeof(prompt), "View selected %s %s%.*s%s ? ", (handle->type == URL) ? "URL" : "Attachment", (handle->type == URL) ? "\"" : "", - MIN(MAX(0,sc-27), sizeof(prompt)-50), + (int) MIN(MAX(0,sc-27), sizeof(prompt)-50), (handle->type == URL) ? handle->h.url.path : "", (handle->type == URL) ? ((strlen(handle->h.url.path) > MAX(0,sc-27)) @@ -1964,8 +1964,8 @@ url_local_nntp(char *url) if(group_len){ snprintf(folder, sizeof(folder), "{%.*s/nntp}#news.%.*s", - MIN((group - 1) - (url + 7), MAILTMPLEN-20), url + 7, - MIN(group_len, MAILTMPLEN-20), group); + (int) MIN((group - 1) - (url + 7), MAILTMPLEN-20), url + 7, + (int) MIN(group_len, MAILTMPLEN-20), group); folder[sizeof(folder)-1] = '\0'; } else diff --git a/alpine/newmail.c b/alpine/newmail.c index ba1dbda..a8818db 100644 --- a/alpine/newmail.c +++ b/alpine/newmail.c @@ -304,7 +304,7 @@ newmailfifo(int is_us, char *from, char *subject, char *folder) tmtxt = ""; snprintf(buf, sizeof(buf), "New Mail window started at %.*s\n", - MIN(100, strlen(tmtxt)-1), tmtxt); + (int) MIN(100, strlen(tmtxt)-1), tmtxt); (void) write(fifofd, buf, strlen(buf)); snprintf(buf, sizeof(buf), " %-*s%-*s%-*s\n", diff --git a/alpine/osdep/debuging.c b/alpine/osdep/debuging.c index 55cbc9b..4f115fe 100644 --- a/alpine/osdep/debuging.c +++ b/alpine/osdep/debuging.c @@ -397,13 +397,13 @@ dump_config(struct pine *ps, gf_io_t pc, int brief) (i == 3) ? vars->post_user_val.l : (i == 4) ? vars->global_val.l : vars->fixed_val.l; - if(t && *t){ + if(t && *t){ /* MAILTMPLEN = sizeof(tmp) */ snprintf(tmp, sizeof(tmp), " %20.20s : %.*s\n", vars->name, - sizeof(tmp)-26, **t ? *t : quotes); + MAILTMPLEN-26, **t ? *t : quotes); gf_puts(tmp, pc); while(++t && *t){ snprintf(tmp, sizeof(tmp)," %20.20s : %.*s\n","", - sizeof(tmp)-26, **t ? *t : quotes); + MAILTMPLEN-26, **t ? *t : quotes); gf_puts(tmp, pc); } } @@ -416,9 +416,9 @@ dump_config(struct pine *ps, gf_io_t pc, int brief) (i == 3) ? vars->post_user_val.p : (i == 4) ? vars->global_val.p : vars->fixed_val.p; - if(t){ + if(t){ /* MAILTMPLEN = sizeof(tmp) */ snprintf(tmp, sizeof(tmp), " %20.20s : %.*s\n", vars->name, - sizeof(tmp)-26, *t ? t : quotes); + MAILTMPLEN-26, *t ? t : quotes); gf_puts(tmp, pc); } } diff --git a/alpine/osdep/fltrname.c b/alpine/osdep/fltrname.c index e9a6c40..f601c06 100644 --- a/alpine/osdep/fltrname.c +++ b/alpine/osdep/fltrname.c @@ -39,6 +39,7 @@ static char rcsid[] = "$Id: fltrname.c 769 2007-10-24 00:15:40Z hubert@u.washing char * filter_filename(char *file, int *fatal, int strict) { +#define ERRORLEN 100 #define ALLOW_WEIRD 1 #ifdef ALLOW_WEIRD static char illegal[] = {'\177', '\0'}; @@ -53,7 +54,7 @@ filter_filename(char *file, int *fatal, int strict) '\\', '^', '|', '\177', '\0'}; #endif /* UNIX */ #endif - static char error[100]; + static char error[ERRORLEN]; char ill_file[MAXPATH+1], *ill_char, *ptr, e2[20]; int i; @@ -91,7 +92,7 @@ filter_filename(char *file, int *fatal, int strict) ill_file[MIN(ptr-file,sizeof(ill_file)-1)] = '\0'; snprintf(error, sizeof(error), "Character \"%s\" after \"%.*s\" not allowed in file name", - ill_char, sizeof(error)-50, ill_file); + ill_char, ERRORLEN-50, ill_file); } else { snprintf(error, sizeof(error), "First character, \"%s\", not allowed in file name", @@ -102,7 +103,7 @@ filter_filename(char *file, int *fatal, int strict) } if((i=is_writable_dir(file)) == 0 || i == 1){ - snprintf(error, sizeof(error), "\"%.*s\" is a directory", sizeof(error)-50, file); + snprintf(error, sizeof(error), "\"%.*s\" is a directory", ERRORLEN-50, file); return(error); } diff --git a/alpine/status.c b/alpine/status.c index e3962ee..771c5d1 100644 --- a/alpine/status.c +++ b/alpine/status.c @@ -1149,7 +1149,7 @@ output_message_modal(SMQ_T *mq_entry, int ding) add_review_message(m->text, -1); if((p = strstr(m->text, "[ALERT]")) != NULL){ - snprintf(t, SIZEOF_20KBUF-(t-tmp_20k_buf), "%*.*s\n", indent + p - m->text, p - m->text, m->text); + snprintf(t, SIZEOF_20KBUF-(t-tmp_20k_buf), "%*.*s\n", (int)(indent + p - m->text), (int) (p - m->text), m->text); tmp_20k_buf[SIZEOF_20KBUF-1] = '\0'; t += strlen(t); @@ -1166,7 +1166,7 @@ output_message_modal(SMQ_T *mq_entry, int ding) q > p && !isspace((unsigned char)*q); q--) ; - snprintf(t, SIZEOF_20KBUF-(t-tmp_20k_buf), "\n%*.*s", indent + q - p, q - p, p); + snprintf(t, SIZEOF_20KBUF-(t-tmp_20k_buf), "\n%*.*s", (int) (indent + q - p), (int) (q - p), p); tmp_20k_buf[SIZEOF_20KBUF-1] = '\0'; t += strlen(t); p = q + 1; diff --git a/alpine/takeaddr.c b/alpine/takeaddr.c index e51bcb7..7701ce3 100644 --- a/alpine/takeaddr.c +++ b/alpine/takeaddr.c @@ -1569,7 +1569,7 @@ whereis_taline(TA_S *current) buf[0] = '\0'; snprintf(tmp, sizeof(tmp), _("Word to find %s%.*s%s: "), (last[0]) ? "[" : "", - sizeof(tmp)-20, (last[0]) ? last : "", + MAX_SEARCH, (last[0]) ? last : "", /* MAX_SEARCH == sizeof(tmp) - 20 */ (last[0]) ? "]" : ""); tmp[sizeof(tmp)-1] = '\0'; help = NO_HELP; @@ -1892,11 +1892,11 @@ update_takeaddr_screen(struct pine *ps, TA_S *current, TA_SCREEN_S *screen, Pos } } else{ - if(screen->mode == ListMode) + if(screen->mode == ListMode) /* 6*MAX_SCREEN_COLS + 24 = sizeof(buf2)-6 */ snprintf(buf2, sizeof(buf2), "[%c] %.*s", ctmp->checked ? 'X' : SPACE, - sizeof(buf2)-6, buf1); + 6*MAX_SCREEN_COLS + 24, buf1); else - snprintf(buf2, sizeof(buf2), " %.*s", sizeof(buf2)-6, buf1); + snprintf(buf2, sizeof(buf2), " %.*s", 6*MAX_SCREEN_COLS+24, buf1); buf2[sizeof(buf2)-1] = '\0'; } @@ -2066,6 +2066,7 @@ attached_addr_handler(TA_S *current, int added) int take_without_edit(TA_S *ta_list, int num_in_list, int command_line, TA_STATE_S **tas, char *cmd) { +#define OURTMPBUFLEN 200 PerAddrBook *pab_dst; SAVE_STATE_S state; /* For saving state of addrbooks temporarily */ int rc, total_to_copy; @@ -2074,7 +2075,7 @@ take_without_edit(TA_S *ta_list, int num_in_list, int command_line, TA_STATE_S * int err = 0, need_write = 0, we_cancel = 0; adrbk_cntr_t new_entry_num; char warn[2][MAX_NICKNAME+1]; - char tmp[200]; + char tmp[OURTMPBUFLEN]; TA_S *current; SWOOP_S *swoop_list = NULL, *sw; @@ -2150,13 +2151,13 @@ take_without_edit(TA_S *ta_list, int num_in_list, int command_line, TA_STATE_S * else{ snprintf(tmp, sizeof(tmp), "Entry with nickname \"%.*s\" already exists, replace ", - sizeof(tmp)-50, warn[0]); + OURTMPBUFLEN-50, warn[0]); } } else if(how_many_dups == 2) snprintf(tmp, sizeof(tmp), "Nicknames \"%.*s\" and \"%.*s\" already exist, replace ", - (sizeof(tmp)-50)/2, warn[0], (sizeof(tmp)-50)/2, warn[1]); + (OURTMPBUFLEN-50)/2, warn[0], (OURTMPBUFLEN-50)/2, warn[1]); else snprintf(tmp, sizeof(tmp), "%d of the nicknames already exist, replace ", how_many_dups); @@ -2413,14 +2414,15 @@ get_out: ps_global->mangled_footer = 1; if(err){ - char capcmd[50]; +#define CAPCMDLEN 50 + char capcmd[CAPCMDLEN]; ret = -1; snprintf(capcmd, sizeof(capcmd), "%c%.*s", islower((unsigned char)(*cmd)) ? toupper((unsigned char)*cmd) : *cmd, - sizeof(capcmd)-2, cmd+1); + CAPCMDLEN-2, cmd+1); if(need_write) q_status_message1(SM_ORDER | SM_DING, 3, 4, "%.200s only partially completed", capcmd); @@ -2433,7 +2435,7 @@ get_out: snprintf(tmp, sizeof(tmp), "Saved %d %s to \"%.*s\"", total_to_copy, (total_to_copy > 1) ? "entries" : "entry", - sizeof(tmp)-30, pab_dst->abnick); + OURTMPBUFLEN-30, pab_dst->abnick); q_status_message(SM_ORDER, 4, 4, tmp); } diff --git a/pico/attach.c b/pico/attach.c index be4a9fb..3a70272 100644 --- a/pico/attach.c +++ b/pico/attach.c @@ -170,7 +170,7 @@ AskAttach(char *cmnt, size_t cmntlen, LMLIST **lm) ? "." : ((gmode & MDTREE) || opertree[0]) ? opertree : gethomedir(NULL), - C_FILESEP, p - fn, fn); + C_FILESEP, (int) (p - fn), fn); } else{ fname = fn; @@ -1069,8 +1069,8 @@ process_tag: /* enclosed in [] */ * whole attachment, comment or done! */ if(c == ',' || c == '\0' || c == '\"'){ - strncpy(sz, (lblsz) ? lblsz : prettysz(attsz), sizeof(sz)); - sz[sizeof(sz)-1] = '\0'; + strncpy(sz, (lblsz) ? lblsz : prettysz(attsz), szlen); + sz[szlen-1] = '\0'; snprintf(ctmp, sizeof(ctmp), " (%s) %s", sz, (c == '\"') ? "" : "\"\""); u = utf8_to_ucs4_cpystr(ctmp); diff --git a/pico/browse.c b/pico/browse.c index 7994010..11d3eb3 100644 --- a/pico/browse.c +++ b/pico/browse.c @@ -1482,7 +1482,7 @@ FileBrowse(char *dir, size_t dirlen, char *fn, size_t fnlen, tmp[sizeof(tmp)-1] = '\0'; } - strncat(tmp, gmp->current->fname, sizeof(tmp)-strlen(tmp)); + strncat(tmp, gmp->current->fname, sizeof(tmp)-strlen(tmp)-1); tmp[sizeof(tmp)-1] = '\0'; } diff --git a/pico/file.c b/pico/file.c index 405d2c6..29f1680 100644 --- a/pico/file.c +++ b/pico/file.c @@ -408,7 +408,7 @@ file_split(char *dirbuf, size_t dirbuflen, char *orig_fname, int is_for_browse) ? opertree : ((is_for_browse && browse_dir[0]) ? browse_dir : gethomedir(NULL)), - C_FILESEP, p - orig_fname, orig_fname); + C_FILESEP, (int) (p - orig_fname), orig_fname); } else{ fn = orig_fname; @@ -645,7 +645,7 @@ filewrite(int f, int n) ? "." : ((gmode & MDTREE) || opertree[0]) ? opertree : gethomedir(NULL), - C_FILESEP, p - fname, fname); + C_FILESEP, (int) (p - fname), fname); } else{ fn = fname; diff --git a/pith/conf.c b/pith/conf.c index 40fdbcd..4b2dc38 100644 --- a/pith/conf.c +++ b/pith/conf.c @@ -7630,7 +7630,7 @@ panic1(char *message, char *arg) #define SIZEOFBUF 1001 char buf1[SIZEOFBUF], buf2[SIZEOFBUF]; - snprintf(buf1, sizeof(buf1), "%.*s", MAX(SIZEOFBUF - 1 - strlen(message), 0), arg); + snprintf(buf1, sizeof(buf1), "%.*s", (int) MAX(SIZEOFBUF - 1 - strlen(message), 0), arg); snprintf(buf2, sizeof(buf2), message, buf1); alpine_panic(buf2); } diff --git a/pith/context.c b/pith/context.c index e92ee67..735cf1c 100644 --- a/pith/context.c +++ b/pith/context.c @@ -190,18 +190,18 @@ context_apply(char *b, CONTEXT_S *c, char *name, size_t len) else if(name[0] == '#'){ if(IS_REMOTE(c->context)){ char *p = strchr(c->context, '}'); /* name specifies namespace */ - snprintf(b, len, "%.*s", MIN(p - c->context + 1, len-1), c->context); + snprintf(b, len, "%.*s", (int) MIN(p - c->context + 1, len-1), c->context); b[MIN(p - c->context + 1, len-1)] = '\0'; - snprintf(b+strlen(b), len-strlen(b), "%.*s", len-1-strlen(b), name); + snprintf(b+strlen(b), len-strlen(b), "%.*s", (int)(len-1-strlen(b)), name); } else{ strncpy(b, name, len-1); } } else if(c->dir && c->dir->ref){ /* has reference string! */ - snprintf(b, len, "%.*s", len-1, c->dir->ref); + snprintf(b, len, "%.*s", (int) len-1, c->dir->ref); b[len-1] = '\0'; - snprintf(b+strlen(b), len-strlen(b), "%.*s", len-1-strlen(b), name); + snprintf(b+strlen(b), len-strlen(b), "%.*s", (int) (len-1-strlen(b)), name); } else{ /* no ref, apply to context */ char *pq = NULL; @@ -713,7 +713,7 @@ new_context(char *cntxt_string, int *prime) snprintf(tmp_20k_buf, SIZEOF_20KBUF, "%solders%s%.100s in %.*s%s", (*host) ? "F" : "Local f", (*host) ? " on " : "", (*host) ? host : "", - p ? MIN(p - rcontext, 100) : 0, + p ? (int) MIN(p - rcontext, 100) : 0, rcontext, (p && (p - rcontext) > 0) ? "" : "home directory"); } diff --git a/pith/filter.c b/pith/filter.c index 70a89f1..0aa38db 100644 --- a/pith/filter.c +++ b/pith/filter.c @@ -5393,7 +5393,7 @@ html_a_relative(char *base_url, char *rel_url, HANDLE_S *h) if(len + strlen(rel_path) < sizeof(tmp)-1){ if(len) - snprintf(path = tmp, sizeof(tmp), "%.*s", len, base_path); + snprintf(path = tmp, sizeof(tmp), "%.*s", (int) len, base_path); strncpy(tmp + len, rel_path, sizeof(tmp)-len); tmp[sizeof(tmp)-1] = '\0'; diff --git a/pith/help.c b/pith/help.c index 1c1b9ab..8291713 100644 --- a/pith/help.c +++ b/pith/help.c @@ -40,7 +40,7 @@ help_name2section(char *url, int url_len) HelpType newhelp = NO_HELP; struct help_texts *t; - snprintf(name, sizeof(name), "%.*s", MIN(url_len,sizeof(name)), url); + snprintf(name, sizeof(name), "%.*s", (int) MIN(url_len,sizeof(name)), url); for(t = h_texts; t->help_text != NO_HELP; t++) if(!strucmp(t->tag, name)){ diff --git a/pith/init.c b/pith/init.c index 978297f..ba77f70 100644 --- a/pith/init.c +++ b/pith/init.c @@ -378,8 +378,8 @@ get_mail_list(CONTEXT_S *list_cntxt, char *folder_base) folder_base_len = strlen(searchname) - 1; } else -#endif - snprintf(searchname, sizeof(searchname), "%.*s*", sizeof(searchname)-2, folder_base); +#endif /* MAXPATH + 1 = sizeof(searchmane) */ + snprintf(searchname, sizeof(searchname), "%.*s*", MAXPATH+1-2, folder_base); build_folder_list(NULL, list_cntxt, searchname, NULL, BFL_FLDRONLY); diff --git a/pith/mailcmd.c b/pith/mailcmd.c index f3ac0ed..ff0f7fa 100644 --- a/pith/mailcmd.c +++ b/pith/mailcmd.c @@ -1570,22 +1570,22 @@ expunge_and_close(MAILSTREAM *stream, char **final_msg, long unsigned int flags) } } - if(!no_close){ + if(!no_close){ /* MAX_SCREEN_COLS+1 = sizeof(buff2) */ unsigned char *fname = folder_name_decoded((unsigned char *)folder); if(stream->nmsgs){ snprintf(buff2, sizeof(buff2), "Clos%s folder \"%.*s\". %s%s%s message%s.", ing, - sizeof(buff2)-50, pretty_fn((char *) fname), + MAX_SCREEN_COLS+1-50, pretty_fn((char *) fname), final_msg ? "Kept" : "Keeping", (stream->nmsgs == 1L) ? " single" : " all ", (stream->nmsgs > 1L) ? comatose(stream->nmsgs) : "", plural(stream->nmsgs)); } - else{ + else{ /* MAX_SCREEN_COLS+1 = sizeof(buff2) */ snprintf(buff2, sizeof(buff2), "Clos%s empty folder \"%.*s\"", - ing, sizeof(buff2)-50, pretty_fn((char *) fname)); + ing, MAX_SCREEN_COLS+1-50, pretty_fn((char *) fname)); } if(fname) fs_give((void **)&fname); @@ -1616,9 +1616,9 @@ expunge_and_close(MAILSTREAM *stream, char **final_msg, long unsigned int flags) buff1, sizeof(buff1))) != NULL) q_status_message(SM_ORDER, F_ON(F_AUTO_READ_MSGS,ps_global) ? 0 : 3, 5, moved_msg); - + /* MAX_SCREEN_COLS+1 = sizeof(buff2) */ snprintf(buff2, sizeof(buff2), "Clos%s news group \"%.*s\"", - ing, sizeof(buff2)-50, pretty_fn(folder)); + ing, MAX_SCREEN_COLS+1-50, pretty_fn(folder)); if(F_ON(F_NEWS_CATCHUP, ps_global)){ MESSAGECACHE *mc; @@ -1648,11 +1648,11 @@ expunge_and_close(MAILSTREAM *stream, char **final_msg, long unsigned int flags) if(F_ON(F_NEWS_CROSS_DELETE, ps_global)) cross_delete_crossposts(stream); } - else{ + else{ /* MAX_SCREEN_COLS+1 = sizeof(buff2) */ unsigned char *fname = folder_name_decoded((unsigned char *)folder); snprintf(buff2, sizeof(buff2), "Clos%s read-only folder \"%.*s\". No changes to save", - ing, sizeof(buff2)-60, pretty_fn((char *) fname)); + ing, MAX_SCREEN_COLS+1-60, pretty_fn((char *) fname)); if(fname) fs_give((void **)&fname); } diff --git a/pith/mailindx.c b/pith/mailindx.c index a1e889e..586e0d8 100644 --- a/pith/mailindx.c +++ b/pith/mailindx.c @@ -6142,7 +6142,7 @@ from_str(IndexColType ctype, INDEXDATA_S *idata, char *str, size_t strsize, ICE_ if(ctype == iFromTo && (newsgroups = fetch_newsgroups(idata)) && *newsgroups){ - snprintf(fptr, strsize, "To: %-*.*s", strsize-1-4, strsize-1-4, + snprintf(fptr, strsize, "To: %-*.*s", (int)(strsize-1-4), (int)(strsize-1-4), newsgroups); break; } @@ -6174,9 +6174,9 @@ from_str(IndexColType ctype, INDEXDATA_S *idata, char *str, size_t strsize, ICE_ len = strlen(mb); if(!at || strsize-1 <= len) - snprintf(fptr, strsize, "%-*.*s", strsize-1, strsize-1, mb); + snprintf(fptr, strsize, "%-*.*s", (int)(strsize-1), (int)(strsize-1), mb); else - snprintf(fptr, strsize, "%s@%-*.*s", mb, strsize-1-len-1, strsize-1-len-1, hst); + snprintf(fptr, strsize, "%s@%-*.*s", mb, (int)(strsize-1-len-1), (int)(strsize-1-len-1), hst); } break; diff --git a/pith/mimedesc.c b/pith/mimedesc.c index 80d2f84..dbe83f1 100644 --- a/pith/mimedesc.c +++ b/pith/mimedesc.c @@ -70,8 +70,9 @@ void describe_mime(struct mail_bodystruct *body, char *prefix, int num, int should_show, int multalt, int flags) { +#define NUMXLEN 512 PART *part; - char numx[512], string[800], *description; + char numx[NUMXLEN], string[800], *description; int n, named = 0, can_display_ext; ATTACH_S *a; @@ -279,8 +280,8 @@ describe_mime(struct mail_bodystruct *body, char *prefix, int num, (a+1)->description = NULL; if(body->type == TYPEMESSAGE && body->encoding <= ENCBASE64 && body->subtype && strucmp(body->subtype, "rfc822") == 0){ - body = body->nested.msg->body; - snprintf(numx, sizeof(numx), "%.*s%d.", sizeof(numx)-20, prefix, num); + body = body->nested.msg->body; /* NUMXLEN = sizeof(numx) */ + snprintf(numx, sizeof(numx), "%.*s%d.", NUMXLEN-20, prefix, num); numx[sizeof(numx)-1] = '\0'; describe_mime(body, numx, 1, should_show, 0, flags); } diff --git a/pith/news.c b/pith/news.c index 0c90d3a..ea1982c 100644 --- a/pith/news.c +++ b/pith/news.c @@ -221,9 +221,9 @@ news_grouper(char *given_group, char **expanded_group, char **error, */ for(server = ps_global->VAR_NNTP_SERVER; server && *server && **server; - server++){ + server++){ /* MAILTMPLEN = sizeof(ng_ref) */ snprintf(ng_ref, sizeof(ng_ref), "{%.*s/nntp}#news.", - sizeof(ng_ref)-30, *server); + MAILTMPLEN-30, *server); if((stream = pine_mail_open(stream, ng_ref, OP_HALFOPEN|SP_USEPOOL|SP_TEMPUSE, NULL)) != NULL) @@ -267,10 +267,10 @@ news_grouper(char *given_group, char **expanded_group, char **error, * interface... */ for(ntmp = nglist; ntmp; ntmp = ntmp->next){ - if(ntmp->found == NotInCache){ + if(ntmp->found == NotInCache){ /* MAILTMPLEN = sizeof(ng_ref) */ snprintf(ng_ref, sizeof(ng_ref), "{%.*s/nntp}#news.%.*s", - sizeof(ng_ref)/2 - 10, *server, - sizeof(ng_ref)/2 - 10, ntmp->groupname); + MAILTMPLEN/2 - 10, *server, + MAILTMPLEN/2 - 10, ntmp->groupname); ps_global->noshow_error = 1; stream = pine_mail_open(stream, ng_ref, OP_SILENT|SP_USEPOOL|SP_TEMPUSE, diff --git a/pith/pine.hlp b/pith/pine.hlp index ee0a1bd..08b1378 100644 --- a/pith/pine.hlp +++ b/pith/pine.hlp @@ -140,7 +140,7 @@ with help text for the config screen and the composer that didn't have any reasonable place to be called from. Dummy change to get revision in pine.hlp ============= h_revision ================= -Alpine Commit 84 2015-07-26 14:15:47 +Alpine Commit 85 2015-07-26 23:36:26 ============= h_news ================= diff --git a/pith/reply.c b/pith/reply.c index 834b945..0ab8dfe 100644 --- a/pith/reply.c +++ b/pith/reply.c @@ -769,17 +769,17 @@ reply_subject(char *subject, char *buf, size_t buflen) && (decoded[1] == 'E' || decoded[1] == 'e')){ if(decoded[2] == ':') - snprintf(buf, buflen, "%.*s", buflen-1, subject); + snprintf(buf, buflen, "%.*s", (int)(buflen-1), subject); else if((decoded[2] == '[') && (p = strchr(decoded, ']'))){ p++; while(*p && isspace((unsigned char)*p)) p++; if(p[0] == ':') - snprintf(buf, buflen, "%.*s", buflen-1, subject); + snprintf(buf, buflen, "%.*s", (int)(buflen-1), subject); } } if(!buf[0]) - snprintf(buf, buflen, "Re: %.*s", buflen-1, + snprintf(buf, buflen, "Re: %.*s", (int)(buflen-1), (subject && *subject) ? subject : "your mail"); buf[buflen-1] = '\0'; @@ -937,14 +937,15 @@ reply_body(MAILSTREAM *stream, ENVELOPE *env, struct mail_bodystruct *orig_body, long int msgno, char *sect_prefix, void *msgtext, char *prefix, int plustext, ACTION_S *role, int toplevel, REDRAFT_POS_S **redraft_pos) { - char *p, *sig = NULL, *section, sect_buf[256]; +#define SECTBUFLEN 256 + char *p, *sig = NULL, *section, sect_buf[SECTBUFLEN]; BODY *body = NULL, *tmp_body = NULL; PART *part; gf_io_t pc; int impl, template_len = 0, leave_cursor_at_top = 0, reply_raw_body = 0; - if(sect_prefix) - snprintf(section = sect_buf, sizeof(sect_buf), "%.*s.1", sizeof(sect_buf)-1, sect_prefix); + if(sect_prefix) /* SECTBUFLEN = sizeof(sect_buf) */ + snprintf(section = sect_buf, sizeof(sect_buf), "%.*s.1", SECTBUFLEN-1, sect_prefix); else section = "1"; @@ -1152,12 +1153,12 @@ reply_body(MAILSTREAM *stream, ENVELOPE *env, struct mail_bodystruct *orig_body, if(F_ON(F_INCLUDE_HEADER, ps_global)) reply_forward_header(stream, msgno, sect_prefix, env, pc, prefix); - + /* SECTBUFLEN = sizeof(sect_buf) */ snprintf(sect_buf, sizeof(sect_buf), "%.*s%s%.*s", - sizeof(sect_buf)/2-2, + SECTBUFLEN/2-2, sect_prefix ? sect_prefix : "", sect_prefix ? "." : "", - sizeof(sect_buf)/2-2, + SECTBUFLEN/2-2, p = partno(orig_body, tmp_body)); sect_buf[sizeof(sect_buf)-1] = '\0'; fs_give((void **) &p); @@ -1173,10 +1174,10 @@ reply_body(MAILSTREAM *stream, ENVELOPE *env, struct mail_bodystruct *orig_body, body->nested.part->body.subtype = cpystr("Plain"); body->nested.part->body.contents.text.data = msgtext; body->nested.part->next = part; - + /* SECTBUFLEN = sizeof(sect_buf) */ for(partnum = 2; part != NULL; part = part->next){ snprintf(sect_buf, sizeof(sect_buf), "%.*s%s%d", - sizeof(sect_buf)/2, + SECTBUFLEN/2, sect_prefix ? sect_prefix : "", sect_prefix ? "." : "", partnum++); sect_buf[sizeof(sect_buf)-1] = '\0'; @@ -2919,18 +2920,19 @@ body_partno(MAILSTREAM *stream, long int msgno, struct mail_bodystruct *end_body char * partno(struct mail_bodystruct *body, struct mail_bodystruct *end_body) { +#define PARTTMPLEN 64 PART *part; int num = 0; - char tmp[64], *p = NULL; + char tmp[PARTTMPLEN], *p = NULL; if(body && body->type == TYPEMULTIPART) { part = body->nested.part; /* first body part */ do { /* for each part */ - num++; + num++; /* PARTTMPLEN = sizeof(tmp) */ if(&part->body == end_body || (p = partno(&part->body, end_body))){ snprintf(tmp, sizeof(tmp), "%d%s%.*s", num, (p) ? "." : "", - sizeof(tmp)-10, (p) ? p : ""); + PARTTMPLEN-10, (p) ? p : ""); tmp[sizeof(tmp)-1] = '\0'; if(p) fs_give((void **)&p); @@ -3593,9 +3595,10 @@ BODY * forward_multi_alt(MAILSTREAM *stream, ENVELOPE *env, struct mail_bodystruct *orig_body, long int msgno, char *sect_prefix, void *msgtext, gf_io_t pc, int flags) { +#define FWDTMPLEN 256 BODY *body = NULL; PART *part = NULL, *bestpart = NULL; - char tmp_buf[256]; + char tmp_buf[FWDTMPLEN]; char *new_charset = NULL; int partnum, bestpartnum; @@ -3650,9 +3653,9 @@ forward_multi_alt(MAILSTREAM *stream, ENVELOPE *env, struct mail_bodystruct *ori forward_delimiter(pc); reply_forward_header(stream, msgno, sect_prefix, env, pc, ""); } - + /* FWDTMPLEN = sizeof(tmp_buf) */ snprintf(tmp_buf, sizeof(tmp_buf), "%.*s%s%s%d", - sizeof(tmp_buf)/2, sect_prefix ? sect_prefix : "", + FWDTMPLEN/2, sect_prefix ? sect_prefix : "", sect_prefix ? "." : "", flags & FWD_NESTED ? "1." : "", partnum); tmp_buf[sizeof(tmp_buf)-1] = '\0'; diff --git a/pith/save.c b/pith/save.c index 46a4d66..67f080a 100644 --- a/pith/save.c +++ b/pith/save.c @@ -1466,15 +1466,16 @@ save_ex_output_body(MAILSTREAM *stream, long int raw, char *section, return(save_ex_replace_body(txtp, len, body, pc)); if(body->type == TYPEMULTIPART){ - char *subsect, boundary[128]; +#define BOUNDARYLEN 128 + char *subsect, boundary[BOUNDARYLEN]; int n, blen; PART *part = body->nested.part; PARAMETER *param; /* Locate supplied multipart boundary */ for (param = body->parameter; param; param = param->next) - if (!strucmp(param->attribute, "boundary")){ - snprintf(boundary, sizeof(boundary), "--%.*s\015\012", sizeof(boundary)-10, + if (!strucmp(param->attribute, "boundary")){ /* BOUNDARYLEN == sizeof(boundary) */ + snprintf(boundary, sizeof(boundary), "--%.*s\015\012", BOUNDARYLEN-10, param->value); blen = strlen(boundary); break; @@ -1516,8 +1517,8 @@ save_ex_output_body(MAILSTREAM *stream, long int raw, char *section, return(0); } while ((part = part->next) != NULL); /* until done */ - - snprintf(boundary, sizeof(boundary), "--%.*s--\015\012", sizeof(boundary)-10,param->value); + /* BOUNDARYLEN = sizeof(boundary) */ + snprintf(boundary, sizeof(boundary), "--%.*s--\015\012", BOUNDARYLEN-10,param->value); *len += blen + 2; return(gf_puts(boundary, pc)); } @@ -1618,10 +1619,10 @@ save_ex_explain_parts(struct mail_bodystruct *body, int depth, long unsigned int PART *part = body->nested.part; /* first body part */ *len = 0; - if(body->description && *body->description){ + if(body->description && *body->description){ /* MAILTMPLEN = sizeof(tmp) */ snprintf(tmp, sizeof(tmp), "%*.*sA %s/%.*s%.10s%.100s%.10s segment described", depth, depth, " ", body_type_names(body->type), - sizeof(tmp)-300, body->subtype ? body->subtype : "Unknown", + MAILTMPLEN-300, body->subtype ? body->subtype : "Unknown", name ? " (Name=\"" : "", name ? name : "", name ? "\")" : ""); @@ -1633,11 +1634,11 @@ save_ex_explain_parts(struct mail_bodystruct *body, int depth, long unsigned int (char *) rfc1522_decode_to_utf8((unsigned char *)tmp_20k_buf, SIZEOF_20KBUF, buftmp)); } - else{ + else{ /* MAILTMPLEN = sizeof(tmp) */ snprintf(tmp, sizeof(tmp), "%*.*sA %s/%.*s%.10s%.100s%.10s segment containing:", depth, depth, " ", body_type_names(body->type), - sizeof(tmp)-300, body->subtype ? body->subtype : "Unknown", + MAILTMPLEN-300, body->subtype ? body->subtype : "Unknown", name ? " (Name=\"" : "", name ? name : "", name ? "\")" : ""); @@ -1656,11 +1657,11 @@ save_ex_explain_parts(struct mail_bodystruct *body, int depth, long unsigned int return(0); while ((part = part->next) != NULL); /* until done */ } - else{ + else{ /* MAILTMPLEN = sizeof(tmp) */ snprintf(tmp, sizeof(tmp), "%*.*sA %s/%.*s%.10s%.100s%.10s segment of about %s bytes%s", depth, depth, " ", body_type_names(body->type), - sizeof(tmp)-300, body->subtype ? body->subtype : "Unknown", + MAILTMPLEN-300, body->subtype ? body->subtype : "Unknown", name ? " (Name=\"" : "", name ? name : "", name ? "\")" : "", @@ -1671,10 +1672,10 @@ save_ex_explain_parts(struct mail_bodystruct *body, int depth, long unsigned int if(!save_ex_output_line(tmp, len, pc)) return(0); - if(body->description && *body->description){ + if(body->description && *body->description){ /* MAILTMPLEN = sizeof(tmp) */ snprintf(buftmp, sizeof(buftmp), "%.75s", body->description); snprintf(tmp, sizeof(tmp), "%*.*s described as \"%.*s\"", depth, depth, " ", - sizeof(tmp)-100, + MAILTMPLEN-100, (char *) rfc1522_decode_to_utf8((unsigned char *)tmp_20k_buf, SIZEOF_20KBUF, buftmp)); if(save_ex_output_line(tmp, &ilen, pc)) diff --git a/pith/send.c b/pith/send.c index 1ba6266..017265c 100644 --- a/pith/send.c +++ b/pith/send.c @@ -5490,10 +5490,11 @@ smtp_command(char *errbuf, size_t errbuflen) errbuf[errbuflen-1] = '\0'; #else /* UNIX */ # if defined(SENDMAIL) && defined(SENDMAILFLAGS) - char tmp[256]; - - snprintf(tmp, sizeof(tmp), "%.*s %.*s", (sizeof(tmp)-3)/2, SENDMAIL, - (sizeof(tmp)-3)/2, SENDMAILFLAGS); +#define SENDTMPLEN 256 + char tmp[SENDTMPLEN]; + /* SENDTMPLEN == sizeof(tmp) */ + snprintf(tmp, sizeof(tmp), "%.*s %.*s", (SENDTMPLEN-3)/2, SENDMAIL, + (SENDTMPLEN-3)/2, SENDMAILFLAGS); return(cpystr(tmp)); # else strncpy(errbuf, _("No default posting command."), errbuflen); @@ -5750,9 +5751,9 @@ piped_smtp_open (char *host, char *service, long unsigned int port) if(strucmp(host, "localhost")){ char tmp[MAILTMPLEN]; - + /* MAILTMPLEN = sizeof(tmp) */ snprintf(tmp, sizeof(tmp), _("Unexpected hostname for piped SMTP: %.*s"), - sizeof(tmp)-50, host); + MAILTMPLEN-50, host); tmp[sizeof(tmp)-1] = '\0'; mm_log(tmp, ERROR); } diff --git a/pith/stream.c b/pith/stream.c index 5cce21c..3c4923b 100644 --- a/pith/stream.c +++ b/pith/stream.c @@ -1909,9 +1909,9 @@ mail_list_internal(MAILSTREAM *s, char *r, char *p) && ((s && s->mailbox && *s->mailbox == '{') || (!s && ((r && *r == '{') || (p && *p == '{'))))){ char tmp[2*MAILTMPLEN]; - - snprintf(tmp, sizeof(tmp), "%.*s%.*s", sizeof(tmp)/2-1, r ? r : "", - sizeof(tmp)/2-1, p); + /* MAILTMPLEN = sizeof(tmp)/2 */ + snprintf(tmp, sizeof(tmp), "%.*s%.*s", MAILTMPLEN-1, r ? r : "", + MAILTMPLEN-1, p); mail_list(s, "", tmp); } else diff --git a/web/src/alpined.d/alpined.c b/web/src/alpined.d/alpined.c index 6936de9..c2e43fc 100644 --- a/web/src/alpined.d/alpined.c +++ b/web/src/alpined.d/alpined.c @@ -7682,6 +7682,7 @@ int PEThreadCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { char *err, errbuf[256], *cmd, *op; + long uidl; imapuid_t uid; dprint((2, "PEThreadCmd")); @@ -7696,14 +7697,15 @@ PEThreadCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST else if(objc < 2){ Tcl_WrongNumArgs(interp, 1, objv, "uid cmd ?args?"); } - else if(Tcl_GetLongFromObj(interp, objv[1], &uid) != TCL_OK){ + else if(Tcl_GetLongFromObj(interp, objv[1], &uidl) != TCL_OK){ return(TCL_ERROR); /* conversion problem? */ } - else if(!peSequenceNumber(uid)){ + else if(!peSequenceNumber(uidl)){ snprintf(err = errbuf, sizeof(errbuf), "%s: UID %ld doesn't exist", - Tcl_GetStringFromObj(objv[0], NULL), uid); + Tcl_GetStringFromObj(objv[0], NULL), uidl); } else if((cmd = Tcl_GetStringFromObj(objv[2], NULL)) != NULL){ + uid = uidl; if(objc == 3){ if(!strucmp(cmd,"info")){ #define WP_MAX_THRD_PREFIX 256 @@ -7846,6 +7848,7 @@ PEMessageCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST { char *err, errbuf[256], *cmd; int i, j; + long uidl; imapuid_t uid; dprint((5, "PEMessageCmd")); @@ -7860,14 +7863,15 @@ PEMessageCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST else if(objc < 3){ Tcl_WrongNumArgs(interp, 0, objv, "PEMessage cmd ?args?"); } - else if(Tcl_GetLongFromObj(interp, objv[1], &uid) != TCL_OK){ + else if(Tcl_GetLongFromObj(interp, objv[1], &uidl) != TCL_OK){ return(TCL_ERROR); /* conversion problem? */ } - else if(!peMessageNumber(uid)){ + else if(!peMessageNumber(uidl)){ snprintf(err = errbuf, sizeof(errbuf), "%s: UID %ld doesn't exist", - Tcl_GetStringFromObj(objv[0], NULL), uid); + Tcl_GetStringFromObj(objv[0], NULL), uidl); } else if((cmd = Tcl_GetStringFromObj(objv[2], NULL)) != NULL){ + uid = uidl; for(i = 0; message_cmds[i].cmd; i++) if(!strcmp(cmd, message_cmds[i].cmd)){ for(j = 0; j < message_cmds[i].hcount; j++) @@ -9632,7 +9636,7 @@ peReplyHeaders(Tcl_Interp *interp, imapuid_t uid, int objc, Tcl_Obj **objv) if(!err && ps_global->mail_stream->uid_validity){ char *prefix = reply_quote_str(env); - snprintf(tmp_20k_buf, SIZEOF_20KBUF, "(%d %s)(1 %lu %lu)%s", + snprintf(tmp_20k_buf, SIZEOF_20KBUF, "(%lu %s)(1 %lu %lu)%s", strlen(prefix), prefix, ps_global->mail_stream->uid_validity, uid, ps_global->mail_stream->mailbox); @@ -11832,6 +11836,7 @@ int PEPostponeCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { char *err = "PEPostpone: unknown request"; + long uidl; imapuid_t uid; dprint((2, "PEPostponeCmd")); @@ -11848,7 +11853,7 @@ PEPostponeCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONS if(s1){ if(!strcmp(s1, "extract")){ - if(Tcl_GetLongFromObj(interp, objv[2], &uid) == TCL_OK){ + if(Tcl_GetLongFromObj(interp, objv[2], &uidl) == TCL_OK){ Tcl_Obj *objHdr = NULL, *objBod = NULL, *objAttach = NULL, *objOpts = NULL; MAILSTREAM *stream; BODY *b; @@ -11862,6 +11867,7 @@ PEPostponeCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONS char *fcc = NULL, *lcc = NULL; unsigned flags = REDRAFT_DEL | REDRAFT_PPND; + uid = uidl; if(objc > 3){ /* optional flags */ int i, nFlags; Tcl_Obj **objFlags; @@ -12121,10 +12127,11 @@ PEPostponeCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONS return(rv); } else if(!strcmp(s1, "delete")){ - if(Tcl_GetLongFromObj(interp, objv[2], &uid) == TCL_OK){ + if(Tcl_GetLongFromObj(interp, objv[2], &uidl) == TCL_OK){ MAILSTREAM *stream; long rawno; + uid = uidl; if(postponed_stream(&stream, ps_global->VAR_POSTPONED_FOLDER, "Postponed", 0) && stream){ if((rawno = mail_msgno(stream, uid)) > 0L){ mail_flag(stream, long2string(rawno), "\\DELETED", ST_SET); @@ -13325,7 +13332,7 @@ PEAddressCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST l = strlen(newaddr) + strlen(tres->str) + 2 + (tstr2 ? strlen(tstr2) : 0); newnewaddr = (char *) fs_get(l * sizeof(char)); - snprintf(newnewaddr, l, "%.*s%s%s", tstr1 - newaddr, + snprintf(newnewaddr, l, "%.*s%s%s", (int) (tstr1 - newaddr), newaddr, tres->str, tstr2 ? tstr2 : ""); fs_give((void **)&newaddr); newaddr = newnewaddr; diff --git a/web/src/alpined.d/wpcomm.c b/web/src/alpined.d/wpcomm.c index b9f1707..a115a8c 100644 --- a/web/src/alpined.d/wpcomm.c +++ b/web/src/alpined.d/wpcomm.c @@ -76,7 +76,7 @@ WPSendCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST ob if(objc == 3 && (fname = Tcl_GetStringFromObj(objv[1], NULL)) - && (cmd = Tcl_GetByteArrayFromObj(objv[2], &wlen))){ + && (cmd = (char *) Tcl_GetByteArrayFromObj(objv[2], &wlen))){ if((s = socket(AF_UNIX, SOCK_STREAM, 0)) == -1){ snprintf(errbuf = buf, sizeof(buf), "WPC: socket: %s", strerror(errno)); } -- 2.11.4.GIT