NetBSD Problem Report #44959
From www@NetBSD.org Fri May 13 07:36:38 2011
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
by www.NetBSD.org (Postfix) with ESMTP id 1723763B95D
for <gnats-bugs@gnats.NetBSD.org>; Fri, 13 May 2011 07:36:38 +0000 (UTC)
Message-Id: <20110513073529.18E3263C600@www.NetBSD.org>
Date: Fri, 13 May 2011 07:35:29 +0000 (UTC)
From: henning.petersen@t-online.de
Reply-To: henning.petersen@t-online.de
To: gnats-bugs@NetBSD.org
Subject: Missing closedir in glob.c
X-Send-Pr-Version: www-1.0
>Number: 44959
>Category: lib
>Synopsis: Missing closedir in glob.c
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: lib-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri May 13 07:40:00 +0000 2011
>Closed-Date: Sun Jul 20 20:24:21 +0000 2014
>Last-Modified: Sun Jul 20 20:24:21 +0000 2014
>Originator: Henning Petersen
>Release: NetBSD-current
>Organization:
>Environment:
>Description:
Returning error without closedir.
>How-To-Repeat:
>Fix:
diff -u -r1.29 glob.c
--- lib/libc/gen/glob.c 22 Jan 2011 16:24:44 -0000 1.29
+++ lib/libc/gen/glob.c 13 May 2011 04:42:40 -0000
@@ -799,6 +799,7 @@
errno = 0;
*pathend++ = SEP;
*pathend = EOS;
+ closedir(dirp);
return GLOB_NOSPACE;
}
>Release-Note:
>Audit-Trail:
From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: lib/44959: Missing closedir in glob.c
Date: Fri, 13 May 2011 10:09:44 +0200
Doesn't it need
if (pglob->gl_flags & GLOB_ALTDIRFUNC)
(*pglob->gl_closedir)(dirp);
else
closedir(dirp);
or something?
Martin
From: henning petersen <henning.petersen@t-online.de>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: lib/44959: Missing closedir in glob.c
Date: Fri, 13 May 2011 11:42:26 +0200
This is a multi-part message in MIME format.
--------------040605030606090405010207
Content-Type: text/plain; charset=ISO-8859-15
Content-Transfer-Encoding: 7bit
Am 13.05.2011 10:10, schrieb Martin Husemann:
> The following reply was made to PR lib/44959; it has been noted by GNATS.
>
> From: Martin Husemann <martin@duskware.de>
> To: gnats-bugs@NetBSD.org
> Cc:
> Subject: Re: lib/44959: Missing closedir in glob.c
> Date: Fri, 13 May 2011 10:09:44 +0200
>
> Doesn't it need
>
> if (pglob->gl_flags & GLOB_ALTDIRFUNC)
> (*pglob->gl_closedir)(dirp);
> else
> closedir(dirp);
>
>
> or something?
>
> Martin
>
>
Is this OK.
--- lib/libc/gen/glob.c 22 Jan 2011 16:24:44 -0000 1.29
+++ lib/libc/gen/glob.c 13 May 2011 09:29:29 -0000
@@ -799,7 +799,8 @@
errno = 0;
*pathend++ = SEP;
*pathend = EOS;
- return GLOB_NOSPACE;
+ error = GLOB_NOSPACE;
+ break;
}
/*
--------------040605030606090405010207
Content-Type: text/plain;
name="glob.c.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="glob.c.diff"
diff -u -r1.29 glob.c
--- lib/libc/gen/glob.c 22 Jan 2011 16:24:44 -0000 1.29
+++ lib/libc/gen/glob.c 13 May 2011 09:29:29 -0000
@@ -799,7 +799,8 @@
errno = 0;
*pathend++ = SEP;
*pathend = EOS;
- return GLOB_NOSPACE;
+ error = GLOB_NOSPACE;
+ break;
}
/*
--------------040605030606090405010207--
From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: henning.petersen@t-online.de, christos@NetBSD.org
Subject: Re: lib/44959: Missing closedir in glob.c
Date: Sat, 14 May 2011 23:31:23 +0200
On Fri, May 13, 2011 at 09:45:02AM +0000, henning petersen wrote:
> Is this OK.
I think it is, but I do not understand the comment below the loop:
* Again Posix X/Open issue with regards to error handling.
and maybe we should return "error" in this case, like:
if ((error || errno) && (pglob->gl_flags & GLOB_ERR))
return error ? error : GLOB_ABORTED;
Christos, could you review? Or anyone?
Martin
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/44959 CVS commit: src/lib/libc/gen
Date: Sat, 14 May 2011 18:44:06 -0400
Module Name: src
Committed By: christos
Date: Sat May 14 22:44:06 UTC 2011
Modified Files:
src/lib/libc/gen: glob.c
Log Message:
PR/44959: Henning Petersen: glob forgets to closedir on out of space condition.
To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/lib/libc/gen/glob.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: christos@zoulas.com (Christos Zoulas)
To: Martin Husemann <martin@duskware.de>, gnats-bugs@NetBSD.org
Cc: henning.petersen@t-online.de
Subject: Re: lib/44959: Missing closedir in glob.c
Date: Sat, 14 May 2011 18:47:52 -0400
On May 14, 11:31pm, martin@duskware.de (Martin Husemann) wrote:
-- Subject: Re: lib/44959: Missing closedir in glob.c
| I think it is, but I do not understand the comment below the loop:
|
| * Again Posix X/Open issue with regards to error handling.
|
| and maybe we should return "error" in this case, like:
|
| if ((error || errno) && (pglob->gl_flags & GLOB_ERR))
| return error ? error : GLOB_ABORTED;
|
|
| Christos, could you review? Or anyone?
This goes back the the discussion on when to return an error when opendir
fails. I vote to leave it alone. One can control what happens with GLOB_ERR.
I fixed the closedir issue as suggested.
christos
State-Changed-From-To: open->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sun, 20 Jul 2014 20:24:21 +0000
State-Changed-Why:
the actual problem was fixed in 2011
>Unformatted:
(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-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.