summaryrefslogtreecommitdiff
path: root/sys/src/cmd/va
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2020-04-19 22:59:21 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2020-04-19 22:59:21 +0200
commite24bfa4941679fafc7578f542acc08acd18fff99 (patch)
tree1cb96c81e703d93ba37ed8a1e70e8e33bdf6ae88 /sys/src/cmd/va
parent3f87ffea44150d233b11a38b1ca3673207fe206e (diff)
?a: catch symb[NSYMB] buffer overflow in lexer, cleanup, assume thechar is a rune
Diffstat (limited to 'sys/src/cmd/va')
-rw-r--r--sys/src/cmd/va/lex.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/sys/src/cmd/va/lex.c b/sys/src/cmd/va/lex.c
index 61448d2eb..dc32a4f1d 100644
--- a/sys/src/cmd/va/lex.c
+++ b/sys/src/cmd/va/lex.c
@@ -42,7 +42,7 @@ main(int argc, char *argv[])
break;
} ARGEND
if(*argv == 0) {
- print("usage: %ca [-options] file.s\n", thechar);
+ print("usage: %Ca [-options] file.s\n", thechar);
errorexit();
}
if(argc > 1 && systemtype(Windows)){
@@ -96,10 +96,10 @@ main(int argc, char *argv[])
int
assemble(char *file)
{
- char ofile[100], incfile[20], *p;
+ char *ofile, *p;
int i, of;
- strcpy(ofile, file);
+ ofile = strdup(file);
p = utfrrune(ofile, pathchar());
if(p) {
include[0] = ofile;
@@ -107,16 +107,13 @@ assemble(char *file)
} else
p = ofile;
if(outfile == 0) {
- outfile = p;
- if(outfile){
+ if(p){
+ outfile = p;
p = utfrrune(outfile, '.');
if(p)
if(p[1] == 's' && p[2] == 0)
p[0] = 0;
- p = utfrune(outfile, 0);
- p[0] = '.';
- p[1] = thechar;
- p[2] = 0;
+ outfile = smprint("%s.%C", outfile, thechar);
} else
outfile = "/dev/null";
}
@@ -124,15 +121,13 @@ assemble(char *file)
if(p) {
setinclude(p);
} else {
- if(systemtype(Plan9)) {
- sprint(incfile,"/%s/include", thestring);
- setinclude(strdup(incfile));
- }
+ if(systemtype(Plan9))
+ setinclude(smprint("/%s/include", thestring));
}
of = mycreat(outfile, 0664);
if(of < 0) {
- yyerror("%ca: cannot create %s", thechar, outfile);
+ yyerror("%Ca: cannot create %s", thechar, outfile);
errorexit();
}
Binit(&obuf, of, OWRITE);