Skip to content

Commit c4218c8

Browse files
committed
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 <[email protected]> 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
1 parent 0e3e659 commit c4218c8

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*) mod_session_dbd: ensure format used with SessionDBDCookieName and
2+
SessionDBDCookieName2 are correct.
3+
Github #503 [Thomas Meyer <thomas m3y3r.de>]

modules/session/mod_session_dbd.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ static const char *check_string(cmd_parms * cmd, const char *string)
537537
{
538538
if (APR_SUCCESS != ap_cookie_check_string(string)) {
539539
return apr_pstrcat(cmd->pool, cmd->directive->directive,
540-
" cannot be empty, or contain '=', ';' or '&'.",
540+
" cannot contain '=', ';' or '&'.",
541541
NULL);
542542
}
543543
return NULL;
@@ -571,6 +571,11 @@ static const char *set_cookie_name(cmd_parms * cmd, void *config, const char *ar
571571
char *line = apr_pstrdup(cmd->pool, args);
572572
session_dbd_dir_conf *conf = (session_dbd_dir_conf *) config;
573573
char *cookie = apr_strtok(line, " \t", &last);
574+
if (!cookie) {
575+
return apr_pstrcat(cmd->pool, cmd->directive->directive,
576+
" requires at least one argument!",
577+
NULL);
578+
}
574579
conf->name = cookie;
575580
conf->name_set = 1;
576581
while (apr_isspace(*last)) {
@@ -586,6 +591,11 @@ static const char *set_cookie_name2(cmd_parms * cmd, void *config, const char *a
586591
char *line = apr_pstrdup(cmd->pool, args);
587592
session_dbd_dir_conf *conf = (session_dbd_dir_conf *) config;
588593
char *cookie = apr_strtok(line, " \t", &last);
594+
if (!cookie) {
595+
return apr_pstrcat(cmd->pool, cmd->directive->directive,
596+
" requires at least one argument!",
597+
NULL);
598+
}
589599
conf->name2 = cookie;
590600
conf->name2_set = 1;
591601
while (apr_isspace(*last)) {

0 commit comments

Comments
 (0)