From 580be13e744988852d6f94cca99d704210904735 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Tue, 14 Aug 2007 14:04:41 +0000 Subject: [PATCH] If we can open sudoers but fail to read the first byte, close the file stream before trying again. --- sudo.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sudo.c b/sudo.c index 5ebd6e47c..2f17db4a2 100644 --- a/sudo.c +++ b/sudo.c @@ -978,7 +978,6 @@ open_sudoers(sudoers, keepopen) { struct stat statbuf; FILE *fp = NULL; - char c; int rootstat, i; /* @@ -1030,8 +1029,9 @@ open_sudoers(sudoers, keepopen) /* Solaris sometimes returns EAGAIN so try 10 times */ for (i = 0; i < 10 ; i++) { errno = 0; - if ((fp = fopen(sudoers, "r")) == NULL || - fread(&c, sizeof(c), 1, fp) != 1) { + if ((fp = fopen(sudoers, "r")) == NULL || fgetc(fp) == EOF) { + if (fp != NULL) + fclose(fp); fp = NULL; if (errno != EAGAIN && errno != EWOULDBLOCK) break; -- 2.40.0