]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
mod_session_dbd: set_cookie_name: ensure correct format
authorEric Covener <covener@apache.org>
Mon, 6 Jan 2025 19:28:35 +0000 (19:28 +0000)
committerEric Covener <covener@apache.org>
Mon, 6 Jan 2025 19:28:35 +0000 (19:28 +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

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1922931 13f79535-47bb-0310-9956-ffa450edef68

modules/session/mod_session_dbd.c

index f683da2172f0c03ae79f4e6afae9360909041055..619addb7b693a0fd999c7eaad249a437bb81a8f9 100644 (file)
@@ -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)) {