From 51f5cfe2c5c104ff536b2bb7252393cb927c0e53 Mon Sep 17 00:00:00 2001 From: gad Date: Fri, 6 Apr 2001 02:14:39 +0000 Subject: Make sure the euid is restored in an obscure error situation. Submitted by: J Wunsch in freebsd-audit --- usr.sbin/lpr/common_source/common.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'usr.sbin/lpr/common_source') diff --git a/usr.sbin/lpr/common_source/common.c b/usr.sbin/lpr/common_source/common.c index 07e9bd4..e693e15 100644 --- a/usr.sbin/lpr/common_source/common.c +++ b/usr.sbin/lpr/common_source/common.c @@ -115,7 +115,7 @@ getq(pp, namelist) register int nitems; struct stat stbuf; DIR *dirp; - int arraysz; + int arraysz, statres; seteuid(euid); if ((dirp = opendir(pp->spool_dir)) == NULL) { @@ -140,9 +140,10 @@ getq(pp, namelist) if (d->d_name[0] != 'c' || d->d_name[1] != 'f') continue; /* daemon control files only */ seteuid(euid); - if (stat(d->d_name, &stbuf) < 0) - continue; /* Doesn't exist */ + statres = stat(d->d_name, &stbuf); seteuid(uid); + if (statres < 0) + continue; /* Doesn't exist */ q = (struct jobqueue *)malloc(sizeof(time_t) + strlen(d->d_name) + 1); if (q == NULL) -- cgit v1.1