Skip to content
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

fix: Validate tm put into strftime #510

Merged
merged 1 commit into from
Apr 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/sentry_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,12 @@ sentry__msec_time_to_iso8601(uint64_t time)
struct tm tm_buf;
tm = gmtime_r(&secs, &tm_buf);
#endif
// It might as well be that the `time` parameter is broken in some way and
// would create a broken `tm` that then later causes formatting issues. We
// have seen super strange timestamps in some event payloads.
if (!tm || tm->tm_year > 9000) {
return NULL;
}
size_t written = strftime(buf, buf_len, "%Y-%m-%dT%H:%M:%S", tm);
if (written == 0) {
return NULL;
Expand Down
3 changes: 3 additions & 0 deletions src/sentry_value.c
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,9 @@ sentry_value_to_msgpack(sentry_value_t value, size_t *size_out)
sentry_value_t
sentry__value_new_string_owned(char *s)
{
if (!s) {
return sentry_value_new_null();
}
sentry_value_t rv
= new_thing_value(s, THING_TYPE_STRING | THING_TYPE_FROZEN);
if (sentry_value_is_null(rv)) {
Expand Down