new version that does not suffer from buffer overflow
On 2012.07.13. 15:21, Deniss wrote:
> hello here !
>
diff -ur imap-2007f.orig/src/c-client/mail.c imap-2007f/src/c-client/mail.c
--- imap-2007f.orig/src/c-client/mail.c 2011-07-23 03:20:18.000000000 +0300
+++ imap-2007f/src/c-client/mail.c 2012-07-11 13:28:29.000000000 +0300
@@ -3251,6 +3265,10 @@
{
unsigned long i,j,k,x,y;
for (i = 1; i <= stream->nmsgs; i++) mail_elt (stream,i)->sequence = NIL;
+
+ //MR: this issues sequence lookup mseq and fills cache
+ imap_msgnos (stream, sequence);
+
while (sequence && *sequence){/* while there is something to parse */
if (*sequence == '*') { /* maximum message */
i = stream->nmsgs ? mail_uid (stream,stream->nmsgs) : stream->uid_last;
diff -ur imap-2007f.orig/src/c-client/mail.h imap-2007f/src/c-client/mail.h
--- imap-2007f.orig/src/c-client/mail.h 2011-07-23 03:20:18.000000000 +0300
+++ imap-2007f/src/c-client/mail.h 2012-07-11 13:26:16.000000000 +0300
@@ -1476,6 +1476,8 @@
unsigned long (*uid) (MAILSTREAM *stream,unsigned long msgno);
/* return message number from UID */
unsigned long (*msgno) (MAILSTREAM *stream,unsigned long uid);
+ /* fill cache from UID list */
+ void (*msgnos) (MAILSTREAM *stream, unsigned char *sequence);
/* modify flags */
void (*flag) (MAILSTREAM *stream,char *sequence,char *flag,long flags);
/* per-message modify flags */
--- imap-2007f.orig/src/c-client/imap4r1.c 2011-07-23 03:20:18.000000000
+0300
+++ imap-2007f/src/c-client/imap4r1.c 2012-07-23 16:57:09.000000000 +0300
@@ -180,6 +180,7 @@
long flags);
unsigned long imap_uid (MAILSTREAM *stream,unsigned long msgno);
unsigned long imap_msgno (MAILSTREAM *stream,unsigned long uid);
+void imap_msgnos (MAILSTREAM *stream, unsigned char *uids);
void imap_flag (MAILSTREAM *stream,char *sequence,char *flag,long flags);
long imap_search (MAILSTREAM *stream,char *charset,SEARCHPGM *pgm,long flags);
unsigned long *imap_sort (MAILSTREAM *stream,char *charset,SEARCHPGM *spg,
@@ -294,6 +295,7 @@
imap_msgdata, /* fetch partial message */
imap_uid, /* unique identifier */
imap_msgno, /* message number */
+ imap_msgnos, /* message numbers */
imap_flag, /* modify flags */
NIL, /* per-message modify flags */
imap_search, /* search for message based on criteria */
@@ -1947,6 +1949,48 @@
}
return 0; /* didn't find the UID anywhere */
}
+
+/*
+* MR, this is dummy function just to fill cache
+* does not care what it returns, if result is good, then cache will be filled
+* uids delimiter is ','
+*/
+void imap_msgnos (MAILSTREAM *stream, unsigned char *uids)
+{
+ IMAPPARSEDREPLY *reply;
+ IMAPARG *args[3],aseq,aatt;
+ char seq[MAILTMPLEN];
+ char *p, *dp;
+ int i,j;
+
+ aseq.type = SEQUENCE; aseq.text = (void *) seq;
+ aatt.type = ATOM; aatt.text = (void *) "UID";
+ args[0] = &aseq; args[1] = &aatt; args[2] = NIL;
+
+ p = uids; // pointer to move
+ dp = uids; // pointer to latest delimiter fit in buffer
+
+ /* loop until end */
+ while (*p) {
+ for ( i = 0; i < MAILTMPLEN; i++) {
+ seq[i] = *p;
+ if ( seq[i] == ',') { dp = p; j = i; }
+ if ( seq[i] == '\0' ) {
+ if (!imap_OK (stream,reply = imap_send (stream,"UID FETCH",args)))
mm_log (reply->text,ERROR);
+ return;
+ }
+ p++;
+ }
+
+ seq[j] = '\0';
+ p = dp+1;
+
+ /* send "UID FETCH uid UID" */
+ if (!imap_OK (stream,reply = imap_send (stream,"UID FETCH",args))) mm_log
(reply->text,ERROR);
+ }
+
+}
+
/* IMAP modify flags
* Accepts: MAIL stream
_______________________________________________
Imap-uw mailing list
[email protected]
http://mailman2.u.washington.edu/mailman/listinfo/imap-uw