From 7c946bfafe961c1dda51d19b5c29a5600ef1e5ec Mon Sep 17 00:00:00 2001 From: Eduardo Chappa Date: Sun, 26 Jul 2015 08:29:05 -0600 Subject: * Fix compilation error in arg.c when pwdcertdir was being freed, even though a password file might have not been defined. * Work on reducing the number of warnings in OSX. --- alpine/adrbkcmd.c | 17 +++++++++++++++-- alpine/arg.c | 2 +- alpine/imap.c | 2 +- alpine/osdep/execview.c | 5 ++--- alpine/smime.c | 16 +++++++++------- configure | 26 +++++++++++++------------- configure.ac | 35 +---------------------------------- imap/src/c-client/mail.c | 2 +- imap/src/osdep/unix/ckp_pam.c | 4 ++-- imap/src/osdep/unix/ssl_unix.c | 16 ++++++++-------- imap/src/osdep/unix/unix.c | 13 +++++++------ pith/osdep/mimedisp.c | 14 ++++++++++++++ pith/pine.hlp | 2 +- 13 files changed, 75 insertions(+), 79 deletions(-) diff --git a/alpine/adrbkcmd.c b/alpine/adrbkcmd.c index 592b16b8..8b80800b 100644 --- a/alpine/adrbkcmd.c +++ b/alpine/adrbkcmd.c @@ -7593,7 +7593,13 @@ url_local_ldap(char *url) ps_global->mangled_footer = 1; #if (LDAPAPI >= 11) +#ifdef _WINDOWS if((ld = ldap_init(ldapurl->lud_host, ldapurl->lud_port)) == NULL) +#else + snprintf(tmp_20k_buf, SIZEOF_20KBUF, "ldap://%s:%d", ldapurl->lud_host, ldapurl->lud_port); + tmp_20k_buf[SIZEOF_20KBUF-1] = '\0'; + if(ldap_initialize(&ld, tmp_20k_buf) != LDAP_SUCCESS) +#endif #else if((ld = ldap_open(ldapurl->lud_host, ldapurl->lud_port)) == NULL) #endif @@ -7618,9 +7624,16 @@ url_local_ldap(char *url) our_ldap_set_option(ld, LDAP_OPT_RESTART, LDAP_OPT_ON); t.tv_sec = 30; t.tv_usec = 0; +#ifdef _WINDOWS ld_err = ldap_search_st(ld, ldapurl->lud_dn, ldapurl->lud_scope, ldapurl->lud_filter, ldapurl->lud_attrs, 0, &t, &result); +#else + ld_err = ldap_search_ext_s(ld, ldapurl->lud_dn, ldapurl->lud_scope, + ldapurl->lud_filter, ldapurl->lud_attrs, 0, + NULL, NULL, + &t, DEF_LDAP_SIZE, &result); +#endif if(ld_err != LDAP_SUCCESS){ if(we_cancel){ cancel_busy_cue(-1); @@ -7630,7 +7643,7 @@ url_local_ldap(char *url) snprintf(ebuf, sizeof(ebuf), _("LDAP search failed: %s"), ldap_err2string(ld_err)); ebuf[sizeof(ebuf)-1] = '\0'; q_status_message(SM_ORDER, 3, 5, ebuf); - ldap_unbind(ld); + ldap_unbind_ext(ld, NULL, NULL); } else if(!ps_global->intr_pending){ if(we_cancel){ @@ -7645,7 +7658,7 @@ url_local_ldap(char *url) if(ldap_count_entries(ld, result) == 0){ q_status_message(SM_ORDER, 3, 5, _("No matches found for url")); - ldap_unbind(ld); + ldap_unbind_ext(ld, NULL, NULL); if(result) ldap_msgfree(result); } diff --git a/alpine/arg.c b/alpine/arg.c index bb949f3b..836adf36 100644 --- a/alpine/arg.c +++ b/alpine/arg.c @@ -293,7 +293,7 @@ Loop: while(--ac > 0) } else{ if(pine_state->smimedir) - fs_give((void **)&pine_state->pwdcertdir); + fs_give((void **)&pine_state->smimedir); pine_state->smimedir = cpystr(str); } diff --git a/alpine/imap.c b/alpine/imap.c index 4b6f0ee6..f4cccfcd 100644 --- a/alpine/imap.c +++ b/alpine/imap.c @@ -2762,7 +2762,7 @@ preserve_prompt(void) #elif APPLEKEYCHAIN int rc; - if(rc = macos_store_pass_prompt()){ + if((rc = macos_store_pass_prompt()) != 0){ if(want_to(_("Preserve password for next login"), 'y', 'x', NO_HELP, WT_NORM) == 'y'){ diff --git a/alpine/osdep/execview.c b/alpine/osdep/execview.c index 9ef2855e..4ce5d549 100644 --- a/alpine/osdep/execview.c +++ b/alpine/osdep/execview.c @@ -227,7 +227,7 @@ exec_mailcap_cmd(MCAP_CMD_S *mc_cmd, char *image_file, int needsterminal) r_file_h = &result_file; } - if(syspipe = open_system_pipe(command, r_file_h, NULL, mode, 0, pipe_callback, NULL)){ + if((syspipe = open_system_pipe(command, r_file_h, NULL, mode, 0, pipe_callback, NULL)) != NULL){ close_system_pipe(&syspipe, NULL, pipe_callback); if(needsterminal == 1) q_status_message(SM_ORDER, 0, 4, "VIEWER command completed"); @@ -349,10 +349,9 @@ url_os_specified_browser(char *url) if(mime_os_specific_access()){ return(cpystr("open")); } -#else +#endif /* do nothing here */ return(NULL); -#endif } /* diff --git a/alpine/smime.c b/alpine/smime.c index ca18b3ee..8949487e 100644 --- a/alpine/smime.c +++ b/alpine/smime.c @@ -62,6 +62,7 @@ void smime_manage_certs_init (struct pine *, CONF_S **, CONF_S **, WhichCert void display_certificate_information(struct pine *, X509 *, char *, WhichCerts, int num); int manage_certs_tool(struct pine *ps, int cmd, CONF_S **cl, unsigned flags); int manage_certificate_info_tool(int, MSGNO_S *, SCROLL_S *); +void smime_setup_size(char **, size_t, size_t); /* @@ -1324,13 +1325,14 @@ manage_certs_tool(struct pine *ps, int cmd, CONF_S **cl, unsigned flags) } void -smime_setup_size(char **s, size_t n) +smime_setup_size(char **s, size_t buflen, size_t n) { char *t = *s; *t++ = ' '; *t++ = '%'; *t++ = '-'; - sprintf(t+strlen(t), "%d.%d", n, n); + snprintf(t+strlen(t), buflen-3, "%zu.%zu", n, n); + t[strlen(t)-1] = '\0'; t += strlen(t); *t++ = 's'; *t++ = ' '; @@ -1395,11 +1397,11 @@ void smime_manage_certs_init(struct pine *ps, CONF_S **ctmp, CONF_S **first_line memset(u, '\0', sizeof(u)); t = u; - smime_setup_size(&t, s); - smime_setup_size(&t, e); - smime_setup_size(&t, df); - smime_setup_size(&t, dt); - smime_setup_size(&t, md5); + smime_setup_size(&t, sizeof(u), s); + smime_setup_size(&t, sizeof(u) - strlen(t), e); + smime_setup_size(&t, sizeof(u) - strlen(t), df); + smime_setup_size(&t, sizeof(u) - strlen(t), dt); + smime_setup_size(&t, sizeof(u) - strlen(t), md5); for(cl = data, i = 0; cl; cl = cl->next) if(cl->name){ diff --git a/configure b/configure index 7b262108..0f0a03f7 100755 --- a/configure +++ b/configure @@ -17919,9 +17919,9 @@ if test "x$ac_cv_lib_lber_ber_alloc" = xyes; then : fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing ldap_init" >&5 -$as_echo_n "checking for library containing ldap_init... " >&6; } -if ${ac_cv_search_ldap_init+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing ldap_initialize" >&5 +$as_echo_n "checking for library containing ldap_initialize... " >&6; } +if ${ac_cv_search_ldap_initialize+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS @@ -17934,11 +17934,11 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext #ifdef __cplusplus extern "C" #endif -char ldap_init (); +char ldap_initialize (); int main () { -return ldap_init (); +return ldap_initialize (); ; return 0; } @@ -17951,25 +17951,25 @@ for ac_lib in '' ldap; do LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : - ac_cv_search_ldap_init=$ac_res + ac_cv_search_ldap_initialize=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext - if ${ac_cv_search_ldap_init+:} false; then : + if ${ac_cv_search_ldap_initialize+:} false; then : break fi done -if ${ac_cv_search_ldap_init+:} false; then : +if ${ac_cv_search_ldap_initialize+:} false; then : else - ac_cv_search_ldap_init=no + ac_cv_search_ldap_initialize=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_ldap_init" >&5 -$as_echo "$ac_cv_search_ldap_init" >&6; } -ac_res=$ac_cv_search_ldap_init +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_ldap_initialize" >&5 +$as_echo "$ac_cv_search_ldap_initialize" >&6; } +ac_res=$ac_cv_search_ldap_initialize if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" @@ -18046,7 +18046,7 @@ $as_echo "$as_me: * * * Including LDAP Support" >&6;} $as_echo "#define ENABLE_LDAP /**/" >>confdefs.h fi - fi +fi if test "x$alpine_PAM" != "xnone" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing pam_start" >&5 diff --git a/configure.ac b/configure.ac index f4cf950a..ba9ba201 100644 --- a/configure.ac +++ b/configure.ac @@ -1412,7 +1412,7 @@ if test "$alpine_with_ldap" = "yes" ; then [ LIBS="$LIBS -llber" ]) - AC_SEARCH_LIBS(ldap_init,ldap, + AC_SEARCH_LIBS(ldap_initialize,ldap, [ alpine_has_ldap=yes ], @@ -1427,39 +1427,6 @@ if test "$alpine_with_ldap" = "yes" ; then AC_MSG_NOTICE([* * * Including LDAP Support]) AC_DEFINE([ENABLE_LDAP], [], [Enable LDAP query support]) fi - dnl we use deprecated functions (ldap_get_values) - dnl OpenLDAP 2.3.x doesn't define LDAP_DEPRECATED by default like 2.2.x -dnl AC_MSG_CHECKING([if we should define LDAP_DEPRECATED]) -dnl AC_RUN_IFELSE( -dnl [AC_LANG_SOURCE([[ -dnl #include -dnl #include -dnl #include -dnl int main(void) { -dnl -dnl if (LDAP_VENDOR_VERSION >= 20300) -dnl exit(0); -dnl -dnl exit(2); -dnl } -dnl ]])], -dnl [ -dnl AC_MSG_RESULT(yes) -dnl AC_DEFINE(LDAP_DEPRECATED, 1, -dnl [Define if you use OpenLDAP 2.3.x deprecated functions]) -dnl -dnl ], -dnl [ -dnl AC_MSG_RESULT(no) -dnl ], -dnl [ -dnl AC_MSG_WARN([cross compiling: not checking]) -dnl ] -dnl ) -dnl -dnl else -dnl AC_MSG_NOTICE([Cannot find LDAP functions! Excluding LDAP support.]) -dnl fi fi dnl PAM support is needed to build c-client in some linux, and hence Alpine. diff --git a/imap/src/c-client/mail.c b/imap/src/c-client/mail.c index 1b6f93c3..f3e4bdd2 100644 --- a/imap/src/c-client/mail.c +++ b/imap/src/c-client/mail.c @@ -1677,7 +1677,7 @@ char *mail_fetch_message (MAILSTREAM *stream,unsigned long msgno, unsigned long i,j; if (len) *len = 0; /* default return size */ if (flags & FT_UID) { /* UID form of call */ - if (msgno = mail_msgno (stream,msgno)) flags &= ~FT_UID; + if ((msgno = mail_msgno (stream,msgno)) != 0L) flags &= ~FT_UID; else return ""; /* must get UID/msgno map first */ } /* initialize message data identifier */ diff --git a/imap/src/osdep/unix/ckp_pam.c b/imap/src/osdep/unix/ckp_pam.c index 60c6c1f7..5bc31f3d 100644 --- a/imap/src/osdep/unix/ckp_pam.c +++ b/imap/src/osdep/unix/ckp_pam.c @@ -104,13 +104,13 @@ struct passwd *checkpw (struct passwd *pw,char *pass,int argc,char *argv[]) conv.appdata_ptr = &cred; cred.uname = name; cred.pass = pass; - if (pw = ((pam_start ((char *) mail_parameters (NIL,GET_SERVICENAME,NIL), + if ((pw = ((pam_start ((char *) mail_parameters (NIL,GET_SERVICENAME,NIL), pw->pw_name,&conv,&hdl) == PAM_SUCCESS) && (pam_set_item (hdl,PAM_RHOST,tcp_clientaddr ()) == PAM_SUCCESS) && (pam_authenticate (hdl,NIL) == PAM_SUCCESS) && (pam_acct_mgmt (hdl,NIL) == PAM_SUCCESS) && (pam_setcred (hdl,PAM_ESTABLISH_CRED) == PAM_SUCCESS)) ? - getpwnam (name) : NIL) { + getpwnam (name) : NIL) != NULL) { #if 0 /* * Some people have reported that this causes a SEGV in strncpy() from diff --git a/imap/src/osdep/unix/ssl_unix.c b/imap/src/osdep/unix/ssl_unix.c index d77ed719..16b4228c 100644 --- a/imap/src/osdep/unix/ssl_unix.c +++ b/imap/src/osdep/unix/ssl_unix.c @@ -261,11 +261,11 @@ static char *ssl_start_work (SSLSTREAM *stream,char *host,unsigned long flags) /* set default paths to CAs... */ SSL_CTX_set_default_verify_paths (stream->context); /* ...unless a non-standard path desired */ - if (s = (char *) mail_parameters (NIL,GET_SSLCAPATH,NIL)) + if ((s = (char *) mail_parameters (NIL,GET_SSLCAPATH,NIL)) != NULL) SSL_CTX_load_verify_locations (stream->context,NIL,s); /* want to send client certificate? */ if (scc && (s = (*scc) ()) && (sl = strlen (s))) { - if (cert = PEM_read_bio_X509 (bio = BIO_new_mem_buf (s,sl),NIL,NIL,NIL)) { + if ((cert = PEM_read_bio_X509 (bio = BIO_new_mem_buf (s,sl),NIL,NIL,NIL)) != NULL) { SSL_CTX_use_certificate (stream->context,cert); X509_free (cert); } @@ -274,8 +274,8 @@ static char *ssl_start_work (SSLSTREAM *stream,char *host,unsigned long flags) /* want to supply private key? */ if ((t = (sck ? (*sck) () : s)) && (tl = strlen (t))) { EVP_PKEY *key; - if (key = PEM_read_bio_PrivateKey (bio = BIO_new_mem_buf (t,tl), - NIL,NIL,"")) { + if ((key = PEM_read_bio_PrivateKey (bio = BIO_new_mem_buf (t,tl), + NIL,NIL,"")) != NULL) { SSL_CTX_use_PrivateKey (stream->context,key); EVP_PKEY_free (key); } @@ -354,8 +354,8 @@ static char *ssl_validate_cert (X509 *cert,char *host) /* and that it has a name */ else if (!cert->name) ret = "No name in certificate"; /* locate CN */ - else if (s = strstr (cert->name,"/CN=")) { - if (t = strchr (s += 4,'/')) *t = '\0'; + else if ((s = strstr (cert->name,"/CN=")) != NULL) { + if ((t = strchr (s += 4,'/')) != NULL) *t = '\0'; /* host name matches pattern? */ ret = ssl_compare_hostnames (host,s) ? NIL : "Server name does not match certificate"; @@ -785,7 +785,7 @@ void ssl_server_init (char *server) } } } - while (i = ERR_get_error ()) /* SSL failure */ + while ((i = ERR_get_error ()) != 0L) /* SSL failure */ syslog (LOG_ERR,"SSL error status: %.80s",ERR_error_string (i,NIL)); ssl_close (stream); /* punt stream */ exit (1); /* punt this program too */ @@ -807,7 +807,7 @@ static RSA *ssl_genkey (SSL *con,int export,int keylength) if (!(key = RSA_generate_key (export ? keylength : 1024,RSA_F4,NIL,NIL))) { syslog (LOG_ALERT,"Unable to generate temp key, host=%.80s", tcp_clienthost ()); - while (i = ERR_get_error ()) + while ((i = ERR_get_error ()) != 0L) syslog (LOG_ALERT,"SSL error status: %s",ERR_error_string (i,NIL)); exit (1); } diff --git a/imap/src/osdep/unix/unix.c b/imap/src/osdep/unix/unix.c index 8bca508c..cda5798c 100644 --- a/imap/src/osdep/unix/unix.c +++ b/imap/src/osdep/unix/unix.c @@ -398,15 +398,16 @@ long unix_rename (MAILSTREAM *stream,char *old,char *newname) MM_CRITICAL (stream); /* get the c-client lock */ if (!dummy_file (file,old) || (newname && (!((s = mailboxfile (tmp,newname)) && *s) || - ((s = strrchr (tmp,'/')) && !s[1])))) - sprintf (tmp,newname ? - "Can't rename mailbox %.80s to %.80s: invalid name" : - "Can't delete mailbox %.80s: invalid name", + ((s = strrchr (tmp,'/')) && !s[1])))){ + if(newname) + sprintf (tmp, "Can't rename mailbox %.80s to %.80s: invalid name", old,newname); + else + sprintf (tmp, "Can't delete mailbox %.80s: invalid name",old); /* lock out other c-clients */ - else if ((ld = lockname (lock,file,LOCK_EX|LOCK_NB,&i)) < 0) + } else if ((ld = lockname (lock,file,LOCK_EX|LOCK_NB,&i)) < 0) sprintf (tmp,"Mailbox %.80s is in use by another process",old); - + else { if ((fd = unix_lock (file,O_RDWR, (long) mail_parameters (NIL,GET_MBXPROTECTION,NIL), diff --git a/pith/osdep/mimedisp.c b/pith/osdep/mimedisp.c index 2ee99293..7917a716 100644 --- a/pith/osdep/mimedisp.c +++ b/pith/osdep/mimedisp.c @@ -412,12 +412,21 @@ osx_build_mime_type_cmd(mime_type, cmd, cmdlen, sp_hndlp) CFStringRef str_ref = NULL, ret_str_ref = NULL; CFURLRef url_ref = NULL; +#ifdef AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER + if(&LSCopyDefaultApplicationURLForContentType == NULL) + return 0; +#else if(&LSCopyApplicationForMIMEType == NULL) return 0; +#endif if((str_ref = CFStringCreateWithCString(NULL, mime_type, kCFStringEncodingASCII)) == NULL) return 0; +#ifdef AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER + if(LSCopyDefaultApplicationURLForContentType(str_ref, kLSRolesAll, &url_ref) +#else if(LSCopyApplicationForMIMEType(str_ref, kLSRolesAll, &url_ref) +#endif != kLSApplicationNotFoundErr){ if((ret_str_ref = CFURLGetString(url_ref)) == NULL) return 0; @@ -454,8 +463,13 @@ osx_build_mime_ext_cmd(mime_ext, cmd, cmdlen, sp_hndlp) ? mime_ext+1 : mime_ext, kCFStringEncodingASCII)) == NULL) return 0; +#ifdef AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER + if(LSCopyDefaultApplicationURLForContentType(str_ref, + kLSRolesAll, &url_ref) +#else if(LSGetApplicationForInfo(kLSUnknownType, kLSUnknownCreator, str_ref, kLSRolesAll, NULL, &url_ref) +#endif != kLSApplicationNotFoundErr){ if((ret_str_ref = CFURLGetString(url_ref)) == NULL) return 0; diff --git a/pith/pine.hlp b/pith/pine.hlp index b568f2c4..6ce90a71 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 82 2015-07-24 22:13:48 +Alpine Commit 83 2015-07-26 08:29:01 ============= h_news ================= -- cgit v1.2.3-54-g00ecf