"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/mx/mime.c" between
s-nail-14.9.18.tar.xz and s-nail-14.9.19.tar.xz

About: S-nail is a mail processing system intended to provide the functionality of the POSIX mailx command and offers extensions for line editing, IDNA, MIME, S/MIME, SMTP and POP3 (and IMAP). It is usable as a mail batch language.

mime.c  (s-nail-14.9.18.tar.xz):mime.c  (s-nail-14.9.19.tar.xz)
skipping to change at line 86 skipping to change at line 86
#endif #endif
#define _CS_ITER_STEP() _cs_iter = su_cs_sep_c(&_cs_iter_base, ',', TRU1) #define _CS_ITER_STEP() _cs_iter = su_cs_sep_c(&_cs_iter_base, ',', TRU1)
/* Is 7-bit enough? */ /* Is 7-bit enough? */
#ifdef mx_HAVE_ICONV #ifdef mx_HAVE_ICONV
static boole _has_highbit(char const *s); static boole _has_highbit(char const *s);
static boole _name_highbit(struct mx_name *np); static boole _name_highbit(struct mx_name *np);
#endif #endif
/* fwrite(3) while checking for displayability */ /* fwrite(3) while checking for displayability */
static sz _fwrite_td(struct str const *input, static sz _fwrite_td(struct str const *input, enum tdflags flags,
boole failiconv, enum tdflags flags,
struct str *outrest, struct quoteflt *qf); struct str *outrest, struct quoteflt *qf);
/* Convert header fields to RFC 2047 format and write to the file fo */ /* Convert header fields to RFC 2047 format and write to the file fo */
static sz mime_write_tohdr(struct str *in, FILE *fo, static sz mime_write_tohdr(struct str *in, FILE *fo,
uz *colp, enum a_mime_structure_hack msh); uz *colp, enum a_mime_structure_hack msh);
#ifdef mx_HAVE_ICONV #ifdef mx_HAVE_ICONV
static sz a_mime__convhdra(struct str *inp, FILE *fp, uz *colp, static sz a_mime__convhdra(struct str *inp, FILE *fp, uz *colp,
enum a_mime_structure_hack msh); enum a_mime_structure_hack msh);
#else #else
skipping to change at line 160 skipping to change at line 159
static n_sighdl_t __mimefwtd_opipe; static n_sighdl_t __mimefwtd_opipe;
static void static void
__mimefwtd_onsig(int sig) /* TODO someday, we won't need it no more */ __mimefwtd_onsig(int sig) /* TODO someday, we won't need it no more */
{ {
NYD; /* Signal handler */ NYD; /* Signal handler */
__mimefwtd_sig = sig; __mimefwtd_sig = sig;
siglongjmp(__mimefwtd_actjmp, 1); siglongjmp(__mimefwtd_actjmp, 1);
} }
static sz static sz
_fwrite_td(struct str const *input, boole failiconv, enum tdflags flags, _fwrite_td(struct str const *input, enum tdflags flags,
struct str *outrest, struct quoteflt *qf) struct str *outrest, struct quoteflt *qf)
{ {
/* TODO note: after send/MIME layer rewrite we will have a string pool /* TODO note: after send/MIME layer rewrite we will have a string pool
* TODO so that memory allocation count drops down massively; for now, * TODO so that memory allocation count drops down massively; for now,
* TODO v14.* that is, we pay a lot & heavily depend on the allocator */ * TODO v14.* that is, we pay a lot & heavily depend on the allocator */
/* TODO well if we get a broken pipe here, and it happens to /* TODO well if we get a broken pipe here, and it happens to
* TODO happen pretty easy when sleeping in a full pipe buffer, * TODO happen pretty easy when sleeping in a full pipe buffer,
* TODO then the current codebase performs longjump away; * TODO then the current codebase performs longjump away;
* TODO this leaves memory leaks behind ('think up to 3 per, * TODO this leaves memory leaks behind ('think up to 3 per,
* TODO dep. upon alloca availability). For this to be fixed * TODO dep. upon alloca availability). For this to be fixed
* TODO we either need to get rid of the longjmp()s (tm) or * TODO we either need to get rid of the longjmp()s (tm) or
* TODO the storage must come from the outside or be tracked * TODO the storage must come from the outside or be tracked
* TODO in a carrier struct. Best both. But storage reuse * TODO in a carrier struct. Best both. But storage reuse
* TODO would be a bigbig win besides */ * TODO would be a bigbig win besides */
/* *input* _may_ point to non-modifyable buffer; but even then it only /* *input* _may_ point to non-modifyable buffer; but even then it only
* needs to be dup'ed away if we have to transform the content */ * needs to be dup'ed away if we have to transform the content */
struct str in, out; struct str in, out;
sz rv; sz rv;
NYD_IN; NYD_IN;
UNUSED(failiconv);
UNUSED(outrest); UNUSED(outrest);
in = *input; in = *input;
out.s = NULL; out.s = NULL;
out.l = 0; out.l = 0;
#ifdef mx_HAVE_ICONV #ifdef mx_HAVE_ICONV
if ((flags & TD_ICONV) && iconvd != (iconv_t)-1) { if ((flags & TD_ICONV) && iconvd != (iconv_t)-1) {
int err; int err;
char *buf; char *buf;
skipping to change at line 229 skipping to change at line 227
if(j != 0) if(j != 0)
n_str_assign_buf(outrest, cp, j); n_str_assign_buf(outrest, cp, j);
in.l = i; in.l = i;
}else{ }else{
n_str_assign(outrest, &in); n_str_assign(outrest, &in);
goto jleave; goto jleave;
} }
} }
#endif #endif
if((err = n_iconv_str(iconvd, if((err = n_iconv_str(iconvd, n_ICONV_UNIDEFAULT,
(failiconv ? n_ICONV_NONE : n_ICONV_UNIDEFAULT),
&out, &in, &in)) != 0){ &out, &in, &in)) != 0){
if(err != su_ERR_INVAL) if(err != su_ERR_INVAL)
n_iconv_reset(iconvd); n_iconv_reset(iconvd);
if(outrest != NULL && in.l > 0){ if(outrest != NULL && in.l > 0){
/* Incomplete multibyte at EOF is special xxx _INVAL? */ /* Incomplete multibyte at EOF is special xxx _INVAL? */
if (flags & _TD_EOF) { if (flags & _TD_EOF) {
out.s = n_realloc(out.s, out.l + sizeof(su_utf8_replacer)); out.s = n_realloc(out.s, out.l + sizeof(su_utf8_replacer));
if(n_psonce & n_PSO_UNICODE){ if(n_psonce & n_PSO_UNICODE){
su_mem_copy(&out.s[out.l], su_utf8_replacer, su_mem_copy(&out.s[out.l], su_utf8_replacer,
skipping to change at line 1388 skipping to change at line 1385
case CONV_FROMB64_T: case CONV_FROMB64_T:
if(!b64_decode_part(&out, &in, outrest, inrest)){ if(!b64_decode_part(&out, &in, outrest, inrest)){
jeb64: jeb64:
n_err(_("Invalid Base64 encoding ignored\n")); n_err(_("Invalid Base64 encoding ignored\n"));
xsize = 0; /* TODO size = -1 stops outer levels! */ xsize = 0; /* TODO size = -1 stops outer levels! */
break; break;
} }
} }
jqpb64_dec: jqpb64_dec:
if ((xsize = out.l) != 0) if ((xsize = out.l) != 0)
xsize = _fwrite_td(&out, FAL0, (dflags & ~_TD_BUFCOPY), outrest, qf); xsize = _fwrite_td(&out, (dflags & ~_TD_BUFCOPY), outrest, qf);
break; break;
case CONV_TOB64: case CONV_TOB64:
/* TODO hack which is necessary unless this is a filter based approach /* TODO hack which is necessary unless this is a filter based approach
* TODO and each filter has its own buffer (as necessary): we must not * TODO and each filter has its own buffer (as necessary): we must not
* TODO pass through a number of bytes which causes padding, otherwise we * TODO pass through a number of bytes which causes padding, otherwise we
* TODO produce multiple adjacent base64 streams, and that is not treated * TODO produce multiple adjacent base64 streams, and that is not treated
* TODO in the same relaxed fashion like completely bogus bytes by at * TODO in the same relaxed fashion like completely bogus bytes by at
* TODO least mutt and OpenSSL. So we need an expensive workaround * TODO least mutt and OpenSSL. So we need an expensive workaround
* TODO unless we have input->iconv->base64 filter chain as such!! :( */ * TODO unless we have input->iconv->base64 filter chain as such!! :( */
if(size != 0 && /* for Coverity, else ASSERT() */ inrest != NULL){ if(size != 0 && /* for Coverity, else ASSERT() */ inrest != NULL){
skipping to change at line 1449 skipping to change at line 1446
if(dflags & _TD_BUFCOPY){ if(dflags & _TD_BUFCOPY){
n_str_dup(&out, &in); n_str_dup(&out, &in);
in = out; in = out;
out.s = NULL; out.s = NULL;
dflags &= ~_TD_BUFCOPY; dflags &= ~_TD_BUFCOPY;
} }
col = 0; col = 0;
xsize = mime_write_tohdr_a(&in, f, &col, a_MIME_SH_NONE); xsize = mime_write_tohdr_a(&in, f, &col, a_MIME_SH_NONE);
}break; }break;
default: default:
xsize = _fwrite_td(&in, TRU1, dflags, NULL, qf); xsize = _fwrite_td(&in, dflags, NULL, qf);
break; break;
} }
jleave: jleave:
if (out.s != NULL) if (out.s != NULL)
n_free(out.s); n_free(out.s);
if (in.s != ptr) if (in.s != ptr)
n_free(in.s); n_free(in.s);
safe_signal(SIGPIPE, __mimemw_opipe); safe_signal(SIGPIPE, __mimemw_opipe);
if (__mimemw_sig != 0) if (__mimemw_sig != 0)
 End of changes. 6 change blocks. 
8 lines changed or deleted 5 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)