UBSAN warnings on calls to memcpy

Gary Lockyer gary at catalyst.net.nz
Thu May 23 03:20:40 UTC 2019


One of the more common UBSAN errors is
"null pointer passed as argument 2, which is declared to never be null"

These are calls to memcpy where the source length is 0, and the data is
NULL. Adding an "if (length > 0) {" guard before the memcpy would fix
the warning.

I'm inclined to think we should do this, but also agree that it does
clutter the code. While the call to memcpy should be safe, removing the
warnings reduces the clutter and makes it less likely we'll miss a real
issue.

Thoughts and comments appreciated.

Ngā mihi
Gary.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20190523/efcea25a/signature.sig>


More information about the samba-technical mailing list