-
-
Notifications
You must be signed in to change notification settings - Fork 334
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
feat: replace occurences of strncpy to strlcpy #4636
base: main
Are you sure you want to change the base?
Changes from all commits
4251e53
3926467
db5da99
4c0eb5e
49be080
ce9668b
9b7cdec
536cc1a
e3e0127
ef8f619
332142b
b8efac1
6c67afd
7c9a4ae
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 | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -1256,9 +1256,18 @@ decodeElement(const char *const name, SentryCrashJSONDecodeContext *context) | |||||||||||||||||||||||
SENTRY_ASYNC_SAFE_LOG_DEBUG("Number is too long."); | ||||||||||||||||||||||||
return SentryCrashJSON_ERROR_DATA_TOO_LONG; | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
// Must use strncpy instead of strlcpy, because of the following reason: | ||||||||||||||||||||||||
// | ||||||||||||||||||||||||
// Also note that strlcpy() and strlcat() only operate on true ''C'' strings. | ||||||||||||||||||||||||
// This means that for strlcpy() src must be NUL-terminated and for strlcat() | ||||||||||||||||||||||||
// both src and dst must be NUL-terminated. | ||||||||||||||||||||||||
// | ||||||||||||||||||||||||
// Source: https://linux.die.net/man/3/strlcpy | ||||||||||||||||||||||||
strncpy(context->stringBuffer, start, len); | ||||||||||||||||||||||||
Comment on lines
+1261
to
1266
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. Thanks for adding this context here. This concerns me a little bit since Worth noting that while this is from the original KSCrash implementation that still is like this, the JSON codec was completely rewritten in BugSnag and no longer uses a This doesn't need to be handled here now, but we should make a mental note of this: we may want to revisit the general design of the JSON encoder for crash reports one day, depending on how much we care about memory safety. Also I'd omit the doc portion mentioning strlcat since that's not what's being used
Suggested change
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. During testing I went ahead an replaced it with Thanks for the cleanup of |
||||||||||||||||||||||||
context->stringBuffer[len] = '\0'; | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
// Parses a floating point number from stringBuffer into value using %lg format | ||||||||||||||||||||||||
// %lg uses shortest decimal representation and removes trailing zeros | ||||||||||||||||||||||||
sscanf(context->stringBuffer, "%lg", &value); | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
value *= sign; | ||||||||||||||||||||||||
|
This file was deleted.
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.
I think I resolved this conflict incorrectly. Did we want these items from the beta release's changes repeated in the 8.43.0 RC?
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.
You are correct, there have been a couple of releases since I opened up this PR. I'll fix this when getting ready to merge.