[master] 0fa4baead Using memcpy() in bstrcpy() confused FlexeLint, use strcpy() instead.
dridi at varni.sh
Mon Oct 21 09:20:36 UTC 2019
On Mon, Oct 21, 2019 at 9:11 AM Poul-Henning Kamp <phk at phk.freebsd.dk> wrote:
> In message <1ed5d96b-c6f3-5665-f311-23a6e369d1c5 at uplex.de>, Nils Goroll writes:
> >On 21/10/2019 10:34, Poul-Henning Kamp wrote:
> >> - size_t lbstrcpy =3D strlen(src) + 1; \
> >> - assert(lbstrcpy <=3D sizeof dst); \
> >> - memcpy(dst, src, lbstrcpy); \
> >> + assert(strlen(src) + 1 <=3D sizeof (dst)); \
> >> + strcpy((dst), (src)); \
> >> } while (0)
> >> =20
> >> // TODO #define strcpy BANNED
> >This introduces the conflict with the plan to #define ban strcpy.
> Yes, but we can live with this strcpy() as protected by the assert
> for now. Once it is the last one in the tree, not so much.
> >Can't we find a different way to appease flexelint?
> I tried, but it seems to use some heuristic for memcpy which
> ignores what it learned from strlen() right above.
> I didnt want to spend a lot of time on it now.
When we get to the point of banning strcpy we can maybe disable the
offending lint before the offending line and restore it afterwards?
We have some margin anyway until we get there.
More information about the varnish-commit