summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
authorKurt Miller <kurt@cvs.openbsd.org>2005-09-30 14:51:53 +0000
committerKurt Miller <kurt@cvs.openbsd.org>2005-09-30 14:51:53 +0000
commit4cc856aee9566a0f2fc926e3137a17fc6cd9f68e (patch)
tree6bee8de37887cbe466d9d195fd341543f20c8a12 /regress
parent96c95ae27cabfdb84f146f5f0b3b20a72f8f342f (diff)
regress for a shared object with depenencies that have a shared common
dependency (similar to gaim). checks for use after free in dlclose.
Diffstat (limited to 'regress')
-rw-r--r--regress/libexec/ld.so/dlclose/test2/Makefile5
-rw-r--r--regress/libexec/ld.so/dlclose/test2/Makefile.inc35
-rw-r--r--regress/libexec/ld.so/dlclose/test2/libaa/Makefile13
-rw-r--r--regress/libexec/ld.so/dlclose/test2/libaa/aa.c20
-rw-r--r--regress/libexec/ld.so/dlclose/test2/libaa/shlib_version2
-rw-r--r--regress/libexec/ld.so/dlclose/test2/libbb/Makefile11
-rw-r--r--regress/libexec/ld.so/dlclose/test2/libbb/bb.c20
-rw-r--r--regress/libexec/ld.so/dlclose/test2/libbb/shlib_version2
-rw-r--r--regress/libexec/ld.so/dlclose/test2/libcc/Makefile11
-rw-r--r--regress/libexec/ld.so/dlclose/test2/libcc/cc.c20
-rw-r--r--regress/libexec/ld.so/dlclose/test2/libcc/shlib_version2
-rw-r--r--regress/libexec/ld.so/dlclose/test2/libzz/Makefile8
-rw-r--r--regress/libexec/ld.so/dlclose/test2/libzz/shlib_version2
-rw-r--r--regress/libexec/ld.so/dlclose/test2/libzz/zz.c20
-rw-r--r--regress/libexec/ld.so/dlclose/test2/prog1/Makefile8
-rw-r--r--regress/libexec/ld.so/dlclose/test2/prog1/main.c53
16 files changed, 232 insertions, 0 deletions
diff --git a/regress/libexec/ld.so/dlclose/test2/Makefile b/regress/libexec/ld.so/dlclose/test2/Makefile
new file mode 100644
index 00000000000..1be41e98e32
--- /dev/null
+++ b/regress/libexec/ld.so/dlclose/test2/Makefile
@@ -0,0 +1,5 @@
+# $OpenBSD: Makefile,v 1.1.1.1 2005/09/30 14:51:52 kurt Exp $
+
+SUBDIR+= libzz libcc libbb libaa prog1
+
+.include <bsd.subdir.mk>
diff --git a/regress/libexec/ld.so/dlclose/test2/Makefile.inc b/regress/libexec/ld.so/dlclose/test2/Makefile.inc
new file mode 100644
index 00000000000..29fa31b06a9
--- /dev/null
+++ b/regress/libexec/ld.so/dlclose/test2/Makefile.inc
@@ -0,0 +1,35 @@
+# $OpenBSD: Makefile.inc,v 1.1.1.1 2005/09/30 14:51:52 kurt Exp $
+
+.include <bsd.obj.mk>
+
+AA_DIR=${.CURDIR}/../libaa
+
+AA_OBJDIR!= if [ -d $(AA_DIR)/${__objdir} ]; then \
+ echo "$(AA_DIR)/${__objdir}"; \
+ else \
+ echo "$(AA_DIR)"; \
+ fi
+
+BB_DIR=${.CURDIR}/../libbb
+
+BB_OBJDIR!= if [ -d $(BB_DIR)/${__objdir} ]; then \
+ echo "$(BB_DIR)/${__objdir}"; \
+ else \
+ echo "$(BB_DIR)"; \
+ fi
+
+CC_DIR=${.CURDIR}/../libcc
+
+CC_OBJDIR!= if [ -d $(CC_DIR)/${__objdir} ]; then \
+ echo "$(CC_DIR)/${__objdir}"; \
+ else \
+ echo "$(CC_DIR)"; \
+ fi
+
+ZZ_DIR=${.CURDIR}/../libzz
+
+ZZ_OBJDIR!= if [ -d $(ZZ_DIR)/${__objdir} ]; then \
+ echo "$(ZZ_DIR)/${__objdir}"; \
+ else \
+ echo "$(ZZ_DIR)"; \
+ fi
diff --git a/regress/libexec/ld.so/dlclose/test2/libaa/Makefile b/regress/libexec/ld.so/dlclose/test2/libaa/Makefile
new file mode 100644
index 00000000000..ab782f45dd2
--- /dev/null
+++ b/regress/libexec/ld.so/dlclose/test2/libaa/Makefile
@@ -0,0 +1,13 @@
+# $OpenBSD: Makefile,v 1.1.1.1 2005/09/30 14:51:52 kurt Exp $
+
+LIB= aa
+SRCS= aa.c
+LDADD+= -Wl,-E
+LDADD+= -Wl,-rpath,$(BB_OBJDIR)
+LDADD+= -Wl,-rpath,$(CC_OBJDIR)
+LDADD+= -L$(BB_OBJDIR) -lbb
+LDADD+= -L$(CC_OBJDIR) -lcc
+
+regress: all
+
+.include <bsd.lib.mk>
diff --git a/regress/libexec/ld.so/dlclose/test2/libaa/aa.c b/regress/libexec/ld.so/dlclose/test2/libaa/aa.c
new file mode 100644
index 00000000000..3b4bae19210
--- /dev/null
+++ b/regress/libexec/ld.so/dlclose/test2/libaa/aa.c
@@ -0,0 +1,20 @@
+/* $OpenBSD: aa.c,v 1.1.1.1 2005/09/30 14:51:52 kurt Exp $ */
+
+/*
+ * Copyright (c) 2005 Kurt Miller <kurt@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+int aaSymbol;
diff --git a/regress/libexec/ld.so/dlclose/test2/libaa/shlib_version b/regress/libexec/ld.so/dlclose/test2/libaa/shlib_version
new file mode 100644
index 00000000000..987ef746955
--- /dev/null
+++ b/regress/libexec/ld.so/dlclose/test2/libaa/shlib_version
@@ -0,0 +1,2 @@
+major=1
+minor=0
diff --git a/regress/libexec/ld.so/dlclose/test2/libbb/Makefile b/regress/libexec/ld.so/dlclose/test2/libbb/Makefile
new file mode 100644
index 00000000000..4d2ab5ffa5c
--- /dev/null
+++ b/regress/libexec/ld.so/dlclose/test2/libbb/Makefile
@@ -0,0 +1,11 @@
+# $OpenBSD: Makefile,v 1.1.1.1 2005/09/30 14:51:52 kurt Exp $
+
+LIB= bb
+SRCS= bb.c
+LDADD+= -Wl,-E
+LDADD+= -Wl,-rpath,$(ZZ_OBJDIR)
+LDADD+= -L$(ZZ_OBJDIR) -lzz
+
+regress: all
+
+.include <bsd.lib.mk>
diff --git a/regress/libexec/ld.so/dlclose/test2/libbb/bb.c b/regress/libexec/ld.so/dlclose/test2/libbb/bb.c
new file mode 100644
index 00000000000..ba123dd25e3
--- /dev/null
+++ b/regress/libexec/ld.so/dlclose/test2/libbb/bb.c
@@ -0,0 +1,20 @@
+/* $OpenBSD: bb.c,v 1.1.1.1 2005/09/30 14:51:52 kurt Exp $ */
+
+/*
+ * Copyright (c) 2005 Kurt Miller <kurt@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+int bbSymbol;
diff --git a/regress/libexec/ld.so/dlclose/test2/libbb/shlib_version b/regress/libexec/ld.so/dlclose/test2/libbb/shlib_version
new file mode 100644
index 00000000000..987ef746955
--- /dev/null
+++ b/regress/libexec/ld.so/dlclose/test2/libbb/shlib_version
@@ -0,0 +1,2 @@
+major=1
+minor=0
diff --git a/regress/libexec/ld.so/dlclose/test2/libcc/Makefile b/regress/libexec/ld.so/dlclose/test2/libcc/Makefile
new file mode 100644
index 00000000000..1d1b49834c8
--- /dev/null
+++ b/regress/libexec/ld.so/dlclose/test2/libcc/Makefile
@@ -0,0 +1,11 @@
+# $OpenBSD: Makefile,v 1.1.1.1 2005/09/30 14:51:52 kurt Exp $
+
+LIB= cc
+SRCS= cc.c
+LDADD+= -Wl,-E
+LDADD+= -Wl,-rpath,$(ZZ_OBJDIR)
+LDADD+= -L$(ZZ_OBJDIR) -lzz
+
+regress: all
+
+.include <bsd.lib.mk>
diff --git a/regress/libexec/ld.so/dlclose/test2/libcc/cc.c b/regress/libexec/ld.so/dlclose/test2/libcc/cc.c
new file mode 100644
index 00000000000..b93f0a89f88
--- /dev/null
+++ b/regress/libexec/ld.so/dlclose/test2/libcc/cc.c
@@ -0,0 +1,20 @@
+/* $OpenBSD: cc.c,v 1.1.1.1 2005/09/30 14:51:52 kurt Exp $ */
+
+/*
+ * Copyright (c) 2005 Kurt Miller <kurt@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+int ccSymbol;
diff --git a/regress/libexec/ld.so/dlclose/test2/libcc/shlib_version b/regress/libexec/ld.so/dlclose/test2/libcc/shlib_version
new file mode 100644
index 00000000000..987ef746955
--- /dev/null
+++ b/regress/libexec/ld.so/dlclose/test2/libcc/shlib_version
@@ -0,0 +1,2 @@
+major=1
+minor=0
diff --git a/regress/libexec/ld.so/dlclose/test2/libzz/Makefile b/regress/libexec/ld.so/dlclose/test2/libzz/Makefile
new file mode 100644
index 00000000000..c51fb092590
--- /dev/null
+++ b/regress/libexec/ld.so/dlclose/test2/libzz/Makefile
@@ -0,0 +1,8 @@
+# $OpenBSD: Makefile,v 1.1.1.1 2005/09/30 14:51:52 kurt Exp $
+
+LIB= zz
+SRCS= zz.c
+
+regress: all
+
+.include <bsd.lib.mk>
diff --git a/regress/libexec/ld.so/dlclose/test2/libzz/shlib_version b/regress/libexec/ld.so/dlclose/test2/libzz/shlib_version
new file mode 100644
index 00000000000..987ef746955
--- /dev/null
+++ b/regress/libexec/ld.so/dlclose/test2/libzz/shlib_version
@@ -0,0 +1,2 @@
+major=1
+minor=0
diff --git a/regress/libexec/ld.so/dlclose/test2/libzz/zz.c b/regress/libexec/ld.so/dlclose/test2/libzz/zz.c
new file mode 100644
index 00000000000..17c986a35be
--- /dev/null
+++ b/regress/libexec/ld.so/dlclose/test2/libzz/zz.c
@@ -0,0 +1,20 @@
+/* $OpenBSD: zz.c,v 1.1.1.1 2005/09/30 14:51:52 kurt Exp $ */
+
+/*
+ * Copyright (c) 2005 Kurt Miller <kurt@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+int zzSymbol;
diff --git a/regress/libexec/ld.so/dlclose/test2/prog1/Makefile b/regress/libexec/ld.so/dlclose/test2/prog1/Makefile
new file mode 100644
index 00000000000..2750853da1e
--- /dev/null
+++ b/regress/libexec/ld.so/dlclose/test2/prog1/Makefile
@@ -0,0 +1,8 @@
+# $OpenBSD: Makefile,v 1.1.1.1 2005/09/30 14:51:52 kurt Exp $
+
+PROG= prog1
+SRCS= main.c
+LDFLAGS+= -Wl,-E
+LDFLAGS+= -Wl,-rpath,$(AA_OBJDIR)
+
+.include <bsd.regress.mk>
diff --git a/regress/libexec/ld.so/dlclose/test2/prog1/main.c b/regress/libexec/ld.so/dlclose/test2/prog1/main.c
new file mode 100644
index 00000000000..10ba7b35088
--- /dev/null
+++ b/regress/libexec/ld.so/dlclose/test2/prog1/main.c
@@ -0,0 +1,53 @@
+/* $OpenBSD: main.c,v 1.1.1.1 2005/09/30 14:51:52 kurt Exp $ */
+
+/*
+ * Copyright (c) 2005 Kurt Miller <kurt@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <dlfcn.h>
+#include <stdio.h>
+
+int
+main()
+{
+ int ret = 0;
+ void *libaa;
+
+ libaa = dlopen("libaa.so", RTLD_LAZY);
+
+ if (libaa == NULL) {
+ printf("dlopen(\"libaa.so\", RTLD_LAZY) FAILED\n");
+ return (1);
+ }
+
+ if(dlclose(libaa)) {
+ printf("dlclose(libaa) FAILED\n%s\n",dlerror());
+ ret = 1;
+ }
+
+ libaa = dlopen("libaa.so", RTLD_LAZY);
+
+ if (libaa == NULL) {
+ printf("dlopen(\"libaa.so\", RTLD_LAZY) FAILED\n");
+ return (1);
+ }
+
+ if(dlclose(libaa)) {
+ printf("dlclose(libaa) FAILED\n%s\n",dlerror());
+ ret = 1;
+ }
+
+ return (ret);
+}