Backport «buffer: ignore negative allocation lengths» to v5.x
This backports #7051 (by @addaleax) to v5.x. It landed cleanly and is straightforward fix for #7047 (closed).
I originally included this in #7169 backport, but that one is semver-minor, and I'm not exactly sure if the next 5.x release will be a semver-minor, but I definitely want this to make it into the next 5.x release.
/cc @jasnell, you already reviewed this backport in #7169, but could you also leave a comment here? Also /cc @TheAlphaNerd