1
0
mirror of https://github.com/apache/httpd.git synced 2026-10-23 22:49:01 +03:00
Files
apache/test/modules/generators/env.py
Joe Orton 54cc53eb4b mod_autoindex: fix one-byte over-read past end of description
Stop reading (and writing) one byte past the end of a file
description when it ends inside an unterminated "&" entity or "<"
tag, as a ScanHTMLTitles title can.

* modules/generators/mod_autoindex.c (terminate_description): Check
  for the terminating NUL before advancing past it when scanning an
  unterminated "<" tag or "&" entity, and break out of the loop at
  end of string rather than continuing past it.

* test/modules/generators/env.py (GeneratorsTestSetup.__init__): Load
  mod_autoindex for the generators test suite.

* test/modules/generators/htdocs/autoindex/: New test content.

* test/modules/generators/test_002_autoindex.py (TestAutoindex): New
  test that a ScanHTMLTitles description ending in a bare "&" is
  rendered without reading past the end of the description.

Submitted by: arshiya tabasum <arshi bugqore.com>
GitHub: closes #812


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1939181 13f79535-47bb-0310-9956-ffa450edef68
2026-10-17 11:18:52 +00:00

40 lines
1.2 KiB
Python

import inspect
import logging
import os
import subprocess
from pyhttpd.env import HttpdTestEnv, HttpdTestSetup
log = logging.getLogger(__name__)
class GeneratorsTestSetup(HttpdTestSetup):
def __init__(self, env: 'HttpdTestEnv'):
super().__init__(env=env)
self.add_source_dir(os.path.dirname(inspect.getfile(GeneratorsTestSetup)))
self.add_modules(["cgid", "include", "headers", "autoindex"])
class GeneratorsTestEnv(HttpdTestEnv):
def __init__(self, pytestconfig=None):
super().__init__(pytestconfig=pytestconfig)
# A LogLevel for an unloaded module is a fatal config error.
log_modules = ["include", "core"]
if self.has_cgid_module:
log_modules.insert(0, "cgid")
self.add_httpd_log_modules(log_modules)
def setup_httpd(self, setup: HttpdTestSetup = None):
super().setup_httpd(setup=GeneratorsTestSetup(env=self))
@property
def has_cgid_module(self) -> bool:
"""Whether mod_cgid was built, shared or static."""
if self.has_shared_module("cgid"):
return True
p = subprocess.run([os.path.join(self.bin_dir, "httpd"), "-l"],
capture_output=True, text=True)
return "mod_cgid.c" in p.stdout