From: Todd C. Miller Date: Tue, 14 Aug 2007 14:04:41 +0000 (+0000) Subject: If we can open sudoers but fail to read the first byte, close the X-Git-Tag: SUDO_1_7_0~440 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=580be13e744988852d6f94cca99d704210904735;p=sudo If we can open sudoers but fail to read the first byte, close the file stream before trying again. --- 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;