fix: guard WinHttp URL port parsing exceptions#60
Conversation
|
Also, the PR description says invalid ports leave the port at default |
std::stol accepts strings like "12312abc" by parsing only the numeric prefix. Use the pos parameter to verify the entire port substring was consumed, and treat trailing garbage as invalid.
|
Good catches, thanks for the review.
|
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Problem
WinHttp::ParseUrlcallsstd::stoion the port substring extracted from URLs likehost:port. If the port field is empty, non-numeric, or out of range,std::stoithrowsstd::invalid_argumentorstd::out_of_range, crashing the caller.Changes
std::stoicall in a try-catch block.[1, 65535]are accepted.std::stol'sposparameter to reject partially-numeric port strings (e.g.,host:12312abc).ParsedUrl, which callers already handle as a "skip this URL" signal.Testing
host:,host:abc,host:999999,host:12312abc, and valid URLs to confirm no regression.