X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=lib%2Fhivex.c;h=4b9fcf0512a80a1184417ce9ed541fae9b3440d3;hb=96f1edbae1ed41ec1c4e558060b7b33b6b749ea4;hp=a3f5171231b986db0600d7bf45223c9f73678b2e;hpb=5a4fd441d23f96ca618e55d4e54471d2e0fa94af;p=hivex.git diff --git a/lib/hivex.c b/lib/hivex.c index a3f5171..4b9fcf0 100644 --- a/lib/hivex.c +++ b/lib/hivex.c @@ -294,9 +294,16 @@ hivex_open (const char *filename, int flags) if (h->filename == NULL) goto error; +#ifdef O_CLOEXEC h->fd = open (filename, O_RDONLY | O_CLOEXEC); +#else + h->fd = open (filename, O_RDONLY); +#endif if (h->fd == -1) goto error; +#ifndef O_CLOEXEC + fcntl (h->fd, F_SETFD, FD_CLOEXEC); +#endif struct stat statbuf; if (fstat (h->fd, &statbuf) == -1)