* Fixed an unterminated string bug in IMAP APPEND. Storing messages should
authorArt Cancro <ajc@citadel.org>
Sat, 14 Apr 2001 04:26:44 +0000 (04:26 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 14 Apr 2001 04:26:44 +0000 (04:26 +0000)
  work now.

citadel/ChangeLog
citadel/imap_misc.c
citadel/internet_addressing.c

index e24c3da3463f717bfb1a784908e9bab51d9cfc6c..7d4c94d09176926f37b1f848f8a6695f69d2395a 100644 (file)
@@ -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 <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import 
-
index 40c1cd62815a51c5bc5c3d278bc82b267e846106..85432bbaa0450f64d49ec3fdbe1685a2e056d086 100644 (file)
@@ -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?
index 7db812b4ab74803c2bfecb2d4245986c524e9aaa..389000713f78db483d7ce552c7cca14d703341ec 100644 (file)
@@ -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) {