diff options
-rw-r--r-- | camel/ChangeLog | 50 | ||||
-rw-r--r-- | camel/camel-cipher-context.c | 2 | ||||
-rw-r--r-- | camel/camel-mime-filter-basic.c | 10 | ||||
-rw-r--r-- | camel/camel-mime-filter-charset.c | 16 | ||||
-rw-r--r-- | camel/camel-mime-filter.h | 8 | ||||
-rw-r--r-- | camel/camel-mime-part-utils.c | 9 | ||||
-rw-r--r-- | camel/camel-mime-utils.c | 144 | ||||
-rw-r--r-- | camel/camel-mime-utils.h | 31 | ||||
-rw-r--r-- | camel/camel-pgp-context.c | 4 | ||||
-rw-r--r-- | camel/camel-sasl-digest-md5.c | 2 | ||||
-rw-r--r-- | camel/camel-stream-filter.c | 5 |
11 files changed, 171 insertions, 110 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index 6e58fb3e20..319d5c47c3 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,53 @@ +2001-12-04 Jeffrey Stedfast <fejj@ximian.com> + + * camel-mime-utils.c (header_content_type_simple): Protect against + either of the types being NULL. + +2001-12-05 Jeffrey Stedfast <fejj@ximian.com> + + * camel-mime-filter-basic.c (filter): If complete() allocates + len+2 bytes for the out buffer, so should this. See bug #16371 for + an example case. + +2001-12-05 Jeffrey Stedfast <fejj@ximian.com> + + * camel-sasl-digest-md5.c: iconv() returns a size_t, not an int. + + * camel-pgp-context.c: The return value of iconv() is a size_t, + not an int. + + * camel-mime-part-utils.c (convert_buffer): Always use size_t args + for iconv(). + + * camel-mime-filter-charset.c (complete): Always use size_t args + for iconv(). + (filter): Same. + + * camel-mime-utils.c (header_address_fold): Make headerlen a + size_t instead of an int. + (header_fold): Same. + (base64_encode_close): We should be returning a size_t and inlen + should also be a size_t. + (base64_encode_step): Same here. + (base64_decode_step): Here too. + (base64_encode_simple): And here... + (base64_decode_simple): Same. + (uuencode_close): We should also use size_t's here... + (uuencode_step): And here too. + (uudecode_step): And also here. + (quoted_encode_close): Same idea here. + (quoted_encode_step): Again here. + (quoted_decode_step): Here too. + (quoted_encode): Input length should be a size_t. + (rfc2047_decode_word): Same. + (g_string_append_len): Here too. + (append_8bit): " + (rfc2047_encode_word): " + (quote_word): " + (hex_decode): " + (rfc2184_decode): Use size_t's with iconv(). + (header_decode_param): Same. + 2001-12-09 Jon Trowbridge <trow@ximian.com> * camel-folder-summary.c: Add "NeedsReply" to the flag_names array diff --git a/camel/camel-cipher-context.c b/camel/camel-cipher-context.c index 2a7b8864b6..feefff5565 100644 --- a/camel/camel-cipher-context.c +++ b/camel/camel-cipher-context.c @@ -28,8 +28,6 @@ #include <glib.h> -#include <iconv.h> - #ifdef ENABLE_THREADS #include <pthread.h> #define CIPHER_LOCK(ctx) g_mutex_lock (((CamelCipherContext *) ctx)->priv->lock) diff --git a/camel/camel-mime-filter-basic.c b/camel/camel-mime-filter-basic.c index ff21ad9609..4f56f46bba 100644 --- a/camel/camel-mime-filter-basic.c +++ b/camel/camel-mime-filter-basic.c @@ -96,7 +96,7 @@ static void complete(CamelMimeFilter *mf, char *in, size_t len, size_t prespace, char **out, size_t *outlen, size_t *outprespace) { CamelMimeFilterBasic *f = (CamelMimeFilterBasic *)mf; - int newlen; + size_t newlen; switch(f->type) { case CAMEL_MIME_FILTER_BASIC_BASE64_ENC: @@ -160,8 +160,8 @@ static void filter(CamelMimeFilter *mf, char *in, size_t len, size_t prespace, char **out, size_t *outlen, size_t *outprespace) { CamelMimeFilterBasic *f = (CamelMimeFilterBasic *)mf; - int newlen; - + size_t newlen; + switch(f->type) { case CAMEL_MIME_FILTER_BASIC_BASE64_ENC: /* wont go to more than 2x size (overly conservative) */ @@ -188,9 +188,9 @@ filter(CamelMimeFilter *mf, char *in, size_t len, size_t prespace, char **out, s break; case CAMEL_MIME_FILTER_BASIC_QP_DEC: /* output can't possibly exceed the input size */ - camel_mime_filter_set_size(mf, len, FALSE); + camel_mime_filter_set_size(mf, len + 2, FALSE); newlen = quoted_decode_step(in, len, mf->outbuf, &f->state, &f->save); - g_assert(newlen <= len); + g_assert(newlen <= len + 2); break; case CAMEL_MIME_FILTER_BASIC_UU_DEC: if (!f->uu_begin) { diff --git a/camel/camel-mime-filter-charset.c b/camel/camel-mime-filter-charset.c index 537b93c5ff..d3a02ffd15 100644 --- a/camel/camel-mime-filter-charset.c +++ b/camel/camel-mime-filter-charset.c @@ -74,7 +74,7 @@ reset(CamelMimeFilter *mf) CamelMimeFilterCharset *f = (CamelMimeFilterCharset *)mf; char buf[16]; char *buffer; - int outlen = 16; + size_t outlen = 16; /* what happens with the output bytes if this resets the state? */ if (f->ic != (iconv_t) -1) { @@ -87,11 +87,10 @@ static void complete(CamelMimeFilter *mf, char *in, size_t len, size_t prespace, char **out, size_t *outlenptr, size_t *outprespace) { CamelMimeFilterCharset *f = (CamelMimeFilterCharset *)mf; - int converted; + size_t converted, inlen, outlen; const char *inbuf; char *outbuf; - int inlen, outlen; - + if (f->ic == (iconv_t) -1) { goto donothing; } @@ -110,7 +109,7 @@ complete(CamelMimeFilter *mf, char *in, size_t len, size_t prespace, char **out, if (inlen>0) { converted = e_iconv(f->ic, &inbuf, &inlen, &outbuf, &outlen); - if (converted == -1) { + if (converted == (size_t) -1) { if (errno != EINVAL) { g_warning("error occured converting: %s", strerror(errno)); goto donothing; @@ -125,7 +124,7 @@ complete(CamelMimeFilter *mf, char *in, size_t len, size_t prespace, char **out, /* this 'resets' the output stream, returning back to the initial shift state for multishift charactersets */ converted = e_iconv(f->ic, NULL, 0, &outbuf, &outlen); - if (converted == -1) { + if (converted == (size_t) -1) { g_warning("Conversion failed to complete: %s", strerror(errno)); } @@ -153,10 +152,9 @@ static void filter(CamelMimeFilter *mf, char *in, size_t len, size_t prespace, char **out, size_t *outlenptr, size_t *outprespace) { CamelMimeFilterCharset *f = (CamelMimeFilterCharset *)mf; - int converted; + size_t converted, inlen, outlen; const char *inbuf; char *outbuf; - int inlen, outlen; if (f->ic == (iconv_t) -1) { goto donothing; @@ -169,7 +167,7 @@ filter(CamelMimeFilter *mf, char *in, size_t len, size_t prespace, char **out, s outbuf = mf->outbuf; outlen = mf->outsize; converted = e_iconv(f->ic, &inbuf, &inlen, &outbuf, &outlen); - if (converted == -1) { + if (converted == (size_t) -1) { if (errno != EINVAL) { g_warning("error occured converting: %s", strerror(errno)); goto donothing; diff --git a/camel/camel-mime-filter.h b/camel/camel-mime-filter.h index 6d0821014c..76f20ff7f6 100644 --- a/camel/camel-mime-filter.h +++ b/camel/camel-mime-filter.h @@ -41,12 +41,12 @@ struct _CamelMimeFilter { char *outreal; /* real malloc'd buffer */ char *outbuf; /* first 'writable' position allowed (outreal + outpre) */ char *outptr; - int outsize; - int outpre; /* prespace of this buffer */ + size_t outsize; + size_t outpre; /* prespace of this buffer */ char *backbuf; - int backsize; - int backlen; /* significant data there */ + size_t backsize; + size_t backlen; /* significant data there */ }; struct _CamelMimeFilterClass { diff --git a/camel/camel-mime-part-utils.c b/camel/camel-mime-part-utils.c index 131667e696..65c99c6dc8 100644 --- a/camel/camel-mime-part-utils.c +++ b/camel/camel-mime-part-utils.c @@ -101,10 +101,11 @@ static GByteArray * convert_buffer (GByteArray *in, const char *to, const char *from) { iconv_t ic; - int inlen, outlen, i=2; + size_t inlen, outlen; char *inbuf, *outbuf; char *buffer; GByteArray *out = NULL; + int i = 2; d(printf("converting buffer from %s to %s: '%.*s'\n", from, to, (int)in->len, in->data)); @@ -123,7 +124,7 @@ convert_buffer (GByteArray *in, const char *to, const char *from) inlen = in->len; outbuf = buffer; - if (e_iconv(ic, (const char **)&inbuf, &inlen, &outbuf, &outlen) == -1) { + if (e_iconv(ic, (const char **)&inbuf, &inlen, &outbuf, &outlen) == (size_t) -1) { g_free(buffer); g_warning("conversion failed: %s", strerror(errno)); /* we didn't have enough space */ @@ -140,7 +141,7 @@ convert_buffer (GByteArray *in, const char *to, const char *from) /* close off the conversion */ outbuf = buffer; outlen = in->len * i + 16; - if (e_iconv(ic, NULL, 0, &outbuf, &outlen) != -1) + if (e_iconv(ic, NULL, 0, &outbuf, &outlen) != (size_t) -1) g_byte_array_append(out, buffer, (in->len*i+16) - outlen); g_free(buffer); @@ -157,7 +158,7 @@ convert_buffer (GByteArray *in, const char *to, const char *from) static gboolean is_7bit (GByteArray *buffer) { - register int i; + register unsigned int i; for (i = 0; i < buffer->len; i++) if (buffer->data[i] > 127) diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c index 674fab7cbc..0d14cb035d 100644 --- a/camel/camel-mime-utils.c +++ b/camel/camel-mime-utils.c @@ -206,8 +206,8 @@ base64_init(void) /* call this when finished encoding everything, to flush off the last little bit */ -int -base64_encode_close(unsigned char *in, int inlen, gboolean break_lines, unsigned char *out, int *state, int *save) +size_t +base64_encode_close(unsigned char *in, size_t inlen, gboolean break_lines, unsigned char *out, int *state, int *save) { int c1, c2; unsigned char *outptr = out; @@ -251,8 +251,8 @@ base64_encode_close(unsigned char *in, int inlen, gboolean break_lines, unsigned output at a time, saves left-over state in state and save (initialise to 0 on first invocation). */ -int -base64_encode_step(unsigned char *in, int len, gboolean break_lines, unsigned char *out, int *state, int *save) +size_t +base64_encode_step(unsigned char *in, size_t len, gboolean break_lines, unsigned char *out, int *state, int *save) { register unsigned char *inptr, *outptr; @@ -337,8 +337,8 @@ base64_encode_step(unsigned char *in, int len, gboolean break_lines, unsigned ch * * Decodes a chunk of base64 encoded data **/ -int -base64_decode_step(unsigned char *in, int len, unsigned char *out, int *state, unsigned int *save) +size_t +base64_decode_step(unsigned char *in, size_t len, unsigned char *out, int *state, unsigned int *save) { register unsigned char *inptr, *outptr; unsigned char *inend, c; @@ -386,7 +386,7 @@ base64_decode_step(unsigned char *in, int len, unsigned char *out, int *state, u } char * -base64_encode_simple (const char *data, int len) +base64_encode_simple (const char *data, size_t len) { unsigned char *out; int state = 0, outlen; @@ -399,8 +399,8 @@ base64_encode_simple (const char *data, int len) return (char *)out; } -int -base64_decode_simple (char *data, int len) +size_t +base64_decode_simple (char *data, size_t len) { int state = 0; unsigned int save = 0; @@ -424,8 +424,8 @@ base64_decode_simple (char *data, int len) * encoding data with uuencode_step to flush off the last little * bit. **/ -int -uuencode_close (unsigned char *in, int len, unsigned char *out, unsigned char *uubuf, int *state, guint32 *save, char *uulen) +size_t +uuencode_close (unsigned char *in, size_t len, unsigned char *out, unsigned char *uubuf, int *state, guint32 *save, char *uulen) { register unsigned char *outptr, *bufptr; register guint32 saved; @@ -497,8 +497,8 @@ uuencode_close (unsigned char *in, int len, unsigned char *out, unsigned char *u * left-over state in @uubuf, @state and @save (initialize to 0 on first * invocation). **/ -int -uuencode_step (unsigned char *in, int len, unsigned char *out, unsigned char *uubuf, int *state, guint32 *save, char *uulen) +size_t +uuencode_step (unsigned char *in, size_t len, unsigned char *out, unsigned char *uubuf, int *state, guint32 *save, char *uulen) { register unsigned char *inptr, *outptr, *bufptr; unsigned char *inend; @@ -575,8 +575,8 @@ uuencode_step (unsigned char *in, int len, unsigned char *out, unsigned char *uu * a chunk of uuencoded data. Assumes the "begin <mode> <file name>" * line has been stripped off. **/ -int -uudecode_step (unsigned char *in, int len, unsigned char *out, int *state, guint32 *save, char *uulen) +size_t +uudecode_step (unsigned char *in, size_t len, unsigned char *out, int *state, guint32 *save, char *uulen) { register unsigned char *inptr, *outptr; unsigned char *inend, ch; @@ -652,8 +652,8 @@ uudecode_step (unsigned char *in, int len, unsigned char *out, int *state, guint /* complete qp encoding */ -int -quoted_encode_close(unsigned char *in, int len, unsigned char *out, int *state, int *save) +size_t +quoted_encode_close(unsigned char *in, size_t len, unsigned char *out, int *state, int *save) { register unsigned char *outptr = out; int last; @@ -681,11 +681,11 @@ quoted_encode_close(unsigned char *in, int len, unsigned char *out, int *state, } /* perform qp encoding, initialise state to -1 and save to 0 on first invocation */ -int -quoted_encode_step (unsigned char *in, int len, unsigned char *out, int *statep, int *save) +size_t +quoted_encode_step (unsigned char *in, size_t len, unsigned char *out, int *statep, int *save) { register guchar *inptr, *outptr, *inend; - guchar c; + unsigned char c; register int sofar = *save; /* keeps track of how many chars on a line */ register int last = *statep; /* keeps track if last char to end was a space cr etc */ @@ -767,8 +767,8 @@ quoted_encode_step (unsigned char *in, int len, unsigned char *out, int *statep, Note: Trailing rubbish (at the end of input), like = or =x or =\r will be lost. */ -int -quoted_decode_step(unsigned char *in, int len, unsigned char *out, int *savestate, int *saveme) +size_t +quoted_decode_step(unsigned char *in, size_t len, unsigned char *out, int *savestate, int *saveme) { register unsigned char *inptr, *outptr; unsigned char *inend, c; @@ -860,7 +860,7 @@ quoted_decode_step(unsigned char *in, int len, unsigned char *out, int *savestat which is slightly different than plain quoted-printable (mainly by allowing 0x20 <> _) */ static int -quoted_decode(const unsigned char *in, int len, unsigned char *out) +quoted_decode(const unsigned char *in, size_t len, unsigned char *out) { register const unsigned char *inptr; register unsigned char *outptr; @@ -907,7 +907,7 @@ quoted_decode(const unsigned char *in, int len, unsigned char *out) /* safemask is the mask to apply to the camel_mime_special_table to determine what characters can safely be included without encoding */ static int -quoted_encode(const unsigned char *in, int len, unsigned char *out, unsigned short safemask) +quoted_encode (const unsigned char *in, size_t len, unsigned char *out, unsigned short safemask) { register const unsigned char *inptr, *inend; unsigned char *outptr; @@ -971,7 +971,7 @@ header_decode_lwsp(const char **in) /* decode rfc 2047 encoded string segment */ static char * -rfc2047_decode_word(const char *in, int len) +rfc2047_decode_word(const char *in, size_t len) { const char *inptr = in+2; const char *inend = in+len-2; @@ -979,12 +979,12 @@ rfc2047_decode_word(const char *in, int len) const char *charset; char *encname, *p; int tmplen; - int ret; + size_t ret; char *decword = NULL; char *decoded = NULL; char *outbase = NULL; char *outbuf; - int inlen, outlen; + size_t inlen, outlen; gboolean retried = FALSE; iconv_t ic; @@ -1049,9 +1049,9 @@ rfc2047_decode_word(const char *in, int len) retry: ic = e_iconv_open ("UTF-8", charset); - if (ic != (iconv_t)-1) { + if (ic != (iconv_t) -1) { ret = e_iconv (ic, &inbuf, &inlen, &outbuf, &outlen); - if (ret >= 0) { + if (ret != (size_t) -1) { e_iconv (ic, NULL, 0, &outbuf, &outlen); *outbuf = 0; decoded = g_strdup (outbase); @@ -1083,7 +1083,7 @@ rfc2047_decode_word(const char *in, int len) /* grrr, glib should have this ! */ static GString * -g_string_append_len(GString *st, const char *s, int l) +g_string_append_len(GString *st, const char *s, size_t l) { char *tmp; @@ -1098,7 +1098,7 @@ g_string_append_len(GString *st, const char *s, int l) according to the rfc's. Anyway, since the conversion to utf-8 is trivial, just do it here without iconv */ static GString * -append_latin1 (GString *out, const char *in, int len) +append_latin1 (GString *out, const char *in, size_t len) { unsigned int c; @@ -1116,10 +1116,10 @@ append_latin1 (GString *out, const char *in, int len) } static int -append_8bit (GString *out, const char *inbuf, int inlen, const char *charset) +append_8bit (GString *out, const char *inbuf, size_t inlen, const char *charset) { char *outbase, *outbuf; - int outlen; + size_t outlen; iconv_t ic; ic = e_iconv_open ("UTF-8", charset); @@ -1128,8 +1128,8 @@ append_8bit (GString *out, const char *inbuf, int inlen, const char *charset) outlen = inlen * 6 + 16; outbuf = outbase = g_malloc(outlen); - - if (e_iconv(ic, &inbuf, &inlen, &outbuf, &outlen) == -1) { + + if (e_iconv(ic, &inbuf, &inlen, &outbuf, &outlen) == (size_t) -1) { w(g_warning("Conversion to '%s' failed: %s", charset, strerror(errno))); g_free(outbase); e_iconv_close(ic); @@ -1147,7 +1147,7 @@ append_8bit (GString *out, const char *inbuf, int inlen, const char *charset) /* decodes a simple text, rfc822 + rfc2047 */ static char * -header_decode_text (const char *in, int inlen, const char *default_charset) +header_decode_text (const char *in, size_t inlen, const char *default_charset) { GString *out; const char *inptr, *inend, *start, *chunk, *locale_charset; @@ -1214,7 +1214,7 @@ header_decode_string (const char *in, const char *default_charset) /* FIXME: needs a way to cache iconv opens for different charsets? */ static void -rfc2047_encode_word(GString *outstring, const char *in, int len, const char *type, unsigned short safemask) +rfc2047_encode_word(GString *outstring, const char *in, size_t len, const char *type, unsigned short safemask) { iconv_t ic = (iconv_t *)-1; char *buffer, *out, *ascii; @@ -1236,8 +1236,9 @@ rfc2047_encode_word(GString *outstring, const char *in, int len, const char *typ ic = e_iconv_open (type, "UTF-8"); while (inlen) { - int convlen, i, proclen; - + size_t convlen, proclen; + int i; + /* break up words into smaller bits, what we really want is encoded + overhead < 75, but we'll just guess what that means in terms of input chars, and assume its good enough */ @@ -1280,7 +1281,7 @@ rfc2047_encode_word(GString *outstring, const char *in, int len, const char *typ hopefully-small-enough chunks, and leave it at that */ convlen = MIN(inlen, CAMEL_FOLD_PREENCODED); p = inptr; - if (e_iconv(ic, &inptr, &convlen, &out, &outlen) == -1) { + if (e_iconv (ic, &inptr, &convlen, &out, &outlen) == (size_t) -1) { w(g_warning("Conversion problem: conversion truncated: %s", strerror(errno))); /* blah, we include it anyway, better than infinite loop ... */ inptr = p + convlen; @@ -1445,7 +1446,7 @@ header_encode_string (const unsigned char *in) /* apply quoted-string rules to a string */ static void -quote_word(GString *out, gboolean do_quotes, const char *start, int len) +quote_word(GString *out, gboolean do_quotes, const char *start, size_t len) { int i, c; @@ -1634,7 +1635,7 @@ header_encode_phrase (const unsigned char *in) wordl = words; while (wordl) { const char *start; - int len; + size_t len; word = wordl->data; @@ -1728,7 +1729,7 @@ header_decode_quoted_string(const char **in) { const char *inptr = *in; char *out = NULL, *outptr; - int outlen; + size_t outlen; int c; header_decode_lwsp(&inptr); @@ -1826,10 +1827,10 @@ header_decode_int(const char **in) #define HEXVAL(c) (isdigit (c) ? (c) - '0' : tolower (c) - 'a' + 10) static char * -hex_decode (const char *in, int len) +hex_decode (const char *in, size_t len) { - const guchar *inend = (const guchar *) in + len; - guchar *inptr, *outptr; + const unsigned char *inend = in + len; + unsigned char *inptr, *outptr; char *outbuf; outptr = outbuf = g_malloc (len); @@ -1856,7 +1857,7 @@ hex_decode (const char *in, int len) */ static char * -rfc2184_decode (const char *in, int len) +rfc2184_decode (const char *in, size_t len) { const char *inptr = in; const char *inend = in + len; @@ -1880,7 +1881,7 @@ rfc2184_decode (const char *in, int len) if (inptr < inend) { char *decword, *outbase, *outbuf; const char *inbuf; - int inlen, outlen; + size_t inlen, outlen; iconv_t ic; inbuf = decword = hex_decode (inptr, inend - inptr); @@ -1888,13 +1889,13 @@ rfc2184_decode (const char *in, int len) ic = e_iconv_open ("UTF-8", charset); if (ic != (iconv_t) -1) { - int ret; + size_t ret; outlen = inlen * 6 + 16; outbuf = outbase = g_malloc (outlen); ret = e_iconv (ic, &inbuf, &inlen, &outbuf, &outlen); - if (ret >= 0) { + if (ret != (size_t) -1) { e_iconv (ic, NULL, 0, &outbuf, &outlen); *outbuf = '\0'; g_free (decoded); @@ -2034,7 +2035,7 @@ header_decode_param (const char **in, char **paramp, char **valuep, int *is_rfc2 * locale and converting to utf8 */ char *outbase, *outbuf, *p; const char *charset, *inbuf; - int inlen, outlen; + size_t inlen, outlen; iconv_t ic; inbuf = value; @@ -2043,13 +2044,13 @@ header_decode_param (const char **in, char **paramp, char **valuep, int *is_rfc2 charset = e_iconv_locale_charset (); ic = e_iconv_open ("UTF-8", charset ? charset : "ISO-8859-1"); if (ic != (iconv_t) -1) { - int ret; + size_t ret; outlen = inlen * 6 + 16; outbuf = outbase = g_malloc (outlen); ret = e_iconv (ic, &inbuf, &inlen, &outbuf, &outlen); - if (ret >= 0) { + if (ret != (size_t) -1) { e_iconv (ic, NULL, 0, &outbuf, &outlen); *outbuf = '\0'; } @@ -2362,8 +2363,9 @@ header_decode_mailbox(const char **in) pre = header_decode_word(&inptr); if (pre) { - int l = strlen(last); - int p = strlen(pre); + size_t l = strlen (last); + size_t p = strlen (pre); + /* dont append ' ' between sucsessive encoded words */ if ((l>6 && last[l-2] == '?' && last[l-1] == '=') && (p>6 && pre[0] == '=' && pre[1] == '?')) { @@ -2967,7 +2969,7 @@ header_param_list_format_append (GString *out, struct _header_param *p) gboolean encoded = FALSE; gboolean quote = FALSE; int here = out->len; - int nlen, vlen; + size_t nlen, vlen; char *value; if (!p->value) { @@ -3158,9 +3160,19 @@ header_content_type_format(struct _header_content_type *ct) } char * -header_content_type_simple(struct _header_content_type *ct) +header_content_type_simple (struct _header_content_type *ct) { - return g_strdup_printf("%s/%s", ct->type, ct->subtype); + if (ct->type == NULL) { + w(g_warning ("Content-Type with no main type")); + return g_strdup ("text/plain"); + } else if (ct->subtype == NULL) { + w(g_warning ("Content-Type with no sub type: %s", ct->type)); + if (!strcasecmp (ct->type, "multipart")) + return g_strdup_printf ("%s/mixed", ct->type); + else + return g_strdup (ct->type); + } else + return g_strdup_printf ("%s/%s", ct->type, ct->subtype); } char * @@ -3472,7 +3484,7 @@ void header_raw_append_parse(struct _header_raw **list, const char *header, int offset) { register const char *in; - int fieldlen; + size_t fieldlen; char *name; in = header; @@ -3630,8 +3642,8 @@ header_msgid_generate (void) #define COUNT_LOCK() #define COUNT_UNLOCK() #endif /* ENABLE_THREADS */ - static gint count = 0; - gint hrv; + static int count = 0; + int hrv; char *ret; hrv = gethostname (host, sizeof (host)); @@ -3935,13 +3947,13 @@ header_address_list_format(struct _header_address *a) } char * -header_address_fold (const char *in, int headerlen) +header_address_fold (const char *in, size_t headerlen) { - int len, outlen, i; + size_t len, outlen; const char *inptr = in, *space, *p, *n; GString *out; char *ret; - int needunfold = FALSE; + int i, needunfold = FALSE; if (in == NULL) return NULL; @@ -4011,9 +4023,9 @@ header_address_fold (const char *in, int headerlen) /* simple header folding */ /* will work even if the header is already folded */ char * -header_fold(const char *in, int headerlen) +header_fold(const char *in, size_t headerlen) { - int len, outlen, i; + size_t len, outlen, i; const char *inptr = in, *space, *p, *n; GString *out; char *ret; diff --git a/camel/camel-mime-utils.h b/camel/camel-mime-utils.h index 77dcae8430..fcd1a06fa5 100644 --- a/camel/camel-mime-utils.h +++ b/camel/camel-mime-utils.h @@ -148,8 +148,8 @@ void header_raw_clear(struct _header_raw **list); char *header_raw_check_mailing_list(struct _header_raw **list); /* fold a header */ -char *header_address_fold (const char *in, int headerlen); -char *header_fold (const char *in, int headerlen); +char *header_address_fold (const char *in, size_t headerlen); +char *header_fold (const char *in, size_t headerlen); char *header_unfold (const char *in); /* decode a header which is a simple token */ @@ -186,23 +186,24 @@ char *header_location_decode(const char *in); void header_mime_decode(const char *in, int *maj, int *min); /* do incremental base64/quoted-printable (de/en)coding */ -int base64_decode_step(unsigned char *in, int len, unsigned char *out, int *state, unsigned int *save); +size_t base64_decode_step(unsigned char *in, size_t len, unsigned char *out, int *state, unsigned int *save); -int base64_encode_step(unsigned char *in, int len, gboolean break_lines, unsigned char *out, int *state, int *save); -int base64_encode_close(unsigned char *in, int inlen, gboolean break_lines, unsigned char *out, int *state, int *save); +size_t base64_encode_step(unsigned char *in, size_t len, gboolean break_lines, unsigned char *out, int *state, int *save); +size_t base64_encode_close(unsigned char *in, size_t len, gboolean break_lines, unsigned char *out, int *state, int *save); -int uudecode_step (unsigned char *in, int len, unsigned char *out, int *state, guint32 *save, char *uulen); -int uuencode_step (unsigned char *in, int len, unsigned char *out, unsigned char *uubuf, int *state, - guint32 *save, char *uulen); -int uuencode_close (unsigned char *in, int len, unsigned char *out, unsigned char *uubuf, int *state, - guint32 *save, char *uulen); +size_t uudecode_step (unsigned char *in, size_t len, unsigned char *out, int *state, guint32 *save, char *uulen); -int quoted_decode_step(unsigned char *in, int len, unsigned char *out, int *savestate, int *saveme); +size_t uuencode_step (unsigned char *in, size_t len, unsigned char *out, unsigned char *uubuf, int *state, + guint32 *save, char *uulen); +size_t uuencode_close (unsigned char *in, size_t len, unsigned char *out, unsigned char *uubuf, int *state, + guint32 *save, char *uulen); -int quoted_encode_step(unsigned char *in, int len, unsigned char *out, int *state, int *save); -int quoted_encode_close(unsigned char *in, int len, unsigned char *out, int *state, int *save); +size_t quoted_decode_step(unsigned char *in, size_t len, unsigned char *out, int *savestate, int *saveme); -char *base64_encode_simple (const char *data, int len); -int base64_decode_simple (char *data, int len); +size_t quoted_encode_step(unsigned char *in, size_t len, unsigned char *out, int *state, int *save); +size_t quoted_encode_close(unsigned char *in, size_t len, unsigned char *out, int *state, int *save); + +char *base64_encode_simple (const char *data, size_t len); +size_t base64_decode_simple (char *data, size_t len); #endif /* ! _CAMEL_MIME_UTILS_H */ diff --git a/camel/camel-pgp-context.c b/camel/camel-pgp-context.c index e754fdc670..16b3ea72b7 100644 --- a/camel/camel-pgp-context.c +++ b/camel/camel-pgp-context.c @@ -1066,11 +1066,11 @@ pgp_verify (CamelCipherContext *ctx, CamelCipherHash hash, CamelStream *istream, cd = e_iconv_open ("UTF-8", locale); if (cd != (iconv_t) -1) { const char *inbuf; - int ret; + size_t ret; inbuf = diagnostics; ret = e_iconv (cd, &inbuf, &inlen, &outbuf, &outlen); - if (ret >= 0) { + if (ret != (size_t) -1) { e_iconv (cd, NULL, 0, &outbuf, &outlen); } e_iconv_close (cd); diff --git a/camel/camel-sasl-digest-md5.c b/camel/camel-sasl-digest-md5.c index 28cc081ab0..a88612de7b 100644 --- a/camel/camel-sasl-digest-md5.c +++ b/camel/camel-sasl-digest-md5.c @@ -709,7 +709,7 @@ digest_response (struct _DigestResponse *resp) outbuf = username = g_malloc0 (outlen + 1); buf = resp->username; - if (cd == (iconv_t) -1 || e_iconv (cd, &buf, &len, &outbuf, &outlen) == -1) { + if (cd == (iconv_t) -1 || e_iconv (cd, &buf, &len, &outbuf, &outlen) == (size_t) -1) { /* We can't convert to UTF-8 - pretend we never got a charset param? */ g_free (resp->charset); resp->charset = NULL; diff --git a/camel/camel-stream-filter.c b/camel/camel-stream-filter.c index 2e782d03c1..b325aea1f1 100644 --- a/camel/camel-stream-filter.c +++ b/camel/camel-stream-filter.c @@ -306,8 +306,9 @@ do_flush (CamelStream *stream) struct _CamelStreamFilterPrivate *p = _PRIVATE(filter); struct _filter *f; char *buffer; - int len, presize; - + int presize; + size_t len; + if (p->last_was_read) { g_warning("Flushing a filter stream without writing to it"); return 0; |