Good catch! You are quite right, and I just putback the fix: 6640582 zio_checksum_sha256() incorrect if buffer size not a multiple of 64
Fortunately the old code generates the right result whenever the buffer size *is* a multiple of 64. All buffers are at least sector-aligned (512 bytes), so everything's OK on disk. Thanks again, Jeff On Sun, Oct 07, 2007 at 10:36:08AM -0700, douglas steinwand wrote: > http://cvs.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/common/fs/zfs/sha256.c > > The block padding calculation in ZFS's sha256.c (lines 114-115) appears to be > wrong: > for (i = 0; i < padsize; i++) > pad[i] = ((uint8_t *)buf)[i]; > > The padding there is taking bytes from the start of buf, when in fact it > should be from the end (the part not already transformed). As such, the > zio_checksum_SHA256 function is not actually calculating the correct sha256 > digest of the passed buf. It could be corrected something like this: > > for (i = 0; i < padsize; i++) > pad[i] = ((uint8_t *)buf)[i + size - padsize]; > -- > This messages posted from opensolaris.org > _______________________________________________ > zfs-code mailing list > zfs-code at opensolaris.org > http://mail.opensolaris.org/mailman/listinfo/zfs-code