Skip to content

mod_setenvif: Don't take SetEnvIfExpr backreferences from a stale match (BZ 70369) - #1076

Open
arturobernalg wants to merge 1 commit into
apache:trunkfrom
arturobernalg:fix/httpd-70369-setenvif-expr-backref
Open

arturobernalg wants to merge 1 commit into
apache:trunkfrom
arturobernalg:fix/httpd-70369-setenvif-expr-backref

Conversation

@arturobernalg

Copy link
Copy Markdown
Member

SetEnvIfExpr took $N from the previous rule's match, or from uninitialized memory, when its expression captured nothing. $N is now empty there; backslash escapes in the value still apply.

Same pattern as mod_rewrite in #1075. Test in test/modules/metadata, RED on trunk, GREEN with the fix.

https://bz.apache.org/bugzilla/show_bug.cgi?id=70369


  • This PR does not report or address a security vulnerability
    (see SECURITY.md and
    https://www.apache.org/security/#reporting-a-vulnerability).
  • Code follows the httpd style guide.
  • New log messages (level debug or higher) use an empty APLOGNO() tag;
    numbers are assigned by a committer at merge time (see docs/log-message-tags/README).
  • If the change is user-visible, a changes-entries/*.txt file is included,
    following the template in README.CHANGES (not needed otherwise).
  • Test cases based on pyhttpd are included where appropriate, in the
    test/modules/xxx directory matching the modules/xxx module source,
    or test/modules/core for core server changes. On Unix, verify these
    pass locally with e.g. make check-pytest PYTEST_DIRS=test/modules/xxx.

For a SetEnvIfExpr rule, val and regm still held the previous rule's
value and match (or nothing at all), so $N in the value came from
another rule or from uninitialized memory whenever the expression ran
no capturing regex. Reset both before evaluating the expression, so
that $N comes only from its own capturing match and is empty otherwise.

PR 70369.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant