Thanks for the patch! The person checking it in would be me ;-)
However I am considering just slurping the entire result set into memory
at level of auth_check_user_ext recursion. One would need an absurd
number of improperly recursive aliases for this to be a problem.
Thinking of a heuristic to work defensively around such a situation.
Aaron
On Thu, 2007-08-09 at 11:27 +0200, Peter Hochgemuth wrote:
> Hi,
>
> I found the bug in the sqlite implementation of db_set_result_set() and
> fixed it. Maybe somebody can check this in into SVN.
> The patch is
>
> #! /bin/sh /usr/share/dpatch/dpatch-run
> ## 04_dbsqlite.dpatch by <Peter.Hochgemuth at pobox.com>
> ##
> ## All lines beginning with `## DP:' are a description of the patch.
> ## DP:
> ## DP: [segfault in auth_check_user_ext() using sqlite] after:
> ## DP: saveres = db_get_result_set();
> ## DP: db_set_result_set(NULL);
> ## DP: ...
> ## DP: db_set_result_set(saveres);
> ## DP: the call to db_free_result() in db_set_result_set() cleared out
> the values referenced by db_get_result_set()
> ## DP:
> ## DP: remove memory leaks in db_free_result()
> ## DP: don't reuse lastq in db_query() since we dont know if the value
> is referenced by a db_get_result_set()
>
> @DPATCH@
> diff -urNad dbmail-2.2.6-rc1.orig/modules/dbsqlite.c
> dbmail-2.2.6-rc1/modules/dbsqlite.c
> --- dbmail-2.2.6-rc1.orig/modules/dbsqlite.c 2007-07-14
> 11:56:54.000000000 +0200
> +++ dbmail-2.2.6-rc1/modules/dbsqlite.c 2007-08-09 09:27:38.000000000
> +0200
> @@ -289,8 +289,7 @@
> {
> if (lastq) {
> if (lastq->resp) sqlite3_free_table(lastq->resp);
> - lastq->resp = 0;
> - lastq->rows = lastq->cols = 0;
> + free(lastq);
> }
> lastq = 0;
>
> @@ -328,14 +327,11 @@
> char *errmsg;
> int res, retry=0;
>
> - if (lastq) {
> - if (lastq->resp) sqlite3_free_table(lastq->resp);
> - } else {
> - lastq = (struct qtmp *)malloc(sizeof(struct qtmp));
> - if (!lastq) {
> - TRACE(TRACE_ERROR, "malloc failed: %s",
> strerror(errno));
> - return -1;
> - }
> + db_free_result();
> + lastq = (struct qtmp *)malloc(sizeof(struct qtmp));
> + if (!lastq) {
> + TRACE(TRACE_ERROR, "malloc failed: %s", strerror(errno));
> + return -1;
> }
> TRACE(TRACE_DEBUG,"%s", the_query);
>
> @@ -355,6 +351,7 @@
>
> TRACE(TRACE_ERROR, "sqlite3_get_table failed: %s", errmsg);
> sqlite3_free(errmsg);
> + db_free_result();
> return -1;
> }
>
> @@ -414,6 +411,5 @@
>
> void db_set_result_set(void *the_result_set)
> {
> - db_free_result();
> lastq = (struct qtmp *)the_result_set;
> }
>
>
> Am Mittwoch, den 08.08.2007, 00:03 -0700 schrieb Aaron Stone:
> > I rewrote auth_check_user_ext a little bit. I'll try to find time to put
> > the code through some testing this week and check it into SVN.
> >
> > Aaron
> >
>
_______________________________________________
Dbmail-dev mailing list
[email protected]
http://twister.fastxs.net/mailman/listinfo/dbmail-dev