Package: asterisk / 1:1.6.2.9-2+squeeze12

h323-workaround-openh323-segfault Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Subject: Hack dynamic loader to workaround libopenh323 bug
Author: Faidon Liambotis <paravoid@debian.org>
Forwarded: no
Last-Update: 2009-12-19

libopenh323 is buggy and crashes on dlclose() when the library was opened with
RTLD_LAZY (#438815). Hack around this by opening it with RTLD_NOW by matching
the module names (chan_h323.so and the external chan_oh323.so)

This is a very crude hack needed because we are removing libopenh323
dependencies from the asterisk binary. (h323-no-deps-on-asterisk)
Namely, it will have unexpected results if e.g. the user renames the module
for any reason.

Should be removed when #438815 closes.

--- a/main/loader.c
+++ b/main/loader.c
@@ -382,6 +382,12 @@ static struct ast_module *load_dynamic_m
 	if (missing_so)
 		strcat(resource_being_loaded->resource, ".so");
 
+	/* libopenh323 is buggy and segfaults on dlclose() when opened with
+	 * RTLD_LAZY. Workaround this until it gets fixed */
+	if (!strcasecmp(resource_being_loaded->resource, "chan_h323.so") ||
+	    !strcasecmp(resource_being_loaded->resource, "chan_oh323.so"))
+		lib = dlopen(fn, RTLD_NOW | RTLD_LOCAL);
+
 	if (!(lib = dlopen(fn, RTLD_LAZY | RTLD_LOCAL))) {
 		ast_log(LOG_WARNING, "Error loading module '%s': %s\n", resource_in, dlerror());
 		ast_free(resource_being_loaded);