summaryrefslogtreecommitdiff
path: root/sys/dev/microcode/ncr53cxxx
diff options
context:
space:
mode:
authorHakan Olsson <ho@cvs.openbsd.org>2003-04-06 18:54:21 +0000
committerHakan Olsson <ho@cvs.openbsd.org>2003-04-06 18:54:21 +0000
commit51ab7e02d9e6e7c9950f34bc0cc7cc72bb53bd12 (patch)
tree749f8097655f1aa27f2d7a4a1ecdad5e155781a5 /sys/dev/microcode/ncr53cxxx
parent0f64621783b3f46a4851826b9f4284e3c9dbeb61 (diff)
strcat/strcpy/sprintf cleanup. krw@, anil@ ok. art@ tested sparc64.
Diffstat (limited to 'sys/dev/microcode/ncr53cxxx')
-rw-r--r--sys/dev/microcode/ncr53cxxx/ncr53cxxx.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/sys/dev/microcode/ncr53cxxx/ncr53cxxx.c b/sys/dev/microcode/ncr53cxxx/ncr53cxxx.c
index ba90ce6898d..0926a84ff85 100644
--- a/sys/dev/microcode/ncr53cxxx/ncr53cxxx.c
+++ b/sys/dev/microcode/ncr53cxxx/ncr53cxxx.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ncr53cxxx.c,v 1.3 1996/08/31 10:49:16 pefo Exp $ */
+/* $OpenBSD: ncr53cxxx.c,v 1.4 2003/04/06 18:54:20 ho Exp $ */
/*
* Copyright (c) 1995 Michael L. Hitch
@@ -393,6 +393,7 @@ void parse ()
char c;
char string[64];
char *s;
+ size_t len;
ntokens = tokenix = 0;
while (1) {
@@ -414,8 +415,9 @@ void parse ()
*s++ = *p++;
}
*s = 0;
- tokens[ntokens].name = malloc (strlen (string) + 1);
- strcpy (tokens[ntokens].name, string);
+ len = strlen (string) + 1;
+ tokens[ntokens].name = malloc (len);
+ strlcpy (tokens[ntokens].name, string, len);
tokens[ntokens].type = 0;
}
else {
@@ -462,6 +464,7 @@ void define_symbol (char *name, unsigned long value, short type, short flags)
{
int i;
struct patchlist *p;
+ size_t len;
for (i = 0; i < nsymbols; ++i) {
if (symbols[i].type == type && strcmp (symbols[i].name, name) == 0) {
@@ -492,8 +495,9 @@ void define_symbol (char *name, unsigned long value, short type, short flags)
symbols[nsymbols].flags = flags;
symbols[nsymbols].value = value;
symbols[nsymbols].patchlist = NULL;
- symbols[nsymbols].name = malloc (strlen (name) + 1);
- strcpy (symbols[nsymbols].name, name);
+ len = strlen (name) + 1;
+ symbols[nsymbols].name = malloc (len);
+ strlcpy (symbols[nsymbols].name, name, len);
++nsymbols;
}
@@ -524,9 +528,11 @@ void close_script ()
void new_script (char *name)
{
+ size_t len = strlen (name) + 1;
+
close_script ();
- script_name = malloc (strlen (name) + 1);
- strcpy (script_name, name);
+ script_name = malloc (len);
+ strlcpy (script_name, name, len);
}
int reserved (char *string, int t)
@@ -652,6 +658,7 @@ int lookup (char *name)
{
int i;
struct patchlist *p;
+ size_t len;
for (i = 0; i < nsymbols; ++i) {
if (strcmp (name, symbols[i].name) == 0) {
@@ -678,8 +685,9 @@ int lookup (char *name)
symbols[nsymbols].patchlist = p;
p->next = NULL;
p->offset = dsps + 4;
- symbols[nsymbols].name = malloc (strlen (name) + 1);
- strcpy (symbols[nsymbols].name, name);
+ len = strlen (name) + 1;
+ symbols[nsymbols].name = malloc (len);
+ strlcpy (symbols[nsymbols].name, name, len);
++nsymbols;
return (0);
}
@@ -1138,14 +1146,15 @@ char * makefn (base, sub)
char *sub;
{
char *fn;
+ size_t len = strlen (base) + strlen (sub) + 2;
- fn = malloc (strlen (base) + strlen (sub) + 2);
- strcpy (fn, base);
+ fn = malloc (len);
+ strlcpy (fn, base, len);
base = strrchr(fn, '.');
if (base)
*base = 0;
- strcat (fn, ".");
- strcat (fn, sub);
+ strlcat (fn, ".", len);
+ strlcat (fn, sub, len);
return (fn);
}