From: Todd C. Miller Date: Fri, 11 May 2018 13:51:43 +0000 (-0600) Subject: Add debug warning if lseek() fails (should not be possible). X-Git-Tag: SUDO_1_8_24^2~90 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4a3aa5f6e6b222d308f2468364d6fe472faf0fde;p=sudo Add debug warning if lseek() fails (should not be possible). --- diff --git a/plugins/sudoers/match.c b/plugins/sudoers/match.c index 5b853f725..d51d8fd15 100644 --- a/plugins/sudoers/match.c +++ b/plugins/sudoers/match.c @@ -495,13 +495,17 @@ is_script(int fd) { bool ret = false; char magic[2]; + debug_decl(is_script, SUDOERS_DEBUG_MATCH) if (read(fd, magic, 2) == 2) { if (magic[0] == '#' && magic[1] == '!') ret = true; } - (void) lseek(fd, (off_t)0, SEEK_SET); - return ret; + if (lseek(fd, (off_t)0, SEEK_SET) == -1) { + sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_ERRNO|SUDO_DEBUG_LINENO, + "unable to rewind script fd"); + } + debug_return_int(ret); } /* @@ -782,7 +786,10 @@ digest_matches(int fd, const char *file, const struct sudo_digest *sd) debug_decl(digest_matches, SUDOERS_DEBUG_MATCH) file_digest = sudo_filedigest(fd, file, sd->digest_type, &digest_len); - (void) lseek(fd, (off_t)0, SEEK_SET); + if (lseek(fd, (off_t)0, SEEK_SET) == -1) { + sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_ERRNO|SUDO_DEBUG_LINENO, + "unable to rewind digest fd"); + } if (file_digest == NULL) { /* Warning (if any) printed by sudo_filedigest() */ goto done;