ubeddulla commented on code in PR #3376:
URL: https://github.com/apache/brpc/pull/3376#discussion_r3568190956


##########
src/butil/containers/case_ignored_flat_map.h:
##########
@@ -29,7 +29,11 @@ namespace butil {
 // note: using char caused crashes on ubuntu 20.04 aarch64 (VM on apple M1)
 inline char ascii_tolower(int/*note*/ c) {
     extern const signed char* const g_tolower_map;
-    return g_tolower_map[c];
+    // g_tolower_map is biased by +128 and sized for a signed-char index
+    // ([-128,127]). Callers pass a `char`; on platforms where `char` is
+    // unsigned (aarch64, riscv64) a byte >= 0x80 arrives here as 128..255 and
+    // indexes past the 256-entry table. Fold back into signed-char range.
+    return g_tolower_map[(signed char)c];

Review Comment:
   Done — the to_lower test now iterates all 256 byte values passed as a char 
and compares against ::tolower, so the 128..255 promotion path is exercised.



##########
src/brpc/uri.cpp:
##########
@@ -168,7 +168,7 @@ int URI::SetHttpURL(const char* url) {
     bool need_scheme = true;
     bool need_user_info = true;
     for (; true; ++p) {
-        const char action = g_url_parsing_fast_action_map[(int)*p];
+        const char action = g_url_parsing_fast_action_map[(signed char)*p];
         if (action == URI_PARSE_CONTINUE) {

Review Comment:
   Fair point on CI. For now I added a URL test with high-bit bytes that reads 
OOB under ASan without the fold, which catches it on any 
-funsigned-char/aarch64 ASan run. Adding a dedicated -funsigned-char CI job 
feels like a separate change; happy to follow up with one if you'd like it in 
scope.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to