On 02/04/2015 02:53 PM, Jan Kaluža wrote:
Hi,
I'm CCing httpd-dev list too, because this question has not been
answered on APR list yet and since it causes mod_authn_dbd to stop
working randomly with pgsql, I think it could be interesting even for
httpd developers.
I'm also attaching example patch which fixes this issue on httpd side,
but I think we should consider fixing it in the APR-util.
httpd's mod_authn_dbd module currently seems to expect that lifetime of
apr_dbd_get_entry(...) result is the same as of the pool used in
apr_dbd_get_row(...) function.
But this is not a true for at least pgsql backend. Its get_entry
function returns "return PQgetvalue(row->res->res, row->n, n);".
Documentation for PQgetvalue says following:
"One must explicitly copy the data into other storage if it is to be
used past the lifetime of the PGresult structure itself."
res->res is also freed in dbd_pgsql_get_row(...).
Is that correct behaviour and httpd's mod_authn_dbd module should strdup
the result, or is it apr_dbd, which should return result with expected
lifetime?
Regards,
Jan Kaluza
Regards,
Jan Kaluza
Index: modules/aaa/mod_authn_dbd.c
===================================================================
--- modules/aaa/mod_authn_dbd.c (revision 1644346)
+++ modules/aaa/mod_authn_dbd.c (working copy)
@@ -169,7 +169,8 @@
i++;
}
#endif
- dbd_password = apr_dbd_get_entry(dbd->driver, row, 0);
+ dbd_password = apr_pstrdup(r->pool,
+ apr_dbd_get_entry(dbd->driver, row, 0));
}
/* we can't break out here or row won't get cleaned up */
}
@@ -263,7 +264,8 @@
i++;
}
#endif
- dbd_hash = apr_dbd_get_entry(dbd->driver, row, 0);
+ dbd_hash = apr_pstrdup(r->pool,
+ apr_dbd_get_entry(dbd->driver, row, 0));
}
/* we can't break out here or row won't get cleaned up */
}