]> Cypherpunks repositories - gostls13.git/commitdiff
libmach: fix incorrect use of memset
authorDave Cheney <dave@cheney.net>
Thu, 1 Sep 2011 17:43:03 +0000 (13:43 -0400)
committerRuss Cox <rsc@golang.org>
Thu, 1 Sep 2011 17:43:03 +0000 (13:43 -0400)
Fixes #2213.

R=rsc
CC=golang-dev
https://golang.org/cl/4975047

src/libmach/executable.c

index fa0fa1b5fdba7852ec6c8c8590c2d10f622ee748..9d45323021347483d8ae780b8f3dde68f378b917 100644 (file)
@@ -811,7 +811,7 @@ elf64dotout(int fd, Fhdr *fp, ExecHdr *hp)
                buf = malloc(sh[ep->shstrndx].size);
                if (buf == 0)
                        goto done;
-               memset(buf, 0, sizeof buf);
+               memset(buf, 0, sh[ep->shstrndx].size);
                seek(fd, sh[ep->shstrndx].offset, 0);
                i = read(fd, buf, sh[ep->shstrndx].size);
                USED(i);        // shut up ubuntu gcc
@@ -989,7 +989,7 @@ elfdotout(int fd, Fhdr *fp, ExecHdr *hp)
                buf = malloc(sh[ep->shstrndx].size);
                if (buf == 0)
                        goto done;
-               memset(buf, 0, sizeof buf);
+               memset(buf, 0, sh[ep->shstrndx].size);
                seek(fd, sh[ep->shstrndx].offset, 0);
                i = read(fd, buf, sh[ep->shstrndx].size);
                USED(i);        // shut up ubuntu gcc