]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
mod_session_dbd: set_cookie_name: ensure correct format
authorYann Ylavic <ylavic@apache.org>
Tue, 10 Jun 2025 11:00:37 +0000 (11:00 +0000)
committerYann Ylavic <ylavic@apache.org>
Tue, 10 Jun 2025 11:00:37 +0000 (11:00 +0000)
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 <thomas@m3y3r.de>

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

changes-entries/SessionDBDCookieName.txt [new file with mode: 0644]
modules/session/mod_session_dbd.c

diff --git a/changes-entries/SessionDBDCookieName.txt b/changes-entries/SessionDBDCookieName.txt
new file mode 100644 (file)
index 0000000..76c0aa1
--- /dev/null
@@ -0,0 +1,3 @@
+  *) mod_session_dbd: ensure format used with SessionDBDCookieName and
+     SessionDBDCookieName2 are correct.
+     Github #503 [Thomas Meyer <thomas m3y3r.de>]
index f683da2172f0c03ae79f4e6afae9360909041055..65af9370f990edf16c9ef7ae9a02fc7d8266abb1 100644 (file)
@@ -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)) {