Problems with LD_PRELOAD and calloc() interposition for certain executables

前端 未结 4 1090
情歌与酒
情歌与酒 2021-02-09 15:49

Relating to a previous question of mine

I\'ve successfully interposed malloc, but calloc seems to be more problematic.

That is with ce

4条回答
  •  醉酒成梦
    2021-02-09 16:23

    With regard to __nano_init() being called twice: You've declared the function as a constructor, so it's called when the library is loaded, and it's called a second time explicitly when your malloc() and calloc() implementations are first called. Pick one.

    With regard to the calloc() interposer crashing your application: Some of the functions you're using, including dlsym() and fprintf(), may themselves be attempting to allocate memory, calling your interposer functions. Consider the consequences, and act accordingly.

提交回复
热议问题