Repository navigation
Fix allocation size overflow guards in ap_proxy_canonenc_ex and ap_make_full_path - #671
SABITHSAHEB wants to merge 1 commit into
Conversation
|
Using |
|
Makes sense, reverted to ap_assert across the board: restored the ones I'd removed and used it for the new checks too instead of the error-return paths. I also pulled the unrelated mod_core atoi changes and the cookie reverse-map sizing churn so this stays focused on the escape helpers. Pushed. |
|
any update? |
this doesn't compile in C90 in various places. Build with |
|
Fixed and pushed. The offenders were escape_backref in mod_rewrite.c and ftp_escape_globbingchars in mod_proxy_ftp.c, where the new declarations ended up after statements; moved them up into the declaration blocks. Rebuilt with --enable-maintainer-mode and the touched files compile clean now under -Wdeclaration-after-statement. The only failure left in my tree was the pre-existing SSL_get_handshake_rtt apr_uint64_t vs uint64_t mismatch on macOS with homebrew apr, unrelated to this patch. |
|
Squash it please. |
abe5b2b to
0627888
Compare
|
Done, squashed to a single commit. |
0627888 to
fb421bf
Compare
|
Squashed to a single commit and rebased onto current trunk, no content changes. |
|
Analysis by Claude:
🤖 Generated with Claude Code |
ap_proxy_canonenc_ex(): len is an int, so 3 * len + 1 is computed in int arithmetic and overflows for len > INT_MAX / 3. Assert that len is non-negative and within (INT_MAX - 1) / 3 before allocating. ap_make_full_path(): assert that len1 + len2 + 3 cannot wrap, bounding len2 first so the limit for len1 itself cannot wrap.
fb421bf to
3e7df0a
Compare
|
Both points are right. The canonenc check was comparing against the size_t range, so it could never fire, and the make_full_path one could wrap. Both are fixed: canonenc now uses I agree the others can't be reached, so I dropped them. That covers the ssl_engine_vars, escape_backref, ms_wdv, mod_proxy_ftp and escape_logitem guards, plus the abort() to ap_assert() churn in ap_escape_html2. The PR is now just these two lines, still one commit, and the title and description are updated to match. |
Two
ap_assert()guards on allocation sizes:ap_proxy_canonenc_ex():lenis anint, so3 * len + 1is evaluated inintarithmetic and overflows forlen > INT_MAX / 3. The check now stays in theintdomain:len >= 0 && len <= (INT_MAX - 1) / 3.ap_make_full_path():len2is bounded before it is subtracted, so the limit onlen1cannot itself wrap.Checked with
-std=c89 -Werror=declaration-after-statement.