]> granicus.if.org Git - sudo/commitdiff
If the lock record doesn't match the expected record size we need
authorTodd C. Miller <Todd.Miller@sudo.ws>
Sat, 16 Dec 2017 04:08:38 +0000 (21:08 -0700)
committerTodd C. Miller <Todd.Miller@sudo.ws>
Sat, 16 Dec 2017 04:08:38 +0000 (21:08 -0700)
to seek to the end of the record as we otherwise may have gone too
far (or not far enough).  Fixes interop problems when the time stamp
record changes size.

plugins/sudoers/timestamp.c

index b2f50e4722e5f60604713e3aca1d0a6c037f9897..3b7b8728fe4c15336aa53c661245fcb06eced55a 100644 (file)
@@ -608,6 +608,14 @@ timestamp_lock(void *vcookie, struct passwd *pw)
        if (ts_write(cookie->fd, cookie->fname, &entry, 0) == -1)
            debug_return_bool(false);
     }
+    if (entry.size != sizeof(entry)) {
+       /* Reset position if the lock record has an unexpected size. */
+       if (lseek(cookie->fd, entry.size, SEEK_SET) == -1) {
+           sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_ERRNO|SUDO_DEBUG_LINENO,
+               "unable to seek to %lld", (long long)entry.size);
+           debug_return_bool(false);
+       }
+    }
 
     /* Search for a tty/ppid-based record or append a new one. */
     sudo_debug_printf(SUDO_DEBUG_DEBUG|SUDO_DEBUG_LINENO,