[sr-dev] git:5.1:289eb374: core: check return of dlsym() before dlerror() handling

Daniel-Constantin Mierla miconda at gmail.com
Wed Mar 14 11:27:16 CET 2018


Module: kamailio
Branch: 5.1
Commit: 289eb37432bfc61855234893daa6be27d40f8788
URL: https://github.com/kamailio/kamailio/commit/289eb37432bfc61855234893daa6be27d40f8788

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2018-03-14T11:21:17+01:00

core: check return of dlsym() before dlerror() handling

- cope with the case when dlerror is not reset by dlsym
- related to GH #1465

(cherry picked from commit 045d44762ce7cd267e64849c1c138d45b1fa040f)

---

Modified: src/core/sr_module.c

---

Diff:  https://github.com/kamailio/kamailio/commit/289eb37432bfc61855234893daa6be27d40f8788.diff
Patch: https://github.com/kamailio/kamailio/commit/289eb37432bfc61855234893daa6be27d40f8788.patch

---

diff --git a/src/core/sr_module.c b/src/core/sr_module.c
index 594f3d6af8..8a195fc12d 100644
--- a/src/core/sr_module.c
+++ b/src/core/sr_module.c
@@ -630,11 +630,14 @@ int load_module(char* mod_path)
 		if(expref.len>3 && strcmp(expref.s+expref.len-3, ".so")==0)
 			expref.len -= 3;
 		snprintf(exbuf, 62, "_%.*s_exports", expref.len, expref.s);
-		exp = (union module_exports_u*)dlsym(handle, exbuf);
 		LM_DBG("looking up exports with name: %s\n", exbuf);
-		if ( (error =(char*)dlerror())!=0 ){
-			LM_ERR("%s\n", error);
-			goto error1;
+		exp = (union module_exports_u*)dlsym(handle, exbuf);
+		if(exp==NULL) {
+			if ( (error =(char*)dlerror())!=0 ){
+				LM_ERR("failure for exports symbol: %s - dlerror: %s\n",
+						exbuf, error);
+				goto error1;
+			}
 		}
 	}
 	/* hack to allow for kamailio style dlflags inside exports */




More information about the sr-dev mailing list