From: Russ Cox Date: Sun, 2 Jan 2011 22:59:57 +0000 (-0500) Subject: mkfs: avoid out of bounds access to sb in wsect X-Git-Url: https://git.devinivas.org/?a=commitdiff_plain;h=e92fd6142de05627096a1e831140e5bd355e45be;p=cs3210-lab0.git mkfs: avoid out of bounds access to sb in wsect --- diff --git a/mkfs.c b/mkfs.c index 5f572cf..f227b5f 100644 --- 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);