Skip to content

Commit

Permalink
hook: skip only symbol names prefixed with "pthread" or "__pthread"
Browse files Browse the repository at this point in the history
Sometimes share libraries might contain symbols with string "pthread" in
the middle of their names. For these symbols, they are bound to a
negative number and may therefore lead to a segfault.

This patch limits such cases to those with "pthread" or "__pthread"
prefixing ones.

Signed-off-by: You-Sheng Yang <vicamo@gmail.com>
  • Loading branch information
vicamo committed Jan 21, 2016
1 parent 3cc7ba1 commit 2e36fae
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion hybris/common/hooks.c
Expand Up @@ -1750,7 +1750,8 @@ void *get_hooked_symbol(char *sym)
return ((struct _hook*)found)->func;
}

if (strstr(sym, "pthread") != NULL)
if ((0 == strncmp(sym, "pthread", 7)) ||
(0 == strncmp(sym, "__pthread", 9)))
{
/* safe */
if (strcmp(sym, "pthread_sigmask") == 0)
Expand Down

0 comments on commit 2e36fae

Please sign in to comment.