aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.in2
-rw-r--r--driver.c6
-rw-r--r--fetchmail.h2
-rw-r--r--imap.c41
-rw-r--r--pop3.c13
5 files changed, 31 insertions, 33 deletions
diff --git a/Makefile.in b/Makefile.in
index 9348df72..01710b87 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -204,7 +204,7 @@ $(srcdir)/rcfile_y.c: $(srcdir)/rcfile_y.y
parser = $(srcdir)/rcfile_l.l $(srcdir)/rcfile_y.y
headers = $(srcdir)/fetchmail.h $(srcdir)/socket.h $(srcdir)/smtp.h \
- $(srcdir)/md5.h $(srcdir)/md5global.h
+ $(srcdir)/mx.h $(srcdir)/md5.h $(srcdir)/md5global.h
extra = $(srcdir)/alloca.c $(srcdir)/getopt.[ch] $(srcdir)/getopt1.c \
$(srcdir)/strcasecmp.c
docs = $(srcdir)/COPYING $(srcdir)/README $(srcdir)/INSTALL $(srcdir)/NEWS \
diff --git a/driver.c b/driver.c
index 888dae4d..6cb18cd8 100644
--- a/driver.c
+++ b/driver.c
@@ -838,8 +838,12 @@ struct method *proto; /* protocol method table */
/* we may need to get sizes in order to check message limits */
msgsizes = (int *)NULL;
if (!ctl->fetchall && proto->getsizes && ctl->limit)
- if ((msgsizes = (proto->getsizes)(socket, count)) == (int *)NULL)
+ {
+ msgsizes = (int *)alloca(sizeof(int) * count);
+
+ if ((ok = (proto->getsizes)(socket, count, msgsizes)) != 0)
return(PS_ERROR);
+ }
if (check_only)
{
diff --git a/fetchmail.h b/fetchmail.h
index a34b0e43..34df7079 100644
--- a/fetchmail.h
+++ b/fetchmail.h
@@ -109,7 +109,7 @@ struct method
int (*parse_response)(); /* response_parsing function */
int (*getauth)(); /* authorization fetcher */
int (*getrange)(); /* get message range to fetch */
- int *(*getsizes)(); /* get sizes of messages */
+ int (*getsizes)(); /* get sizes of messages */
int (*is_old)(); /* check for old message */
int (*fetch)(); /* fetch a given message */
int (*trail)(); /* eat trailer of a message */
diff --git a/imap.c b/imap.c
index 286d469c..fbacc3cb 100644
--- a/imap.c
+++ b/imap.c
@@ -111,39 +111,34 @@ int *countp, *newp;
return(0);
}
-static int *imap_getsizes(socket, count)
+static int imap_getsizes(socket, count, sizes)
/* capture the sizes of all messages */
int socket;
int count;
+int *sizes;
{
- int ok, *sizes;
+ char buf [POPBUFSIZE+1];
- if ((sizes = (int *)malloc(sizeof(int) * count)) == (int *)NULL)
- return((int *)NULL);
- else
+ gen_send(socket, "FETCH 1:%d RFC822.SIZE", count);
+ while (SockGets(socket, buf, sizeof(buf)) >= 0)
{
- char buf [POPBUFSIZE+1];
-
- gen_send(socket, "FETCH 1:%d RFC822.SIZE", count);
- while (SockGets(socket, buf, sizeof(buf)) >= 0)
- {
- int num, size;
-
- if (outlevel == O_VERBOSE)
- fprintf(stderr,"%s\n",buf);
- if (strstr(buf, "OK"))
- break;
- else if (sscanf(buf, "* %d FETCH (RFC822.SIZE %d)", &num, &size) == 2)
- sizes[num - 1] = size;
- else
- sizes[num - 1] = -1;
- }
+ int num, size;
- return(sizes);
+ if (outlevel == O_VERBOSE)
+ fprintf(stderr,"%s\n",buf);
+ if (strstr(buf, "OK"))
+ break;
+ else if (sscanf(buf, "* %d FETCH (RFC822.SIZE %d)", &num, &size) == 2)
+ sizes[num - 1] = size;
+ else
+ sizes[num - 1] = -1;
}
+
+ return(0);
}
static imap_is_old(socket, ctl, num)
+/* is the given message old? */
int socket;
struct query *ctl;
int num;
@@ -182,7 +177,7 @@ int *lenp;
}
static imap_trail(socket, ctl, number)
-/* discard tail of FETCH response */
+/* discard tail of FETCH response after reading message text */
int socket;
struct query *ctl;
int number;
diff --git a/pop3.c b/pop3.c
index 5287afd0..a52838af 100644
--- a/pop3.c
+++ b/pop3.c
@@ -186,17 +186,16 @@ int *countp, *newp;
return(0);
}
-static int *pop3_getsizes(socket, count)
+static int pop3_getsizes(socket, count, sizes)
/* capture the sizes of all messages */
int socket;
int count;
+int *sizes;
{
- int ok, *sizes;
+ int ok;
if ((ok = gen_transact(socket, "LIST")) != 0)
- return((int *)NULL);
- else if ((sizes = (int *)malloc(sizeof(int) * count)) == (int *)NULL)
- return((int *)NULL);
+ return(ok);
else
{
char buf [POPBUFSIZE+1];
@@ -215,12 +214,12 @@ int count;
sizes[num - 1] = -1;
}
- return(sizes);
+ return(0);
}
}
static int pop3_is_old(socket, ctl, num)
-/* is the goiven message old? */
+/* is the given message old? */
int socket;
struct query *ctl;
int num;