Skip to content

Commit

Permalink
UriNormalize.c: Fix .hostText copying in uriMakeOwnerEngine (#121)
Browse files Browse the repository at this point in the history
Commit is viewed best with "git show --ignore-all-space <sha1>"
  • Loading branch information
hartwork committed Oct 15, 2021
1 parent c5d53b2 commit 987b046
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Expand Up @@ -4,6 +4,10 @@ NOTE: uriparser is looking for help with a few things:

XXXX-XX-XX -- X.X.X

* Fixed: Fix a bug affecting both uriNormalizeSyntax* and uriMakeOwner*
functions where the text range in .hostText would not be duped using
malloc but remain unchanged (and hence "not owned") for URIs with
an IPv4 or IPv6 address hostname (GitHub #121)
* Fixed: CMake: Call "enable_language(CXX)" prior to tinkering with
CMAKE_CXX_* variables (GitHub #110)
Thanks to Alexander Richardson for the patch (originally at libexpat)
Expand Down
29 changes: 13 additions & 16 deletions src/UriNormalize.c
Expand Up @@ -407,22 +407,19 @@ static URI_INLINE UriBool URI_FUNC(MakeOwnerEngine)(URI_TYPE(Uri) * uri,

/* Host */
if ((*doneMask & URI_NORMALIZE_HOST) == 0) {
if ((uri->hostData.ip4 == NULL)
&& (uri->hostData.ip6 == NULL)) {
if (uri->hostData.ipFuture.first != NULL) {
/* IPvFuture */
if (!URI_FUNC(MakeRangeOwner)(doneMask, URI_NORMALIZE_HOST,
&(uri->hostData.ipFuture), memory)) {
return URI_FALSE; /* Raises malloc error */
}
uri->hostText.first = uri->hostData.ipFuture.first;
uri->hostText.afterLast = uri->hostData.ipFuture.afterLast;
} else if (uri->hostText.first != NULL) {
/* Regname */
if (!URI_FUNC(MakeRangeOwner)(doneMask, URI_NORMALIZE_HOST,
&(uri->hostText), memory)) {
return URI_FALSE; /* Raises malloc error */
}
if (uri->hostData.ipFuture.first != NULL) {
/* IPvFuture */
if (!URI_FUNC(MakeRangeOwner)(doneMask, URI_NORMALIZE_HOST,
&(uri->hostData.ipFuture), memory)) {
return URI_FALSE; /* Raises malloc error */
}
uri->hostText.first = uri->hostData.ipFuture.first;
uri->hostText.afterLast = uri->hostData.ipFuture.afterLast;
} else if (uri->hostText.first != NULL) {
/* Regname */
if (!URI_FUNC(MakeRangeOwner)(doneMask, URI_NORMALIZE_HOST,
&(uri->hostText), memory)) {
return URI_FALSE; /* Raises malloc error */
}
}
}
Expand Down

0 comments on commit 987b046

Please sign in to comment.