[ERRATUM][PATCH] Fix _dl_ldsopath when no slash in INTERP path
Ignacy Gawędzki
uclibc at qult.net
Fri Dec 23 00:19:01 UTC 2011
When the INTERP program header contains a simple name with no slash, don't
crash trying to dereference a NULL pointer, but rather set _dl_ldsopath to ".".
---
ldso/ldso/ldso.c | 22 ++++++++++++++--------
1 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/ldso/ldso/ldso.c b/ldso/ldso/ldso.c
index 0dff978..f36ade3 100644
--- a/ldso/ldso/ldso.c
+++ b/ldso/ldso/ldso.c
@@ -580,10 +580,13 @@ of this helper program; chances are you did not intend to run this program.\n\
/* Store the path where the shared lib loader was found
* for later use
*/
- _dl_ldsopath = _dl_strdup(tpnt->libname);
- ptmp = _dl_strrchr(_dl_ldsopath, '/');
- if (ptmp != _dl_ldsopath)
- *ptmp = '\0';
+ ptmp = _dl_strrchr(tpnt->libname, '/');
+ if (ptmp != NULL) {
+ _dl_ldsopath = _dl_strdup(tpnt->libname);
+ if (ptmp != tpnt->libname)
+ _dl_ldsopath[ptmp - tpnt->libname] = '\0';
+ } else
+ _dl_ldsopath = _dl_strdup(".");
_dl_debug_early("Lib Loader: (%x) %s\n", (unsigned) DL_LOADADDR_BASE(tpnt->loadaddr), tpnt->libname);
}
@@ -694,10 +697,13 @@ of this helper program; chances are you did not intend to run this program.\n\
/* Store the path where the shared lib loader was found
* for later use
*/
- _dl_ldsopath = _dl_strdup(tpnt->libname);
- ptmp = _dl_strrchr(_dl_ldsopath, '/');
- if (ptmp != _dl_ldsopath)
- *ptmp = '\0';
+ ptmp = _dl_strrchr(tpnt->libname, '/');
+ if (ptmp != NULL) {
+ _dl_ldsopath = _dl_strdup(tpnt->libname);
+ if (ptmp != tpnt->libname)
+ _dl_ldsopath[ptmp - tpnt->libname] = '\0';
+ } else
+ _dl_ldsopath = _dl_strdup(".");
}
_dl_debug_early("Lib Loader: (%x) %s\n", (unsigned) DL_LOADADDR_BASE(tpnt->loadaddr), tpnt->libname);
#endif
--
1.7.5.4
More information about the uClibc
mailing list