File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -1006,7 +1006,10 @@ namespace ada::parser {
1006
1006
// and append the result to url’s path.
1007
1007
if (pointer != pointer_end) {
1008
1008
if (character_sets::bit_at (character_sets::C0_CONTROL_PERCENT_ENCODE, *pointer)) {
1009
- url.path += character_sets::hex + *pointer * 4 ;
1009
+ // We cast to an unsigned 8-bit integer because
1010
+ // *pointer is of type 'char' which may be signed or unsigned.
1011
+ // A negative index access in 'character_sets::hex' is unsafe.
1012
+ url.path += character_sets::hex[uint8_t (*pointer) * 4 ];
1010
1013
} else {
1011
1014
url.path += *pointer;
1012
1015
}
@@ -1177,7 +1180,7 @@ namespace ada::parser {
1177
1180
// a Windows drive letter and base’s path[0] is a normalized Windows drive letter,
1178
1181
// then append base’s path[0] to url’s path.
1179
1182
if (std::distance (pointer, pointer_end) > 0 && !base_url->path .empty ()) {
1180
- if (!checkers::is_windows_drive_letter (pointer + pointer[ 0 ] )) {
1183
+ if (!checkers::is_windows_drive_letter ({ pointer, size_t (pointer_end - pointer)} )) {
1181
1184
std::string first_base_url_path = base_url->path .substr (1 , base_url->path .find_first_of (' /' , 1 ));
1182
1185
1183
1186
if (checkers::is_normalized_windows_drive_letter (first_base_url_path)) {
You can’t perform that action at this time.
0 commit comments