]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/cc, cmd/ld: do not overflow strings in symbol lookup.
authorRémy Oudompheng <oudomphe@phare.normalesup.org>
Mon, 25 Mar 2013 07:20:22 +0000 (08:20 +0100)
committerRémy Oudompheng <oudomphe@phare.normalesup.org>
Mon, 25 Mar 2013 07:20:22 +0000 (08:20 +0100)
R=golang-dev, dave, minux.ma
CC=golang-dev
https://golang.org/cl/7876044

src/cmd/cc/lexbody
src/cmd/ld/lib.c

index 5fa980267bc8fae9ba93076ea74d6182a1f6f5da..f4a69739c86aa61232bdf9fbc0b64c52a071af5c 100644 (file)
@@ -263,7 +263,7 @@ lookup(void)
        for(s = hash[h]; s != S; s = s->link) {
                if(s->name[0] != c)
                        continue;
-               if(memcmp(s->name, symb, l) == 0)
+               if(strcmp(s->name, symb) == 0)
                        return s;
        }
        s = alloc(sizeof(*s));
index 18cae3175c4215fe927e6c08ca2ca13bad741821..f42b8dfddfa35176f4c6bd388f9fd5c73b7a459d 100644 (file)
@@ -846,17 +846,16 @@ _lookup(char *symb, int v, int creat)
        Sym *s;
        char *p;
        int32 h;
-       int l, c;
+       int c;
 
        h = v;
        for(p=symb; c = *p; p++)
                h = h+h+h + c;
-       l = (p - symb) + 1;
        // not if(h < 0) h = ~h, because gcc 4.3 -O2 miscompiles it.
        h &= 0xffffff;
        h %= NHASH;
        for(s = hash[h]; s != S; s = s->hash)
-               if(memcmp(s->name, symb, l) == 0)
+               if(strcmp(s->name, symb) == 0)
                        return s;
        if(!creat)
                return nil;