summaryrefslogtreecommitdiff
path: root/sys/src/cmd/8l/obj.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2015-02-17 22:13:35 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2015-02-17 22:13:35 +0100
commit03feba8cc1a68da8882bfc90d182365308a00743 (patch)
tree7abec9fa0987ffd70ae30dffb7496d34d1d32241 /sys/src/cmd/8l/obj.c
parentfdeea811b7f309e1bd542a0a23fd382e332b2c2e (diff)
[125678kqv][cl]: fix sprint() and strcpy() buffer overflows
Diffstat (limited to 'sys/src/cmd/8l/obj.c')
-rw-r--r--sys/src/cmd/8l/obj.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/sys/src/cmd/8l/obj.c b/sys/src/cmd/8l/obj.c
index a6aec8d85..2aeee6811 100644
--- a/sys/src/cmd/8l/obj.c
+++ b/sys/src/cmd/8l/obj.c
@@ -393,11 +393,9 @@ objfile(char *file)
if(file[0] == '-' && file[1] == 'l') {
if(debug['9'])
- sprint(name, "/%s/lib/lib", thestring);
+ snprint(name, sizeof name, "/%s/lib/lib%s.a", thestring, file+2);
else
- sprint(name, "/usr/%clib/lib", thechar);
- strcat(name, file+2);
- strcat(name, ".a");
+ snprint(name, sizeof name, "/usr/%clib/lib%s.a", thechar, file+2);
file = name;
}
if(debug['v'])
@@ -455,7 +453,7 @@ objfile(char *file)
s = lookup(e+5, 0);
if(s->type != SXREF)
continue;
- sprint(pname, "%s(%s)", file, s->name);
+ snprint(pname, sizeof pname, "%s(%s)", file, s->name);
if(debug['v'])
Bprint(&bso, "%5.2f library: %s\n", cputime(), pname);
Bflush(&bso);
@@ -574,17 +572,17 @@ addlib(char *obj)
return;
if(histfrog[0]->name[1] == '/') {
- sprint(name, "");
+ name[0] = 0;
i = 1;
} else
if(histfrog[0]->name[1] == '.') {
- sprint(name, ".");
+ snprint(name, sizeof name, ".");
i = 0;
} else {
if(debug['9'])
- sprint(name, "/%s/lib", thestring);
+ snprint(name, sizeof name, "/%s/lib", thestring);
else
- sprint(name, "/usr/%clib", thechar);
+ snprint(name, sizeof name, "/usr/%clib", thechar);
i = 0;
}
@@ -1012,7 +1010,7 @@ loop:
goto casdef;
if(p->from.type == D_FCONST) {
/* size sb 9 max */
- sprint(literal, "$%lux", ieeedtof(&p->from.ieee));
+ snprint(literal, sizeof literal, "$%lux", ieeedtof(&p->from.ieee));
s = lookup(literal, 0);
if(s->type == 0) {
s->type = SBSS;
@@ -1057,7 +1055,7 @@ loop:
goto casdef;
if(p->from.type == D_FCONST) {
/* size sb 18 max */
- sprint(literal, "$%lux.%lux",
+ snprint(literal, sizeof literal, "$%lux.%lux",
p->from.ieee.l, p->from.ieee.h);
s = lookup(literal, 0);
if(s->type == 0) {