]> granicus.if.org Git - zfs/commit
Fix coverity defects: 147480, 147584
authorTobin Harding <me@tobin.cc>
Mon, 16 Oct 2017 22:32:48 +0000 (09:32 +1100)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Mon, 16 Oct 2017 22:32:48 +0000 (15:32 -0700)
commitced28193b06b3d93f404a5d67713c124731a2a0d
tree9e4190db472b596e896dc80ec41220450204b2d6
parent7670f721fc82e6cdcdd31f83760a79b6f2f2b998
Fix coverity defects: 147480, 147584

CID 147480: Logically dead code (DEADCODE)

Remove non-null check and subsequent function call. Add ASSERT to future
proof the code.

usage label is only jumped to before `zhp` is initialized.

CID 147584: Out-of-bounds access (OVERRUN)

Subtract length of current string from buffer length for `size` argument
to `snprintf`.

Starting address for the write is the start of the buffer + the current
string length. We need to subtract this string length else risk a buffer
overflow.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tobin C. Harding <me@tobin.cc>
Closes #6745
cmd/zdb/zdb.c
cmd/zfs/zfs_main.c