aboutsummaryrefslogtreecommitdiffstats
path: root/lib/libzfs/libzfs_sendrecv.c
diff options
context:
space:
mode:
authorTony Hutter <[email protected]>2017-06-28 10:05:16 -0700
committerBrian Behlendorf <[email protected]>2017-06-28 10:05:16 -0700
commit682ce104cdd80db4b67eea09eb0a90324c5f98ee (patch)
tree3fa2067633f5c089685600f25601af0f791bfcaf /lib/libzfs/libzfs_sendrecv.c
parentcda0317e4d2a1277b328e4fc42ee3699bbe46c12 (diff)
GCC 7.1 fixes
GCC 7.1 with will warn when we're not checking the snprintf() return code in cases where the buffer could be truncated. This patch either checks the snprintf return code (where applicable), or simply disables the warnings (ztest.c). Reviewed-by: Chunwei Chen <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Tony Hutter <[email protected]> Closes #6253
Diffstat (limited to 'lib/libzfs/libzfs_sendrecv.c')
-rw-r--r--lib/libzfs/libzfs_sendrecv.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/libzfs/libzfs_sendrecv.c b/lib/libzfs/libzfs_sendrecv.c
index 71ee8faae..ff909f1e3 100644
--- a/lib/libzfs/libzfs_sendrecv.c
+++ b/lib/libzfs/libzfs_sendrecv.c
@@ -1867,9 +1867,13 @@ zfs_send(zfs_handle_t *zhp, const char *fromsnap, const char *tosnap,
drr_versioninfo, DMU_COMPOUNDSTREAM);
DMU_SET_FEATUREFLAGS(drr.drr_u.drr_begin.
drr_versioninfo, featureflags);
- (void) snprintf(drr.drr_u.drr_begin.drr_toname,
+ if (snprintf(drr.drr_u.drr_begin.drr_toname,
sizeof (drr.drr_u.drr_begin.drr_toname),
- "%s@%s", zhp->zfs_name, tosnap);
+ "%s@%s", zhp->zfs_name, tosnap) >=
+ sizeof (drr.drr_u.drr_begin.drr_toname)) {
+ err = EINVAL;
+ goto stderr_out;
+ }
drr.drr_payloadlen = buflen;
err = dump_record(&drr, packbuf, buflen, &zc, outfd);