-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RKOTLIN-1089] Guard decoding issues when core logs invalid utf-8 messages #1792
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,13 +82,12 @@ static std::string string_to_hex(const std::string& message, realm::StringData& | |
ret << "error_code = " << error_code << "; "; | ||
ret << "retcode = " << retcode << "; "; | ||
ret << "StringData.size = " << str.size() << "; "; | ||
ret << "StringData.data = " << str << "; "; | ||
ret << "StringData as hex = "; | ||
ret << "StringData as hex ="; | ||
for (std::string::size_type i = 0; i < str.size(); ++i) | ||
ret << " 0x" << std::hex << std::setfill('0') << std::setw(2) << (int)s[i]; | ||
ret << "; "; | ||
ret << "in_begin = " << in_begin << "; "; | ||
ret << "in_end = " << in_end << "; "; | ||
ret << "in_begin = " << (void*) in_begin << "; "; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why casting to opaque pointer? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If treating |
||
ret << "in_end = " << (void*) in_end << "; "; | ||
ret << "out_curr = " << out_curr << "; "; | ||
ret << "out_end = " << out_end << ";"; | ||
return ret.str(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -973,7 +973,15 @@ realm_set_log_callback([](void *userdata, const char *category, realm_log_level_ | |
"(SLjava/lang/String;Ljava/lang/String;)V"); | ||
|
||
push_local_frame(jenv, 2); | ||
jenv->CallVoidMethod(log_callback, log_method, java_level, to_jstring(jenv, category), to_jstring(jenv, message)); | ||
jstring j_message = NULL; | ||
try { | ||
j_message = to_jstring(jenv, message); | ||
} catch (RuntimeError exception) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you observe this on Android & JVM? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is on both platforms |
||
std::ostringstream ret; | ||
ret << "Invalid data: " << exception.reason(); | ||
j_message = to_jstring(jenv, ret.str()); | ||
} | ||
jenv->CallVoidMethod(log_callback, log_method, java_level, to_jstring(jenv, category), j_message); | ||
jni_check_exception(jenv); | ||
jenv->PopLocalFrame(NULL); | ||
}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're not printing data?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This
string_to_hex
is only used to make a hex-dump of the data when we fail to decode it from UTF-8. So don't think it makes sense to include the non-decodable string itself. The result of this method is used as the message of an exception and we cannot pass that on to the JVM if the message itself is not valid unicode.