[dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-sync.c, 1.151, 1.152

cras at dovecot.org cras at dovecot.org
Fri Apr 22 23:58:21 EEST 2005


Update of /var/lib/cvs/dovecot/src/lib-storage/index/mbox
In directory talvi:/tmp/cvs-serv4928

Modified Files:
	mbox-sync.c 
Log Message:
Error message fix.



Index: mbox-sync.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync.c,v
retrieving revision 1.151
retrieving revision 1.152
diff -u -d -r1.151 -r1.152
--- mbox-sync.c	22 Apr 2005 20:55:36 -0000	1.151
+++ mbox-sync.c	22 Apr 2005 20:58:18 -0000	1.152
@@ -513,17 +513,25 @@
 	const char *str;
 	uint32_t uid_last;
 	unsigned int i;
+	int ret;
 
 	i_assert(sync_ctx->base_uid_last_offset != 0);
 
 	/* first check that the 10 bytes are there and they're exactly as
 	   expected. just an extra safety check to make sure we never write
 	   to wrong location in the mbox file. */
-	if (pread_full(sync_ctx->write_fd, buf, sizeof(buf),
-		       sync_ctx->base_uid_last_offset) <= 0) {
+	ret = pread_full(sync_ctx->write_fd, buf, sizeof(buf),
+			 sync_ctx->base_uid_last_offset);
+	if (ret < 0) {
 		mbox_set_syscall_error(sync_ctx->mbox, "pread_full()");
 		return -1;
 	}
+	if (ret == 0) {
+		mail_storage_set_critical(STORAGE(sync_ctx->mbox->storage),
+			"X-IMAPbase uid-last unexpectedly points outside "
+			"mbox file %s", sync_ctx->mbox->path);
+		return -1;
+	}
 
 	for (i = 0, uid_last = 0; i < sizeof(buf); i++) {
 		if (buf[i] < '0' || buf[i] > '9') {



More information about the dovecot-cvs mailing list