From 74df826babb53a1d1af2dddd9a99d9fc673c8168 Mon Sep 17 00:00:00 2001 From: Eduardo Chappa Date: Mon, 10 Aug 2015 19:34:04 -0600 Subject: [PATCH] * add non-breaking space (UCS \240) to list of spaces in function lisblank. * Clean up some code in pith/smime.c. --- include/general.h | 1 + pico/line.c | 4 +++- pith/pine.hlp | 2 +- pith/smime.c | 67 +++++++++++++++++++++++-------------------------------- 4 files changed, 33 insertions(+), 41 deletions(-) diff --git a/include/general.h b/include/general.h index 8a97d49..40016ec 100644 --- a/include/general.h +++ b/include/general.h @@ -78,6 +78,7 @@ #define BSLASH '\\' /* back slash */ #define QUOTE '"' /* double quote char */ #define DEL '\177' /* delete */ +#define NBSPC '\240' /* Non-breaking space */ /* * These help with isspace when dealing with UCS-4 characters. diff --git a/pico/line.c b/pico/line.c index 22aa5cc..4bbecb3 100644 --- a/pico/line.c +++ b/pico/line.c @@ -617,7 +617,9 @@ lisblank(LINE *line) ? ucs4_strlen(qstr) : 0; for(; n < llength(line); n++) - if(!ucs4_isspace(lgetc(line, n).c)) + if(!ucs4_isspace(lgetc(line, n).c) + || lgetc(line, n).c >= 0xff + || (unsigned char) lgetc(line,n).c != NBSPC) return(FALSE); return(TRUE); diff --git a/pith/pine.hlp b/pith/pine.hlp index acd3863..4044892 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 88 2015-08-07 17:43:07 +Alpine Commit 89 2015-08-10 19:34:01 ============= h_news ================= diff --git a/pith/smime.c b/pith/smime.c index 4e9cad8..e4829dd 100644 --- a/pith/smime.c +++ b/pith/smime.c @@ -2236,29 +2236,25 @@ encrypt_file(char *fp, char *text, PERSONAL_CERT *pc) sk_X509_push(encerts, X509_dup(pc->cert)); if(text){ - if((out = BIO_new(BIO_s_mem())) == NULL) - goto end; - (void) BIO_reset(out); - BIO_puts(out, text); + if((out = BIO_new(BIO_s_mem())) != NULL){ + (void) BIO_reset(out); + BIO_puts(out, text); + } } - else{ - if(!(out = BIO_new_file(fp, "rb"))) - goto end; - + else if((out = BIO_new_file(fp, "rb")) != NULL){ BIO_read_filename(out, fp); - } - if((p7 = PKCS7_encrypt(encerts, out, cipher, 0)) == NULL) - goto end; - BIO_set_close(out, BIO_CLOSE); - BIO_free(out); - if(!(out = BIO_new_file(fp, "w"))) - goto end; - BIO_reset(out); - rv = PEM_write_bio_PKCS7(out, p7); - BIO_flush(out); + if((p7 = PKCS7_encrypt(encerts, out, cipher, 0)) != NULL){ + BIO_set_close(out, BIO_CLOSE); + BIO_free(out); + if((out = BIO_new_file(fp, "w")) != NULL){ + BIO_reset(out); + rv = PEM_write_bio_PKCS7(out, p7); + BIO_flush(out); + } + } + } -end: if(out != NULL) BIO_free(out); PKCS7_free(p7); @@ -2962,7 +2958,7 @@ decrypt_file(char *fp, int *rv, PERSONAL_CERT *pc) int i, j; long unsigned int len; void *ret; - + if(pc == NULL || (text = read_file(fp, 0)) == NULL || *text == '\0') return NULL; @@ -2971,38 +2967,31 @@ decrypt_file(char *fp, int *rv, PERSONAL_CERT *pc) && text[i] != '-'; j++, i++) tmp[j] = text[i]; tmp[j] = '\0'; - + ret = rfc822_base64((unsigned char *)tmp, strlen(tmp), &len); - + if((in = BIO_new_mem_buf((char *)ret, len)) != NULL){ p7 = d2i_PKCS7_bio(in, NULL); BIO_free(in); } - + if (text) fs_give((void **)&text); if (ret) fs_give((void **)&ret); - + if (rv) *rv = pc->key == NULL ? -1 : 1; out = BIO_new(BIO_s_mem()); (void) BIO_reset(out); - - i = PKCS7_decrypt(p7, pc->key, pc->cert, out, 0); - - if(i == 0){ + + if(PKCS7_decrypt(p7, pc->key, pc->cert, out, 0) != 0){ + BIO_get_mem_data(out, &tmp); + text = cpystr(tmp); + BIO_free(out); + } else q_status_message1(SM_ORDER, 1, 1, _("Error decrypting: %s"), - (char*) openssl_error_string()); - goto end; - } - - BIO_get_mem_data(out, &tmp); - - text = cpystr(tmp); - BIO_free(out); - -end: + (char *) openssl_error_string()); PKCS7_free(p7); - + return text; } -- 2.11.4.GIT