]> granicus.if.org Git - zfs/commit
Correct snprintf() size argument
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Wed, 1 May 2019 02:41:12 +0000 (11:41 +0900)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 1 May 2019 02:41:12 +0000 (19:41 -0700)
commitf0ce0436aa801a5b281f93a456d394fe141034f7
treec4ecfffe9b4b2915215e2a38fc0eaa9d94df0a62
parent77449a1ab0467a6fc43211a9c19d6f60be52a737
Correct snprintf() size argument

The size argument of snprintf(3) in glibc and snprintf() in Linux
kernel includes trailing \0, as snprintf(3) man page explains it as
"write at most size bytes (including the trailing null byte ('\0'))",
i.e. snprintf() can just take buffer size.

e.g. For snprintf() in module/zfs/zfs_ctldir.c, a buffer size is
MAXPATHLEN, and a caller is passing MAXPATHLEN to snprintf(), so size
should just be `path_len` to do what the caller is trying to do.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Richard Laager <rlaager@wiktel.com>
Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Closes #8692
lib/libzfs/libzfs_sendrecv.c
module/spl/spl-err.c
module/zfs/zfs_ctldir.c