When emulating DSO_NEXT with shl_get() we need to skip the program's

handle.  This used to be documented as being index -2 but now it
seems to be index 0.  As this is not guaranteed we need to look up
the real handle value for PROG_HANDLE and skip it when interating
through all the DSOs.  Fixes infinite recursion on HP-UX in the
getenv() replacement.
This commit is contained in:
Todd C. Miller
2014-02-11 07:43:13 -07:00
parent 151f001d81
commit 02d86aafe8

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2012-2013 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2010, 2012-2014 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -131,9 +131,16 @@ sudo_dso_findsym(void *vhandle, const char *symbol)
*/
if (vhandle == SUDO_DSO_NEXT) {
/* Iterate over all shared libs looking for symbol. */
shl_t myhandle = PROG_HANDLE;
struct shl_descriptor *desc;
int idx = 0;
/* Find program's real handle. */
if (shl_gethandle(PROG_HANDLE, &desc) == 0)
myhandle = desc->handle;
while (shl_get(idx++, &desc) == 0) {
if (desc->handle == myhandle)
continue;
if (shl_findsym(&desc->handle, symbol, TYPE_UNDEFINED, &value) == 0)
break;
}