summaryrefslogtreecommitdiffstats
path: root/cmd/zdb
diff options
context:
space:
mode:
authorTobin Harding <[email protected]>2017-10-17 09:32:48 +1100
committerBrian Behlendorf <[email protected]>2017-10-16 15:32:48 -0700
commitced28193b06b3d93f404a5d67713c124731a2a0d (patch)
tree9e4190db472b596e896dc80ec41220450204b2d6 /cmd/zdb
parent7670f721fc82e6cdcdd31f83760a79b6f2f2b998 (diff)
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 <[email protected]> Signed-off-by: Tobin C. Harding <[email protected]> Closes #6745
Diffstat (limited to 'cmd/zdb')
-rw-r--r--cmd/zdb/zdb.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c
index ae8d00f15..af34bd9ad 100644
--- a/cmd/zdb/zdb.c
+++ b/cmd/zdb/zdb.c
@@ -2001,13 +2001,13 @@ dump_object(objset_t *os, uint64_t object, int verbosity, int *print_header,
aux[0] = '\0';
if (doi.doi_checksum != ZIO_CHECKSUM_INHERIT || verbosity >= 6) {
- (void) snprintf(aux + strlen(aux), sizeof (aux), " (K=%s)",
- ZDB_CHECKSUM_NAME(doi.doi_checksum));
+ (void) snprintf(aux + strlen(aux), sizeof (aux) - strlen(aux),
+ " (K=%s)", ZDB_CHECKSUM_NAME(doi.doi_checksum));
}
if (doi.doi_compress != ZIO_COMPRESS_INHERIT || verbosity >= 6) {
- (void) snprintf(aux + strlen(aux), sizeof (aux), " (Z=%s)",
- ZDB_COMPRESS_NAME(doi.doi_compress));
+ (void) snprintf(aux + strlen(aux), sizeof (aux) - strlen(aux),
+ " (Z=%s)", ZDB_COMPRESS_NAME(doi.doi_compress));
}
(void) printf("%10lld %3u %5s %5s %5s %6s %5s %6s %s%s\n",