NetBSD Problem Report #51815
From www@NetBSD.org Tue Jan 10 10:46:44 2017
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 5ED967A28E
for <gnats-bugs@gnats.NetBSD.org>; Tue, 10 Jan 2017 10:46:44 +0000 (UTC)
Message-Id: <20170110104643.7C6257A2A3@mollari.NetBSD.org>
Date: Tue, 10 Jan 2017 10:46:43 +0000 (UTC)
From: yaneurabeya@gmail.com
Reply-To: yaneurabeya@gmail.com
To: gnats-bugs@NetBSD.org
Subject: [PATCH] tests/lib/libc/string/t_str{chr,len}: don't leak dlopen'ed handle
X-Send-Pr-Version: www-1.0
>Number: 51815
>Category: bin
>Synopsis: [PATCH] tests/lib/libc/string/t_str{chr,len}: don't leak dlopen'ed handle
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Jan 10 10:50:00 +0000 2017
>Closed-Date: Tue Jan 10 18:21:34 +0000 2017
>Last-Modified: Sat Jan 14 20:50:01 +0000 2017
>Originator: Ngie Cooper
>Release: 7.0.2
>Organization:
>Environment:
n/a
>Description:
The attached patch fixes an issue where the dlopen'ed handle would be leaked.
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
From: "Ngie Cooper (yaneurabeya)" <yaneurabeya@gmail.com>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: bin/51815: [PATCH] tests/lib/libc/string/t_str{chr,len}: don't
leak dlopen'ed handle
Date: Tue, 10 Jan 2017 02:50:53 -0800
--Apple-Mail=_3AA14E2C-4325-4B4E-BBB7-B9F81F10EA7D
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=us-ascii
Patch attached.
--Apple-Mail=_3AA14E2C-4325-4B4E-BBB7-B9F81F10EA7D
Content-Disposition: attachment;
filename=t_strchr-and-t_strlen-dont-leak-the-dlopen_ed-handle.patch
Content-Type: application/octet-stream;
x-unix-mode=0644;
name="t_strchr-and-t_strlen-dont-leak-the-dlopen_ed-handle.patch"
Content-Transfer-Encoding: 7bit
Index: t_strchr.c
===================================================================
RCS file: /cvsroot/src/tests/lib/libc/string/t_strchr.c,v
retrieving revision 1.1
diff -u -p -r1.1 t_strchr.c
--- t_strchr.c 7 Jul 2011 08:59:33 -0000 1.1
+++ t_strchr.c 10 Jan 2017 10:37:18 -0000
@@ -58,9 +58,10 @@ ATF_TC_HEAD(strchr_basic, tc)
ATF_TC_BODY(strchr_basic, tc)
{
- unsigned int t, a;
+ void *dl_handle;
char *off;
char buf[32];
+ unsigned int t, a;
const char *tab[] = {
"",
@@ -245,8 +246,8 @@ ATF_TC_BODY(strchr_basic, tc)
"abcdefgh/abcdefgh/",
};
-
- strchr_fn = dlsym(dlopen(0, RTLD_LAZY), "test_strchr");
+ dl_handle = dlopen(NULL, RTLD_LAZY);
+ strchr_fn = dlsym(dl_handle, "test_strlen");
if (!strchr_fn)
strchr_fn = strchr;
@@ -281,6 +282,7 @@ ATF_TC_BODY(strchr_basic, tc)
verify_strchr(buf + a, 0xff, t, a);
}
}
+ (void)dlclose(dl_handle);
}
ATF_TP_ADD_TCS(tp)
--Apple-Mail=_3AA14E2C-4325-4B4E-BBB7-B9F81F10EA7D--
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/51815 CVS commit: src/tests/lib/libc/string
Date: Tue, 10 Jan 2017 10:34:49 -0500
Module Name: src
Committed By: christos
Date: Tue Jan 10 15:34:49 UTC 2017
Modified Files:
src/tests/lib/libc/string: t_strchr.c
Log Message:
PR/51815: Ngie Cooper: don't leak dlopen'ed handle
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/string/t_strchr.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: dholland@NetBSD.org
State-Changed-When: Tue, 10 Jan 2017 18:21:34 +0000
State-Changed-Why:
christos committed it, thanks
From: "Ngie Cooper (yaneurabeya)" <yaneurabeya@gmail.com>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@netbsd.org,
netbsd-bugs@netbsd.org,
dholland@NetBSD.org
Subject: Re: bin/51815 ([PATCH] tests/lib/libc/string/t_str{chr,len}: don't
leak dlopen'ed handle)
Date: Tue, 10 Jan 2017 23:32:32 -0800
--Apple-Mail=_13A5D743-4A39-4F48-8537-A914C8E21692
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset=utf-8
I forgot to add the other portion of the diff last night when I sent it =
(the t_strlen part). I=E2=80=99ve attached the second part.
-Ngie=
--Apple-Mail=_13A5D743-4A39-4F48-8537-A914C8E21692
Content-Disposition: attachment;
filename=t_strlen-dont-leak-the-dlopen_ed-handle.patch
Content-Type: application/octet-stream;
x-unix-mode=0644;
name="t_strlen-dont-leak-the-dlopen_ed-handle.patch"
Content-Transfer-Encoding: 7bit
? obj
? string
? t_strchr-and-t_strlen-dont-leak-the-dlopen_ed-handle.patch
? t_strerror-add-missing-stdio-h-header.patch
? t_strlen-dont-leak-the-dlopen_ed-handle.patch
Index: t_strlen.c
===================================================================
RCS file: /cvsroot/src/tests/lib/libc/string/t_strlen.c,v
retrieving revision 1.5
diff -u -r1.5 t_strlen.c
--- t_strlen.c 14 Jul 2011 07:33:20 -0000 1.5
+++ t_strlen.c 11 Jan 2017 07:30:45 -0000
@@ -40,6 +40,7 @@
ATF_TC_BODY(strlen_basic, tc)
{
+ void *dl_handle;
/* try to trick the compiler */
size_t (*strlen_fn)(const char *);
@@ -107,7 +108,8 @@
* During testing it is useful have the rest of the program
* use a known good version!
*/
- strlen_fn = dlsym(dlopen(NULL, RTLD_LAZY), "test_strlen");
+ dl_handle = dlopen(NULL, RTLD_LAZY);
+ strlen_fn = dlsym(dl_handle, "test_strlen");
if (!strlen_fn)
strlen_fn = strlen;
@@ -134,6 +136,7 @@
}
}
}
+ (void)dlclose(dl_handle);
}
ATF_TC(strlen_huge);
--Apple-Mail=_13A5D743-4A39-4F48-8537-A914C8E21692--
From: "Ngie Cooper (yaneurabeya)" <yaneurabeya@gmail.com>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@netbsd.org,
netbsd-bugs@netbsd.org
Subject: Re: bin/51815 ([PATCH] tests/lib/libc/string/t_str{chr,len}: don't
leak dlopen'ed handle)
Date: Fri, 13 Jan 2017 17:57:14 -0800
--Apple-Mail=_008FB936-DF2A-4CD9-BDBB-FE1C75A95B8F
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset=utf-8
Hi!
I=E2=80=99m resending the t_strlen portion of the diff, just in =
case it was lost before, since it hasn=E2=80=99t been applied to NetBSD =
yet.
Thanks!
-Ngie
--Apple-Mail=_008FB936-DF2A-4CD9-BDBB-FE1C75A95B8F
Content-Disposition: attachment;
filename=t_strlen-dont-leak-the-dlopen_ed-handle.patch
Content-Type: application/octet-stream;
x-unix-mode=0644;
name="t_strlen-dont-leak-the-dlopen_ed-handle.patch"
Content-Transfer-Encoding: 7bit
? obj
? string
? t_strchr-and-t_strlen-dont-leak-the-dlopen_ed-handle.patch
? t_strerror-add-missing-stdio-h-header.patch
? t_strlen-dont-leak-the-dlopen_ed-handle.patch
Index: t_strlen.c
===================================================================
RCS file: /cvsroot/src/tests/lib/libc/string/t_strlen.c,v
retrieving revision 1.5
diff -u -r1.5 t_strlen.c
--- t_strlen.c 14 Jul 2011 07:33:20 -0000 1.5
+++ t_strlen.c 11 Jan 2017 07:30:45 -0000
@@ -40,6 +40,7 @@
ATF_TC_BODY(strlen_basic, tc)
{
+ void *dl_handle;
/* try to trick the compiler */
size_t (*strlen_fn)(const char *);
@@ -107,7 +108,8 @@
* During testing it is useful have the rest of the program
* use a known good version!
*/
- strlen_fn = dlsym(dlopen(NULL, RTLD_LAZY), "test_strlen");
+ dl_handle = dlopen(NULL, RTLD_LAZY);
+ strlen_fn = dlsym(dl_handle, "test_strlen");
if (!strlen_fn)
strlen_fn = strlen;
@@ -134,6 +136,7 @@
}
}
}
+ (void)dlclose(dl_handle);
}
ATF_TC(strlen_huge);
--Apple-Mail=_008FB936-DF2A-4CD9-BDBB-FE1C75A95B8F--
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/51815 CVS commit: src/tests/lib/libc/string
Date: Sat, 14 Jan 2017 15:49:24 -0500
Module Name: src
Committed By: christos
Date: Sat Jan 14 20:49:24 UTC 2017
Modified Files:
src/tests/lib/libc/string: t_strlen.c
Log Message:
PR/51815: Ngie Cooper: don't leak dlopen'ed handle
To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libc/string/t_strlen.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
>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-2014
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.