*AddrPtr = 0;
i = 0;
while (!IsEmptyStr (&source[i])) {
- if (nColons > nAddrPtrMax){
+ if (nColons >= nAddrPtrMax){
long *ptr;
ptr = (long *) malloc(sizeof (long) * nAddrPtrMax * 2);
memcpy (ptr, AddrPtr, sizeof (long) * nAddrPtrMax);
free (AddrPtr), AddrPtr = ptr;
+
ptr = (long *) malloc(sizeof (long) * nAddrPtrMax * 2);
- memset(ptr + sizeof (long) * nAddrPtrMax, 0, sizeof (long) * nAddrPtrMax - 1);
+ memset(&ptr[nAddrPtrMax], 0,
+ sizeof (long) * nAddrPtrMax);
+
memcpy (ptr, AddrUtf8, sizeof (long) * nAddrPtrMax);
free (AddrUtf8), AddrUtf8 = ptr;
nAddrPtrMax *= 2;
if (source[i] == '"')
InQuotes = !InQuotes;
if (!InQuotes && source[i] == ',') {
- nColons++;
AddrPtr[nColons] = i;
+ nColons++;
}
i++;
}
EncodedMaxLen = nColons * (sizeof(headerStr) + 3) + SourceLen * 3;
Encoded = (char*) malloc (EncodedMaxLen);
- for (i = 1; i <= nColons; i++)
+ for (i = 0; i < nColons; i++)
source[AddrPtr[i]++] = '\0';
nPtr = Encoded;
*nPtr = '\0';
- for (i = 0; i <= nColons && nPtr != NULL; i++) {
+ for (i = 0; i < nColons && nPtr != NULL; i++) {
nmax = EncodedMaxLen - (nPtr - Encoded);
if (AddrUtf8[i]) {
process_rfc822_addr(&source[AddrPtr[i]],
i--; /* do it once more with properly lengthened buffer */
}
}
- for (i = 1; i <= nColons; i++)
+ for (i = 0; i < nColons; i++)
source[--AddrPtr[i]] = ',';
free(AddrUtf8);
free(AddrPtr);
if (!is_valid_message(TheMessage)) {
CtdlLogPrintf(CTDL_ERR,
"ERROR: invalid preloaded message for output\n");
+ cit_backtrace ();
return(om_no_such_msg);
}
else if (i == 'P') {
cprintf("Return-Path: %s%s", mptr, nl);
}
+ else if (i == 'L') {
+ cprintf("List-ID: %s%s", mptr, nl);
+ }
else if (i == 'V') {
if ((flags & QP_EADDR) != 0)
mptr = qp_encode_email_addrs(mptr);
* Note: this could be much more efficient. Right now we use two temporary
* files, and still pull the message into memory as with all others.
*/
-void CtdlWriteObject(char *req_room, /* Room to stuff it in */
- char *content_type, /* MIME type of this object */
- char *tempfilename, /* Where to fetch it from */
+void CtdlWriteObject(char *req_room, /* Room to stuff it in */
+ char *content_type, /* MIME type of this object */
+ char *raw_message, /* Data to be written */
+ off_t raw_length, /* Size of raw_message */
struct ctdluser *is_mailbox, /* Mailbox room? */
- int is_binary, /* Is encoding necessary? */
- int is_unique, /* Del others of this type? */
- unsigned int flags /* Internal save flags */
+ int is_binary, /* Is encoding necessary? */
+ int is_unique, /* Del others of this type? */
+ unsigned int flags /* Internal save flags */
)
{
- FILE *fp;
struct ctdlroom qrbuf;
char roomname[ROOMNAMELEN];
struct CtdlMessage *msg;
-
- char *raw_message = NULL;
char *encoded_message = NULL;
- off_t raw_length = 0;
if (is_mailbox != NULL) {
MailboxName(roomname, sizeof roomname, is_mailbox, req_room);
safestrncpy(roomname, req_room, sizeof(roomname));
}
- fp = fopen(tempfilename, "rb");
- if (fp == NULL) {
- CtdlLogPrintf(CTDL_CRIT, "Cannot open %s: %s\n",
- tempfilename, strerror(errno));
- return;
- }
- fseek(fp, 0L, SEEK_END);
- raw_length = ftell(fp);
- rewind(fp);
CtdlLogPrintf(CTDL_DEBUG, "Raw length is %ld\n", (long)raw_length);
- raw_message = malloc((size_t)raw_length + 2);
- fread(raw_message, (size_t)raw_length, 1, fp);
- fclose(fp);
-
if (is_binary) {
- encoded_message = malloc((size_t)
- (((raw_length * 134) / 100) + 4096 ) );
+ encoded_message = malloc((size_t) (((raw_length * 134) / 100) + 4096 ) );
}
else {
encoded_message = malloc((size_t)(raw_length + 4096));
);
}
else {
- raw_message[raw_length] = 0;
memcpy(
&encoded_message[strlen(encoded_message)],
raw_message,
);
}
- free(raw_message);
-
CtdlLogPrintf(CTDL_DEBUG, "Allocating\n");
msg = malloc(sizeof(struct CtdlMessage));
memset(msg, 0, sizeof(struct CtdlMessage));
return(conf);
}
-void CtdlPutSysConfig(char *sysconfname, char *sysconfdata) {
- char temp[PATH_MAX];
- FILE *fp;
- CtdlMakeTempFileName(temp, sizeof temp);
-
- fp = fopen(temp, "w");
- if (fp == NULL) return;
- fprintf(fp, "%s", sysconfdata);
- fclose(fp);
-
- /* this handy API function does all the work for us */
- CtdlWriteObject(SYSCONFIGROOM, sysconfname, temp, NULL, 0, 1, 0);
- unlink(temp);
+void CtdlPutSysConfig(char *sysconfname, char *sysconfdata) {
+ CtdlWriteObject(SYSCONFIGROOM, sysconfname, sysconfdata, (strlen(sysconfdata)+1), NULL, 0, 1, 0);
}