Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
77053797
Commit
77053797
authored
Jan 28, 2010
by
Dean Prichard
Committed by
Russ Cox
Jan 28, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avoid overflow of symb buffer in 5a/6a/8a/5c/6c/8c
R=rsc CC=golang-dev
https://golang.org/cl/194099
parent
c9150003
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
56 additions
and
8 deletions
+56
-8
src/cmd/5a/a.h
src/cmd/5a/a.h
+3
-1
src/cmd/5a/lex.c
src/cmd/5a/lex.c
+2
-0
src/cmd/6a/a.h
src/cmd/6a/a.h
+3
-1
src/cmd/6a/lex.c
src/cmd/6a/lex.c
+1
-0
src/cmd/8a/a.h
src/cmd/8a/a.h
+3
-1
src/cmd/8a/lex.c
src/cmd/8a/lex.c
+2
-0
src/cmd/cc/cc.h
src/cmd/cc/cc.h
+3
-1
src/cmd/cc/lex.c
src/cmd/cc/lex.c
+19
-2
src/cmd/cc/lexbody
src/cmd/cc/lexbody
+18
-2
src/cmd/cc/macbody
src/cmd/cc/macbody
+2
-0
No files found.
src/cmd/5a/a.h
View file @
77053797
...
...
@@ -142,6 +142,7 @@ EXTERN int32 lineno;
EXTERN
int
nerrors
;
EXTERN
int32
nhunk
;
EXTERN
int
ninclude
;
EXTERN
int32
nsymb
;
EXTERN
Gen
nullgen
;
EXTERN
char
*
outfile
;
EXTERN
int
pass
;
...
...
@@ -149,7 +150,7 @@ EXTERN char* pathname;
EXTERN
int32
pc
;
EXTERN
int
peekc
;
EXTERN
int
sym
;
EXTERN
char
symb
[
NSYMB
]
;
EXTERN
char
*
symb
;
EXTERN
int
thechar
;
EXTERN
char
*
thestring
;
EXTERN
int32
thunk
;
...
...
@@ -157,6 +158,7 @@ EXTERN Biobuf obuf;
void
*
alloc
(
int32
);
void
*
allocn
(
void
*
,
int32
,
int32
);
void
ensuresymb
(
int32
);
void
errorexit
(
void
);
void
pushio
(
void
);
void
newio
(
void
);
...
...
src/cmd/5a/lex.c
View file @
77053797
...
...
@@ -57,6 +57,8 @@ main(int argc, char *argv[])
thechar
=
'5'
;
thestring
=
"arm"
;
ensuresymb
(
NSYMB
);
memset
(
debug
,
0
,
sizeof
(
debug
));
cinit
();
outfile
=
0
;
...
...
src/cmd/6a/a.h
View file @
77053797
...
...
@@ -155,6 +155,7 @@ EXTERN int32 lineno;
EXTERN
int
nerrors
;
EXTERN
int32
nhunk
;
EXTERN
int
ninclude
;
EXTERN
int32
nsymb
;
EXTERN
Gen
nullgen
;
EXTERN
char
*
outfile
;
EXTERN
int
pass
;
...
...
@@ -162,7 +163,7 @@ EXTERN char* pathname;
EXTERN
int32
pc
;
EXTERN
int
peekc
;
EXTERN
int
sym
;
EXTERN
char
symb
[
NSYMB
]
;
EXTERN
char
*
symb
;
EXTERN
int
thechar
;
EXTERN
char
*
thestring
;
EXTERN
int32
thunk
;
...
...
@@ -170,6 +171,7 @@ EXTERN Biobuf obuf;
void
*
alloc
(
int32
);
void
*
allocn
(
void
*
,
int32
,
int32
);
void
ensuresymb
(
int32
);
void
errorexit
(
void
);
void
pushio
(
void
);
void
newio
(
void
);
...
...
src/cmd/6a/lex.c
View file @
77053797
...
...
@@ -61,6 +61,7 @@ main(int argc, char *argv[])
thechar
=
'6'
;
thestring
=
"amd64"
;
ensuresymb
(
NSYMB
);
memset
(
debug
,
0
,
sizeof
(
debug
));
cinit
();
outfile
=
0
;
...
...
src/cmd/8a/a.h
View file @
77053797
...
...
@@ -156,6 +156,7 @@ EXTERN int32 lineno;
EXTERN
int
nerrors
;
EXTERN
int32
nhunk
;
EXTERN
int
ninclude
;
EXTERN
int32
nsymb
;
EXTERN
Gen
nullgen
;
EXTERN
char
*
outfile
;
EXTERN
int
pass
;
...
...
@@ -163,7 +164,7 @@ EXTERN char* pathname;
EXTERN
int32
pc
;
EXTERN
int
peekc
;
EXTERN
int
sym
;
EXTERN
char
symb
[
NSYMB
]
;
EXTERN
char
*
symb
;
EXTERN
int
thechar
;
EXTERN
char
*
thestring
;
EXTERN
int32
thunk
;
...
...
@@ -171,6 +172,7 @@ EXTERN Biobuf obuf;
void
*
alloc
(
int32
);
void
*
allocn
(
void
*
,
int32
,
int32
);
void
ensuresymb
(
int32
);
void
errorexit
(
void
);
void
pushio
(
void
);
void
newio
(
void
);
...
...
src/cmd/8a/lex.c
View file @
77053797
...
...
@@ -60,6 +60,8 @@ main(int argc, char *argv[])
thechar
=
'8'
;
thestring
=
"386"
;
ensuresymb
(
NSYMB
);
memset
(
debug
,
0
,
sizeof
(
debug
));
cinit
();
outfile
=
0
;
...
...
src/cmd/cc/cc.h
View file @
77053797
...
...
@@ -492,6 +492,7 @@ EXTERN int32 nhunk;
EXTERN
int
ninclude
;
EXTERN
Node
*
nodproto
;
EXTERN
Node
*
nodcast
;
EXTERN
int32
nsymb
;
EXTERN
Biobuf
outbuf
;
EXTERN
Biobuf
diagbuf
;
EXTERN
char
*
outfile
;
...
...
@@ -500,7 +501,7 @@ EXTERN int peekc;
EXTERN
int32
stkoff
;
EXTERN
Type
*
strf
;
EXTERN
Type
*
strl
;
EXTERN
char
symb
[
NSYMB
]
;
EXTERN
char
*
symb
;
EXTERN
Sym
*
symstring
;
EXTERN
int
taggen
;
EXTERN
Type
*
tfield
;
...
...
@@ -573,6 +574,7 @@ int mpatov(char*, vlong*);
*/
void
*
allocn
(
void
*
,
int32
,
int32
);
void
*
alloc
(
int32
);
void
ensuresymb
(
int32
);
void
cinit
(
void
);
int
compile
(
char
*
,
char
**
,
int
);
void
errorexit
(
void
);
...
...
src/cmd/cc/lex.c
View file @
77053797
...
...
@@ -85,6 +85,7 @@ main(int argc, char *argv[])
char
*
defs
[
50
],
*
p
;
int
nproc
,
nout
,
i
,
c
,
ndef
;
ensuresymb
(
NSYMB
);
memset
(
debug
,
0
,
sizeof
(
debug
));
tinit
();
cinit
();
...
...
@@ -392,7 +393,7 @@ newfile(char *s, int f)
Sym
*
slookup
(
char
*
s
)
{
ensuresymb
(
strlen
(
s
));
strcpy
(
symb
,
s
);
return
lookup
();
}
...
...
@@ -408,7 +409,9 @@ lookup(void)
if
((
uchar
)
symb
[
0
]
==
0xc2
&&
(
uchar
)
symb
[
1
]
==
0xb7
)
{
// turn leading · into ""·
memmove
(
symb
+
2
,
symb
,
strlen
(
symb
)
+
1
);
h
=
strlen
(
symb
);
ensuresymb
(
h
+
2
);
memmove
(
symb
+
2
,
symb
,
h
+
1
);
symb
[
0
]
=
'"'
;
symb
[
1
]
=
'"'
;
}
...
...
@@ -1584,3 +1587,17 @@ allocn(void *p, int32 n, int32 d)
memset
((
char
*
)
p
+
n
,
0
,
d
);
return
p
;
}
void
ensuresymb
(
int32
n
)
{
if
(
symb
==
nil
)
{
symb
=
alloc
(
NSYMB
+
1
);
nsymb
=
NSYMB
;
}
if
(
n
>
nsymb
)
{
symb
=
allocn
(
symb
,
nsymb
,
n
+
1
-
nsymb
);
nsymb
=
n
;
}
}
src/cmd/cc/lexbody
View file @
77053797
...
...
@@ -125,6 +125,20 @@ allocn(void *p, int32 on, int32 n)
return p;
}
void
ensuresymb(int32 n)
{
if(symb == nil) {
symb = alloc(NSYMB+1);
nsymb = NSYMB;
}
if(n > nsymb) {
symb = allocn(symb, nsymb, n+1-nsymb);
nsymb = n;
}
}
void
setinclude(char *p)
{
...
...
@@ -209,7 +223,7 @@ newfile(char *s, int f)
Sym*
slookup(char *s)
{
ensuresymb(strlen(s));
strcpy(symb, s);
return lookup();
}
...
...
@@ -225,7 +239,9 @@ lookup(void)
if((uchar)symb[0] == 0xc2 && (uchar)symb[1] == 0xb7) {
// turn leading · into ""·
memmove(symb+2, symb, strlen(symb)+1);
h = strlen(symb);
ensuresymb(h+2);
memmove(symb+2, symb, h+1);
symb[0] = '"';
symb[1] = '"';
}
...
...
src/cmd/cc/macbody
View file @
77053797
...
...
@@ -140,6 +140,7 @@ dodefine(char *cp)
char *p;
int32 l;
ensuresymb(strlen(cp));
strcpy(symb, cp);
p = strchr(symb, '=');
if(p) {
...
...
@@ -574,6 +575,7 @@ macinc(void)
for(i=0; i<ninclude; i++) {
if(i == 0 && c0 == '>')
continue;
ensuresymb(strlen(include[i])+strlen(str)+2);
strcpy(symb, include[i]);
strcat(symb, "/");
if(strcmp(symb, "./") == 0)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment