summaryrefslogtreecommitdiff
path: root/test/dlwrap.c
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gmail.com>2018-02-23 09:36:30 +0000
committerGitHub <noreply@github.com>2018-02-23 09:36:30 +0000
commit64fc3ac7ce15bd18ecd75bb02f87b59ecb701816 (patch)
treed0d19e10df504860d318b51c9c3136c21725f95b /test/dlwrap.c
parent6bdfdcef3dff741cae6d57bbd7786ed0cca2af7a (diff)
parentc8d7ae6bf8f2d0946f8955d1d0f8de3a18306e23 (diff)
downloadlibepoxy-64fc3ac7ce15bd18ecd75bb02f87b59ecb701816.tar.gz
Merge pull request #143 from ikeydoherty/comp-warnings
Fix printf family usage
Diffstat (limited to 'test/dlwrap.c')
-rw-r--r--test/dlwrap.c36
1 files changed, 20 insertions, 16 deletions
diff --git a/test/dlwrap.c b/test/dlwrap.c
index dd83c62..25e17de 100644
--- a/test/dlwrap.c
+++ b/test/dlwrap.c
@@ -145,7 +145,7 @@ dlwrap_real_dlopen(const char *filename, int flag)
if (!real_dlopen) {
real_dlopen = (fips_dlopen_t) dlwrap_real_dlsym(RTLD_NEXT, "dlopen");
if (!real_dlopen) {
- fprintf(stderr, "Error: Failed to find symbol for dlopen.\n");
+ fputs("Error: Failed to find symbol for dlopen.\n", stderr);
exit(1);
}
}
@@ -163,7 +163,11 @@ wrapped_dlsym(const char *prefix, const char *name)
char *wrap_name;
void *symbol;
- asprintf(&wrap_name, "override_%s_%s", prefix, name);
+ if (asprintf(&wrap_name, "override_%s_%s", prefix, name) < 0) {
+ fputs("Error: Failed to allocate memory.\n", stderr);
+ abort();
+ }
+
symbol = dlwrap_real_dlsym(RTLD_DEFAULT, wrap_name);
free(wrap_name);
return symbol;
@@ -248,22 +252,22 @@ dlwrap_real_dlsym(void *handle, const char *name)
break;
}
if (i == num_versions) {
- fprintf(stderr, "Internal error: Failed to find real dlsym\n");
- fprintf(stderr,
- "This may be a simple matter of fips not knowing about the version of GLIBC that\n"
- "your program is using. Current known versions are:\n\n\t");
+ fputs("Internal error: Failed to find real dlsym\n", stderr);
+ fputs("This may be a simple matter of fips not knowing about the version of GLIBC that\n"
+ "your program is using. Current known versions are:\n\n\t",
+ stderr);
for (i = 0; i < num_versions; i++)
fprintf(stderr, "%s ", version[i]);
- fprintf(stderr,
- "\n\nYou can inspect your version by first finding libdl.so.2:\n"
- "\n"
- "\tldd <your-program> | grep libdl.so\n"
- "\n"
- "And then inspecting the version attached to the dlsym symbol:\n"
- "\n"
- "\treadelf -s /path/to/libdl.so.2 | grep dlsym\n"
- "\n"
- "And finally, adding the version to dlwrap.c:dlwrap_real_dlsym.\n");
+ fputs("\n\nYou can inspect your version by first finding libdl.so.2:\n"
+ "\n"
+ "\tldd <your-program> | grep libdl.so\n"
+ "\n"
+ "And then inspecting the version attached to the dlsym symbol:\n"
+ "\n"
+ "\treadelf -s /path/to/libdl.so.2 | grep dlsym\n"
+ "\n"
+ "And finally, adding the version to dlwrap.c:dlwrap_real_dlsym.\n",
+ stderr);
exit(1);
}