summaryrefslogtreecommitdiff
path: root/www/lighttpd/files/patch-2799-bug2331
blob: f53e92927f3f9aea3e2d4e6f9dbf17f7d0377488 (plain) (blame)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
Index: src/http_auth_digest.c
===================================================================
--- src/http_auth_digest.c	(revision 2798)
+++ src/http_auth_digest.c	(revision 2799)
@@ -1,26 +0,0 @@
-#include "buffer.h"
-
-#include "http_auth_digest.h"
-
-#include <string.h>
-
-#ifndef USE_OPENSSL
-# include "md5.h"
-
-typedef li_MD5_CTX MD5_CTX;
-#define MD5_Init li_MD5_Init
-#define MD5_Update li_MD5_Update
-#define MD5_Final li_MD5_Final
-
-#endif
-
-void CvtHex(IN HASH Bin, OUT HASHHEX Hex) {
-	unsigned short i;
-
-	for (i = 0; i < HASHLEN; i++) {
-		Hex[i*2] = int2hex((Bin[i] >> 4) & 0xf);
-		Hex[i*2+1] = int2hex(Bin[i] & 0xf);
-	}
-	Hex[HASHHEXLEN] = '\0';
-}
-
Index: src/http_auth_digest.h
===================================================================
--- src/http_auth_digest.h	(revision 2798)
+++ src/http_auth_digest.h	(revision 2799)
@@ -1,24 +0,0 @@
-#ifndef _DIGCALC_H_
-#define _DIGCALC_H_
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#define HASHLEN 16
-typedef unsigned char HASH[HASHLEN];
-#define HASHHEXLEN 32
-typedef char HASHHEX[HASHHEXLEN+1];
-#ifdef USE_OPENSSL
-#define IN const
-#else
-#define IN
-#endif
-#define OUT
-
-void CvtHex(
-    IN HASH Bin,
-    OUT HASHHEX Hex
-    );
-
-#endif
Index: src/mod_secure_download.c
===================================================================
--- src/mod_secure_download.c	(revision 2798)
+++ src/mod_secure_download.c	(revision 2799)
@@ -8,18 +8,8 @@
 #include <stdlib.h>
 #include <string.h>
 
-#ifdef USE_OPENSSL
-# include <openssl/md5.h>
-#else
-# include "md5.h"
+#include "md5.h"
 
-typedef li_MD5_CTX MD5_CTX;
-#define MD5_Init li_MD5_Init
-#define MD5_Update li_MD5_Update
-#define MD5_Final li_MD5_Final
-
-#endif
-
 #define HASHLEN 16
 typedef unsigned char HASH[HASHLEN];
 #define HASHHEXLEN 32
