Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2020-05-29 18:56:58 +0300
committerJames M Snell <jasnell@gmail.com>2020-05-30 20:26:24 +0300
commit3f32126fd554be32cb53a2458849697146145fda (patch)
treee3457c11006596a7c1ee79a7db0f0c97e193be9d /src/node_url.cc
parentc45f881b92cc9ea7087fc6f74fd3dabe4adc2420 (diff)
src: avoid OOB read in URL parser
This is not a big concern, because right now, all (non-test) inputs to the parser are `'\0'`-terminated, but we should be future-proof here and not perform these OOB reads. PR-URL: https://github.com/nodejs/node/pull/33640 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'src/node_url.cc')
-rw-r--r--src/node_url.cc6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/node_url.cc b/src/node_url.cc
index 8751588d8bf..a181d5fb5d8 100644
--- a/src/node_url.cc
+++ b/src/node_url.cc
@@ -1488,7 +1488,7 @@ void URL::Parse(const char* input,
state = kSpecialRelativeOrAuthority;
} else if (special) {
state = kSpecialAuthoritySlashes;
- } else if (p[1] == '/') {
+ } else if (p + 1 < end && p[1] == '/') {
state = kPathOrAuthority;
p++;
} else {
@@ -1548,7 +1548,7 @@ void URL::Parse(const char* input,
}
break;
case kSpecialRelativeOrAuthority:
- if (ch == '/' && p[1] == '/') {
+ if (ch == '/' && p + 1 < end && p[1] == '/') {
state = kSpecialAuthorityIgnoreSlashes;
p++;
} else {
@@ -1696,7 +1696,7 @@ void URL::Parse(const char* input,
break;
case kSpecialAuthoritySlashes:
state = kSpecialAuthorityIgnoreSlashes;
- if (ch == '/' && p[1] == '/') {
+ if (ch == '/' && p + 1 < end && p[1] == '/') {
p++;
} else {
continue;