Skip to content

Commit 51841eb

Browse files
authored
Merge pull request from GHSA-g3x6-p824-x6hm
Fix Out-of-bound read in url_canonize2 and url_canonize3
2 parents 907f2ac + 32a209f commit 51841eb

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

libsofia-sip-ua/url/url.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,12 @@ char *url_canonize2(char *d, char const * const s, size_t n,
364364
continue;
365365
}
366366

367-
h1 = s[i + 1], h2 = s[i + 2];
367+
h1 = s[i + 1];
368+
if (!h1) {
369+
*d = '\0';
370+
return NULL;
371+
}
372+
h2 = s[i + 2];
368373

369374
if (!IS_HEX(h1) || !IS_HEX(h2)) {
370375
*d = '\0';
@@ -422,7 +427,12 @@ char *url_canonize3(char *d, char const * const s, size_t n,
422427
continue;
423428
}
424429

425-
h1 = s[i + 1], h2 = s[i + 2];
430+
h1 = s[i + 1];
431+
if (!h1) {
432+
*d = '\0';
433+
return NULL;
434+
}
435+
h2 = s[i + 2];
426436

427437
if (!IS_HEX(h1) || !IS_HEX(h2)) {
428438
*d = '\0';

0 commit comments

Comments
 (0)