X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=utils%2Fmountd%2Fcache.c;h=a265ecda9f6412fefa457b79a915f32cfa0506c9;hb=b7f4ad19f9b3b8e0f93da719a86d0e865be5ab75;hp=96492b8f5b467ec55ddc408eeb798339a8ce47f0;hpb=e09fbc8933961a0a774217ef32d73da373ddc670;p=nfs-utils.git diff --git a/utils/mountd/cache.c b/utils/mountd/cache.c index 96492b8..a265ecd 100644 --- a/utils/mountd/cache.c +++ b/utils/mountd/cache.c @@ -376,6 +376,7 @@ cache_get_filehandle(nfs_export *exp, int len, char *p) FILE *f = fopen("/proc/fs/nfsd/filehandle", "r+"); char buf[200]; char *bp = buf; + int failed; static struct nfs_fh_len fh; if (!f) @@ -388,7 +389,9 @@ cache_get_filehandle(nfs_export *exp, int len, char *p) qword_printint(f, len); qword_eol(f); - if (fgets(buf, sizeof(buf), f) == NULL) + failed = (fgets(buf, sizeof(buf), f) == NULL); + fclose(f); + if (failed) return NULL; memset(fh.fh_handle, 0, sizeof(fh.fh_handle)); fh.fh_size = qword_get(&bp, fh.fh_handle, NFS3_FHSIZE);