Skip to content

Cap snprintf return value in mod_maxminddb to prevent stack over-read#153

Open
kodareef5 wants to merge 1 commit intolighttpd:masterfrom
kodareef5:fix-snprintf-overread
Open

Cap snprintf return value in mod_maxminddb to prevent stack over-read#153
kodareef5 wants to merge 1 commit intolighttpd:masterfrom
kodareef5:fix-snprintf-overread

Conversation

@kodareef5
Copy link
Copy Markdown

snprintf at lines 379/382 returns the number of characters that would have been written, which can exceed sizeof(buf) for large double/float values. This value is used directly as the data length for http_header_env_set, causing a stack buffer over-read. Cap vlen to sizeof(buf) - 1 after each snprintf call.

snprintf returns the number of characters that would have been
written, which can exceed the buffer size for large double/float
values (e.g., DBL_MAX → ~315 chars). This return value is used
directly as the data length for http_header_env_set, causing a
stack buffer over-read when vlen > sizeof(buf).

Cap vlen to sizeof(buf) - 1 after each snprintf call.
@gstrauss
Copy link
Copy Markdown
Member

gstrauss commented Mar 24, 2026

Did you find any double/float values in the maxminddb GeoIP2 database that exceed the buffer size in mod_maxminddb.c (buf[34]) when using snprintf using format string "%.5f" to stringify the double/float value?

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants