The structure we copy this out is a large (unaligned) binary blob, hence
let's better use the memdup_suffix0() so that gcc doesn't make
assumption about the source being a valid string.
ref = BTRFS_IOCTL_SEARCH_HEADER_BODY(sh);
- p = strndup((char*) ref + sizeof(struct btrfs_root_ref), le64toh(ref->name_len));
+ p = memdup_suffix0((char*) ref + sizeof(struct btrfs_root_ref), le64toh(ref->name_len));
if (!p)
return -ENOMEM;
continue;
ref = BTRFS_IOCTL_SEARCH_HEADER_BODY(sh);
- p = strndup((char*) ref + sizeof(struct btrfs_root_ref), le64toh(ref->name_len));
+ p = memdup_suffix0((char*) ref + sizeof(struct btrfs_root_ref), le64toh(ref->name_len));
if (!p)
return -ENOMEM;