urlapi: deny hostnames with more than one trailing dot#21622
Closed
bagder wants to merge 4 commits into
Closed
Conversation
Such names cannot be resolved with DNS. While they *can* still be resolved with /etc/hosts or --resolve tricks, they easily cause internal problems because their trailing dots. Let's not allow them anymore.
There was a problem hiding this comment.
Pull request overview
Rejects URLs whose hostname is just a single dot or ends in two or more dots, since such names are not resolvable via DNS and cause internal issues.
Changes:
- Add hostname validation in
hostname_check()to returnCURLUE_BAD_HOSTNAMEfor hostnames that are a single.or end with... - Update lib1560 test cases (single dot, multiple trailing dots) and add new URL-roundtrip tests that expect
CURLUE_BAD_HOSTNAME. - Update
test_17_04_double_dotto expect curl to exit with code 3 (malformed URL) instead of TLS-level failures.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| lib/urlapi.c | Reject hostnames that are a single dot or have 2+ trailing dots |
| tests/libtest/lib1560.c | Update existing cases and add new URL tests for the new rule |
| tests/http/test_17_ssl_use.py | Adjust SSL trailing-dot test to expect curl exit code 3 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
comment language Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
outcast36
pushed a commit
to greearb/curl
that referenced
this pull request
Jun 3, 2026
Or consisting of just a single dot. Such names cannot be resolved with DNS. While they *can* still be resolved with /etc/hosts or --resolve tricks, they easily cause internal problems because their trailing dots. Let's not allow them anymore. Closes curl#21622
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
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.
Or if the host name is just a single dot.
Such names cannot be resolved with DNS.
While they can still be resolved with /etc/hosts or --resolve tricks, they easily cause internal problems because their trailing dots.
Let's not allow them anymore.