Skip to content

Commit 2bd8ed6

Browse files
santigimenoerikolofsson
authored andcommitted
deps: fix GHSA-f74f-cvh7-c6q6/CVE-2024-24806
Refs: GHSA-f74f-cvh7-c6q6 PR-URL: nodejs#51614
1 parent 11e370f commit 2bd8ed6

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

deps/uv/src/idna.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,9 @@ long uv__idna_toascii(const char* s, const char* se, char* d, char* de) {
273273
char* ds;
274274
int rc;
275275

276+
if (s == se)
277+
return UV_EINVAL;
278+
276279
ds = d;
277280

278281
si = s;
@@ -307,8 +310,9 @@ long uv__idna_toascii(const char* s, const char* se, char* d, char* de) {
307310
return rc;
308311
}
309312

310-
if (d < de)
311-
*d++ = '\0';
313+
if (d >= de)
314+
return UV_EINVAL;
312315

316+
*d++ = '\0';
313317
return d - ds; /* Number of bytes written. */
314318
}

deps/uv/test/test-idna.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ TEST_IMPL(utf8_decode1) {
9999
TEST_IMPL(utf8_decode1_overrun) {
100100
const char* p;
101101
char b[1];
102+
char c[1];
102103

103104
/* Single byte. */
104105
p = b;
@@ -112,6 +113,10 @@ TEST_IMPL(utf8_decode1_overrun) {
112113
ASSERT_EQ((unsigned) -1, uv__utf8_decode1(&p, b + 1));
113114
ASSERT_EQ(p, b + 1);
114115

116+
b[0] = 0x7F;
117+
ASSERT_EQ(UV_EINVAL, uv__idna_toascii(b, b + 0, c, c + 1));
118+
ASSERT_EQ(UV_EINVAL, uv__idna_toascii(b, b + 1, c, c + 1));
119+
115120
return 0;
116121
}
117122

@@ -145,8 +150,8 @@ TEST_IMPL(idna_toascii) {
145150
/* Illegal inputs. */
146151
F("\xC0\x80\xC1\x80", UV_EINVAL); /* Overlong UTF-8 sequence. */
147152
F("\xC0\x80\xC1\x80.com", UV_EINVAL); /* Overlong UTF-8 sequence. */
153+
F("", UV_EINVAL);
148154
/* No conversion. */
149-
T("", "");
150155
T(".", ".");
151156
T(".com", ".com");
152157
T("example", "example");

0 commit comments

Comments
 (0)