From 56085e3341cb9ad983c22dd41e10daa090bbc48b Mon Sep 17 00:00:00 2001 From: Jaakko Heinonen Date: Mon, 1 Nov 2010 06:17:02 +0000 Subject: MFC r213668: - Print the nmount(2) provided error message only when it is set. - Ensure that the error message is NUL-terminated before printing it. PR: bin/147482 --- sbin/mksnap_ffs/mksnap_ffs.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'sbin') diff --git a/sbin/mksnap_ffs/mksnap_ffs.c b/sbin/mksnap_ffs/mksnap_ffs.c index f0db853e8163..7dcf5c216b2e 100644 --- a/sbin/mksnap_ffs/mksnap_ffs.c +++ b/sbin/mksnap_ffs/mksnap_ffs.c @@ -121,8 +121,12 @@ main(int argc, char **argv) build_iovec(&iov, &iovlen, "update", NULL, 0); build_iovec(&iov, &iovlen, "snapshot", NULL, 0); - if (nmount(iov, iovlen, stfsbuf.f_flags) < 0) - err(1, "Cannot create snapshot %s: %s", snapname, errmsg); + *errmsg = '\0'; + if (nmount(iov, iovlen, stfsbuf.f_flags) < 0) { + errmsg[sizeof(errmsg) - 1] = '\0'; + err(1, "Cannot create snapshot %s%s%s", snapname, + *errmsg != '\0' ? ": " : "", errmsg); + } if ((fd = open(snapname, O_RDONLY)) < 0) err(1, "Cannot open %s", snapname); if (fstat(fd, &stbuf) != 0) -- cgit v1.3