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.
This commit is contained in:
Todd C. Miller
2021-01-23 08:44:00 -07:00
parent 1f8638577d
commit 0754533d24

View File

@@ -643,8 +643,8 @@ timestamp_lock(void *vcookie, struct passwd *pw)
if (entry.size == sizeof(struct timestamp_entry_v1)) { if (entry.size == sizeof(struct timestamp_entry_v1)) {
/* Old sudo record, convert it to TS_LOCKEXCL. */ /* Old sudo record, convert it to TS_LOCKEXCL. */
entry.type = TS_LOCKEXCL; entry.type = TS_LOCKEXCL;
memset((char *)&entry + offsetof(struct timestamp_entry, type), 0, memset((char *)&entry + offsetof(struct timestamp_entry, flags), 0,
nread - offsetof(struct timestamp_entry, type)); nread - offsetof(struct timestamp_entry, flags));
if (ts_write(cookie->fd, cookie->fname, &entry, 0) == -1) if (ts_write(cookie->fd, cookie->fname, &entry, 0) == -1)
debug_return_bool(false); debug_return_bool(false);
} else { } else {