commit e92fd6142de05627096a1e831140e5bd355e45be
parent 2ea6c764c34d3025b5f3121a0919fda7d1eb9b01
Author: Russ Cox <rsc@swtch.com>
Date: Sun, 2 Jan 2011 17:59:57 -0500
mkfs: avoid out of bounds access to sb in wsect
Diffstat:
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/mkfs.c b/mkfs.c
@@ -90,7 +90,9 @@ main(int argc, char *argv[])
for(i = 0; i < nblocks + usedblocks; i++)
wsect(i, zeroes);
- wsect(1, &sb);
+ memset(buf, 0, sizeof(buf));
+ memmove(buf, &sb, sizeof(sb));
+ wsect(1, buf);
rootino = ialloc(T_DIR);
assert(rootino == ROOTINO);