updated URL for project

fixed segmentation fault caused by double free() when an error occurred
during the IMAP transmission.

fixed bug where isync could not handle a 0 value UIDVALIDITY
This commit is contained in:
Michael Elkins 2002-06-18 06:37:55 +00:00
parent 7741548ff8
commit f6c037c854
6 changed files with 33 additions and 19 deletions

3
README
View File

@ -5,7 +5,7 @@
|_|___/\__, |_| |_|\___|
|___/
isync - IMAP4 to maildir mailbox synchronization program
http://www.sigpipe.org:8080/isync/
http://www.cs.hmc.edu/~me/isync/
Author: Michael Elkins <me@mutt.org>
@ -29,6 +29,7 @@ maintained, and all flags are synchronized.
* Microsoft Exchange 2000 IMAP4rev1 server version 6.0.4417.0
* Courier-IMAP 1.2.3
* WU-IMAP 2000
* Domino IMAP4 Server Release 5.0.8
* Platforms

View File

@ -16,7 +16,7 @@
\" along with this program; if not, write to the Free Software
\" Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
..
.TH isync 1 "2002 Apr 19"
.TH isync 1 "2002 Jun 17"
..
.SH NAME
isync - synchronize IMAP4 and maildir mailboxes
@ -337,7 +337,7 @@ mutt(1), maildir(5)
Up to date information on
.B isync
can be found at
http://www.sigpipe.org:8080/isync/.
http://www.cs.hmc.edu/~me/isync/.
..
.SH AUTHOR
Written by Michael R. Elkins <me@mutt.org>.

View File

@ -91,6 +91,8 @@ struct mailbox
unsigned int deleted; /* # of deleted messages */
unsigned int uidvalidity;
unsigned int maxuid; /* largest uid we know about */
unsigned int uidseen : 1; /* flag indicating whether or not we saw a
valid value for UIDVALIDITY */
};
/* message dispositions */

View File

@ -80,15 +80,21 @@ parse_info (message_t * m, char *s)
}
}
static unsigned int
read_uid (const char *path, const char *file)
/*
* There are three possible results of this function:
* >1 uid was already seen
* 0 uid was not yet seen
* -1 unable to read uid because of some other error
*/
static int
read_uid (const char *path, const char *file, unsigned int *uid /* out */)
{
char full[_POSIX_PATH_MAX];
int fd;
int ret = 0;
int ret = -1;
int len;
char buf[64];
unsigned int uid = 0;
char buf[64], *ptr;
snprintf (full, sizeof (full), "%s/%s", path, file);
fd = open (full, O_RDONLY);
@ -103,18 +109,20 @@ read_uid (const char *path, const char *file)
}
len = read (fd, buf, sizeof (buf) - 1);
if (len == -1)
{
perror ("read");
ret = -1;
}
else
{
buf[len] = 0;
uid = atol (buf);
errno = 0;
*uid = strtoul (buf, &ptr, 10);
if (errno)
perror ("strtoul");
else if (ptr && *ptr == '\n')
ret = 1;
/* else invalid value */
}
close (fd);
return ret ? (unsigned int) ret : uid;
return ret;
}
/* NOTE: this is NOT NFS safe */
@ -233,12 +241,14 @@ maildir_open (const char *path, int flags)
goto err;
/* check for the uidvalidity value */
m->uidvalidity = read_uid (m->path, "isyncuidvalidity");
if (m->uidvalidity == (unsigned int) -1)
goto err;
i = read_uid (m->path, "isyncuidvalidity", &m->uidvalidity);
if (i == -1)
goto err;
else if (i > 0)
m->uidseen = 1;
/* load the current maxuid */
if ((m->maxuid = read_uid (m->path, "isyncmaxuid")) == (unsigned int) -1)
if (read_uid (m->path, "isyncmaxuid", &m->maxuid) == -1)
goto err;
if (flags & OPEN_FAST)

1
main.c
View File

@ -312,6 +312,7 @@ main (int argc, char **argv)
imap_close (imap); /* Just to be safe. Don't really know
* what the problem was.
*/
imap = NULL; /* context no longer valid */
break;
}

2
sync.c
View File

@ -71,7 +71,7 @@ sync_mailbox (mailbox_t * mbox, imap_t * imap, int flags,
int upload = 0;
unsigned int msg_count;
if (mbox->uidvalidity > 0)
if (mbox->uidseen)
{
if (mbox->uidvalidity != imap->uidvalidity)
{