]> git.ipfire.org Git - thirdparty/util-linux.git/commit
liblkid: Add length check in probe_nilfs2 before crc32
authorTorsten Hilbrich <torsten.hilbrich@secunet.com>
Mon, 20 Jun 2016 05:09:10 +0000 (07:09 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 24 Jun 2016 09:13:24 +0000 (11:13 +0200)
commitac681a310c32319423297544833932f4d689a7a2
treeb1abeb3da379f3b38c9eaf2168c45d781c498660
parent81a307bd4d906815dad7b6b3c355f663907a68c4
liblkid: Add length check in probe_nilfs2 before crc32

The bytes variable is read from the file system to probe and must be
checked before used as length parameter in the crc32 call.

The following problems may occur here:

- bytes smaller than sumoff + 4: underflow in length calculation
- bytes larger than remaining space in sb: overflow of buffer

This fixes a problem where an encrypted volume had the correct magic
values 0x3434 at offset 0x406 and the following uint16_t (which is
read into the nilfs_super_block.s_bytes struct) was parsed as 1.

Then crc32 was called with the length value 18446744073709551597
causing a segmentation fault.

[kzak@redhat.com: - fix probe_nilfs2() return code]

Signed-off-by: Karel Zak <kzak@redhat.com>
libblkid/src/superblocks/nilfs.c