diff options
author | Anna Henningsen <anna@addaleax.net> | 2020-05-29 18:56:58 +0300 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2020-05-30 20:26:24 +0300 |
commit | 3f32126fd554be32cb53a2458849697146145fda (patch) | |
tree | e3457c11006596a7c1ee79a7db0f0c97e193be9d /src/node_url.cc | |
parent | c45f881b92cc9ea7087fc6f74fd3dabe4adc2420 (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.cc | 6 |
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; |