char buf[SIZ];
char *ptr;
size_t headers_size, text_size, total_size;
- size_t bytes_to_send;
+ size_t bytes_to_send = 0;
+ struct MetaData smi;
+ int need_to_rewrite_metadata = 0;
+ /* If this is an RFC822.SIZE fetch, first look in the message's
+ * metadata record to see if we've saved that information.
+ */
+ if (!strcasecmp(whichfmt, "RFC822.SIZE")) {
+ GetMetaData(&smi, msgnum);
+ if (smi.meta_rfc822_length > 0L) {
+ cprintf("RFC822.SIZE %ld", smi.meta_rfc822_length);
+ return;
+ }
+ need_to_rewrite_metadata = 1;
+ }
+
/* Cache the most recent RFC822 FETCH because some clients like to
* fetch in pieces, and we don't want to have to go back to the
* message store for each piece.
CC->redirect_buffer = NULL;
CC->redirect_len = 0;
CC->redirect_alloc = 0;
+ if (need_to_rewrite_metadata) {
+ smi.meta_rfc822_length = (long)IMAP->cached_rfc822_len;
+ PutMetaData(&smi);
+ }
}
/*
* fields. But we can use it for "To" and possibly others.
*/
void imap_output_envelope_addr(char *addr) {
- char individual_addr[SIZ];
+ char individual_addr[256];
int num_addrs;
int i;
- char user[SIZ];
- char node[SIZ];
- char name[SIZ];
+ char user[256];
+ char node[256];
+ char name[256];
if (addr == NULL) {
cprintf("NIL ");
/* Output them one by one. */
for (i=0; i<num_addrs; ++i) {
- extract_token(individual_addr, addr, i, ',');
+ extract_token(individual_addr, addr, i, ',', sizeof individual_addr);
striplt(individual_addr);
process_rfc822_addr(individual_addr, user, node, name);
cprintf("(");
void *cbuserdata
) {
- char subtype[SIZ];
+ char subtype[128];
cprintf(" ");
/* disposition */
- extract_token(subtype, cbtype, 1, '/');
+ extract_token(subtype, cbtype, 1, '/', sizeof subtype);
imap_strout(subtype);
/* body language */
int have_encoding = 0;
int lines = 0;
size_t i;
- char cbmaintype[SIZ];
- char cbsubtype[SIZ];
+ char cbmaintype[128];
+ char cbsubtype[128];
if (cbtype != NULL) if (strlen(cbtype)>0) have_cbtype = 1;
if (have_cbtype) {
- extract_token(cbmaintype, cbtype, 0, '/');
- extract_token(cbsubtype, cbtype, 1, '/');
+ extract_token(cbmaintype, cbtype, 0, '/', sizeof cbmaintype);
+ extract_token(cbsubtype, cbtype, 1, '/', sizeof cbsubtype);
}
else {
strcpy(cbmaintype, "TEXT");
*/
num_sets = num_tokens(actual_range, ',');
for (s=0; s<num_sets; ++s) {
- extract_token(setstr, actual_range, s, ',');
+ extract_token(setstr, actual_range, s, ',', sizeof setstr);
- extract_token(lostr, setstr, 0, ':');
+ extract_token(lostr, setstr, 0, ':', sizeof lostr);
if (num_tokens(setstr, ':') >= 2) {
- extract_token(histr, setstr, 1, ':');
+ extract_token(histr, setstr, 1, ':', sizeof histr);
if (!strcmp(histr, "*")) snprintf(histr, sizeof histr, "%ld", LONG_MAX);
}
else {
- strcpy(histr, lostr);
+ safestrncpy(histr, lostr, sizeof histr);
}
lo = atol(lostr);
hi = atol(histr);