From b5eb45a153202d72aeb48de1149e7c74aef979fd Mon Sep 17 00:00:00 2001 From: Eduardo Chappa Date: Sat, 8 May 2021 21:01:02 -0600 Subject: * Clear out some gcc warnings, and code improvement. Work in progress. --- alpine/adrbkcmd.c | 7 ++++--- alpine/alpine.c | 2 +- alpine/folder.c | 2 +- alpine/imap.c | 5 +++-- alpine/mailcmd.c | 18 +++++++++--------- alpine/mailindx.c | 8 +++++--- alpine/mailview.c | 6 ++++-- alpine/osdep/debuging.c | 2 +- alpine/osdep/fltrname.c | 2 +- alpine/remote.c | 6 +++--- alpine/reply.c | 6 +++--- alpine/roleconf.c | 13 +++++++------ alpine/send.c | 13 +++++++------ imap/src/c-client/auth_bea.c | 7 +++++-- imap/src/c-client/auth_gss.c | 6 +++--- imap/src/c-client/auth_oa2.c | 7 +++++-- imap/src/c-client/oauth2_aux.c | 5 +++++ pico/browse.c | 22 +++++++++++----------- pico/display.c | 6 +++--- pico/osdep/color.c | 2 +- pico/random.c | 4 ++-- pico/search.c | 2 +- pith/mailcmd.c | 17 ++++++++--------- pith/osdep/pipe.c | 5 +++-- pith/reply.c | 4 ++-- pith/smime.c | 14 ++++++++------ pith/string.c | 4 ++-- 27 files changed, 108 insertions(+), 87 deletions(-) diff --git a/alpine/adrbkcmd.c b/alpine/adrbkcmd.c index c22ca31..94d9077 100644 --- a/alpine/adrbkcmd.c +++ b/alpine/adrbkcmd.c @@ -2185,11 +2185,12 @@ convert_abook_to_remote(struct pine *ps, PerAddrBook *pab, char *rem_folder_pref if(*rem_abook){ file = cpystr(rem_abook); if(pab->abnick){ - nick = (char *)fs_get((MAX(strlen(pab->abnick),strlen("Address Book"))+8) * sizeof(char)); - snprintf(nick, sizeof(nick), "Remote %s", + int len = MAX(strlen(pab->abnick),strlen("Address Book"))+8; + nick = (char *)fs_get(len * sizeof(char)); + snprintf(nick, len, "Remote %s", (pab->abnick && !strcmp(pab->abnick, DF_ADDRESSBOOK)) ? "Address Book" : pab->abnick); - nick[sizeof(nick)-1] = '\0'; + nick[len-1] = '\0'; } else nick = cpystr("Remote Address Book"); diff --git a/alpine/alpine.c b/alpine/alpine.c index c2b7b37..cb75260 100644 --- a/alpine/alpine.c +++ b/alpine/alpine.c @@ -1098,7 +1098,7 @@ main(int argc, char **argv) args.data.mail.attachlist) && pine_state->next_screen)) free_attachment_list(&args.data.mail.attachlist); - goodnight_gracey(pine_state, 0); + goodnight_gracey(pine_state, 0); } else { q_status_message(SM_ORDER | SM_DING, 3, 4, diff --git a/alpine/folder.c b/alpine/folder.c index 94a27b7..c39b80a 100644 --- a/alpine/folder.c +++ b/alpine/folder.c @@ -3571,7 +3571,7 @@ char * folder_lister_fullname(FSTATE_S *fs, char *name) { if(fs->context->dir->status & CNTXT_SUBDIR){ - char tmp[2*MAILTMPLEN], tmp2[2*MAILTMPLEN], *p; + char tmp[2*MAILTMPLEN+1], tmp2[2*MAILTMPLEN+1], *p; if(fs->context->dir->ref){ snprintf(tmp, sizeof(tmp), "%.*s%.*s", diff --git a/alpine/imap.c b/alpine/imap.c index 91f87b1..e1abfd8 100644 --- a/alpine/imap.c +++ b/alpine/imap.c @@ -165,7 +165,7 @@ OAUTH2_S * oauth2_select_flow(char *host) { OAUTH2_S *oa2list, *oa2; - int i, rv; + int i = 0, rv; char *method; if(ps_global->ttyo){ @@ -474,7 +474,7 @@ char * oauth2_get_access_code(unsigned char *url, char *method, OAUTH2_S *oauth2, int *tryanother) { char tmp[MAILTMPLEN]; - char *code; + char *code = NULL; if(ps_global->ttyo){ SCROLL_S sargs; @@ -3775,6 +3775,7 @@ write_passfile(pinerc, l) fclose(fp); #ifdef SMIME if(text != NULL){ + i = 0; /* to quell gcc */ if(ps_global->pwdcert == NULL){ q_status_message(SM_ORDER, 3, 3, "Attempting to encrypt password file"); i = setup_pwdcert(&ps_global->pwdcert); diff --git a/alpine/mailcmd.c b/alpine/mailcmd.c index 905ddb1..6285e6e 100644 --- a/alpine/mailcmd.c +++ b/alpine/mailcmd.c @@ -662,6 +662,8 @@ view_text: thrd = fetch_thread(stream, mn_m2raw(msgmap, new_msgno)); if(thrd && thrd->top) topthrd = fetch_thread(stream, thrd->top); + else + topthrd = NULL; if(topthrd) j = count_lflags_in_thread(stream, topthrd, msgmap, MN_NONE); @@ -1340,7 +1342,7 @@ get_out: if(del_count > 0L){ 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), MAX_SCREEN_COLS+1-40, + plural(del_count), MAX_SCREEN_COLS+1-45, pretty_fn(state->cur_folder)); prompt[sizeof(prompt)-1] = '\0'; if(F_ON(F_FULL_AUTO_EXPUNGE, state) @@ -1718,6 +1720,7 @@ cmd_flag(struct pine *state, MSGNO_S *msgmap, int aopt) char *keyword_array[2]; int user_defined_flags = 0, mailbox_flags = 0; int directly_to_maint_screen = 0; + int use_maint_screen = F_ON(F_FLAG_SCREEN_DFLT, ps_global); long unflagged, flagged, flags, rawno; MESSAGECACHE *mc = NULL; KEYWORD_S *kw; @@ -1949,11 +1952,8 @@ go_again: else #endif { - int use_maint_screen; int keyword_shortcut = 0; - use_maint_screen = F_ON(F_FLAG_SCREEN_DFLT, ps_global); - if(!use_maint_screen){ /* * We're going to call cmd_flag_prompt(). We need @@ -2761,7 +2761,7 @@ save_prompt(struct pine *state, CONTEXT_S **cntxt, char *nfldr, size_t len_nfldr SaveDel *dela, SavePreserveOrder *prea) { int rc, ku = -1, n, flags, last_rc = 0, saveable_count = 0, done = 0; - int delindex, preindex, r; + int delindex = 0, preindex = 0, r; char prompt[6*MAX_SCREEN_COLS+1], *p, expanded[MAILTMPLEN]; char *buf = tmp_20k_buf; char shortbuf[200]; @@ -3255,7 +3255,7 @@ create_for_save_prompt(CONTEXT_S *context, char *folder, int sequence_sensitive) int cmd_expunge(struct pine *state, MAILSTREAM *stream, MSGNO_S *msgmap, int agg) { - long del_count, prefilter_del_count; + long del_count, prefilter_del_count = 0; int we_cancel = 0, rv = 0; char prompt[MAX_SCREEN_COLS+1]; char *sequence; @@ -3587,12 +3587,12 @@ cmd_export(struct pine *state, MSGNO_S *msgmap, int qline, int aopt) { char filename[MAXPATH+1], full_filename[MAXPATH+1], *err; char nmsgs[80]; - int r, leading_nl, failure = 0, orig_errno, rflags = GER_NONE; + int r, leading_nl, failure = 0, orig_errno = 0, rflags = GER_NONE; int flags = GE_IS_EXPORT | GE_SEQ_SENSITIVE, rv = 0; ENVELOPE *env; MESSAGECACHE *mc; BODY *b; - long i, count = 0L, start_of_append, rawno; + long i, count = 0L, start_of_append = 0, rawno; gf_io_t pc; STORE_S *store; struct variable *vars = state ? ps_global->vars : NULL; @@ -8266,7 +8266,7 @@ select_by_gm_content(MAILSTREAM *stream, MSGNO_S *msgmap, long int msgno, SEARCH int select_by_text(MAILSTREAM *stream, MSGNO_S *msgmap, long int msgno, SEARCHSET **limitsrch) { - int r, ku, type, we_cancel = 0, flags, rv, ekeyi = 0; + int r = '\0', ku, type, we_cancel = 0, flags, rv, ekeyi = 0; int not = 0, me = 0; char sstring[80], tmp[128]; char *p, *sval = NULL; diff --git a/alpine/mailindx.c b/alpine/mailindx.c index 63f9277..1dbb1b4 100644 --- a/alpine/mailindx.c +++ b/alpine/mailindx.c @@ -319,7 +319,7 @@ index_lister(struct pine *state, CONTEXT_S *cntxt, char *folder, MAILSTREAM *str { UCS ch; int cmd, which_keys, force, - cur_row, cur_col, km_popped, paint_status; + cur_row, cur_col = 0, km_popped, paint_status = 0; static int old_day = -1; long i, j, k, old_max_msgno; long lflagged, old_lflagged = 0L; @@ -804,6 +804,8 @@ view_a_thread: thrd = fetch_thread(stream, i); if(thrd && thrd->top) topthrd = fetch_thread(stream, thrd->top); + else + topthrd = NULL; if(topthrd){ set_thread_lflags(stream, topthrd, msgmap, MN_CHID, 1); set_thread_lflags(stream, topthrd, msgmap, MN_CHID2, 0); @@ -833,7 +835,7 @@ view_a_thread: case MC_MOUSE: { MOUSEPRESS mp; - int new_cur; + int new_cur = 0; mouse_get_last (NULL, &mp); mp.row -= 2; @@ -2429,7 +2431,7 @@ int index_scroll_to_pos (long int pos) { static short bad_timing = 0; - long i, j, k; + long i, j, k = 0; if(bad_timing) return (FALSE); diff --git a/alpine/mailview.c b/alpine/mailview.c index 1265b05..11ca4af 100644 --- a/alpine/mailview.c +++ b/alpine/mailview.c @@ -232,7 +232,7 @@ mail_view_screen(struct pine *ps) int we_cancel = 0, flags, cmd = 0; int force_prefer = 0; MESSAGECACHE *mc; - ENVELOPE *env; + ENVELOPE *env = NULL; BODY *body; STORE_S *store; HANDLE_S *handles = NULL; @@ -5023,14 +5023,16 @@ visible_linelen(int line) switch((i < st->line_lengths[line]) ? st->text_lines[line][i] : 0){ case TAG_HANDLE: i++; + n = 0; /* quell gcc */ /* skip the length byte plus more bytes */ if(i < st->line_lengths[line]){ n = st->text_lines[line][i]; i++; } - if(i < st->line_lengths[line] && n > 0) + if(i < st->line_lengths[line] && n > 0){ i += n; + } break; diff --git a/alpine/osdep/debuging.c b/alpine/osdep/debuging.c index 015d38d..2ff0d7d 100644 --- a/alpine/osdep/debuging.c +++ b/alpine/osdep/debuging.c @@ -186,7 +186,7 @@ init_debug(void) void save_debug_on_crash(FILE *dfile, int (*keystrokes) (int *, char *, size_t)) { - char nbuf[5], crashfile[MAXPATH+1], filename[MAXPATH+1]; + char nbuf[11], crashfile[MAXPATH+1], filename[MAXPATH+1]; int i; struct stat dbuf, tbuf; time_t now = time((time_t *)0); diff --git a/alpine/osdep/fltrname.c b/alpine/osdep/fltrname.c index cd17266..7af381e 100644 --- a/alpine/osdep/fltrname.c +++ b/alpine/osdep/fltrname.c @@ -92,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, ERRORLEN-50, ill_file); + ill_char, ERRORLEN-57, ill_file); } else { snprintf(error, sizeof(error), "First character, \"%s\", not allowed in file name", diff --git a/alpine/remote.c b/alpine/remote.c index 7d83b3e..eaa2d58 100644 --- a/alpine/remote.c +++ b/alpine/remote.c @@ -39,7 +39,7 @@ int rd_answer_forge_warning(int, MSGNO_S *, SCROLL_S *); int rd_prompt_about_forged_remote_data(int reason, REMDATA_S *rd, char *extra) { - char tmp[2000]; + char *p, tmp[2000]; char *unknown = ""; int rv = -1; char *foldertype, *foldername, *special; @@ -47,6 +47,8 @@ rd_prompt_about_forged_remote_data(int reason, REMDATA_S *rd, char *extra) foldertype = (rd && rd->t.i.special_hdr && !strucmp(rd->t.i.special_hdr, REMOTE_ABOOK_SUBTYPE)) ? "address book" : (rd && rd->t.i.special_hdr && !strucmp(rd->t.i.special_hdr, REMOTE_PINERC_SUBTYPE)) ? "configuration" : "data"; foldername = (rd && rd->rn) ? rd->rn : unknown; special = (rd && rd->t.i.special_hdr) ? rd->t.i.special_hdr : unknown; + tmp[0] = '\0'; + p = tmp; dprint((1, "rd_check_out_forged_remote_data:\n")); dprint((1, " reason=%d\n", reason)); @@ -177,8 +179,6 @@ rd_prompt_about_forged_remote_data(int reason, REMDATA_S *rd, char *extra) free_handles(&handles); } else{ - char *p = tmp; - snprintf(p, sizeof(tmp), _("\nThe data in the remote %s folder\n\n %s\n\nlooks suspicious. The reason for the suspicion is\n\n "), foldertype, foldername); tmp[sizeof(tmp)-1] = '\0'; diff --git a/alpine/reply.c b/alpine/reply.c index 35331f4..42f5131 100644 --- a/alpine/reply.c +++ b/alpine/reply.c @@ -101,7 +101,7 @@ reply(struct pine *pine_state, ACTION_S *role_arg) { ADDRESS *saved_from, *saved_to, *saved_cc, *saved_resent; ADDRESS *us_in_to_and_cc, *ap; - ENVELOPE *env, *outgoing; + ENVELOPE *env = NULL, *outgoing; BODY *body, *orig_body = NULL; REPLY_S reply; void *msgtext = NULL; @@ -1497,8 +1497,8 @@ forward(struct pine *ps, ACTION_S *role_arg) { char *sig; int ret, forward_raw_body = 0, rv = 0, i; - long msgno, j, totalmsgs, rflags; - ENVELOPE *env, *outgoing; + long msgno = 0L, j, totalmsgs, rflags; + ENVELOPE *env = NULL, *outgoing; BODY *orig_body, *body = NULL; REPLY_S reply; void *msgtext = NULL; diff --git a/alpine/roleconf.c b/alpine/roleconf.c index eed2dd4..0ee3ec8 100644 --- a/alpine/roleconf.c +++ b/alpine/roleconf.c @@ -1162,7 +1162,7 @@ role_config_add(struct pine *ps, CONF_S **cl, long int rflags) { int rv = 0, first_pat = 0; PAT_S *new_pat = NULL, *cur_pat; - PAT_LINE_S *new_patline, *cur_patline; + PAT_LINE_S *new_patline = NULL, *cur_patline; PAT_STATE pstate; char title[80]; @@ -1290,7 +1290,7 @@ role_config_replicate(struct pine *ps, CONF_S **cl, long int rflags) { int rv = 0, first_pat = 0; PAT_S *new_pat = NULL, *cur_pat, *defpat = NULL; - PAT_LINE_S *new_patline, *cur_patline; + PAT_LINE_S *new_patline = NULL, *cur_patline; PAT_STATE pstate; char title[80]; @@ -1881,7 +1881,7 @@ role_config_addfile(struct pine *ps, CONF_S **cl, long int rflags) char dir2[MAXPATH+1], pdir[MAXPATH+1]; char *lc, *newfile = NULL; PAT_LINE_S *file_patline; - int rv = 0, len; + int rv = 0, len = 0; int r = 1, flags; HelpType help = NO_HELP; PAT_TYPE curtype; @@ -5511,11 +5511,12 @@ role_config_edit_screen(struct pine *ps, PAT_S *def, char *title, long int rflag (*result)->patgrp->folder = editlist_to_pattern(folder_pat); if(abook_type_pat && *abook_type_pat){ - for(j = 0; (f = inabook_fldr_types(j)); j++) + for(j = 0; (f = inabook_fldr_types(j)); j++){ if(!strucmp(abook_type_pat, f->name)){ (*result)->patgrp->inabook = f->value; break; } + } if(bitnset(INABOOK_FROM, inabook_type_list)) (*result)->patgrp->inabook |= IAB_FROM; @@ -6183,7 +6184,7 @@ calculate_inick_stuff(struct pine *ps) if(v && !v->global_val.p){ char *str, *astr, *lc, pdir[MAXPATH+1]; ADDRESS *addr; - int len; + int len = 0; switch(i){ case INICK_FROM_CONF: @@ -7120,7 +7121,7 @@ int role_text_tool(struct pine *ps, int cmd, CONF_S **cl, unsigned int flags) { OPT_SCREEN_S *saved_screen; - int rv = -1, oeflags, len, sig, r, i, cancel = 0; + int rv = -1, oeflags, len = 0, sig, r, i, cancel = 0; char *file, *err, title[20], *newfile, *lc, *addr, *fldr = NULL, *tmpfldr; char dir2[MAXPATH+1], pdir[MAXPATH+1], *p; char full_filename[MAXPATH+1], filename[MAXPATH+1]; diff --git a/alpine/send.c b/alpine/send.c index 79b6f29..6209d64 100644 --- a/alpine/send.c +++ b/alpine/send.c @@ -1047,7 +1047,7 @@ pine_simple_send(ENVELOPE *outgoing, /* envelope for outgoing message */ char **tobufp, *p, tmp[MAILTMPLEN]; void *messagebuf; int done = 0, retval = 0, x; - int lastrc, rc = 0, ku, i, resize_len, result, fcc_result; + int lastrc, rc = 0, ku, i, resize_len, result, fcc_result = 0; int og2s_done = 0; HelpType help; static HISTORY_S *history = NULL; @@ -1821,12 +1821,12 @@ pine_send(ENVELOPE *outgoing, struct mail_bodystruct **body, char *start_here_name = NULL; char *suggested_nntp_server = NULL; char *title = NULL; - struct headerentry *he, *headents, *he_to, *he_fcc, *he_news = NULL, *he_lcc = NULL, + struct headerentry *he, *headents, *he_to = NULL, *he_fcc = NULL, *he_news = NULL, *he_lcc = NULL, *he_from = NULL; PINEFIELD *pfields, *pf, *pf_nobody = NULL, *pf_to = NULL, - *pf_smtp_server, *pf_nntp_server, - *pf_fcc = NULL, *pf_err, *pf_uid, *pf_mbox, *pf_curpos, - *pf_ourrep, *pf_ourhdrs, **sending_order; + *pf_smtp_server = NULL, *pf_nntp_server = NULL, + *pf_fcc = NULL, *pf_err = NULL, *pf_uid = NULL, *pf_mbox = NULL, *pf_curpos = NULL, + *pf_ourrep = NULL, *pf_ourhdrs = NULL, **sending_order; METAENV header; ADDRESS *lcc_addr = NULL; ADDRESS *nobody_addr = NULL; @@ -3202,6 +3202,7 @@ pine_send(ENVELOPE *outgoing, struct mail_bodystruct **body, * In the Postpone case, just create it if the user wants to * and create a temporary storage object to write into. */ fake_hup: + fcc_result = 0; lmc.all_written = lmc.text_only = lmc.text_written = 0; if(editor_result & (COMP_GOTHUP | COMP_CANCEL)){ int newfile = 1; @@ -5285,7 +5286,7 @@ filter_message_text(char *fcmd, ENVELOPE *outgoing, struct mail_bodystruct *body ? &body->nested.part->body.contents.text.data : &body->contents.text.data), *tmp_so = NULL, *tmpf_so, - *save_local_so, *readthis_so, *our_tmpf_so = NULL; + *save_local_so, *readthis_so = NULL, *our_tmpf_so = NULL; #define DO_HEADERS 1 if(fcmd diff --git a/imap/src/c-client/auth_bea.c b/imap/src/c-client/auth_bea.c index 4b001ac..e05a500 100644 --- a/imap/src/c-client/auth_bea.c +++ b/imap/src/c-client/auth_bea.c @@ -99,9 +99,12 @@ long auth_oauthbearer_client (authchallenge_t challenger,authrespond_t responder && (oauth2.access_token || (!RefreshToken && oauth2.param[OA2_RefreshToken].value) || (RefreshToken && oauth2.param[OA2_RefreshToken].value - && strcmp(RefreshToken, oauth2.param[OA2_RefreshToken].value) - || oauth2.cancel_refresh_token))) + && strcmp(RefreshToken, oauth2.param[OA2_RefreshToken].value)) + || oauth2.cancel_refresh_token)) mm_login_method (mb, user, (void *) &oauth2, *trial, BEARERNAME); + + if(RefreshToken) + fs_give((void **) &RefreshToken); } /* empty challenge or user requested abort or client does not have info */ diff --git a/imap/src/c-client/auth_gss.c b/imap/src/c-client/auth_gss.c index 52cf6d9..6a33974 100644 --- a/imap/src/c-client/auth_gss.c +++ b/imap/src/c-client/auth_gss.c @@ -401,14 +401,14 @@ char *auth_gssapi_server (authresponse_t responder,int argc,char *argv[]) else { /* can't acquire credentials! */ if (gss_display_name (&dsmn,crname,&buf,&mech) == GSS_S_COMPLETE) - SERVER_LOG ("Failed to acquire credentials for %s",buf.value); + SERVER_LOG ("Failed to acquire credentials for %s",(char *) buf.value); if (smj != GSS_S_FAILURE) do switch (dsmj = gss_display_status (&dsmn,smj,GSS_C_GSS_CODE, GSS_C_NO_OID,&mctx,&resp)) { case GSS_S_COMPLETE: mctx = 0; case GSS_S_CONTINUE_NEEDED: - SERVER_LOG ("Unknown GSSAPI failure: %s",resp.value); + SERVER_LOG ("Unknown GSSAPI failure: %s",(char *)resp.value); gss_release_buffer (&dsmn,&resp); } while (dsmj == GSS_S_CONTINUE_NEEDED); @@ -416,7 +416,7 @@ char *auth_gssapi_server (authresponse_t responder,int argc,char *argv[]) GSS_C_NO_OID,&mctx,&resp)) { case GSS_S_COMPLETE: case GSS_S_CONTINUE_NEEDED: - SERVER_LOG ("GSSAPI mechanism status: %s",resp.value); + SERVER_LOG ("GSSAPI mechanism status: %s",(char *)resp.value); gss_release_buffer (&dsmn,&resp); } while (dsmj == GSS_S_CONTINUE_NEEDED); diff --git a/imap/src/c-client/auth_oa2.c b/imap/src/c-client/auth_oa2.c index 47cd726..7fb3054 100644 --- a/imap/src/c-client/auth_oa2.c +++ b/imap/src/c-client/auth_oa2.c @@ -127,9 +127,12 @@ long auth_oauth2_client (authchallenge_t challenger,authrespond_t responder, cha && (oauth2.access_token || (!RefreshToken && oauth2.param[OA2_RefreshToken].value) || (RefreshToken && oauth2.param[OA2_RefreshToken].value - && strcmp(RefreshToken, oauth2.param[OA2_RefreshToken].value) - || oauth2.cancel_refresh_token))) + && strcmp(RefreshToken, oauth2.param[OA2_RefreshToken].value)) + || oauth2.cancel_refresh_token)) mm_login_method (mb, user, (void *) &oauth2, *trial, OA2NAME); + + if(RefreshToken) + fs_give((void **) &RefreshToken); } /* empty challenge or user requested abort or client does not have info */ diff --git a/imap/src/c-client/oauth2_aux.c b/imap/src/c-client/oauth2_aux.c index 3a58427..ad1c07d 100644 --- a/imap/src/c-client/oauth2_aux.c +++ b/imap/src/c-client/oauth2_aux.c @@ -178,6 +178,7 @@ mm_login_oauth2_c_client_method (NETMBX *mb, char *user, char *method, break; case JLong : oauth2->devicecode.expires_in = *(long *) jx->value; break; + default : break; } if((jx = json_body_value(json, "interval")) != NULL) @@ -186,6 +187,7 @@ mm_login_oauth2_c_client_method (NETMBX *mb, char *user, char *method, break; case JLong : oauth2->devicecode.interval = *(long *) jx->value; break; + default : break; } jx = json_body_value(json, "message"); @@ -224,6 +226,7 @@ mm_login_oauth2_c_client_method (NETMBX *mb, char *user, char *method, break; case JLong : oauth2->expiration = time(0) + *(long *) jx->value; break; + default : break; } oauth2->cancel_refresh_token = 0; /* do not cancel this token. It is good */ break; @@ -282,6 +285,7 @@ mm_login_oauth2_c_client_method (NETMBX *mb, char *user, char *method, break; case JLong : oauth2->expiration = time(0) + *(long *) jx->value; break; + default : break; } jx = json_body_value(json, "expires_in"); @@ -360,6 +364,7 @@ void oauth2deviceinfo_get_accesscode(void *inp, void *outp) break; case JLong : oauth2->expiration = time(0) + *(long *) jx->value; break; + default : break; } rv = OA2_CODE_SUCCESS; diff --git a/pico/browse.c b/pico/browse.c index 8113e4d..7f59274 100644 --- a/pico/browse.c +++ b/pico/browse.c @@ -333,7 +333,7 @@ FileBrowse(char *dir, size_t dirlen, char *fn, size_t fnlen, int row, col, crow, ccol; int flags; int add_file; - char *p, *envp, child[NLINE], tmp[NLINE]; + char *p, *envp, child[2*NLINE+2], tmp[2*NLINE+1]; struct bmaster *mp; struct fcell *tp; EML eml; @@ -721,8 +721,8 @@ FileBrowse(char *dir, size_t dirlen, char *fn, size_t fnlen, case 'e': /* exit or edit */ case 'E': if(gmode&MDBRONLY){ /* run "pico" */ - snprintf(child, sizeof(child), "%s%c%s", gmp->dname, C_FILESEP, - gmp->current->fname); + snprintf(child, sizeof(child), "%.*s%c%.*s", NLINE, gmp->dname, C_FILESEP, + NLINE, gmp->current->fname); /* make sure selected isn't a directory or executable */ if(!LikelyASCII(child)){ emlwrite(_("Can't edit non-text file. Try Launch."), NULL); @@ -812,8 +812,8 @@ FileBrowse(char *dir, size_t dirlen, char *fn, size_t fnlen, tmp[0] = '\0'; i = 0; - snprintf(child, sizeof(child), "%s%c%s", gmp->dname, C_FILESEP, - gmp->current->fname); + snprintf(child, sizeof(child), "%.*s%c%.*s", NLINE, gmp->dname, C_FILESEP, + NLINE, gmp->current->fname); while(!i){ static EXTRAKEYS opts[] = { {"^X", N_("Add Name"), CTRL|'X', KS_NONE}, @@ -1306,8 +1306,8 @@ FileBrowse(char *dir, size_t dirlen, char *fn, size_t fnlen, break; } - snprintf(tmp, sizeof(tmp), "%s%c%s", gmp->dname, C_FILESEP, - gmp->current->fname); + snprintf(tmp, sizeof(tmp), "%.*s%c%.*s", NLINE, gmp->dname, C_FILESEP, + NLINE, gmp->current->fname); if(copy(tmp, child) < 0){ /* copy() will report any error messages */ @@ -1424,8 +1424,8 @@ FileBrowse(char *dir, size_t dirlen, char *fn, size_t fnlen, } } - snprintf(tmp, sizeof(tmp), "%s%c%s", gmp->dname, C_FILESEP, - gmp->current->fname); + snprintf(tmp, sizeof(tmp), "%.*s%c%.*s", NLINE, gmp->dname, C_FILESEP, + NLINE, gmp->current->fname); if(our_rename(tmp, child) < 0){ eml.s = errstr(errno); @@ -1581,8 +1581,8 @@ FileBrowse(char *dir, size_t dirlen, char *fn, size_t fnlen, break; } else if(gmode&MDBRONLY){ - snprintf(child, sizeof(child), "%s%c%s", gmp->dname, C_FILESEP, - gmp->current->fname); + snprintf(child, sizeof(child), "%.*s%c%.*s", NLINE, gmp->dname, C_FILESEP, + NLINE, gmp->current->fname); if(LikelyASCII(child)){ snprintf(tmp, sizeof(tmp), "%s \'%s\'", diff --git a/pico/display.c b/pico/display.c index e8472a0..cde70b5 100644 --- a/pico/display.c +++ b/pico/display.c @@ -375,7 +375,7 @@ int window_signature_block(WINDOW *wp) { LINE *lp, *llp; - int in_sig, is_sig_start; + int in_sig, is_sig_start = 0; int change = 0; llp = wp->w_linep; @@ -1393,7 +1393,7 @@ modeline(WINDOW *wp) bp = wp->w_bufp; if(bp->b_fname[0]) /* File name? */ - snprintf(t2, sizeof(t2), "File: %s", bp->b_fname); + snprintf(t2, sizeof(t2), "File: %.*s", (int) sizeof(t2) - 7, bp->b_fname); else{ strncpy(t2, PICO_NEWBUF_MSG, sizeof(t2)); t2[sizeof(t2)-1] = '\0'; @@ -1430,7 +1430,7 @@ modeline(WINDOW *wp) w2_to_3 = term.t_ncol - (ALLBUTSPACE + w1_to_2); else{ if(bp->b_fname[0]){ - snprintf(t2, sizeof(t2), "%s", bp->b_fname); + snprintf(t2, sizeof(t2), "%.*s", (int) sizeof(t2) - 1, bp->b_fname); w2 = utf8_width(t2); } diff --git a/pico/osdep/color.c b/pico/osdep/color.c index 6fef625..312348c 100644 --- a/pico/osdep/color.c +++ b/pico/osdep/color.c @@ -527,7 +527,7 @@ init_color_table(void) { struct color_table *ct = NULL, *t; int i, count; - char colorname[12]; + char colorname[22]; count = pico_count_in_color_table(); diff --git a/pico/random.c b/pico/random.c index 4d40911..e26cd65 100644 --- a/pico/random.c +++ b/pico/random.c @@ -47,8 +47,8 @@ showcpos(int f, int n) register int cbo; register long nbc; register int lines; - register int thisline; - char buffer[80]; + register int thisline = 0; + char buffer[100]; clp = lforw(curbp->b_linep); /* Grovel the data. */ cbo = 0; diff --git a/pico/search.c b/pico/search.c index 276be60..1f8b292 100644 --- a/pico/search.c +++ b/pico/search.c @@ -1206,7 +1206,7 @@ forscan(int *wrapt, /* boolean indicating search wrapped */ UCS *patptr; /* pointer into pattern */ int stopoff; /* offset to stop search */ LINE *stopline; /* line to stop search */ - int ftest; /* position of first character of test */ + int ftest = 0; /* position of first character of test */ int bsearch; int bol; int eol; diff --git a/pith/mailcmd.c b/pith/mailcmd.c index 098dd8a..2c2b07d 100644 --- a/pith/mailcmd.c +++ b/pith/mailcmd.c @@ -650,7 +650,7 @@ do_broach_folder(char *newfolder, CONTEXT_S *new_context, MAILSTREAM **streamp, ps_global->context_last = ps_global->context_current; snprintf(ps_global->context_current->last_folder, sizeof(ps_global->context_current->last_folder), - "%s", ps_global->cur_folder); + "%.*s", (int) sizeof(ps_global->context_current->last_folder) - 1,ps_global->cur_folder); ps_global->last_unambig_folder[0] = '\0'; } else{ @@ -958,7 +958,7 @@ do_broach_folder(char *newfolder, CONTEXT_S *new_context, MAILSTREAM **streamp, ps_global->context_last = ps_global->context_current; snprintf(ps_global->context_current->last_folder, sizeof(ps_global->context_current->last_folder), - "%s", ps_global->cur_folder); + "%.*s", (int) sizeof(ps_global->context_current->last_folder) - 1, ps_global->cur_folder); ps_global->last_unambig_folder[0] = '\0'; } else{ @@ -2340,7 +2340,7 @@ agg_text_select(MAILSTREAM *stream, MSGNO_S *msgmap, char type, char *namehdr, } } - if(!mepgm) + if(!mepgm){ switch(type){ case 'g' : /* X-GM-EXT-1 */ pgm->x_gm_ext1 = mail_newstringlist(); @@ -2449,7 +2449,7 @@ agg_text_select(MAILSTREAM *stream, MSGNO_S *msgmap, char type, char *namehdr, dprint((1,"\n - BOTCH: select_text unrecognized type\n")); return(1); } - + } /* * If we happen to have any messages excluded, make sure we * don't waste time searching their text... @@ -2502,11 +2502,10 @@ agg_text_select(MAILSTREAM *stream, MSGNO_S *msgmap, char type, char *namehdr, * bits. */ for(msgno = 1L; msgno <= mn_get_total(msgmap); msgno++) - if(stream && msgno <= stream->nmsgs - && (mc=mail_elt(stream, msgno)) && mc->searched) - mc->searched = NIL; - else - mc->searched = T; + if(stream && msgno <= stream->nmsgs){ + if((mc = mail_elt(stream, msgno)) != NULL) + mc->searched = mc->searched ? NIL : T; + } } if(we_cancel) diff --git a/pith/osdep/pipe.c b/pith/osdep/pipe.c index 47a00bd..1e47e83 100644 --- a/pith/osdep/pipe.c +++ b/pith/osdep/pipe.c @@ -481,10 +481,11 @@ open_system_pipe(char *command, char **outfile, char **errfile, int mode, char * pipe_error_msg(char *cmd, char *op, char *res) { - static char ebuf[512]; + static char ebuf[512 + 16 + 1]; - snprintf(ebuf, 256, "Pipe can't %.256s \"%.32sb\": %.223s", + snprintf(ebuf, sizeof(ebuf), "Pipe can't %.256s \"%.32sb\": %.223s", op ? op : "?", cmd ? cmd : "?", res ? res : "?"); + ebuf[sizeof(ebuf) - 1] = '\0'; return(ebuf); } diff --git a/pith/reply.c b/pith/reply.c index 49aaf33..636afa4 100644 --- a/pith/reply.c +++ b/pith/reply.c @@ -945,7 +945,7 @@ reply_body(MAILSTREAM *stream, ENVELOPE *env, struct mail_bodystruct *orig_body, int impl, template_len = 0, leave_cursor_at_top = 0, reply_raw_body = 0; if(sect_prefix) /* SECTBUFLEN = sizeof(sect_buf) */ - snprintf(section = sect_buf, sizeof(sect_buf), "%.*s.1", SECTBUFLEN-1, sect_prefix); + snprintf(section = sect_buf, sizeof(sect_buf), "%.*s.1", SECTBUFLEN-3, sect_prefix); else section = "1"; @@ -3064,7 +3064,7 @@ partno(struct mail_bodystruct *body, struct mail_bodystruct *end_body) num++; /* PARTTMPLEN = sizeof(tmp) */ if(&part->body == end_body || (p = partno(&part->body, end_body))){ snprintf(tmp, sizeof(tmp), "%d%s%.*s", num, (p) ? "." : "", - PARTTMPLEN-10, (p) ? p : ""); + PARTTMPLEN-12, (p) ? p : ""); tmp[sizeof(tmp)-1] = '\0'; if(p) fs_give((void **)&p); diff --git a/pith/smime.c b/pith/smime.c index 07e2291..0ef77e5 100644 --- a/pith/smime.c +++ b/pith/smime.c @@ -203,7 +203,7 @@ setup_pwdcert(void **pwdcert) struct stat sbuf; char pathdir[MAXPATH+1], pathkey[MAXPATH+1], fpath[MAXPATH+1], pathcert[MAXPATH+1]; char fpath2[MAXPATH+1], prompt[MAILTMPLEN]; - char *keyfile, *certfile, *text; + char *keyfile, *certfile, *text = NULL; EVP_PKEY *pkey = NULL; X509 *pcert = NULL; PERSONAL_CERT *pc, *pc2 = NULL; @@ -445,7 +445,7 @@ setup_pwdcert(void **pwdcert) int smime_expunge_cert(WhichCerts ctype) { - int count, removed; + int count = 0, removed; CertList *cl, *dummy, *data; char *path, buf[MAXPATH+1]; char *contents; @@ -640,7 +640,7 @@ import_certificate(WhichCerts ctype, PERSONAL_CERT *p_cert, char *fname) if(ctype == Password){ char PrivateKeyPath[MAXPATH+1], PublicCertPath[MAXPATH+1], s[MAXPATH+1]; char full_name_key[MAXPATH+1], full_name_cert[MAXPATH+1]; - char *use_this_file; + char *use_this_file = NULL; char prompt[500]; EVP_PKEY *key = p_cert ? p_cert->key : NULL; @@ -1151,15 +1151,16 @@ app_RAND_write_file(const char *file) CertList * certlist_from_personal_certs(PERSONAL_CERT *pc) { - CertList *cl; + CertList *cl = NULL; X509 *x; if(pc == NULL) return NULL; - if((x = get_cert_for(pc->name, Public, 1)) != NULL) + if((x = get_cert_for(pc->name, Public, 1)) != NULL){ cl = smime_X509_to_cert_info(x, pc->name); - cl->next = certlist_from_personal_certs(pc->next); + cl->next = certlist_from_personal_certs(pc->next); + } return cl; } @@ -3067,6 +3068,7 @@ do_detached_signature_verify(BODY *b, long msgno, char *section) dprint((9, "do_detached_signature_verify(msgno=%ld type=%d subtype=%s section=%s)", msgno, b->type, b->subtype ? b->subtype : "NULL", (section && *section) ? section : (section != NULL) ? "Top" : "NULL")); smime_init(); + mimetext = bodytext = NULL; /* if it was signed and then encrypted, use the decrypted text * to check the validity of the signature diff --git a/pith/string.c b/pith/string.c index 8b79347..d2d0d75 100644 --- a/pith/string.c +++ b/pith/string.c @@ -1309,7 +1309,7 @@ convert_date_to_local(char *date) { struct tm *tm; time_t ltime; - static char datebuf[26]; + static char datebuf[30]; ltime = date_to_local_time_t(date); if(ltime == (time_t) -1) @@ -1425,7 +1425,7 @@ byte_string(long int bytes) char *a, aa[5]; char *abbrevs = "GMK"; long i, ones, tenths; - static char string[10]; + static char string[50]; ones = 0L; tenths = 0L; -- cgit v1.2.3-54-g00ecf