summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authordavidxu <davidxu@FreeBSD.org>2012-12-28 02:43:33 +0000
committerdavidxu <davidxu@FreeBSD.org>2012-12-28 02:43:33 +0000
commitb7760e9ec4313438ae38f630a7ca1132c5a58cb6 (patch)
tree431448f57138d726657b45bebfd74e2d0eba875c /sys/kern
parentbda4c885f5219d7d17763c96dbb32c5d0a26b2dd (diff)
downloadFreeBSD-src-b7760e9ec4313438ae38f630a7ca1132c5a58cb6.zip
FreeBSD-src-b7760e9ec4313438ae38f630a7ca1132c5a58cb6.tar.gz
Use strlcpy to NULL-terminate error message even if user provided a short
buffer.
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/vfs_mount.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c
index 97b92f8..5926e15 100644
--- a/sys/kern/vfs_mount.c
+++ b/sys/kern/vfs_mount.c
@@ -559,7 +559,7 @@ vfs_donmount(struct thread *td, uint64_t fsflags, struct uio *fsoptions)
if (error || fstype[fstypelen - 1] != '\0') {
error = EINVAL;
if (errmsg != NULL)
- strncpy(errmsg, "Invalid fstype", errmsg_len);
+ strlcpy(errmsg, "Invalid fstype", errmsg_len);
goto bail;
}
fspathlen = 0;
@@ -567,7 +567,7 @@ vfs_donmount(struct thread *td, uint64_t fsflags, struct uio *fsoptions)
if (error || fspath[fspathlen - 1] != '\0') {
error = EINVAL;
if (errmsg != NULL)
- strncpy(errmsg, "Invalid fspath", errmsg_len);
+ strlcpy(errmsg, "Invalid fspath", errmsg_len);
goto bail;
}
@@ -1447,7 +1447,7 @@ vfs_filteropt(struct vfsoptlist *opts, const char **legal)
if (ret != 0) {
TAILQ_FOREACH(opt, opts, link) {
if (strcmp(opt->name, "errmsg") == 0) {
- strncpy((char *)opt->value, errmsg, opt->len);
+ strlcpy((char *)opt->value, errmsg, opt->len);
break;
}
}
OpenPOWER on IntegriCloud