This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
PATCH: Fix the dlopen failure
- From: "H . J . Lu" <hjl at lucon dot org>
- To: GNU C Library <libc-alpha at sources dot redhat dot com>
- Date: Thu, 30 May 2002 14:34:16 -0700
- Subject: PATCH: Fix the dlopen failure
During dlopen, _dl_relocate_object may fail when something goes wrong.
But l_opencount isn't updated yet. When that happens, you get memory
corruption. This patch fixes it.
BTW, I couldn't find a small testcase.
H.J.
---
2002-05-30 H.J. Lu <hjl@gnu.org>
* elf/dl-open.c (dl_open_worker): Make sure the l_opencount is
always right.
(_dl_open): Check args.map->l_opencount instead of
args.map->l_searchlist.r_list[0]->l_opencount for error.
--- elf/dl-open.c.close Thu May 30 08:58:36 2002
+++ elf/dl-open.c Thu May 30 14:10:39 2002
@@ -283,7 +283,11 @@ dl_open_worker (void *a)
}
else
#endif
+ /* We need to make sure the l_opencount is always right
+ even when somethong goes wrong. */
+ ++l->l_opencount;
_dl_relocate_object (l, l->l_scope, lazy, 0);
+ --l->l_opencount;
}
if (l == new)
@@ -503,7 +507,7 @@ _dl_open (const char *file, int mode, co
/* Increment open counters for all objects since this
sometimes has not happened yet. */
- if (args.map->l_searchlist.r_list[0]->l_opencount == 0)
+ if (args.map->l_opencount == 0)
for (i = 0; i < args.map->l_searchlist.r_nlist; ++i)
++args.map->l_searchlist.r_list[i]->l_opencount;