- /*
- * Ignoring the possibility of a member name and just returning
- * the path name. See docs: sys/ldr.h, loadquery() and
- * dlopen()/RTLD_MEMBER.
- */
- if ((dl->dli_fname =
- OPENSSL_strdup(this_ldi->ldinfo_filename)) == NULL)
+ if ((buffer = OPENSSL_malloc(buffer_sz)) != NULL) {
+ OPENSSL_strlcpy(buffer, this_ldi->ldinfo_filename, buffer_sz);
+ if (member_len > 0) {
+ /*
+ * Need to respect a possible member name and not just
+ * returning the path name in this case. See docs:
+ * sys/ldr.h, loadquery() and dlopen()/RTLD_MEMBER.
+ */
+ OPENSSL_strlcat(buffer, "(", buffer_sz);
+ OPENSSL_strlcat(buffer, member, buffer_sz);
+ OPENSSL_strlcat(buffer, ")", buffer_sz);
+ }
+ dl->dli_fname = buffer;
+ } else {