authpf file descriptor leak (minor)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

authpf file descriptor leak (minor)

Peter Postma
Forget the previous message, Theo prefers diffs ;-)

The following was found by Coverity:
File descriptor leak in authpf (fopen without fclose).


Index: authpf.c
===================================================================
RCS file: /cvs/src/usr.sbin/authpf/authpf.c,v
retrieving revision 1.96
diff -u -u -r1.96 authpf.c
--- authpf.c 12 Dec 2005 16:06:01 -0000 1.96
+++ authpf.c 17 Mar 2006 21:56:11 -0000
@@ -555,10 +555,12 @@
     sizeof(tmp));
  while (fputs(tmp, stdout) != EOF && !feof(f)) {
  if (fgets(tmp, sizeof(tmp), f) == NULL) {
+ fclose(f);
  fflush(stdout);
  return (0);
  }
  }
+ fclose(f);
  }
  fflush(stdout);
  return (0);

--
Peter Postma