@@ -200,7 +190,7 @@
 
 URIHANDLER_FUNC(mod_secdownload_uri_handler) {
 	plugin_data *p = p_d;
-	MD5_CTX Md5Ctx;
+	li_MD5_CTX Md5Ctx;
 	HASH HA1;
 	const char *rel_uri, *ts_str, *md5_str;
 	time_t ts = 0;
@@ -266,9 +256,9 @@
 	buffer_append_string(p->md5, rel_uri);
 	buffer_append_string_len(p->md5, ts_str, 8);
 
-	MD5_Init(&Md5Ctx);
-	MD5_Update(&Md5Ctx, (unsigned char *)p->md5->ptr, p->md5->used - 1);
-	MD5_Final(HA1, &Md5Ctx);
+	li_MD5_Init(&Md5Ctx);
+	li_MD5_Update(&Md5Ctx, (unsigned char *)p->md5->ptr, p->md5->used - 1);
+	li_MD5_Final(HA1, &Md5Ctx);
 
 	buffer_copy_string_hex(p->md5, (char *)HA1, 16);
 
Index: src/SConscript
===================================================================
--- src/SConscript	(revision 2798)
+++ src/SConscript	(revision 2799)
@@ -12,7 +12,8 @@
       data_integer.c md5.c data_fastcgi.c \
       fdevent_select.c fdevent_libev.c \
       fdevent_poll.c fdevent_linux_sysepoll.c \
-      fdevent_solaris_devpoll.c fdevent_freebsd_kqueue.c \
+      fdevent_solaris_devpoll.c fdevent_solaris_port.c \
+      fdevent_freebsd_kqueue.c \
       data_config.c bitset.c \
       inet_ntop_cache.c crc32.c \
       connections-glue.c \
@@ -62,7 +63,7 @@
 	'mod_redirect' : { 'src' : [ 'mod_redirect.c' ], 'lib' : [ env['LIBPCRE'] ] },
 	'mod_rewrite' : { 'src' : [ 'mod_rewrite.c' ], 'lib' : [ env['LIBPCRE'] ] },
 	'mod_auth' : {
-		'src' : [ 'mod_auth.c', 'http_auth_digest.c', 'http_auth.c' ],
+		'src' : [ 'mod_auth.c', 'http_auth.c' ],
 		'lib' : [ env['LIBCRYPT'], env['LIBLDAP'], env['LIBLBER'] ] },
 	'mod_webdav' : { 'src' : [ 'mod_webdav.c' ], 'lib' : [ env['LIBXML2'], env['LIBSQLITE3'], env['LIBUUID'] ] },
 	'mod_mysql_vhost' : { 'src' : [ 'mod_mysql_vhost.c' ], 'lib' : [ env['LIBMYSQL'] ] },
Index: src/mod_cml_funcs.c
===================================================================
--- src/mod_cml_funcs.c	(revision 2798)
+++ src/mod_cml_funcs.c	(revision 2799)
@@ -17,18 +17,8 @@
 #include <dirent.h>
 #include <stdio.h>
 
-#ifdef USE_OPENSSL
-# include <openssl/md5.h>
-#else
-# include "md5.h"
+#include "md5.h"
 
-typedef li_MD5_CTX MD5_CTX;
-#define MD5_Init li_MD5_Init
-#define MD5_Update li_MD5_Update
-#define MD5_Final li_MD5_Final
-
-#endif
-
 #define HASHLEN 16
 typedef unsigned char HASH[HASHLEN];
 #define HASHHEXLEN 32
@@ -43,7 +33,7 @@
 #ifdef HAVE_LUA_H
 
 int f_crypto_md5(lua_State *L) {
-	MD5_CTX Md5Ctx;
+	li_MD5_CTX Md5Ctx;
 	HASH HA1;
 	buffer b;
 	char hex[33];
@@ -63,9 +53,9 @@
 		lua_error(L);
 	}
 
-	MD5_Init(&Md5Ctx);
-	MD5_Update(&Md5Ctx, (unsigned char *)lua_tostring(L, 1), lua_strlen(L, 1));
-	MD5_Final(HA1, &Md5Ctx);
+	li_MD5_Init(&Md5Ctx);
+	li_MD5_Update(&Md5Ctx, (unsigned char *)lua_tostring(L, 1), lua_strlen(L, 1));
+	li_MD5_Final(HA1, &Md5Ctx);
 
 	buffer_copy_string_hex(&b, (char *)HA1, 16);
 
Index: src/Makefile.am
===================================================================
--- src/Makefile.am	(revision 2798)
+++ src/Makefile.am	(revision 2799)
@@ -241,7 +241,7 @@
 mod_compress_la_LIBADD = $(Z_LIB) $(BZ_LIB) $(common_libadd)
 
 lib_LTLIBRARIES += mod_auth.la
-mod_auth_la_SOURCES = mod_auth.c http_auth_digest.c http_auth.c
+mod_auth_la_SOURCES = mod_auth.c http_auth.c
 mod_auth_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
 mod_auth_la_LIBADD = $(CRYPT_LIB) $(LDAP_LIB) $(LBER_LIB) $(common_libadd)
 
@@ -268,7 +268,7 @@
 
 hdr = server.h buffer.h network.h log.h keyvalue.h \
       response.h request.h fastcgi.h chunk.h \
-      settings.h http_chunk.h http_auth_digest.h \
+      settings.h http_chunk.h \
       md5.h http_auth.h stream.h \
       fdevent.h connections.h base.h stat_cache.h \
       plugin.h mod_auth.h \
Index: src/http_auth.c
===================================================================
--- src/http_auth.c	(revision 2798)
+++ src/http_auth.c	(revision 2799)
@@ -1,7 +1,6 @@
 #include "server.h"
 #include "log.h"
 #include "http_auth.h"
-#include "http_auth_digest.h"
 #include "inet_ntop_cache.h"
 #include "stream.h"
 
@@ -28,18 +27,23 @@
 #include <unistd.h>
 #include <ctype.h>
 
-#ifdef USE_OPENSSL
-# include <openssl/md5.h>
-#else
-# include "md5.h"
+#include "md5.h"
 
-typedef li_MD5_CTX MD5_CTX;
-#define MD5_Init li_MD5_Init
-#define MD5_Update li_MD5_Update
-#define MD5_Final li_MD5_Final
+#define HASHLEN 16
+#define HASHHEXLEN 32
+typedef unsigned char HASH[HASHLEN];
+typedef char HASHHEX[HASHHEXLEN+1];
 
-#endif
+static void CvtHex(const HASH Bin, char Hex[33]) {
+	unsigned short i;
 
+	for (i = 0; i < 16; i++) {
+		Hex[i*2] = int2hex((Bin[i] >> 4) & 0xf);
+		Hex[i*2+1] = int2hex(Bin[i] & 0xf);
+	}
+	Hex[32] = '\0';
+}
+
 /**
  * the $apr1$ handling is taken from apache 1.3.x
  */
@@ -435,7 +439,7 @@
 
 static void to64(char *s, unsigned long v, int n)
 {
-    static unsigned char itoa64[] =         /* 0 ... 63 => ASCII - 64 */
+    static const unsigned char itoa64[] =         /* 0 ... 63 => ASCII - 64 */
         "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
 
     while (--n >= 0) {
@@ -455,7 +459,7 @@
     const char *sp, *ep;
     unsigned char final[APR_MD5_DIGESTSIZE];
     ssize_t sl, pl, i;
-    MD5_CTX ctx, ctx1;
+    li_MD5_CTX ctx, ctx1;
     unsigned long l;
 
     /*
@@ -487,33 +491,33 @@
     /*
      * 'Time to make the doughnuts..'
      */
-    MD5_Init(&ctx);
+    li_MD5_Init(&ctx);
 
     /*
      * The password first, since that is what is most unknown
      */
-    MD5_Update(&ctx, pw, strlen(pw));
+    li_MD5_Update(&ctx, pw, strlen(pw));
 
     /*
      * Then our magic string
      */
-    MD5_Update(&ctx, APR1_ID, strlen(APR1_ID));
+    li_MD5_Update(&ctx, APR1_ID, strlen(APR1_ID));
 
     /*
      * Then the raw salt
      */
-    MD5_Update(&ctx, sp, sl);
+    li_MD5_Update(&ctx, sp, sl);
 
     /*
      * Then just as many characters of the MD5(pw, salt, pw)
      */
-    MD5_Init(&ctx1);
-    MD5_Update(&ctx1, pw, strlen(pw));
-    MD5_Update(&ctx1, sp, sl);
-    MD5_Update(&ctx1, pw, strlen(pw));
-    MD5_Final(final, &ctx1);
+    li_MD5_Init(&ctx1);
+    li_MD5_Update(&ctx1, pw, strlen(pw));
+    li_MD5_Update(&ctx1, sp, sl);
+    li_MD5_Update(&ctx1, pw, strlen(pw));
+    li_MD5_Final(final, &ctx1);
     for (pl = strlen(pw); pl > 0; pl -= APR_MD5_DIGESTSIZE) {
-        MD5_Update(&ctx, final,
+        li_MD5_Update(&ctx, final,
                       (pl > APR_MD5_DIGESTSIZE) ? APR_MD5_DIGESTSIZE : pl);
     }
 
@@ -527,10 +531,10 @@
      */
     for (i = strlen(pw); i != 0; i >>= 1) {
         if (i & 1) {
-            MD5_Update(&ctx, final, 1);
+            li_MD5_Update(&ctx, final, 1);
         }
         else {
-            MD5_Update(&ctx, pw, 1);
+            li_MD5_Update(&ctx, pw, 1);
         }
     }
 
@@ -542,7 +546,7 @@
     strncat(passwd, sp, sl);
     strcat(passwd, "$");
 
-    MD5_Final(final, &ctx);
+    li_MD5_Final(final, &ctx);
 
     /*
      * And now, just to make sure things don't run too fast..
@@ -550,28 +554,28 @@
      * need 30 seconds to build a 1000 entry dictionary...
      */
     for (i = 0; i < 1000; i++) {
-        MD5_Init(&ctx1);
+        li_MD5_Init(&ctx1);
         if (i & 1) {
-            MD5_Update(&ctx1, pw, strlen(pw));
+            li_MD5_Update(&ctx1, pw, strlen(pw));
         }
         else {
-            MD5_Update(&ctx1, final, APR_MD5_DIGESTSIZE);
+            li_MD5_Update(&ctx1, final, APR_MD5_DIGESTSIZE);
         }
         if (i % 3) {
-            MD5_Update(&ctx1, sp, sl);
+            li_MD5_Update(&ctx1, sp, sl);
         }
 
         if (i % 7) {
-            MD5_Update(&ctx1, pw, strlen(pw));
+            li_MD5_Update(&ctx1, pw, strlen(pw));
         }
 
         if (i & 1) {
-            MD5_Update(&ctx1, final, APR_MD5_DIGESTSIZE);
+            li_MD5_Update(&ctx1, final, APR_MD5_DIGESTSIZE);
         }
         else {
-            MD5_Update(&ctx1, pw, strlen(pw));
+            li_MD5_Update(&ctx1, pw, strlen(pw));
         }
-        MD5_Final(final,&ctx1);
+        li_MD5_Final(final,&ctx1);
     }
 
     p = passwd + strlen(passwd);
@@ -614,17 +618,17 @@
 		 * user:realm:md5(user:realm:password)
 		 */
 
-		MD5_CTX Md5Ctx;
+		li_MD5_CTX Md5Ctx;
 		HASH HA1;
 		char a1[256];
 
-		MD5_Init(&Md5Ctx);
-		MD5_Update(&Md5Ctx, (unsigned char *)username->ptr, username->used - 1);
-		MD5_Update(&Md5Ctx, (unsigned char *)":", 1);
-		MD5_Update(&Md5Ctx, (unsigned char *)realm->ptr, realm->used - 1);
-		MD5_Update(&Md5Ctx, (unsigned char *)":", 1);
-		MD5_Update(&Md5Ctx, (unsigned char *)pw, strlen(pw));
-		MD5_Final(HA1, &Md5Ctx);
+		li_MD5_Init(&Md5Ctx);
+		li_MD5_Update(&Md5Ctx, (unsigned char *)username->ptr, username->used - 1);
+		li_MD5_Update(&Md5Ctx, (unsigned char *)":", 1);
+		li_MD5_Update(&Md5Ctx, (unsigned char *)realm->ptr, realm->used - 1);
+		li_MD5_Update(&Md5Ctx, (unsigned char *)":", 1);
+		li_MD5_Update(&Md5Ctx, (unsigned char *)pw, strlen(pw));
+		li_MD5_Final(HA1, &Md5Ctx);
 
 		CvtHex(HA1, a1);
 
@@ -930,7 +934,7 @@
 	int i;
 	buffer *password, *b, *username_buf, *realm_buf;
 
-	MD5_CTX Md5Ctx;
+	li_MD5_CTX Md5Ctx;
 	HASH HA1;
 	HASH HA2;
 	HASH RespHash;
@@ -1067,13 +1071,13 @@
 
 	if (p->conf.auth_backend == AUTH_BACKEND_PLAIN) {
 		/* generate password from plain-text */
-		MD5_Init(&Md5Ctx);
-		MD5_Update(&Md5Ctx, (unsigned char *)username, strlen(username));
-		MD5_Update(&Md5Ctx, (unsigned char *)":", 1);
-		MD5_Update(&Md5Ctx, (unsigned char *)realm, strlen(realm));
-		MD5_Update(&Md5Ctx, (unsigned char *)":", 1);
-		MD5_Update(&Md5Ctx, (unsigned char *)password->ptr, password->used - 1);
-		MD5_Final(HA1, &Md5Ctx);
+		li_MD5_Init(&Md5Ctx);
+		li_MD5_Update(&Md5Ctx, (unsigned char *)username, strlen(username));
+		li_MD5_Update(&Md5Ctx, (unsigned char *)":", 1);
+		li_MD5_Update(&Md5Ctx, (unsigned char *)realm, strlen(realm));
+		li_MD5_Update(&Md5Ctx, (unsigned char *)":", 1);
+		li_MD5_Update(&Md5Ctx, (unsigned char *)password->ptr, password->used - 1);
+		li_MD5_Final(HA1, &Md5Ctx);
 	} else if (p->conf.auth_backend == AUTH_BACKEND_HTDIGEST) {
 		/* HA1 */
 		/* transform the 32-byte-hex-md5 to a 16-byte-md5 */
@@ -1090,45 +1094,45 @@
 
 	if (algorithm &&
 	    strcasecmp(algorithm, "md5-sess") == 0) {
-		MD5_Init(&Md5Ctx);
-		MD5_Update(&Md5Ctx, (unsigned char *)HA1, 16);
-		MD5_Update(&Md5Ctx, (unsigned char *)":", 1);
-		MD5_Update(&Md5Ctx, (unsigned char *)nonce, strlen(nonce));
-		MD5_Update(&Md5Ctx, (unsigned char *)":", 1);
-		MD5_Update(&Md5Ctx, (unsigned char *)cnonce, strlen(cnonce));
-		MD5_Final(HA1, &Md5Ctx);
+		li_MD5_Init(&Md5Ctx);
+		li_MD5_Update(&Md5Ctx, (unsigned char *)HA1, 16);
+		li_MD5_Update(&Md5Ctx, (unsigned char *)":", 1);
+		li_MD5_Update(&Md5Ctx, (unsigned char *)nonce, strlen(nonce));
+		li_MD5_Update(&Md5Ctx, (unsigned char *)":", 1);
+		li_MD5_Update(&Md5Ctx, (unsigned char *)cnonce, strlen(cnonce));
+		li_MD5_Final(HA1, &Md5Ctx);
 	}
 
 	CvtHex(HA1, a1);
 
 	/* calculate H(A2) */
-	MD5_Init(&Md5Ctx);
-	MD5_Update(&Md5Ctx, (unsigned char *)m, strlen(m));
-	MD5_Update(&Md5Ctx, (unsigned char *)":", 1);
-	MD5_Update(&Md5Ctx, (unsigned char *)uri, strlen(uri));
+	li_MD5_Init(&Md5Ctx);
+	li_MD5_Update(&Md5Ctx, (unsigned char *)m, strlen(m));
+	li_MD5_Update(&Md5Ctx, (unsigned char *)":", 1);
+	li_MD5_Update(&Md5Ctx, (unsigned char *)uri, strlen(uri));
 	if (qop && strcasecmp(qop, "auth-int") == 0) {
-		MD5_Update(&Md5Ctx, (unsigned char *)":", 1);
-		MD5_Update(&Md5Ctx, (unsigned char *)"", HASHHEXLEN);
+		li_MD5_Update(&Md5Ctx, (unsigned char *)":", 1);
+		li_MD5_Update(&Md5Ctx, (unsigned char *)"", HASHHEXLEN);
 	}
-	MD5_Final(HA2, &Md5Ctx);
+	li_MD5_Final(HA2, &Md5Ctx);
 	CvtHex(HA2, HA2Hex);
 
 	/* calculate response */
-	MD5_Init(&Md5Ctx);
-	MD5_Update(&Md5Ctx, (unsigned char *)a1, HASHHEXLEN);
-	MD5_Update(&Md5Ctx, (unsigned char *)":", 1);
-	MD5_Update(&Md5Ctx, (unsigned char *)nonce, strlen(nonce));
-	MD5_Update(&Md5Ctx, (unsigned char *)":", 1);
+	li_MD5_Init(&Md5Ctx);
+	li_MD5_Update(&Md5Ctx, (unsigned char *)a1, HASHHEXLEN);
+	li_MD5_Update(&Md5Ctx, (unsigned char *)":", 1);
+	li_MD5_Update(&Md5Ctx, (unsigned char *)nonce, strlen(nonce));
+	li_MD5_Update(&Md5Ctx, (unsigned char *)":", 1);
 	if (qop && *qop) {
-		MD5_Update(&Md5Ctx, (unsigned char *)nc, strlen(nc));
-		MD5_Update(&Md5Ctx, (unsigned char *)":", 1);
-		MD5_Update(&Md5Ctx, (unsigned char *)cnonce, strlen(cnonce));
-		MD5_Update(&Md5Ctx, (unsigned char *)":", 1);
-		MD5_Update(&Md5Ctx, (unsigned char *)qop, strlen(qop));
-		MD5_Update(&Md5Ctx, (unsigned char *)":", 1);
+		li_MD5_Update(&Md5Ctx, (unsigned char *)nc, strlen(nc));
+		li_MD5_Update(&Md5Ctx, (unsigned char *)":", 1);
+		li_MD5_Update(&Md5Ctx, (unsigned char *)cnonce, strlen(cnonce));
+		li_MD5_Update(&Md5Ctx, (unsigned char *)":", 1);
+		li_MD5_Update(&Md5Ctx, (unsigned char *)qop, strlen(qop));
+		li_MD5_Update(&Md5Ctx, (unsigned char *)":", 1);
 	};
-	MD5_Update(&Md5Ctx, (unsigned char *)HA2Hex, HASHHEXLEN);
-	MD5_Final(RespHash, &Md5Ctx);
+	li_MD5_Update(&Md5Ctx, (unsigned char *)HA2Hex, HASHHEXLEN);
+	li_MD5_Final(RespHash, &Md5Ctx);
 	CvtHex(RespHash, a2);
 
 	if (0 != strcmp(a2, respons)) {
@@ -1171,24 +1175,24 @@
 
 int http_auth_digest_generate_nonce(server *srv, mod_auth_plugin_data *p, buffer *fn, char out[33]) {
 	HASH h;
-	MD5_CTX Md5Ctx;
+	li_MD5_CTX Md5Ctx;
 	char hh[32];
 
 	UNUSED(p);
 
 	/* generate shared-secret */
-	MD5_Init(&Md5Ctx);
-	MD5_Update(&Md5Ctx, (unsigned char *)fn->ptr, fn->used - 1);
-	MD5_Update(&Md5Ctx, (unsigned char *)"+", 1);
+	li_MD5_Init(&Md5Ctx);
+	li_MD5_Update(&Md5Ctx, (unsigned char *)fn->ptr, fn->used - 1);
+	li_MD5_Update(&Md5Ctx, (unsigned char *)"+", 1);
 
 	/* we assume sizeof(time_t) == 4 here, but if not it ain't a problem at all */
 	LI_ltostr(hh, srv->cur_ts);
-	MD5_Update(&Md5Ctx, (unsigned char *)hh, strlen(hh));
-	MD5_Update(&Md5Ctx, (unsigned char *)srv->entropy, sizeof(srv->entropy));
+	li_MD5_Update(&Md5Ctx, (unsigned char *)hh, strlen(hh));
+	li_MD5_Update(&Md5Ctx, (unsigned char *)srv->entropy, sizeof(srv->entropy));
 	LI_ltostr(hh, rand());
-	MD5_Update(&Md5Ctx, (unsigned char *)hh, strlen(hh));
+	li_MD5_Update(&Md5Ctx, (unsigned char *)hh, strlen(hh));
 
-	MD5_Final(h, &Md5Ctx);
+	li_MD5_Final(h, &Md5Ctx);
 
 	CvtHex(h, out);
 
Index: src/mod_usertrack.c
===================================================================
--- src/mod_usertrack.c	(revision 2798)
+++ src/mod_usertrack.c	(revision 2799)
@@ -8,18 +8,8 @@
 #include <stdlib.h>
 #include <string.h>
 
-#ifdef USE_OPENSSL
-# include <openssl/md5.h>
-#else
-# include "md5.h"
+#include "md5.h"
 
-typedef li_MD5_CTX MD5_CTX;
-#define MD5_Init li_MD5_Init
-#define MD5_Update li_MD5_Update
-#define MD5_Final li_MD5_Final
-
-#endif
-
 /* plugin config for all request/connections */
 
 typedef struct {
@@ -182,7 +172,7 @@
 	plugin_data *p = p_d;
 	data_string *ds;
 	unsigned char h[16];
-	MD5_CTX Md5Ctx;
+	li_MD5_CTX Md5Ctx;
 	char hh[32];
 
 	if (con->uri.path->used == 0) return HANDLER_GO_ON;
@@ -228,18 +218,18 @@
 	/* taken from mod_auth.c */
 
 	/* generate shared-secret */
-	MD5_Init(&Md5Ctx);
-	MD5_Update(&Md5Ctx, (unsigned char *)con->uri.path->ptr, con->uri.path->used - 1);
-	MD5_Update(&Md5Ctx, (unsigned char *)"+", 1);
+	li_MD5_Init(&Md5Ctx);
+	li_MD5_Update(&Md5Ctx, (unsigned char *)con->uri.path->ptr, con->uri.path->used - 1);
+	li_MD5_Update(&Md5Ctx, (unsigned char *)"+", 1);
 
 	/* we assume sizeof(time_t) == 4 here, but if not it ain't a problem at all */
 	LI_ltostr(hh, srv->cur_ts);
-	MD5_Update(&Md5Ctx, (unsigned char *)hh, strlen(hh));
-	MD5_Update(&Md5Ctx, (unsigned char *)srv->entropy, sizeof(srv->entropy));
+	li_MD5_Update(&Md5Ctx, (unsigned char *)hh, strlen(hh));
+	li_MD5_Update(&Md5Ctx, (unsigned char *)srv->entropy, sizeof(srv->entropy));
 	LI_ltostr(hh, rand());
-	MD5_Update(&Md5Ctx, (unsigned char *)hh, strlen(hh));
+	li_MD5_Update(&Md5Ctx, (unsigned char *)hh, strlen(hh));
 
-	MD5_Final(h, &Md5Ctx);
+	li_MD5_Final(h, &Md5Ctx);
 
 	buffer_append_string_encoded(ds->value, (char *)h, 16, ENCODING_HEX);
 	buffer_append_string_len(ds->value, CONST_STR_LEN("; Path=/"));
Index: src/mod_cml_lua.c
===================================================================
--- src/mod_cml_lua.c	(revision 2798)
+++ src/mod_cml_lua.c	(revision 2799)
@@ -11,18 +11,6 @@
 #include <time.h>
 #include <string.h>
 
-#ifdef USE_OPENSSL
-# include <openssl/md5.h>
-#else
-# include "md5.h"
-
-typedef li_MD5_CTX MD5_CTX;
-#define MD5_Init li_MD5_Init
-#define MD5_Update li_MD5_Update
-#define MD5_Final li_MD5_Final
-
-#endif
-
 #define HASHLEN 16
 typedef unsigned char HASH[HASHLEN];
 #define HASHHEXLEN 32
Index: src/mod_dirlisting.c
===================================================================
--- src/mod_dirlisting.c	(revision 2798)
+++ src/mod_dirlisting.c	(revision 2799)
@@ -657,7 +657,8 @@
 	i = dir->used - 1;
 
 #ifdef HAVE_PATHCONF
-	if (-1 == (name_max = pathconf(dir->ptr, _PC_NAME_MAX))) {
+	if (0 >= (name_max = pathconf(dir->ptr, _PC_NAME_MAX))) {
+		/* some broken fs (fuse) return 0 instead of -1 */
 #ifdef NAME_MAX
 		name_max = NAME_MAX;
 #else