OCaml 4.13.1 rebuild, fixes FS#72998
[arch-packages.git] / libsasl / trunk / 0013-Don-t-use-la-files-for-opening-plugins.patch
blobd024139557359a1939b41e322c5be7c3f5eb7663
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
6 ---
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
12 --- a/lib/dlopen.c
13 +++ b/lib/dlopen.c
14 @@ -246,113 +246,6 @@ static int _sasl_plugin_load(char *plugin, void *library,
15 return result;
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)
27 - FILE *file;
28 - size_t length;
29 - char line[MAX_LINE];
30 - char *ntmp = NULL;
32 - if(!in || !out || !prefix || out == in) return SASL_BADPARAM;
34 - /* Set this so we can detect failure */
35 - *out = '\0';
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);
45 - strcat(line, in);
46 - length = strlen(line);
47 - *(line + (length - strlen(SO_SUFFIX))) = '\0';
48 - strcat(line, LA_SUFFIX);
49 - file = fopen(line, "r");
50 - if(file) {
51 - /* We'll get it on the .la open */
52 - fclose(file);
53 - return SASL_FAIL;
54 - }
55 - }
56 - if (strlen(prefix) + strlen(in) + 1 >= PATH_MAX)
57 - return SASL_BADPARAM;
58 - strcpy(out, prefix);
59 - strcat(out, in);
60 - return SASL_OK;
61 - }
63 - if (strlen(prefix) + strlen(in) + 1 >= MAX_LINE)
64 - return SASL_BADPARAM;
65 - strcpy(line, prefix);
66 - strcat(line, in);
68 - file = fopen(line, "r");
69 - if(!file) {
70 - _sasl_log(NULL, SASL_LOG_WARN,
71 - "unable to open LA file: %s", line);
72 - return SASL_FAIL;
73 - }
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);
80 - fclose(file);
81 - return SASL_BUFOVER;
82 - }
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 */
86 - char *end;
87 - char *start;
88 - size_t len;
89 - end = strrchr(line, '\'');
90 - if(!end) continue;
91 - start = &line[sizeof("dlname=")-1];
92 - len = strlen(start);
93 - if(len > 3 && start[0] == '\'') {
94 - ntmp=&start[1];
95 - *end='\0';
96 - /* Do we have dlname="" ? */
97 - if(ntmp == end) {
98 - _sasl_log(NULL, SASL_LOG_DEBUG,
99 - "dlname is empty in .la file: %s", in);
100 - fclose(file);
101 - return SASL_FAIL;
103 - strcpy(out, prefix);
104 - strcat(out, ntmp);
106 - break;
109 - if(ferror(file) || feof(file)) {
110 - _sasl_log(NULL, SASL_LOG_WARN,
111 - "Error reading .la: %s\n", in);
112 - fclose(file);
113 - return SASL_FAIL;
115 - fclose(file);
117 - if(!(*out)) {
118 - _sasl_log(NULL, SASL_LOG_WARN,
119 - "Could not find a dlname line in .la file: %s", in);
120 - return SASL_FAIL;
123 - return SASL_OK;
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)),
132 - SO_SUFFIX)
133 - && strcmp(dir->d_name + (length - strlen(LA_SUFFIX)),
134 - LA_SUFFIX))
135 + SO_SUFFIX))
136 continue;
138 + /* We only use .so files for loading plugins */
140 memcpy(name,dir->d_name,length);
141 name[length]='\0';
143 - result = _parse_la(prefix, name, tmp);
144 - if(result != SASL_OK)
145 - continue;
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);