Fix issue #5506 "WebServer serveStatic () can cause LoadProhibited ex… #5508
+1
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…ception in _svfprintf_r"
"Using a Core Debug Level of Verbose and the WebServer serveStatic() function with the default value of nullptr for its cache_header argument, results in a LoadProhibited exception in _svfprintf_r().
This is because serveStatic() calls log_v() with cache_header corresponding to a "%s" in its format but without checking that cache_header is not nullptr, and then logv() (indirectly) calls _svfprintf_r().
On the other hand, with a Core Debug Level other than Verbose, this does not occur."
Changed serveStatic() to check the value of cache_header and if it is nullptr, instead pass an empty string to log_v().
This entire section can be deleted if all items are checked.
By completing this PR sufficiently, you help us to improve the quality of Release Notes
Checklist
Summary
Fix issue #5506 "WebServer serveStatic () can cause LoadProhibited exception in _svfprintf_r"
Impact
This change adds null-ness checking to the cache_header argument in WebServer::serveStatic() before passing it to log_v(). If it is null, it passes an empty string ("") instead of nullptr. The only intended/expected impact is to prevent a LoadProhibited exception in _svfprintf_r when serveStatic() is called with a nullptr value for its argument cache_header, which for example, occurs when the default value for cache_header is used.