NetBSD Problem Report #50532

From www@NetBSD.org  Fri Dec 11 10:29:48 2015
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.NetBSD.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 7738BA667D
	for <gnats-bugs@gnats.NetBSD.org>; Fri, 11 Dec 2015 10:29:48 +0000 (UTC)
Message-Id: <20151211102947.959D0A6680@mollari.NetBSD.org>
Date: Fri, 11 Dec 2015 10:29:47 +0000 (UTC)
From: dcb314@hotmail.com
Reply-To: dcb314@hotmail.com
To: gnats-bugs@NetBSD.org
Subject: src/sys/arch/hppa/stand/xxboot/iplsum.c: 2 * resource leaks ?
X-Send-Pr-Version: www-1.0

>Number:         50532
>Category:       port-hppa
>Synopsis:       src/sys/arch/hppa/stand/xxboot/iplsum.c: 2 * resource leaks ?
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    port-hppa-maintainer
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Dec 11 10:30:00 +0000 2015
>Closed-Date:    Sun Dec 13 20:28:20 +0000 2015
>Last-Modified:  Sun Dec 13 20:28:20 +0000 2015
>Originator:     David Binderman
>Release:        cvs dated 20151210
>Organization:
>Environment:
>Description:

[src/sys/arch/hppa/stand/xxboot/iplsum.c:58]: (error) Resource leak: fp
[src/sys/arch/hppa/stand/xxboot/iplsum.c:61]: (error) Resource leak: fp

Source code is

    if ((fp = fopen(argv[1], "rb")) == NULL) {
        perror(argv[1]);
        return 1;
    }
    if ((len = fread(bootblk, 1, sizeof bootblk, fp)) <= IPLOFF) {
        fprintf(stderr, "%s: too short\n", argv[1]);
        return 1;
    } else if (len > BOOTSIZE) {
        fprintf(stderr, "%s: too long (%d vs %d)\n", argv[1], len, BOOTSIZE);
        return 1;
    }

2 * fclose inside the if conditions looks to be a good idea.
>How-To-Repeat:

>Fix:

>Release-Note:

>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/50532 CVS commit: src/sys/arch/hppa/stand/xxboot
Date: Sun, 13 Dec 2015 13:38:23 -0500

 Module Name:	src
 Committed By:	christos
 Date:		Sun Dec 13 18:38:23 UTC 2015

 Modified Files:
 	src/sys/arch/hppa/stand/xxboot: iplsum.c

 Log Message:
 PR/50532: David Binderman: Add missing fclose.


 To generate a diff of this commit:
 cvs rdiff -u -r1.1 -r1.2 src/sys/arch/hppa/stand/xxboot/iplsum.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: wiz@NetBSD.org
State-Changed-When: Sun, 13 Dec 2015 20:28:20 +0000
State-Changed-Why:
christos fixed it.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.