Message ID | 171444680655.957659.12064584983986798030.stgit@frogsfrogsfrogs (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [01/26] xfs: use unsigned ints for non-negative quantities in xfs_attr_remote.c | expand |
diff --git a/fs/xfs/xfs_fsverity.c b/fs/xfs/xfs_fsverity.c index 546c7ec6daadc..f6c650e81cb26 100644 --- a/fs/xfs/xfs_fsverity.c +++ b/fs/xfs/xfs_fsverity.c @@ -874,6 +874,16 @@ xfs_fsverity_write_merkle( .value = (void *)buf, .valuelen = size, }; + const char *p; + + /* + * Don't store trailing zeroes, except for the first byte, which we + * need to avoid ENODATA errors in the merkle read path. + */ + p = buf + size - 1; + while (p >= (const char *)buf && *p == 0) + p--; + args.valuelen = max(1, p - (const char *)buf + 1); xfs_fsverity_init_merkle_args(ip, &name, pos, &args); return xfs_attr_set(&args, XFS_ATTRUPDATE_UPSERT, false);