]> Devi Nivas Git - cs3210-lab1.git/commitdiff
mkfs: avoid out of bounds access to sb in wsect
authorRuss Cox <rsc@swtch.com>
Sun, 2 Jan 2011 22:59:57 +0000 (17:59 -0500)
committerRuss Cox <rsc@swtch.com>
Sun, 2 Jan 2011 22:59:57 +0000 (17:59 -0500)
mkfs.c

diff --git a/mkfs.c b/mkfs.c
index 5f572cf8f7b9dec98ccd76141bf8a888be025103..f227b5f6c266d4704975e883df427648d45c6059 100644 (file)
--- 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);