From: Morten Welinder Date: Fri, 08 Feb 2008 20:15:40 GMT Subject: Re: [PATCH] opening files in remote.c should ensure it is opening a file Message-ID: <118833cc0802081215t380587f6w7b5c0aba66a55799@mail.gmail.com> In-Reply-To: <20080208174654.2e9e679c@pc09.procura.nl> > +/* Helper function to ensure that we are opening a file and not a directory */ > +static FILE *open_file(char *full_path) > +{ > + struct stat st_buf; > + if (stat(full_path, &st_buf) || !S_ISREG(st_buf.st_mode)) > + return NULL; > + return (fopen(full_path, "r")); > +} That looks wrong. stat+fopen has a pointless race condition that open+fstat+fdopen would not have. Morten