Skip to content

Commit d7ad6f8

Browse files
TimWollaDanielEScherzer
authored andcommitted
uri: Update to uriparser-1.0.1 (#21890)
This fixes CVE-2026-42371. (cherry picked from commit 542256c)
1 parent 9cf4182 commit d7ad6f8

4 files changed

Lines changed: 28 additions & 10 deletions

File tree

ext/uri/uriparser/include/uriparser/Uri.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* 5abed1007be99942f49ffe603a894d277066b79b9cb824547af0f3b9481cb9ca (1.0.0+)
1+
/* 53c1cb9f2f728652fe001dc72fa0fa7a0e9fa0b8baaaa9e37561c6cdf88ac4df (1.0.1+)
22
*
33
* uriparser - RFC 3986 URI parsing library
44
*

ext/uri/uriparser/include/uriparser/UriBase.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
/* Version */
5353
# define URI_VER_MAJOR 1
5454
# define URI_VER_MINOR 0
55-
# define URI_VER_RELEASE 0
55+
# define URI_VER_RELEASE 1
5656
# define URI_VER_SUFFIX_ANSI ""
5757
# define URI_VER_SUFFIX_UNICODE URI_ANSI_TO_UNICODE(URI_VER_SUFFIX_ANSI)
5858

ext/uri/uriparser/src/UriCommon.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
# endif
6767

6868
# include <assert.h>
69+
# include <stddef.h>
6970

7071
/*extern*/ const URI_CHAR * const URI_FUNC(SafeToPointTo) = _UT("X");
7172
/*extern*/ const URI_CHAR * const URI_FUNC(ConstPwd) = _UT(".");
@@ -106,6 +107,8 @@ int URI_FUNC(FreeUriPath)(URI_TYPE(Uri) * uri, UriMemoryManager * memory) {
106107
/* Compares two text ranges for equal text content */
107108
int URI_FUNC(CompareRange)(const URI_TYPE(TextRange) * a, const URI_TYPE(TextRange) * b) {
108109
int diff;
110+
ptrdiff_t lenA;
111+
ptrdiff_t lenB;
109112

110113
/* NOTE: Both NULL means equal! */
111114
if ((a == NULL) || (b == NULL)) {
@@ -117,14 +120,16 @@ int URI_FUNC(CompareRange)(const URI_TYPE(TextRange) * a, const URI_TYPE(TextRan
117120
return ((a->first == NULL) ? 0 : 1) - ((b->first == NULL) ? 0 : 1);
118121
}
119122

120-
diff = ((int)(a->afterLast - a->first) - (int)(b->afterLast - b->first));
121-
if (diff > 0) {
123+
lenA = a->afterLast - a->first;
124+
lenB = b->afterLast - b->first;
125+
126+
if (lenA > lenB) {
122127
return 1;
123-
} else if (diff < 0) {
128+
} else if (lenA < lenB) {
124129
return -1;
125130
}
126131

127-
diff = URI_STRNCMP(a->first, b->first, (a->afterLast - a->first));
132+
diff = URI_STRNCMP(a->first, b->first, (size_t)lenA);
128133

129134
if (diff > 0) {
130135
return 1;
@@ -727,7 +732,7 @@ UriBool URI_FUNC(FixPathNoScheme)(URI_TYPE(Uri) * uri, UriMemoryManager * memory
727732
}
728733

729734
/* When dropping a host from a URI without a scheme, an absolute path
730-
* and and empty first path segment, a consecutive reparse would rightfully
735+
* and empty first path segment, a consecutive reparse would rightfully
731736
* mis-classify the first path segment as a host marker due to the "//".
732737
* To protect against this case, we prepend an artificial "." segment
733738
* to the path in here; the function is called after the host has

ext/uri/uriparser/src/UriMemory.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,25 @@
4545
#include "UriConfig.h" /* for HAVE_REALLOCARRAY */
4646

4747
#ifdef HAVE_REALLOCARRAY
48-
# ifndef _GNU_SOURCE
49-
# define _GNU_SOURCE 1
48+
// For glibc >=2.29 of 2019-02-01
49+
# if !defined(_DEFAULT_SOURCE)
50+
# define _DEFAULT_SOURCE 1
5051
# endif
51-
# ifdef __NetBSD__
52+
53+
// For NetBSD (stdlib.h revision 1.122 of 2020-05-26)
54+
# if defined(__NetBSD__) && !defined(_OPENBSD_SOURCE)
5255
# define _OPENBSD_SOURCE 1
5356
# endif
57+
58+
// POSIX 2024 (XPG8) for e.g. Illumos/SmartOS
59+
# if !defined(_XOPEN_SOURCE) || (_XOPEN_SOURCE - 0 < 800)
60+
# undef _XOPEN_SOURCE
61+
# define _XOPEN_SOURCE 800
62+
# endif
63+
# if !defined(_POSIX_C_SOURCE) || (_POSIX_C_SOURCE - 0 < 202405L)
64+
# undef _POSIX_C_SOURCE
65+
# define _POSIX_C_SOURCE 202405L
66+
# endif
5467
#endif
5568

5669
#include <errno.h>

0 commit comments

Comments
 (0)