aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2021-01-13 11:55:06 +0000
committerEric Laurent <elaurent@google.com>2021-01-13 11:55:06 +0000
commitd655935a89e1474d99eb18a8e2bc1a066e1734bf (patch)
tree0b627bd0615a36bc0938faa852c4c317b75b6f8c
parentf86d1a2e03fcc6876d7f0e27e2a2f394963b7ae2 (diff)
downloadtinycompress-d655935a89e1474d99eb18a8e2bc1a066e1734bf.tar.gz
Revert "tinycompress: Fix error handling in plugins."
This reverts commit f86d1a2e03fcc6876d7f0e27e2a2f394963b7ae2. Reason for revert: b/177399104 Change-Id: I672a5f667918df3d2ffdf43cd152d710c7806555
-rw-r--r--compress_plugin.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/compress_plugin.c b/compress_plugin.c
index 24d72ee..d445ae9 100644
--- a/compress_plugin.c
+++ b/compress_plugin.c
@@ -1,6 +1,6 @@
/* compress_plugin.c
**
-** Copyright (c) 2019-2020, The Linux Foundation. All rights reserved.
+** Copyright (c) 2019, The Linux Foundation. All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
@@ -333,9 +333,10 @@ static int compress_plug_open(unsigned int card, unsigned int device,
unsigned int flags, void **data, void *node)
{
struct compress_plug_data *plug_data;
+ const char *err = NULL;
void *dl_hdl;
int rc = 0;
- char *so_name, *open_fn, token[80], *name, *token_saveptr;
+ char *so_name, *open_fn, token[80], *name;
plug_data = calloc(1, sizeof(*plug_data));
if (!plug_data) {
@@ -360,25 +361,22 @@ static int compress_plug_open(unsigned int card, unsigned int device,
}
sscanf(so_name, "lib%s", token);
- token_saveptr = token;
- name = strtok_r(token, ".", &token_saveptr);
- if (!name) {
- fprintf(stderr, "%s: invalid library name\n", __func__);
- goto err_open_fn;
- }
+ name = strtok(token, ".");
open_fn = calloc(1, strlen(name) + strlen("_open") + 1);
if (!open_fn) {
rc = -ENOMEM;
goto err_open_fn;
}
- strlcpy(open_fn, name, strlen(name) + 1);
- strlcat(open_fn, "_open", strlen(name) + strlen("_open") + 1);
+ strncpy(open_fn, name, strlen(name) + 1);
+ strcat(open_fn, "_open");
plug_data->plugin_open_fn = dlsym(dl_hdl, open_fn);
- if (!plug_data->plugin_open_fn) {
+ err = dlerror();
+
+ if (err) {
fprintf(stderr, "%s: dlsym to open fn failed, err = '%s'\n",
- __func__, dlerror());
+ __func__, err);
goto err_dlsym;
}