dovecot: Extensions weren't copied in memory correctly, possibly...

dovecot at dovecot.org dovecot at dovecot.org
Sat Jan 19 09:08:26 EET 2008


details:   http://hg.dovecot.org/dovecot/rev/36092ec27396
changeset: 7170:36092ec27396
user:      Timo Sirainen <tss at iki.fi>
date:      Sat Jan 19 09:08:22 2008 +0200
description:
Extensions weren't copied in memory correctly, possibly causing garbage to
be written to uidlist file.

diffstat:

1 file changed, 22 insertions(+), 1 deletion(-)
src/lib-storage/index/maildir/maildir-uidlist.c |   23 ++++++++++++++++++++++-

diffs (40 lines):

diff -r b9d78196e9ba -r 36092ec27396 src/lib-storage/index/maildir/maildir-uidlist.c
--- a/src/lib-storage/index/maildir/maildir-uidlist.c	Sat Jan 19 08:50:56 2008 +0200
+++ b/src/lib-storage/index/maildir/maildir-uidlist.c	Sat Jan 19 09:08:22 2008 +0200
@@ -1210,6 +1210,27 @@ maildir_uidlist_sync_next_partial(struct
 	ctx->finished = FALSE;
 }
 
+static char *ext_dup(pool_t pool, const char *extensions)
+{
+	char *ret;
+
+	if (extensions == NULL)
+		return NULL;
+
+	T_FRAME_BEGIN {
+		string_t *str = t_str_new(64);
+		unsigned int len;
+
+		while (*extensions != '\0') {
+			len = strlen(extensions);
+			str_append_n(str, extensions, len);
+			extensions += len + 1;
+		}
+		ret = p_strdup(pool, str_c(str));
+	} T_FRAME_END;
+	return ret;
+}
+
 int maildir_uidlist_sync_next(struct maildir_uidlist_sync_ctx *ctx,
 			      const char *filename,
 			      enum maildir_uidlist_rec_flag flags)
@@ -1247,7 +1268,7 @@ int maildir_uidlist_sync_next(struct mai
 		if (old_rec != NULL) {
 			*rec = *old_rec;
 			rec->extensions =
-				p_strdup(ctx->record_pool, rec->extensions);
+				ext_dup(ctx->record_pool, rec->extensions);
 		} else {
 			rec->uid = (uint32_t)-1;
 			ctx->new_files_count++;


More information about the dovecot-cvs mailing list