summaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
authorGreg Hudson <ghudson@mit.edu>2008-10-20 21:14:47 +0000
committerGreg Hudson <ghudson@mit.edu>2008-10-20 21:14:47 +0000
commitae423f53214830de1367627180031283de998746 (patch)
treef3268a5a9d718d570883bf296c52c117e0dfc709 /src/tests
parentcdea7397975a960e3c02479f8aa4ede0bc349105 (diff)
downloadkrb5-ae423f53214830de1367627180031283de998746.tar.gz
krb5-ae423f53214830de1367627180031283de998746.tar.xz
krb5-ae423f53214830de1367627180031283de998746.zip
Use asprintf instead of malloc/strcpy/strcat in many places
ticket: 6200 status: open git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20901 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/shlib/t_loader.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/src/tests/shlib/t_loader.c b/src/tests/shlib/t_loader.c
index 70cd6d13b..cdc255055 100644
--- a/src/tests/shlib/t_loader.c
+++ b/src/tests/shlib/t_loader.c
@@ -5,6 +5,7 @@
#include "autoconf.h"
#include "krb5.h"
#include "gssapi/gssapi.h"
+#include "k5-platform.h"
#define HAVE_DLOPEN 1
static int verbose = 1;
@@ -53,28 +54,20 @@ static void *do_open_1(const char *libname, const char *rev,
{
void *p;
char *namebuf;
- size_t sz;
+ int r;
if (verbose)
printf("from line %d: do_open(%s)...%*s", line, libname,
HORIZ-strlen(libname), "");
- sz = strlen(SHLIB_SUFFIX) + strlen(libname) + 4;
#ifdef _AIX
- sz += strlen(rev) + 8;
+ r = asprintf(&namebuf, "lib%s%s", libname, SHLIB_SUFFIX);
+#else
+ r = asprintf(&namebuf, "lib%s%s(shr.o.%s)", libname, SHLIB_SUFFIX, rev);
#endif
- namebuf = malloc(sz);
- if (namebuf == 0) {
- perror("malloc");
+ if (r < 0) {
+ perror("asprintf");
exit(1);
}
- strcpy(namebuf, "lib");
- strcat(namebuf, libname);
- strcat(namebuf, SHLIB_SUFFIX);
-#ifdef _AIX
- strcat(namebuf, "(shr.o.");
- strcat(namebuf, rev);
- strcat(namebuf, ")");
-#endif
#ifndef RTLD_MEMBER
#define RTLD_MEMBER 0