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
|
--- src.origin/ne_locks.c 2007-02-05 11:09:27.000000000 +0100
+++ src/ne_locks.c 2015-11-11 16:12:11.236849082 +0100
@@ -33,6 +33,10 @@
#include <limits.h>
#endif
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+
#include <ctype.h> /* for isdigit() */
#include "ne_alloc.h"
@@ -428,9 +432,21 @@
if (ne_strcasecmp(timeout, "infinite") == 0) {
return NE_TIMEOUT_INFINITE;
} else if (strncasecmp(timeout, "Second-", 7) == 0) {
- long to = strtol(timeout+7, NULL, 10);
- if (to == LONG_MIN || to == LONG_MAX)
+ // according RFC 4918 the value used for lock timeout is unsigned 32 bit
+ // see: <http://tools.ietf.org/html/rfc4918#section-10.7>
+ // adapt it to the 'long' used internally by neon instead
+ errno = 0;
+ unsigned long to1 = strtoul(timeout+7, NULL, 10);
+ if (to1 == ULONG_MAX && errno == ERANGE)
return NE_TIMEOUT_INVALID;
+ NE_DEBUG(NE_DBG_LOCKS, "Parsed lock timeout: %lu\n", to1);
+ long to;
+ // LONG_MAX means around 68 years,
+ // more than enough for practical use
+ if (to1 > LONG_MAX)
+ return LONG_MAX;
+ else
+ to = (long)to1;
return to;
} else {
return NE_TIMEOUT_INVALID;
|