Problems with LD_PRELOAD and calloc() interposition for certain executables

前端 未结 4 1146
情歌与酒
情歌与酒 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:32

    You can get away with a preliminary poor calloc that simply returns NULL. This actually works on Linux, YMMV.

    static void* poor_calloc(size_t nmemb, size_t size)
    {
        // So dlsym uses calloc internally, which will lead to infinite recursion, since our calloc calls dlsym.
        // Apparently dlsym can cope with slightly wrong calloc, see for further explanation:
        // http://blog.bigpixel.ro/2010/09/interposing-calloc-on-linux
        return NULL; // This is a poor implementation of calloc!
    }
    

提交回复
热议问题