From 98e7a432a78d3ec0e6cbeb9fea11b9e68612150a Mon Sep 17 00:00:00 2001 From: ed Date: Sat, 11 Apr 2009 14:43:22 +0000 Subject: [PATCH] Fix a bug in r185587. fstat(fd, &sb) was not executed unconditionally anymore so sb was read uninitialised when -C is used. Submitted by: Christoph Mallon --- sbin/newfs_msdos/newfs_msdos.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sbin/newfs_msdos/newfs_msdos.c b/sbin/newfs_msdos/newfs_msdos.c index 0b787717037e..d10474cc7d82 100644 --- a/sbin/newfs_msdos/newfs_msdos.c +++ b/sbin/newfs_msdos/newfs_msdos.c @@ -363,8 +363,9 @@ main(int argc, char *argv[]) errx(1, "failed to create %s", fname); if (ftruncate(fd, opt_create)) errx(1, "failed to initialize %jd bytes", (intmax_t)opt_create); - } else if ((fd = open(fname, opt_N ? O_RDONLY : O_RDWR)) == -1 || - fstat(fd, &sb)) + } else if ((fd = open(fname, opt_N ? O_RDONLY : O_RDWR)) == -1) + err(1, "%s", fname); + if (fstat(fd, &sb)) err(1, "%s", fname); if (!opt_N) check_mounted(fname, sb.st_mode);