diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2003-04-06 23:21:42 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2003-04-06 23:21:42 +0000 |
commit | 22a209eb15bd807d8250d44e306c80ce5c4d3296 (patch) | |
tree | 6d4c896d3907c690ccc2f4d5ec2730f0920a247e /usr.sbin | |
parent | 7fb6f7662dff3aac1f5a5371ae29e20ecf2a95f6 (diff) |
use snamesize and realloc properly. ok tdeval@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/kvm_mkdb/kvm_mkdb.c | 6 | ||||
-rw-r--r-- | usr.sbin/kvm_mkdb/nlist.c | 22 |
2 files changed, 16 insertions, 12 deletions
diff --git a/usr.sbin/kvm_mkdb/kvm_mkdb.c b/usr.sbin/kvm_mkdb/kvm_mkdb.c index 350dc7aa0f4..fcf64829149 100644 --- a/usr.sbin/kvm_mkdb/kvm_mkdb.c +++ b/usr.sbin/kvm_mkdb/kvm_mkdb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kvm_mkdb.c,v 1.11 2002/02/16 21:28:03 millert Exp $ */ +/* $OpenBSD: kvm_mkdb.c,v 1.12 2003/04/06 23:21:41 tedu Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -34,7 +34,7 @@ */ #ifndef lint -static char copyright[] = +static const char copyright[] = "@(#) Copyright (c) 1990, 1993\n\ The Regents of the University of California. All rights reserved.\n"; #endif /* not lint */ @@ -43,7 +43,7 @@ static char copyright[] = #if 0 static char sccsid[] = "from: @(#)kvm_mkdb.c 8.3 (Berkeley) 5/4/95"; #else -static char *rcsid = "$OpenBSD: kvm_mkdb.c,v 1.11 2002/02/16 21:28:03 millert Exp $"; +static const char rcsid[] = "$OpenBSD: kvm_mkdb.c,v 1.12 2003/04/06 23:21:41 tedu Exp $"; #endif #endif /* not lint */ diff --git a/usr.sbin/kvm_mkdb/nlist.c b/usr.sbin/kvm_mkdb/nlist.c index 5768a81e314..cb3d88e58d3 100644 --- a/usr.sbin/kvm_mkdb/nlist.c +++ b/usr.sbin/kvm_mkdb/nlist.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nlist.c,v 1.31 2003/04/04 22:40:52 deraadt Exp $ */ +/* $OpenBSD: nlist.c,v 1.32 2003/04/06 23:21:41 tedu Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "from: @(#)nlist.c 8.1 (Berkeley) 6/6/93"; #else -static char *rcsid = "$OpenBSD: nlist.c,v 1.31 2003/04/04 22:40:52 deraadt Exp $"; +static const char rcsid[] = "$OpenBSD: nlist.c,v 1.32 2003/04/06 23:21:41 tedu Exp $"; #endif #endif /* not lint */ @@ -171,12 +171,14 @@ __aout_knlist(fd, db, ksyms) p = strtab + nbuf._strx - sizeof(int); if (*p != '_') { len = strlen(p) + 1; - if (len >= snamesize) - sname = realloc(sname, len + 1024); + if (len >= snamesize) { + snamesize = len + 1024; + sname = realloc(sname, snamesize); + } if (sname == NULL) errx(1, "cannot allocate memory"); *sname = '_'; - strlcpy(sname+1, p, len); + strlcpy(sname + 1, p, snamesize - 1); key.data = (u_char *)sname; key.size = len; } else { @@ -448,7 +450,7 @@ __elf_knlist(fd, db, ksyms) nbuf.n_type = N_FN; break; } - if(ELF_ST_BIND(sbuf.st_info) == STB_LOCAL) + if (ELF_ST_BIND(sbuf.st_info) == STB_LOCAL) nbuf.n_type = N_EXT; *buf = '_'; @@ -606,13 +608,15 @@ __ecoff_knlist(fd, db, ksyms) for (sname = NULL, i = 0; i < nesyms; i++) { /* Need to prepend a '_' */ len = strlen(&mappedfile[extstroff + esyms[i].es_strindex]) + 1; - if (len >= snamesize) - sname = realloc(sname, len + 1024); + if (len >= snamesize) { + snamesize = len + 1024; + sname = realloc(sname, snamesize); + } if (sname == NULL) errx(1, "cannot allocate memory"); *sname = '_'; strlcpy(sname+1, &mappedfile[extstroff + esyms[i].es_strindex], - len - 1); + snamesize - 1); /* Fill in NLIST */ bzero(&nbuf, sizeof(nbuf)); |