From 7d8f8b748ba6f3889018f67c54245ac9fd938123 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sat, 14 Apr 2001 04:26:44 +0000 Subject: [PATCH] * Fixed an unterminated string bug in IMAP APPEND. Storing messages should work now. --- citadel/ChangeLog | 5 ++++- citadel/imap_misc.c | 5 ++++- citadel/internet_addressing.c | 4 ++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index e24c3da34..7d4c94d09 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,8 @@ $Log$ + Revision 573.125 2001/04/14 04:26:44 ajc + * Fixed an unterminated string bug in IMAP APPEND. Storing messages should + work now. + Revision 573.124 2001/04/10 01:04:10 ajc * Finished coding IMAP APPEND. It works, but there's a bug in it somewhere that is corrupting the memory. @@ -2489,4 +2493,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import - diff --git a/citadel/imap_misc.c b/citadel/imap_misc.c index 40c1cd628..85432bbaa 100644 --- a/citadel/imap_misc.c +++ b/citadel/imap_misc.c @@ -207,7 +207,7 @@ void imap_append(int num_parms, char *parms[]) { } imap_free_transmitted_message(); /* just in case. */ - IMAP->transmitted_message = mallok(literal_length); + IMAP->transmitted_message = mallok(literal_length + 1); if (IMAP->transmitted_message == NULL) { cprintf("%s NO Cannot allocate memory.\r\n", parms[0]); return; @@ -216,6 +216,7 @@ void imap_append(int num_parms, char *parms[]) { cprintf("+ Transmit message now.\r\n"); ret = client_read(IMAP->transmitted_message, literal_length); + IMAP->transmitted_message[literal_length] = 0; if (ret != 1) { cprintf("%s NO Read failed.\r\n", parms[0]); return; @@ -223,6 +224,8 @@ void imap_append(int num_parms, char *parms[]) { lprintf(9, "Converting message...\n"); msg = convert_internet_message(IMAP->transmitted_message); + IMAP->transmitted_message = NULL; + IMAP->transmitted_length = 0; /* If the user is locally authenticated, FORCE the From: header to * show up as the real sender. FIXME do we really want to do this? diff --git a/citadel/internet_addressing.c b/citadel/internet_addressing.c index 7db812b4a..389000713 100644 --- a/citadel/internet_addressing.c +++ b/citadel/internet_addressing.c @@ -489,6 +489,10 @@ int convert_field(struct CtdlMessage *msg, int beg, int end) { /* * Convert an RFC822 message (headers + body) to a CtdlMessage structure. + * NOTE: the supplied buffer becomes part of the CtdlMessage structure, and + * will be deallocated when CtdlFreeMessage() is called. Therefore, the + * supplied buffer should be DEREFERENCED. It should not be freed or used + * again. */ struct CtdlMessage *convert_internet_message(char *rfc822) { -- 2.39.2