asprintf() is easier than malloc + sprintf
This commit is contained in:
parent
2ba5ae7ea6
commit
59b2dcde2e
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: modload.c,v 1.38 2003/04/24 20:18:31 ragge Exp $ */
|
||||
/* $NetBSD: modload.c,v 1.39 2003/07/12 16:52:22 itojun Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993 Terrence R. Lambert.
|
||||
@ -34,7 +34,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: modload.c,v 1.38 2003/04/24 20:18:31 ragge Exp $");
|
||||
__RCSID("$NetBSD: modload.c,v 1.39 2003/07/12 16:52:22 itojun Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -167,8 +167,9 @@ verify_entry(const char *entry, char *filename)
|
||||
char *s;
|
||||
|
||||
memset(names, 0, sizeof(names));
|
||||
s = malloc(strlen(entry) + 2);
|
||||
sprintf(s, "_%s", entry); /* safe */
|
||||
asprintf(&s, "_%s", entry); /* safe */
|
||||
if (!s)
|
||||
err(1, "malloc");
|
||||
#ifdef _AOUT_INCLUDE_
|
||||
names[0].n_un.n_name = s;
|
||||
#else
|
||||
@ -340,8 +341,9 @@ main(int argc, char **argv)
|
||||
p++;
|
||||
else
|
||||
p = modout;
|
||||
entry = malloc(strlen(p) + strlen(DFLT_ENTRYEXT) + 1);
|
||||
sprintf(entry, "%s%s", p, DFLT_ENTRYEXT); /* safe */
|
||||
asprintf(&entry, "%s%s", p, DFLT_ENTRYEXT); /* safe */
|
||||
if (!entry)
|
||||
err(1, "malloc");
|
||||
if (verify_entry(entry, modobj))
|
||||
errx(1, "entry point _%s not found in %s",
|
||||
entry, modobj);
|
||||
|
Loading…
Reference in New Issue
Block a user