diff options
author | Tobias Nießen <tniessen@tnie.de> | 2022-03-14 17:23:44 +0100 |
---|---|---|
committer | Danielle Adams <adamzdanielle@gmail.com> | 2022-04-23 22:47:18 -0400 |
commit | 0e3e3fda22b7e26b9cd59d90dc882619a46845ae (patch) | |
tree | 10e135c43e4e236904c3c2d62eaaff4cdee84af0 | |
parent | 2e42ccf1a51b00bfb77d81da6e27f77c55974b4b (diff) | |
download | node-new-0e3e3fda22b7e26b9cd59d90dc882619a46845ae.tar.gz |
src: avoid returning invalid value from hex2bin
If the input is not a valid hexadecimal digit, hex2bin should not return
an invalid value, which is not handled correctly by the caller, which is
the PercentDecode function. However, PercentDecode only ever calls the
hex2bin function with valid hexadecimal digits, so mark the code path
that previously returned an invalid value for non-digits as UNREACHABLE.
PR-URL: https://github.com/nodejs/node/pull/42307
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
-rw-r--r-- | src/node_url.cc | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/node_url.cc b/src/node_url.cc index 79476e7a2f..2541b95aa0 100644 --- a/src/node_url.cc +++ b/src/node_url.cc @@ -230,7 +230,7 @@ unsigned hex2bin(const T ch) { return 10 + (ch - 'A'); if (ch >= 'a' && ch <= 'f') return 10 + (ch - 'a'); - return static_cast<unsigned>(-1); + UNREACHABLE(); } std::string PercentDecode(const char* input, size_t len) { |