aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorNot Zed <NotZed@HelixCode.com>2000-10-17 17:45:38 +0800
committerMichael Zucci <zucchi@src.gnome.org>2000-10-17 17:45:38 +0800
commita8cd947d9bed93078a5edd6a2f483748778422ae (patch)
treeecb7faebf2d79b9c3132cb805533bb951f5604ff /camel
parent97be61b4787ccb3b52a34e625cb5f49c67ace6fe (diff)
downloadgsoc2013-evolution-a8cd947d9bed93078a5edd6a2f483748778422ae.tar
gsoc2013-evolution-a8cd947d9bed93078a5edd6a2f483748778422ae.tar.gz
gsoc2013-evolution-a8cd947d9bed93078a5edd6a2f483748778422ae.tar.bz2
gsoc2013-evolution-a8cd947d9bed93078a5edd6a2f483748778422ae.tar.lz
gsoc2013-evolution-a8cd947d9bed93078a5edd6a2f483748778422ae.tar.xz
gsoc2013-evolution-a8cd947d9bed93078a5edd6a2f483748778422ae.tar.zst
gsoc2013-evolution-a8cd947d9bed93078a5edd6a2f483748778422ae.zip
Added some malloc check debugging stuff.
2000-10-17 Not Zed <NotZed@HelixCode.com> * camel-mime-filter.c: Added some malloc check debugging stuff. * camel-mime-parser.c (struct _header_scan_state): Removed top_part, top_start, and pending. I can't even remember why they were there, and they're not used anymore. * camel-mime-filter-basic.c (filter): Forgot to up the space here too. 2000-10-14 Not Zed <NotZed@HelixCode.com> * camel-mime-filter-basic.c (complete): Ok, so we hit a fixme, 3x just wasn't enough for some sequences. svn path=/trunk/; revision=5962
Diffstat (limited to 'camel')
-rw-r--r--camel/ChangeLog19
-rw-r--r--camel/camel-mime-filter-basic.c8
-rw-r--r--camel/camel-mime-filter.c44
-rw-r--r--camel/camel-mime-parser.c28
4 files changed, 81 insertions, 18 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index fb47c75e5d..d2535a10ed 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,20 @@
+2000-10-17 Not Zed <NotZed@HelixCode.com>
+
+ * camel-mime-filter.c: Added some malloc check debugging stuff.
+
+ * camel-mime-parser.c
+ (struct _header_scan_state): Removed top_part, top_start, and
+ pending. I can't even remember why they were there, and they're
+ not used anymore.
+
+ * camel-mime-filter-basic.c (filter): Forgot to up the space here
+ too.
+
+2000-10-14 Not Zed <NotZed@HelixCode.com>
+
+ * camel-mime-filter-basic.c (complete): Ok, so we hit a fixme, 3x
+ just wasn't enough for some sequences.
+
2000-10-16 Jeffrey Stedfast <fejj@helixcode.com>
* providers/imap/camel-imap-command.c
@@ -46,6 +63,7 @@
the possibility of not getting a LIST response back for the top
level.
+>>>>>>> 1.531
2000-10-12 Dan Winship <danw@helixcode.com>
* providers/imap/camel-imap-summary.c: Simple subclass of
@@ -95,6 +113,7 @@
(camel-mime-parser.c doesn't use this code because of the MEMPOOL
optimization, so nothing was ever actually calling it before.)
+>>>>>>> 1.529
2000-10-11 Not Zed <NotZed@HelixCode.com>
* camel-mime-part.h (struct _CamelMimePart): Removed
diff --git a/camel/camel-mime-filter-basic.c b/camel/camel-mime-filter-basic.c
index 4b351e4ff4..48e2106e35 100644
--- a/camel/camel-mime-filter-basic.c
+++ b/camel/camel-mime-filter-basic.c
@@ -102,8 +102,8 @@ complete(CamelMimeFilter *mf, char *in, size_t len, size_t prespace, char **out,
newlen = base64_encode_close(in, len, mf->outbuf, &f->state, &f->save);
break;
case CAMEL_MIME_FILTER_BASIC_QP_ENC:
- /* FIXME: *3 is probably not quite enough ... */
- camel_mime_filter_set_size(mf, len*3, FALSE);
+ /* *4 is definetly more than needed ... */
+ camel_mime_filter_set_size(mf, len*4, FALSE);
newlen = quoted_encode_close(in, len, mf->outbuf, &f->state, &f->save);
break;
case CAMEL_MIME_FILTER_BASIC_BASE64_DEC:
@@ -146,8 +146,8 @@ filter(CamelMimeFilter *mf, char *in, size_t len, size_t prespace, char **out, s
newlen = base64_encode_step(in, len, mf->outbuf, &f->state, &f->save);
break;
case CAMEL_MIME_FILTER_BASIC_QP_ENC:
- /* FIXME: *3 is probably not quite enough ... */
- camel_mime_filter_set_size(mf, len*3, FALSE);
+ /* *4 is overly conservative, but will do */
+ camel_mime_filter_set_size(mf, len*4, FALSE);
newlen = quoted_encode_step(in, len, mf->outbuf, &f->state, &f->save);
break;
case CAMEL_MIME_FILTER_BASIC_BASE64_DEC:
diff --git a/camel/camel-mime-filter.c b/camel/camel-mime-filter.c
index 678d450af2..9a81dfb452 100644
--- a/camel/camel-mime-filter.c
+++ b/camel/camel-mime-filter.c
@@ -20,6 +20,13 @@
#include "camel-mime-filter.h"
+/*#define MALLOC_CHECK */ /* for some malloc checking, requires mcheck enabled */
+
+/* only suitable for glibc */
+#ifdef MALLOC_CHECK
+#include <mcheck.h>
+#endif
+
struct _CamelMimeFilterPrivate {
char *inbuf;
size_t inlen;
@@ -108,6 +115,28 @@ camel_mime_filter_new (void)
return new;
}
+#ifdef MALLOC_CHECK
+static void
+checkmem(void *p)
+{
+ if (p) {
+ int status = mprobe(p);
+
+ switch (status) {
+ case MCHECK_HEAD:
+ printf("Memory underrun at %p\n", p);
+ abort();
+ case MCHECK_TAIL:
+ printf("Memory overrun at %p\n", p);
+ abort();
+ case MCHECK_FREE:
+ printf("Double free %p\n", p);
+ abort();
+ }
+ }
+}
+#endif
+
static void filter_run(CamelMimeFilter *f,
char *in, size_t len, size_t prespace,
char **out, size_t *outlen, size_t *outprespace,
@@ -117,6 +146,10 @@ static void filter_run(CamelMimeFilter *f,
{
struct _CamelMimeFilterPrivate *p;
+#ifdef MALLOC_CHECK
+ checkmem(f->outreal);
+ checkmem(f->backbuf);
+#endif
/*
here we take a performance hit, if the input buffer doesn't
have the pre-space required. We make a buffer that does ...
@@ -136,6 +169,11 @@ static void filter_run(CamelMimeFilter *f,
prespace = p->inlen - len;
}
+#ifdef MALLOC_CHECK
+ checkmem(f->outreal);
+ checkmem(f->backbuf);
+#endif
+
/* preload any backed up data */
if (f->backlen > 0) {
memcpy(in-f->backlen, f->backbuf, f->backlen);
@@ -146,6 +184,12 @@ static void filter_run(CamelMimeFilter *f,
}
filterfunc(f, in, len, prespace, out, outlen, outprespace);
+
+#ifdef MALLOC_CHECK
+ checkmem(f->outreal);
+ checkmem(f->backbuf);
+#endif
+
}
void camel_mime_filter_filter(CamelMimeFilter *f,
diff --git a/camel/camel-mime-parser.c b/camel/camel-mime-parser.c
index d992af1778..b1c4338760 100644
--- a/camel/camel-mime-parser.c
+++ b/camel/camel-mime-parser.c
@@ -20,6 +20,11 @@
/* What should hopefully be a fast mail parser */
+/* Do not change this code without asking me (Michael Zucchi) first
+
+ There is almost always a reason something was done a certain way.
+ */
+
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@@ -228,11 +233,6 @@ struct _header_scan_state {
int header_start; /* start of last header, or -1 */
- struct _header_scan_stack *top_part; /* top of message header */
- int top_start; /* offset of start */
-
- struct _header_scan_stack *pending; /* if we're pending part info, from the wrong part end */
-
/* filters to apply to all content before output */
int filterid; /* id of next filter */
struct _header_scan_filter *filters;
@@ -1576,12 +1576,12 @@ tail_recurse:
do {
hb = folder_scan_content (s, &state, databuffer, datalength);
+ d(printf ("Content raw: '%.*s'\n", *datalength, *databuffer));
+
if (*datalength > 0) {
- d(printf ("Content raw: '%.*s'\n", *datalength, *databuffer));
-
while (f) {
- camel_mime_filter_filter (f->filter, *databuffer, *datalength, presize,
- databuffer, datalength, &presize);
+ camel_mime_filter_filter(f->filter, *databuffer, *datalength, presize,
+ databuffer, datalength, &presize);
f = f->next;
}
return;
@@ -1589,12 +1589,12 @@ tail_recurse:
} while (hb == h && *datalength > 0);
/* check for any filter completion data */
- while (f) {
- if (*datalength > 0) {
- camel_mime_filter_filter (f->filter, *databuffer, *datalength, presize,
- databuffer, datalength, &presize);
+ if (*datalength > 0) {
+ while (f) {
+ camel_mime_filter_filter(f->filter, *databuffer, *datalength, presize,
+ databuffer, datalength, &presize);
+ f = f->next;
}
- f = f->next;
}
if (*datalength > 0)
return;