From 235130433aa8ef492d1c12270a3687fc5e99d5bd Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Mon, 29 Oct 2018 17:03:20 +0000 Subject: [PATCH] Check __dso_handle is NULL in non-DSO objects. It should only be non-NULL when accessed from a shared object. MFC with: r339738 Sponsored by: DARPA, AFRL --- lib/csu/tests/fini_test.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/csu/tests/fini_test.c b/lib/csu/tests/fini_test.c index 7c6001e4f9b1..df607dc5113d 100644 --- a/lib/csu/tests/fini_test.c +++ b/lib/csu/tests/fini_test.c @@ -119,11 +119,22 @@ ATF_TC_BODY(fini_array_test, tc) } } +extern void *__dso_handle; + +ATF_TC_WITHOUT_HEAD(dso_handle_test); +ATF_TC_BODY(dso_handle_test, tc) +{ + + ATF_REQUIRE_MSG(__dso_handle == NULL, + "Invalid __dso_handle in non-DSO"); +} + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, dtors_test); ATF_TP_ADD_TC(tp, fini_array_test); + ATF_TP_ADD_TC(tp, dso_handle_test); return (atf_no_error()); }