sudo/backport-0004-CVE-2021-3156-Fix-the-memset-offset.patch

20 lines
866 B
Diff
Raw Normal View History

# HG changeset patch
# Parent 5c6c54c8f971dfa21977935328942a57591ce5a8
Fix the memset offset when converting a v1 timestamp to TS_LOCKEXCL.
We want to zero the struct starting at flags, not type (which was just set).
Found by Qualys.
--- a/plugins/sudoers/timestamp.c
+++ b/plugins/sudoers/timestamp.c
@@ -662,8 +662,8 @@ timestamp_lock(void *vcookie, struct pas
if (entry.size == sizeof(struct timestamp_entry_v1)) {
/* Old sudo record, convert it to TS_LOCKEXCL. */
entry.type = TS_LOCKEXCL;
- memset((char *)&entry + offsetof(struct timestamp_entry, type), 0,
- nread - offsetof(struct timestamp_entry, type));
+ memset((char *)&entry + offsetof(struct timestamp_entry, flags), 0,
+ nread - offsetof(struct timestamp_entry, flags));
if (ts_write(cookie->fd, cookie->fname, &entry, 0) == -1)
debug_return_bool(false);
} else {