[dovecot-cvs] dovecot/src/lib-imap imap-base-subject.c, 1.11, 1.12 imap-bodystructure.c, 1.53, 1.54 imap-envelope.c, 1.34, 1.35 imap-match.c, 1.8, 1.9 imap-match.h, 1.6, 1.7 imap-parser.c, 1.51, 1.52 imap-parser.h, 1.21, 1.22

cras at dovecot.org cras at dovecot.org
Sat Jan 14 20:47:36 EET 2006


Update of /var/lib/cvs/dovecot/src/lib-imap
In directory talvi:/tmp/cvs-serv16037/lib-imap

Modified Files:
	imap-base-subject.c imap-bodystructure.c imap-envelope.c 
	imap-match.c imap-match.h imap-parser.c imap-parser.h 
Log Message:
deinit, unref, destroy, close, free, etc. functions now take a pointer to
their data pointer, and set it to NULL. This makes double-frees less likely
to cause security holes.



Index: imap-base-subject.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-imap/imap-base-subject.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- imap-base-subject.c	13 Jan 2006 20:26:09 -0000	1.11
+++ imap-base-subject.c	14 Jan 2006 18:47:34 -0000	1.12
@@ -25,7 +25,7 @@
 		t = charset_to_utf8_begin(charset, NULL);
 		if (t != NULL) {
 			(void)charset_to_ucase_utf8(t, data, &size, buf);
-                        charset_to_utf8_end(t);
+                        charset_to_utf8_end(&t);
 		}
 	}
 

Index: imap-bodystructure.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-imap/imap-bodystructure.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -d -r1.53 -r1.54
--- imap-bodystructure.c	13 Jan 2006 20:26:09 -0000	1.53
+++ imap-bodystructure.c	14 Jan 2006 18:47:34 -0000	1.54
@@ -177,7 +177,7 @@
 			}
 			d->content_type_params =
 				p_strdup_empty(pool, str_c(d->str));
-			str_free(d->str);
+			str_free(&d->str);
 		}
 		if (strcasecmp(name, "Transfer-Encoding") == 0 &&
 		    d->content_transfer_encoding == NULL) {
@@ -209,7 +209,7 @@
 						     parse_save_params_list, d);
 			d->content_disposition_params =
 				p_strdup_empty(pool, str_c(d->str));
-			str_free(d->str);
+			str_free(&d->str);
 		}
 		break;
 	}
@@ -684,7 +684,7 @@
 	if (!ret)
 		i_error("Error parsing IMAP bodystructure: %s", bodystructure);
 
-	imap_parser_destroy(parser);
-	i_stream_unref(input);
+	imap_parser_destroy(&parser);
+	i_stream_unref(&input);
 	return ret;
 }

Index: imap-envelope.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-imap/imap-envelope.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- imap-envelope.c	13 Jan 2006 20:26:09 -0000	1.34
+++ imap-envelope.c	14 Jan 2006 18:47:34 -0000	1.35
@@ -396,7 +396,7 @@
 		ret = FALSE;
 	}
 
-	imap_parser_destroy(parser);
-	i_stream_unref(input);
+	imap_parser_destroy(&parser);
+	i_stream_unref(&input);
 	return ret;
 }

Index: imap-match.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-imap/imap-match.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- imap-match.c	13 Jan 2006 20:26:09 -0000	1.8
+++ imap-match.c	14 Jan 2006 18:47:34 -0000	1.9
@@ -86,9 +86,10 @@
 	return glob;
 }
 
-void imap_match_deinit(struct imap_match_glob *glob)
+void imap_match_deinit(struct imap_match_glob **glob)
 {
-	p_free(glob->pool, glob);
+	p_free((*glob)->pool, *glob);
+	*glob = NULL;
 }
 
 static inline bool cmp_chr(const struct imap_match_glob *glob,

Index: imap-match.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-imap/imap-match.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- imap-match.h	13 Jan 2006 20:26:09 -0000	1.6
+++ imap-match.h	14 Jan 2006 18:47:34 -0000	1.7
@@ -16,7 +16,7 @@
 struct imap_match_glob *
 imap_match_init(pool_t pool, const char *mask, bool inboxcase, char separator);
 
-void imap_match_deinit(struct imap_match_glob *glob);
+void imap_match_deinit(struct imap_match_glob **glob);
 
 enum imap_match_result
 imap_match(struct imap_match_glob *glob, const char *data);

Index: imap-parser.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-imap/imap-parser.c,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -d -r1.51 -r1.52
--- imap-parser.c	13 Jan 2006 20:26:09 -0000	1.51
+++ imap-parser.c	14 Jan 2006 18:47:34 -0000	1.52
@@ -82,10 +82,11 @@
 	return parser;
 }
 
-void imap_parser_destroy(struct imap_parser *parser)
+void imap_parser_destroy(struct imap_parser **parser)
 {
-	pool_unref(parser->pool);
-	i_free(parser);
+	pool_unref((*parser)->pool);
+	i_free(*parser);
+	*parser = NULL;
 }
 
 void imap_parser_reset(struct imap_parser *parser)

Index: imap-parser.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-imap/imap-parser.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- imap-parser.h	13 Jan 2006 20:26:09 -0000	1.21
+++ imap-parser.h	14 Jan 2006 18:47:34 -0000	1.22
@@ -86,7 +86,7 @@
 struct imap_parser *
 imap_parser_create(struct istream *input, struct ostream *output,
 		   size_t max_line_size);
-void imap_parser_destroy(struct imap_parser *parser);
+void imap_parser_destroy(struct imap_parser **parser);
 
 /* Reset the parser to initial state. */
 void imap_parser_reset(struct imap_parser *parser);



More information about the dovecot-cvs mailing list