diff options
author | Tomohiro Kusumi <[email protected]> | 2019-05-01 11:41:12 +0900 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2019-04-30 19:41:12 -0700 |
commit | f0ce0436aa801a5b281f93a456d394fe141034f7 (patch) | |
tree | c4ecfffe9b4b2915215e2a38fc0eaa9d94df0a62 /module/spl | |
parent | 77449a1ab0467a6fc43211a9c19d6f60be52a737 (diff) |
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 <[email protected]>
Reviewed-by: George Melikov <[email protected]>
Reviewed-by: Richard Laager <[email protected]>
Signed-off-by: Tomohiro Kusumi <[email protected]>
Closes #8692
Diffstat (limited to 'module/spl')
-rw-r--r-- | module/spl/spl-err.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/module/spl/spl-err.c b/module/spl/spl-err.c index 4c8f818a9..3c0bb71c0 100644 --- a/module/spl/spl-err.c +++ b/module/spl/spl-err.c @@ -86,7 +86,7 @@ vcmn_err(int ce, const char *fmt, va_list ap) { char msg[MAXMSGLEN]; - vsnprintf(msg, MAXMSGLEN - 1, fmt, ap); + vsnprintf(msg, MAXMSGLEN, fmt, ap); switch (ce) { case CE_IGNORE: |