dovecot-2.1: fts-solr: Don't crash if fts_solr setting is invalid.

dovecot at dovecot.org dovecot at dovecot.org
Tue Apr 23 13:46:38 EEST 2013


details:   http://hg.dovecot.org/dovecot-2.1/rev/c3e487d82df7
changeset: 14959:c3e487d82df7
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Apr 23 13:46:29 2013 +0300
description:
fts-solr: Don't crash if fts_solr setting is invalid.

diffstat:

 src/plugins/fts-solr/fts-backend-solr-old.c |  15 ++++++++++-----
 src/plugins/fts-solr/fts-backend-solr.c     |  14 +++++++++-----
 2 files changed, 19 insertions(+), 10 deletions(-)

diffs (57 lines):

diff -r d044963bf65c -r c3e487d82df7 src/plugins/fts-solr/fts-backend-solr-old.c
--- a/src/plugins/fts-solr/fts-backend-solr-old.c	Tue Apr 23 13:33:12 2013 +0300
+++ b/src/plugins/fts-solr/fts-backend-solr-old.c	Tue Apr 23 13:46:29 2013 +0300
@@ -226,16 +226,21 @@
 }
 
 static int
-fts_backend_solr_init(struct fts_backend *_backend,
-		      const char **error_r ATTR_UNUSED)
+fts_backend_solr_init(struct fts_backend *_backend, const char **error_r)
 {
 	struct solr_fts_backend *backend = (struct solr_fts_backend *)_backend;
 	struct fts_solr_user *fuser = FTS_SOLR_USER_CONTEXT(_backend->ns->user);
-	const struct fts_solr_settings *set = &fuser->set;
 	const char *str;
 
-	if (solr_conn == NULL)
-		solr_conn = solr_connection_init(set->url, set->debug);
+	if (fuser == NULL) {
+		*error_r = "Invalid fts_solr setting";
+		return -1;
+	}
+
+	if (solr_conn == NULL) {
+		solr_conn = solr_connection_init(fuser->set.url,
+						 fuser->set.debug);
+	}
 
 	str = solr_escape_id_str(_backend->ns->user->username);
 	backend->id_username = i_strdup(str);
diff -r d044963bf65c -r c3e487d82df7 src/plugins/fts-solr/fts-backend-solr.c
--- a/src/plugins/fts-solr/fts-backend-solr.c	Tue Apr 23 13:33:12 2013 +0300
+++ b/src/plugins/fts-solr/fts-backend-solr.c	Tue Apr 23 13:46:29 2013 +0300
@@ -156,14 +156,18 @@
 }
 
 static int
-fts_backend_solr_init(struct fts_backend *_backend,
-		      const char **error_r ATTR_UNUSED)
+fts_backend_solr_init(struct fts_backend *_backend, const char **error_r)
 {
 	struct fts_solr_user *fuser = FTS_SOLR_USER_CONTEXT(_backend->ns->user);
-	const struct fts_solr_settings *set = &fuser->set;
 
-	if (solr_conn == NULL)
-		solr_conn = solr_connection_init(set->url, set->debug);
+	if (fuser == NULL) {
+		*error_r = "Invalid fts_solr setting";
+		return -1;
+	}
+	if (solr_conn == NULL) {
+		solr_conn = solr_connection_init(fuser->set.url,
+						 fuser->set.debug);
+	}
 	return 0;
 }
 


More information about the dovecot-cvs mailing list