FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

mappool.c: only raise connectionMax after a successful realloc (fixes #7614) by MarkLee131 · Pull Request #7616 · MapServer/MapServer · GitHub

mappool.c: only raise connectionMax after a successful realloc (fixes #7614) - #7616

Open
MarkLee131 wants to merge 1 commit into
MapServer:mainfrom
MarkLee131:fix/connpool-realloc-rollback
Open

mappool.c: only raise connectionMax after a successful realloc (fixes #7614)#7616
MarkLee131 wants to merge 1 commit into
MapServer:mainfrom
MarkLee131:fix/connpool-realloc-rollback

Conversation

Copy link
Copy Markdown
Contributor

What does this PR do?

This moves the increment after the successful realloc and changes the guard to >=.

It completes f4286d6: that commit stopped the failed realloc from leaking and from nulling connections, but left the connectionMax desync in place, which turned the old near-NULL crash into a silent heap overflow.

What are related issues/pull requests?

Fixes #7614

Tasklist

  • Make sure code is correctly formatted (cf pre-commit configuration)
  • Add test case(s) in /msautotest (follow steps in Regression Testing)
  • Add documentation
  • Review
  • Adjust for comments
  • All CI builds and checks have passed

I could not find a way to write this one as an msautotest case. Triggering it needs the pool array's realloc() to fail, and the suite has no way to inject an allocation failure; msConnPoolRegister() is also not exposed to MapScript, and its callers are the database drivers, so reaching it from the test suite would need a live backend as well. The C reproducer in the issue covers it instead. Glad to add a test if you see an angle I missed.

…apServer#7614)

msConnPoolRegister() incremented connectionMax before the realloc() that
was meant to deliver the new capacity, and did not restore it when the
allocation failed. After one failed grow the recorded capacity stayed 10
entries ahead of the real one, and because the guard was an equality test
the growth path never ran again, so the following registrations each wrote
a whole connectionObj past the end of the array.

Move the increment after the successful realloc and make the guard >= so
that a count which has passed the capacity still grows the array.

This completes f4286d6, which stopped a failed realloc from leaking and
from nulling connections, but left the connectionMax desync in place. That
turned what used to be a near-NULL crash into a silent heap overflow.
jmckenna marked this pull request as ready for review August 27, 2026 13:24
jmckenna added the backport branch-8-6 To backport a pull request to branch-8-6 label Aug 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport branch-8-6 To backport a pull request to branch-8-6

Projects

None yet

Development

Successfully merging this pull request may close these issues.

msConnPoolRegister() writes past the connection array after a failed realloc

2 participants


Back | FazBrowse Home | New Git URL