Bug 153756 - fp leak in hesiod.c .
Summary: fp leak in hesiod.c .
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: standards (show other bugs)
Version: Unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-standards (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-07 10:30 UTC by henning.petersen
Modified: 2011-02-27 09:22 UTC (History)
0 users

See Also:


Attachments
file.diff (268 bytes, patch)
2011-01-07 10:30 UTC, henning.petersen
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description henning.petersen 2011-01-07 10:30:09 UTC
fp leak in hesiod.c .

Fix: diff -u -r1.9 hesiod.c
--- lib/libc/net/hesiod.c	1 May 2003 19:03:14 -0000	1.9
+++ lib/libc/net/hesiod.c	5 Jan 2011 11:03:35 -0000
@@ -325,6 +325,7 @@
 			*which = strdup(data);
 			if (!*which) {
 				errno = ENOMEM;
+				fclose(fp);
 				return -1;
 			}
 		} else {


Patch attached with submission follows:
Comment 1 dfilter service freebsd_committer freebsd_triage 2011-01-08 10:57:05 UTC
Author: kib
Date: Sat Jan  8 10:56:58 2011
New Revision: 217143
URL: http://svn.freebsd.org/changeset/base/217143

Log:
  Fix struct FILE * leak on error (in disabled by default hesiod support code).
  
  Submitted by:	henning petersen <henning.petersen t-online de>
  PR:	153756
  MFC after:	1 week

Modified:
  head/lib/libc/net/hesiod.c

Modified: head/lib/libc/net/hesiod.c
==============================================================================
--- head/lib/libc/net/hesiod.c	Sat Jan  8 08:58:46 2011	(r217142)
+++ head/lib/libc/net/hesiod.c	Sat Jan  8 10:56:58 2011	(r217143)
@@ -324,6 +324,7 @@ read_config_file(ctx, filename)
 			    ? &ctx->lhs : &ctx->rhs;
 			*which = strdup(data);
 			if (!*which) {
+				fclose(fp);
 				errno = ENOMEM;
 				return -1;
 			}
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 2 dfilter service freebsd_committer freebsd_triage 2011-01-15 08:35:46 UTC
Author: kib
Date: Sat Jan 15 08:35:41 2011
New Revision: 217440
URL: http://svn.freebsd.org/changeset/base/217440

Log:
  MFC r217143:
  Fix struct FILE * leak on error (in disabled by default hesiod support code).
  
  PR:   153756

Modified:
  stable/8/lib/libc/net/hesiod.c
Directory Properties:
  stable/8/lib/libc/   (props changed)
  stable/8/lib/libc/locale/   (props changed)
  stable/8/lib/libc/stdtime/   (props changed)
  stable/8/lib/libc/sys/   (props changed)

Modified: stable/8/lib/libc/net/hesiod.c
==============================================================================
--- stable/8/lib/libc/net/hesiod.c	Sat Jan 15 08:18:58 2011	(r217439)
+++ stable/8/lib/libc/net/hesiod.c	Sat Jan 15 08:35:41 2011	(r217440)
@@ -324,6 +324,7 @@ read_config_file(ctx, filename)
 			    ? &ctx->lhs : &ctx->rhs;
 			*which = strdup(data);
 			if (!*which) {
+				fclose(fp);
 				errno = ENOMEM;
 				return -1;
 			}
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 3 Eitan Adler freebsd_committer freebsd_triage 2011-02-27 02:16:38 UTC
State Changed
From-To: open->patched

In head and 8.x but not in 7.x
Comment 4 Konstantin Belousov freebsd_committer freebsd_triage 2011-02-27 09:21:38 UTC
State Changed
From-To: patched->closed

Indeed, fixed in HEAD and 8.