On Mon, Nov 9, 2015 at 1:48 PM, Todd C. Miller <todd.mil...@courtesan.com> wrote: > Use the *at system calls instead of changing directories. ... > + if ((dfd = open(AT_SPOOL, O_RDONLY|O_DIRECTORY)) == -1 || > + (spool = fdopendir(dfd)) == NULL) > perr2("Cannot open ", AT_SPOOL);
If fdopendir() fails, dfd needs to be closed. > + i = openat(dfd, dirent->d_name, > + O_RDONLY|O_NOFOLLOW); > + if (i == -1 || (fp = fdopen(i, "r")) == NULL) > + perr2("Cannot open ", dirent->d_name); Similarly, if fdopen() fails, i needs to be closed. Philip Guenther