1 From: Debian Cyrus SASL Team
2 <pkg-cyrus-sasl2-debian-devel@lists.alioth.debian.org>
3 Date: Thu, 24 Mar 2016 11:35:04 +0100
4 Subject: Don't use la files for opening plugins
7 lib/dlopen.c | 121 ++++-------------------------------------------------------
8 1 file changed, 7 insertions(+), 114 deletions(-)
10 diff --git a/lib/dlopen.c b/lib/dlopen.c
11 index 8284cd8..ef90b11 100644
14 @@ -246,113 +246,6 @@ static int _sasl_plugin_load(char *plugin, void *library,
18 -/* this returns the file to actually open.
19 - * out should be a buffer of size PATH_MAX
20 - * and may be the same as in. */
22 -/* We'll use a static buffer for speed unless someone complains */
23 -#define MAX_LINE 2048
25 -static int _parse_la(const char *prefix, const char *in, char *out)
29 - char line[MAX_LINE];
32 - if(!in || !out || !prefix || out == in) return SASL_BADPARAM;
34 - /* Set this so we can detect failure */
37 - length = strlen(in);
39 - if (strcmp(in + (length - strlen(LA_SUFFIX)), LA_SUFFIX)) {
40 - if(!strcmp(in + (length - strlen(SO_SUFFIX)),SO_SUFFIX)) {
41 - /* check for a .la file */
42 - if (strlen(prefix) + strlen(in) + strlen(LA_SUFFIX) + 1 >= MAX_LINE)
43 - return SASL_BADPARAM;
44 - strcpy(line, prefix);
46 - length = strlen(line);
47 - *(line + (length - strlen(SO_SUFFIX))) = '\0';
48 - strcat(line, LA_SUFFIX);
49 - file = fopen(line, "r");
51 - /* We'll get it on the .la open */
56 - if (strlen(prefix) + strlen(in) + 1 >= PATH_MAX)
57 - return SASL_BADPARAM;
58 - strcpy(out, prefix);
63 - if (strlen(prefix) + strlen(in) + 1 >= MAX_LINE)
64 - return SASL_BADPARAM;
65 - strcpy(line, prefix);
68 - file = fopen(line, "r");
70 - _sasl_log(NULL, SASL_LOG_WARN,
71 - "unable to open LA file: %s", line);
75 - while(!feof(file)) {
76 - if(!fgets(line, MAX_LINE, file)) break;
77 - if(line[strlen(line) - 1] != '\n') {
78 - _sasl_log(NULL, SASL_LOG_WARN,
79 - "LA file has too long of a line: %s", in);
81 - return SASL_BUFOVER;
83 - if(line[0] == '\n' || line[0] == '#') continue;
84 - if(!strncmp(line, "dlname=", sizeof("dlname=") - 1)) {
85 - /* We found the line with the name in it */
89 - end = strrchr(line, '\'');
91 - start = &line[sizeof("dlname=")-1];
92 - len = strlen(start);
93 - if(len > 3 && start[0] == '\'') {
96 - /* Do we have dlname="" ? */
98 - _sasl_log(NULL, SASL_LOG_DEBUG,
99 - "dlname is empty in .la file: %s", in);
103 - strcpy(out, prefix);
109 - if(ferror(file) || feof(file)) {
110 - _sasl_log(NULL, SASL_LOG_WARN,
111 - "Error reading .la: %s\n", in);
118 - _sasl_log(NULL, SASL_LOG_WARN,
119 - "Could not find a dlname line in .la file: %s", in);
125 #endif /* DO_DLOPEN */
127 /* loads a plugin library */
128 @@ -506,18 +399,18 @@ int _sasl_load_plugins(const add_plugin_list_t *entrypoints,
129 if (length + pos>=PATH_MAX) continue; /* too big */
131 if (strcmp(dir->d_name + (length - strlen(SO_SUFFIX)),
133 - && strcmp(dir->d_name + (length - strlen(LA_SUFFIX)),
138 + /* We only use .so files for loading plugins */
140 memcpy(name,dir->d_name,length);
143 - result = _parse_la(prefix, name, tmp);
144 - if(result != SASL_OK)
147 + /* Create full name with path */
148 + strncpy(tmp, prefix, PATH_MAX);
149 + strncat(tmp, name, PATH_MAX);
151 /* skip "lib" and cut off suffix --
152 this only need be approximate */
153 strcpy(plugname, name + 3);