]> code.citadel.org Git - citadel.git/blobdiff - citadel/internet_addressing.c
* fix off by one while copying email headers
[citadel.git] / citadel / internet_addressing.c
index 1a8bdea1253b06bc1e1c7226f5506dacc131c5fe..ce8337f859bde64855d9ba0799f15937755f9dab 100644 (file)
@@ -564,7 +564,7 @@ int convert_field(struct CtdlMessage *msg, const char *beg, const char *end) {
                if (*pos == ':') colonpos = pos;
        }
 
-       if (colonpos < 0) return(0);    /* no colon? not a valid header line */
+       if (colonpos == NULL) return(0);        /* no colon? not a valid header line */
 
        len = end - beg;
        key = malloc(len + 2);
@@ -574,7 +574,7 @@ int convert_field(struct CtdlMessage *msg, const char *beg, const char *end) {
        * ( key + (colonpos - beg) ) = '\0';
        value = &key[(colonpos - beg) + 1];
        unfold_rfc822_field(&value, &valueend);
-       valuelen = valueend - value;
+       valuelen = valueend - value + 1;
 
        /*
         * Here's the big rfc822-to-citadel loop.
@@ -804,6 +804,7 @@ struct CtdlMessage *convert_internet_message_buf(StrBuf **rfc822)
                if (pos >= totalend)
                        alldone = 1;
        }
+       StrBufAppendBufPlain(OtherHeaders, HKEY("\n"), 0);
        if (pos < totalend)
                StrBufAppendBufPlain(OtherHeaders, pos, totalend - pos, 0);
        FreeStrBuf(rfc822);
@@ -836,11 +837,11 @@ struct CtdlMessage *convert_internet_message_buf(StrBuf **rfc822)
  * The caller is responsible for freeing the returned buffer.  If the requested
  * field is not present, or anything else goes wrong, it returns NULL.
  */
-char *rfc822_fetch_field(char *rfc822, char *fieldname) {
+char *rfc822_fetch_field(char *rfc822, const char *fieldname) {
        char *fieldbuf = NULL;
-       char *end_of_headers;
-       char *field_start;
-       char *ptr;
+       const char *end_of_headers;
+       const char *field_start;
+       const char *ptr;
        char *cont;
        char fieldhdr[SIZ];