From: Yann Ylavic Date: Tue, 10 Jun 2025 11:00:37 +0000 (+0000) Subject: mod_session_dbd: set_cookie_name: ensure correct format X-Git-Tag: 2.4.64-rc1-candidate~24 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c4218c88fe078570e7439c652a21f4773a432a76;p=thirdparty%2Fapache%2Fhttpd.git mod_session_dbd: set_cookie_name: ensure correct format If args is an empty string, apr_strtok will return NULL and *last will never get set which results in a SIGSEGV in apr_isspace check Submitted by: Thomas Meyer Github: closes #503 Follow-up to r1922931. In set_cookie_name() and set_cookie_name2(), now that the empty 'name' argument is explicitly handled, the error message in check_string() can be simplified because the cookie name can't be empty anymore when this function is called. Add a change entry to give credits to the author. Merges r1922931, r1926188, r1926189 trunk Submitted by: covener, jailletc36, jailletc36 Reviewed by: jailletc36, rpluem, ylavic git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1926325 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/changes-entries/SessionDBDCookieName.txt b/changes-entries/SessionDBDCookieName.txt new file mode 100644 index 0000000000..76c0aa110a --- /dev/null +++ b/changes-entries/SessionDBDCookieName.txt @@ -0,0 +1,3 @@ + *) mod_session_dbd: ensure format used with SessionDBDCookieName and + SessionDBDCookieName2 are correct. + Github #503 [Thomas Meyer ] diff --git a/modules/session/mod_session_dbd.c b/modules/session/mod_session_dbd.c index f683da2172..65af9370f9 100644 --- a/modules/session/mod_session_dbd.c +++ b/modules/session/mod_session_dbd.c @@ -537,7 +537,7 @@ static const char *check_string(cmd_parms * cmd, const char *string) { if (APR_SUCCESS != ap_cookie_check_string(string)) { return apr_pstrcat(cmd->pool, cmd->directive->directive, - " cannot be empty, or contain '=', ';' or '&'.", + " cannot contain '=', ';' or '&'.", NULL); } return NULL; @@ -571,6 +571,11 @@ static const char *set_cookie_name(cmd_parms * cmd, void *config, const char *ar char *line = apr_pstrdup(cmd->pool, args); session_dbd_dir_conf *conf = (session_dbd_dir_conf *) config; char *cookie = apr_strtok(line, " \t", &last); + if (!cookie) { + return apr_pstrcat(cmd->pool, cmd->directive->directive, + " requires at least one argument!", + NULL); + } conf->name = cookie; conf->name_set = 1; while (apr_isspace(*last)) { @@ -586,6 +591,11 @@ static const char *set_cookie_name2(cmd_parms * cmd, void *config, const char *a char *line = apr_pstrdup(cmd->pool, args); session_dbd_dir_conf *conf = (session_dbd_dir_conf *) config; char *cookie = apr_strtok(line, " \t", &last); + if (!cookie) { + return apr_pstrcat(cmd->pool, cmd->directive->directive, + " requires at least one argument!", + NULL); + } conf->name2 = cookie; conf->name2_set = 1; while (apr_isspace(*last)) {