summaryrefslogtreecommitdiff
path: root/sys/src/cmd/ka
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/ka
parent3f87ffea44150d233b11a38b1ca3673207fe206e (diff)
?a: catch symb[NSYMB] buffer overflow in lexer, cleanup, assume thechar is a rune
Diffstat (limited to 'sys/src/cmd/ka')
-rw-r--r--sys/src/cmd/ka/lex.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/sys/src/cmd/ka/lex.c b/sys/src/cmd/ka/lex.c
index aa2a98c37..66152e405 100644
--- a/sys/src/cmd/ka/lex.c
+++ b/sys/src/cmd/ka/lex.c
@@ -38,7 +38,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)){
@@ -92,10 +92,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;
@@ -103,16 +103,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";
}
@@ -120,15 +117,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);