summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/dso.c31
-rw-r--r--src/multi.c5
2 files changed, 30 insertions, 6 deletions
diff --git a/src/dso.c b/src/dso.c
index d1f8df0..8dbe37b 100644
--- a/src/dso.c
+++ b/src/dso.c
@@ -176,7 +176,7 @@ static void* real_dlsym(lt_module m, const char *name, const char *symbol) {
int driver_open(ca_context *c) {
int ret;
struct private_dso *p;
- const char *driver;
+ char *driver;
ca_return_val_if_fail(c, CA_ERROR_INVALID);
ca_return_val_if_fail(!PRIVATE_DSO(c), CA_ERROR_STATE);
@@ -193,13 +193,30 @@ int driver_open(ca_context *c) {
p->ltdl_initialized = TRUE;
if (c->driver) {
+ char *e;
+ size_t n;
- if ((ret = try_open(c, c->driver)) < 0) {
+ if (!(e = ca_strdup(c->driver))) {
driver_destroy(c);
+ return CA_ERROR_OOM;
+ }
+
+ n = strcspn(e, ",:");
+ e[n] = 0;
+
+ if (n == 0) {
+ driver_destroy(c);
+ ca_free(e);
+ return CA_ERROR_INVALID;
+ }
+
+ if ((ret = try_open(c, e)) < 0) {
+ driver_destroy(c);
+ ca_free(e);
return ret;
}
- driver = c->driver;
+ driver = e;
} else {
const char *const * e;
@@ -223,7 +240,10 @@ int driver_open(ca_context *c) {
return CA_ERROR_NODRIVER;
}
- driver = *e;
+ if (!(driver = ca_strdup(*e))) {
+ driver_destroy(c);
+ return CA_ERROR_OOM;
+ }
}
ca_assert(p->module);
@@ -236,10 +256,13 @@ int driver_open(ca_context *c) {
!(p->driver_cancel = GET_FUNC_PTR(p->module, driver, "driver_cancel", int, (ca_context*, uint32_t id))) ||
!(p->driver_cache = GET_FUNC_PTR(p->module, driver, "driver_cache", int, (ca_context*, ca_proplist *p)))) {
+ ca_free(driver);
driver_destroy(c);
return CA_ERROR_CORRUPT;
}
+ ca_free(driver);
+
if ((ret = p->driver_open(c)) < 0) {
driver_destroy(c);
return ret;
diff --git a/src/multi.c b/src/multi.c
index 0215296..298df7d 100644
--- a/src/multi.c
+++ b/src/multi.c
@@ -105,7 +105,8 @@ int driver_open(ca_context *c) {
int ret = CA_SUCCESS;
ca_return_val_if_fail(c, CA_ERROR_INVALID);
- ca_return_val_if_fail(!c->driver || ca_streq(c->driver, "multi"), CA_ERROR_NODRIVER);
+ ca_return_val_if_fail(c->driver, CA_ERROR_NODRIVER);
+ ca_return_val_if_fail(!strncmp(c->driver, "multi", 5), CA_ERROR_NODRIVER);
ca_return_val_if_fail(!PRIVATE(c), CA_ERROR_STATE);
if (!(c->private = p = ca_new0(struct private, 1)))
@@ -126,7 +127,7 @@ int driver_open(ca_context *c) {
size_t n;
ca_bool_t last;
- n = strcspn(k, ":");
+ n = strcspn(k, ",:");
last = k[n] == 0;
k[n] = 0;