You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "zzzxl1993 (via GitHub)" <gi...@apache.org> on 2023/07/28 11:38:21 UTC
[GitHub] [doris-thirdparty] zzzxl1993 opened a new pull request, #109: [fix] fix string to wstring buffer overflow
zzzxl1993 opened a new pull request, #109:
URL: https://github.com/apache/doris-thirdparty/pull/109
1. string to wstring buffer overflow
2. supports utf8 and non-utf8 strings
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [doris-thirdparty] airborne12 commented on a diff in pull request #109: [fix] fix string to wstring buffer overflow
Posted by "airborne12 (via GitHub)" <gi...@apache.org>.
airborne12 commented on code in PR #109:
URL: https://github.com/apache/doris-thirdparty/pull/109#discussion_r1278737430
##########
src/core/CLucene/util/stringUtil.h:
##########
@@ -234,35 +234,62 @@ class StringUtil {
int32_t surplus_bytes = 0;
uint32_t codepoint = 0;
for (uint8_t c : str) {
- if (bytes_in_char == 0) {
- if ((c & 0x80) == 0) {
- codepoint = c;
- continue;
- } else if ((c & 0xE0) == 0xC0) {
- codepoint = c & 0x1F;
- bytes_in_char = 1;
- } else if ((c & 0xF0) == 0xE0) {
- codepoint = c & 0x0F;
- bytes_in_char = 2;
- } else if ((c & 0xF8) == 0xF0) {
- codepoint = c & 0x07;
- bytes_in_char = 3;
+ if (bytes_in_char == 0) {
+ if ((c & 0x80) == 0) {
+ codepoint = c;
+ continue;
+ } else if ((c & 0xE0) == 0xC0) {
+ codepoint = c & 0x1F;
+ bytes_in_char = 1;
+ } else if ((c & 0xF0) == 0xE0) {
+ codepoint = c & 0x0F;
+ bytes_in_char = 2;
+ } else if ((c & 0xF8) == 0xF0) {
+ codepoint = c & 0x07;
+ bytes_in_char = 3;
+ } else {
+ return -1;
+ }
+ surplus_bytes = 1;
} else {
- return -1;
+ if ((c & 0xC0) != 0x80) return -1;
+ codepoint = (codepoint << 6) | (c & 0x3F);
+ if (!is_valid_codepoint(codepoint)) {
+ return -1;
+ }
+ bytes_in_char--;
+ surplus_bytes++;
}
- surplus_bytes = 1;
- } else {
- if ((c & 0xC0) != 0x80) return -1;
- codepoint = (codepoint << 6) | (c & 0x3F);
- if (!is_valid_codepoint(codepoint)) {
- return -1;
- }
- bytes_in_char--;
- surplus_bytes++;
- }
}
return bytes_in_char == 0 ? 0 : surplus_bytes;
}
+
+ // utf8: 1-4 char = 1 wchar_t, invalid utf8: 1 char = 1 wchar_t
Review Comment:
may be need some unitest for this function
--
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: dev-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@doris.apache.org
For additional commands, e-mail: dev-help@doris.apache.org
[GitHub] [doris-thirdparty] xiaokang merged pull request #109: [fix] fix string to wstring buffer overflow
Posted by "xiaokang (via GitHub)" <gi...@apache.org>.
xiaokang merged PR #109:
URL: https://github.com/apache/doris-thirdparty/pull/109
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
[GitHub] [doris-thirdparty] zzzxl1993 closed pull request #109: [fix] fix string to wstring buffer overflow
Posted by "zzzxl1993 (via GitHub)" <gi...@apache.org>.
zzzxl1993 closed pull request #109: [fix] fix string to wstring buffer overflow
URL: https://github.com/apache/doris-thirdparty/pull/109
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org