summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEduardo Chappa <chappa@washington.edu>2018-05-02 20:27:22 -0600
committerEduardo Chappa <chappa@washington.edu>2018-05-02 20:27:22 -0600
commita252c8d3ee63d466c7ec710286d9a299abe8982c (patch)
tree565423baafad7c9be17959d8bc75b0eab6658f9d
parentc1b6c3ea38d9c61bca1085aaee6f2c153357ccdb (diff)
downloadalpine-a252c8d3ee63d466c7ec710286d9a299abe8982c.tar.xz
* Changes to make Valgrind happy. Work in progress.
-rw-r--r--alpine/smime.c20
-rw-r--r--pith/pine.hlp2
-rw-r--r--pith/smime.c28
-rw-r--r--pith/smkeys.c7
4 files changed, 36 insertions, 21 deletions
diff --git a/alpine/smime.c b/alpine/smime.c
index 3e67bc7d..0bf051ec 100644
--- a/alpine/smime.c
+++ b/alpine/smime.c
@@ -900,6 +900,7 @@ smime_config_init_display(struct pine *ps, CONF_S **ctmp, CONF_S **first_line)
for(i = 0; i < sizeof(tmp) && i < (ps->ttyo ? ps->ttyo->screen_cols : sizeof(tmp)); i++)
tmp[i] = '-';
+ tmp[i] = '\0';
new_confline(ctmp);
(*ctmp)->flags |= CF_NOSELECT;
(*ctmp)->value = cpystr(tmp);
@@ -1458,6 +1459,7 @@ smime_setup_size(char **s, size_t buflen, size_t n)
snprintf(t, buflen-3, "%zu.%zu", n, n);
t += strlen(t);
*t++ = 's';
+ *t = '\0';
*s = t;
}
@@ -1542,6 +1544,7 @@ smime_manage_password_file_certs_init(struct pine *ps, CONF_S **ctmp, CONF_S **f
for(i = 0; i < sizeof(tmp) && i < (ps->ttyo ? ps->ttyo->screen_cols : sizeof(tmp)); i++)
tmp[i] = '-';
+ tmp[i] = '\0';
new_confline(ctmp);
(*ctmp)->flags |= CF_NOSELECT;
@@ -1574,8 +1577,10 @@ smime_manage_password_file_certs_init(struct pine *ps, CONF_S **ctmp, CONF_S **f
smime_setup_size(&t, sizeof(u) - strlen(t), e);
smime_setup_size(&t, sizeof(u) - strlen(t), df);
*t++ = ' '; /* leave an extra space between dates */
+ *t = '\0'; /* make valgrind happy */
smime_setup_size(&t, sizeof(u) - strlen(t), dt);
*t++ = ' '; /* and another space between date and md5 sum */
+ *t = '\0'; /* make valgrind happy again */
smime_setup_size(&t, sizeof(u) - strlen(t), md5);
*t = '\0'; /* tie off */
@@ -1643,6 +1648,8 @@ void smime_manage_certs_init(struct pine *ps, CONF_S **ctmp, CONF_S **first_line
for(i = 0; i < sizeof(tmp) && i < (ps->ttyo ? ps->ttyo->screen_cols : sizeof(tmp)); i++)
tmp[i] = '-';
+ tmp[i] = '\0';
+
new_confline(ctmp);
(*ctmp)->flags |= CF_NOSELECT;
(*ctmp)->value = cpystr(tmp);
@@ -1657,7 +1664,9 @@ void smime_manage_certs_init(struct pine *ps, CONF_S **ctmp, CONF_S **first_line
(*ctmp)->value = cpystr(tmp);
for(i = 0; i < sizeof(tmp) && i < (ps->ttyo ? ps->ttyo->screen_cols : sizeof(tmp)); i++)
- tmp[i] = '-';
+ tmp[i] = '-';
+ tmp[i] = '\0';
+
new_confline(ctmp);
(*ctmp)->flags |= CF_NOSELECT;
(*ctmp)->value = cpystr(tmp);
@@ -1688,8 +1697,10 @@ void smime_manage_certs_init(struct pine *ps, CONF_S **ctmp, CONF_S **first_line
smime_setup_size(&t, sizeof(u) - strlen(t), e);
smime_setup_size(&t, sizeof(u) - strlen(t), df);
*t++ = ' '; /* leave an extra space between dates */
+ *t = '\0'; /* make valgrind happy */
smime_setup_size(&t, sizeof(u) - strlen(t), dt);
*t++ = ' '; /* and another space between date and md5 sum */
+ *t = '\0'; /* make valgrind happy again */
smime_setup_size(&t, sizeof(u) - strlen(t), md5);
*t = '\0'; /* tie off */
@@ -2001,8 +2012,7 @@ save_smime_config_vars(struct pine *ps)
vsave = (SAVED_CONFIG_S *)fs_get((V_LAST_VAR+1)*sizeof(SAVED_CONFIG_S));
memset((void *)vsave, 0, (V_LAST_VAR+1)*sizeof(SAVED_CONFIG_S));
- v = vsave;
- for(vreal = ps->vars; vreal->name; vreal++,v++){
+ for(v = vsave, vreal = ps->vars; vreal->name; vreal++,v++){
if(!(smime_related_var(ps, vreal) || vreal==&ps->vars[V_FEATURE_LIST]))
continue;
@@ -2017,7 +2027,7 @@ save_smime_config_vars(struct pine *ps)
while(list[n])
n++;
- v->saved_user_val.l = (char **)fs_get((n+1) * sizeof(char *));
+ v->saved_user_val.l = (char **)fs_get((n+1)*sizeof(char *));
memset((void *)v->saved_user_val.l, 0, (n+1)*sizeof(char *));
for(i = 0; i < n; i++)
v->saved_user_val.l[i] = cpystr(list[i]);
@@ -2043,7 +2053,7 @@ free_saved_smime_config(struct pine *ps, SAVED_CONFIG_S **vsavep)
if(vsavep && *vsavep){
for(v = *vsavep, vreal = ps->vars; vreal->name; vreal++,v++){
- if(!(smime_related_var(ps, vreal)))
+ if(!(smime_related_var(ps, vreal) || vreal==&ps->vars[V_FEATURE_LIST]))
continue;
if(vreal->is_list){ /* free saved_user_val.l */
diff --git a/pith/pine.hlp b/pith/pine.hlp
index 6127908d..3a4f2b48 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 260 2018-02-26 01:38:04
+Alpine Commit 268 2018-05-02 20:16:40
============= h_news =================
<HTML>
<HEAD>
diff --git a/pith/smime.c b/pith/smime.c
index a6ddc8fa..9a901a82 100644
--- a/pith/smime.c
+++ b/pith/smime.c
@@ -1188,11 +1188,8 @@ renew_cert_data(CertList **data, WhichCerts ctype)
X509_STORE *store = NULL;
if((store = X509_STORE_new()) != NULL){
- if((lookup = X509_STORE_add_lookup(store, X509_LOOKUP_file())) == NULL){
- X509_STORE_free(store);
- store = NULL;
- } else{
- free_certlist(data);
+ if((lookup = X509_STORE_add_lookup(store, X509_LOOKUP_file())) != NULL){
+ free_certlist(data);
if(SMHOLDERTYPE(ctype) == Directory)
add_certs_in_dir(lookup, PATHCERTDIR(ctype), EXTCERT(ctype), data);
else /* if(SMHOLDERTYPE(ctype) == Container) */
@@ -1205,7 +1202,9 @@ renew_cert_data(CertList **data, WhichCerts ctype)
ps_global->smime->publiccertlist = *data;
else
ps_global->smime->cacertlist = *data;
- }
+ }
+ X509_STORE_free(store);
+ store = NULL;
}
}
setup_certs_backup_by_type(ctype);
@@ -1224,6 +1223,9 @@ smime_deinit(void)
{
dprint((9, "smime_deinit()"));
app_RAND_write_file(NULL);
+ if (s_cert_store != NULL) X509_STORE_free(s_cert_store);
+ ERR_free_strings();
+ EVP_cleanup();
free_smime_struct(&ps_global->smime);
}
@@ -3242,11 +3244,9 @@ decrypt_file(char *fp, int *rv, PERSONAL_CERT *pc)
if(pc == NULL || (text = read_file(fp, 0)) == NULL || *text == '\0')
return NULL;
- tmp = fs_get(strlen(text) + (strlen(text) << 6) + 1);
- for(j = 0, i = strlen("-----BEGIN PKCS7-----") + 1; text[i] != '\0'
- && text[i] != '-'; j++, i++)
- tmp[j] = text[i];
- tmp[j] = '\0';
+ tmp = strchr(text + strlen("-----BEGIN PKCS7-----") + strlen(NEWLINE), '-');
+ if(tmp != NULL) *tmp = '\0';
+ tmp = text + strlen("-----BEGIN PKCS7-----") + strlen(NEWLINE);
ret = rfc822_base64((unsigned char *)tmp, strlen(tmp), &len);
@@ -3264,8 +3264,10 @@ decrypt_file(char *fp, int *rv, PERSONAL_CERT *pc)
(void) BIO_reset(out);
if(PKCS7_decrypt(p7, pc->key, pc->cert, out, 0) != 0){
- BIO_get_mem_data(out, &tmp);
- text = cpystr(tmp);
+ len = BIO_get_mem_data(out, &tmp);
+ text = fs_get((len+1)*sizeof(char));
+ strncpy(text, tmp, len);
+ text[len-1] = '\0';
BIO_free(out);
} else
q_status_message1(SM_ORDER, 1, 1, _("Error decrypting: %s"),
diff --git a/pith/smkeys.c b/pith/smkeys.c
index 1889bb96..25144470 100644
--- a/pith/smkeys.c
+++ b/pith/smkeys.c
@@ -637,7 +637,8 @@ smime_get_date(const ASN1_TIME *tm)
char date[MAILTMPLEN];
char buf[MAILTMPLEN];
char *m, *d, *t, *y, *z;
- struct date smd;
+ int len;
+ struct date smd;
struct tm smtm;
(void) BIO_reset(mb);
@@ -645,7 +646,8 @@ smime_get_date(const ASN1_TIME *tm)
return cpystr(_("Invalid"));
(void) BIO_flush(mb);
- BIO_read(mb, iobuf, sizeof(iobuf));
+ len = BIO_read(mb, iobuf, sizeof(iobuf));
+ iobuf[len-1] = '\0';
/* openssl returns the date in the format:
* "MONTH (as name) DAY (as number) TIME(hh:mm:ss) YEAR GMT"
@@ -678,6 +680,7 @@ smime_get_date(const ASN1_TIME *tm)
snprintf(buf, sizeof(buf), "%s/%s/%s", m, d, y + strlen(y) - 2);
buf[sizeof(buf)-1] = '\0';
+ BIO_free(mb);
return cpystr(buf);
}