Hi Eduard, On Wed, Feb 28, 2024 at 11:33:28PM +0200, Eduard Zingerman wrote: > On Wed, 2024-02-28 at 09:07 -0700, Daniel Xu wrote: > > Hi Eduard, > > > > Apologies for long delay - life has been busy. > > Hi Daniel, > > No problem, thank you for reaching back. > > [...] > > > > > +static char *get_func_name(const char *sym) > > > > +{ > > > > + char *func, *end; > > > > + > > > > + if (strncmp(sym, BTF_ID_FUNC_PFX, sizeof(BTF_ID_FUNC_PFX) - 1)) > > > > + return NULL; > > > > + > > > > + /* Strip prefix */ > > > > + func = strdup(sym + sizeof(BTF_ID_FUNC_PFX) - 1); > > > > + > > > > + /* Strip suffix */ > > > > + end = strrchr(func, '_'); > > > > + if (!end || *(end - 1) != '_') { > > > > > > Nit: this would do out of bounds access on malformed input > > > "__BTF_ID__func___" > > > > I think this is actually ok. Reason is we have the strncmp() above > > so we know the prefix is there. Then the strdup() in the malformed cased > > returns empty string. And strrchr() will then return NULL, so we don't > > enter the branch. > > > > I tested it with: https://pastes.dxuuu.xyz/c3j4kk > > > > $ gcc test.c > > dxu@kashmir~/scratch $ ./a.out > > name=(null) > > > > The test is for "__BTF_ID__func__", but nitpick is for "__BTF_ID__func___" > (three underscores in the end). > Ha, got it. Didn't see the 3rd one. Fixed in v5. [...] Thanks, Daniel