]> Cypherpunks repositories - gostls13.git/commitdiff
liblink: check for symgrow size too large
authorIan Lance Taylor <iant@golang.org>
Tue, 21 Jan 2014 14:12:54 +0000 (06:12 -0800)
committerIan Lance Taylor <iant@golang.org>
Tue, 21 Jan 2014 14:12:54 +0000 (06:12 -0800)
Many calls to symgrow pass a vlong value.  Change the function
to not implicitly truncate, and to instead give an error if
the value is too large.

R=golang-codereviews, gobot, rsc
CC=golang-codereviews
https://golang.org/cl/54010043

include/link.h
src/liblink/data.c

index 2e23d20c7c4ede4ecaf5bf71e408e1d86982fb11..32d158428de29d3f11d223f3e883e5af79b64c73 100644 (file)
@@ -500,7 +500,7 @@ vlong       setuint32(Link *ctxt, LSym *s, vlong r, uint32 v);
 vlong  setuint64(Link *ctxt, LSym *s, vlong r, uint64 v);
 vlong  setuint8(Link *ctxt, LSym *s, vlong r, uint8 v);
 vlong  setuintxx(Link *ctxt, LSym *s, vlong off, uint64 v, vlong wid);
-void   symgrow(Link *ctxt, LSym *s, int32 siz);
+void   symgrow(Link *ctxt, LSym *s, vlong siz);
 
 // go.c
 void   double2ieee(uint64 *ieee, double native);
index 9a481b6e5e6d65820088999d8b87f537173c7f71..58d6d6b5e8f58eb66cb54d89531a479b72f59ca9 100644 (file)
@@ -41,10 +41,16 @@ mangle(char *file)
 }
 
 void
-symgrow(Link *ctxt, LSym *s, int32 siz)
+symgrow(Link *ctxt, LSym *s, vlong lsiz)
 {
+       int32 siz;
+
        USED(ctxt);
 
+       siz = (int32)lsiz;
+       if((vlong)siz != lsiz)
+               sysfatal("symgrow size %lld too long", lsiz);
+
        if(s->np >= siz)
                return;