diff options
author | Tobias Nießen <tniessen@tnie.de> | 2022-03-14 19:23:44 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-14 19:23:44 +0300 |
commit | d90ceb2b54a025a98b9cbf18f2403154d356a0c7 (patch) | |
tree | 9e68440e13e52c4878fd587523119456efb949c9 /src/node_url.cc | |
parent | 68626dc4514b70614cd345797662ad8b48735863 (diff) |
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>
Diffstat (limited to 'src/node_url.cc')
-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 79476e7a2f6..2541b95aa0c 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) { |