summaryrefslogtreecommitdiffstats
path: root/contrib/netbsd-tests/lib/libc
diff options
context:
space:
mode:
authorngie <ngie@FreeBSD.org>2017-01-07 09:18:11 +0000
committerngie <ngie@FreeBSD.org>2017-01-07 09:18:11 +0000
commite208031a9ff3d83617ca3928cb3fa2bcfb4ca31e (patch)
tree1aea9067c2aa05ef7838755cc559648c03520f11 /contrib/netbsd-tests/lib/libc
parent35c33432fc83877a787631a33a12b88f8fb30f8d (diff)
downloadFreeBSD-src-e208031a9ff3d83617ca3928cb3fa2bcfb4ca31e.zip
FreeBSD-src-e208031a9ff3d83617ca3928cb3fa2bcfb4ca31e.tar.gz
MFC r311249:
{strchr,strlen}_basic: don't leak the dlopen'ed handle; close after use CID: 978299, 978300
Diffstat (limited to 'contrib/netbsd-tests/lib/libc')
-rw-r--r--contrib/netbsd-tests/lib/libc/string/t_strchr.c12
-rw-r--r--contrib/netbsd-tests/lib/libc/string/t_strlen.c11
2 files changed, 22 insertions, 1 deletions
diff --git a/contrib/netbsd-tests/lib/libc/string/t_strchr.c b/contrib/netbsd-tests/lib/libc/string/t_strchr.c
index 958b186..4556b2c 100644
--- a/contrib/netbsd-tests/lib/libc/string/t_strchr.c
+++ b/contrib/netbsd-tests/lib/libc/string/t_strchr.c
@@ -58,6 +58,9 @@ ATF_TC_HEAD(strchr_basic, tc)
ATF_TC_BODY(strchr_basic, tc)
{
+#ifdef __FreeBSD__
+ void *dl_handle;
+#endif
unsigned int t, a;
char *off;
char buf[32];
@@ -245,8 +248,12 @@ ATF_TC_BODY(strchr_basic, tc)
"abcdefgh/abcdefgh/",
};
-
+#ifdef __FreeBSD__
+ dl_handle = dlopen(NULL, RTLD_LAZY);
+ strchr_fn = dlsym(dl_handle, "test_strlen");
+#else
strchr_fn = dlsym(dlopen(0, RTLD_LAZY), "test_strchr");
+#endif
if (!strchr_fn)
strchr_fn = strchr;
@@ -281,6 +288,9 @@ ATF_TC_BODY(strchr_basic, tc)
verify_strchr(buf + a, 0xff, t, a);
}
}
+#ifdef __FreeBSD__
+ (void)dlclose(dl_handle);
+#endif
}
ATF_TP_ADD_TCS(tp)
diff --git a/contrib/netbsd-tests/lib/libc/string/t_strlen.c b/contrib/netbsd-tests/lib/libc/string/t_strlen.c
index 66158fd..7483dc6 100644
--- a/contrib/netbsd-tests/lib/libc/string/t_strlen.c
+++ b/contrib/netbsd-tests/lib/libc/string/t_strlen.c
@@ -40,6 +40,9 @@ ATF_TC_HEAD(strlen_basic, tc)
ATF_TC_BODY(strlen_basic, tc)
{
+#ifdef __FreeBSD__
+ void *dl_handle;
+#endif
/* try to trick the compiler */
size_t (*strlen_fn)(const char *);
@@ -107,7 +110,12 @@ ATF_TC_BODY(strlen_basic, tc)
* During testing it is useful have the rest of the program
* use a known good version!
*/
+#ifdef __FreeBSD__
+ dl_handle = dlopen(NULL, RTLD_LAZY);
+ strlen_fn = dlsym(dl_handle, "test_strlen");
+#else
strlen_fn = dlsym(dlopen(NULL, RTLD_LAZY), "test_strlen");
+#endif
if (!strlen_fn)
strlen_fn = strlen;
@@ -134,6 +142,9 @@ ATF_TC_BODY(strlen_basic, tc)
}
}
}
+#ifdef __FreeBSD__
+ (void)dlclose(dl_handle);
+#endif
}
ATF_TC(strlen_huge);
OpenPOWER on IntegriCloud