Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / external / neon / neon_fix_lock_timeout_windows.patch
blob72abde76242073a6f1ce3af8a575175567507a7f
1 --- src.origin/ne_locks.c 2007-02-05 11:09:27.000000000 +0100
2 +++ src/ne_locks.c 2015-11-11 16:12:11.236849082 +0100
3 @@ -33,6 +33,10 @@
4 #include <limits.h>
5 #endif
7 +#ifdef HAVE_ERRNO_H
8 +#include <errno.h>
9 +#endif
11 #include <ctype.h> /* for isdigit() */
13 #include "ne_alloc.h"
14 @@ -428,9 +432,21 @@
15 if (ne_strcasecmp(timeout, "infinite") == 0) {
16 return NE_TIMEOUT_INFINITE;
17 } else if (strncasecmp(timeout, "Second-", 7) == 0) {
18 - long to = strtol(timeout+7, NULL, 10);
19 - if (to == LONG_MIN || to == LONG_MAX)
20 + // according RFC 4918 the value used for lock timeout is unsigned 32 bit
21 + // see: <http://tools.ietf.org/html/rfc4918#section-10.7>
22 + // adapt it to the 'long' used internally by neon instead
23 + errno = 0;
24 + unsigned long to1 = strtoul(timeout+7, NULL, 10);
25 + if (to1 == ULONG_MAX && errno == ERANGE)
26 return NE_TIMEOUT_INVALID;
27 + NE_DEBUG(NE_DBG_LOCKS, "Parsed lock timeout: %lu\n", to1);
28 + long to;
29 + // LONG_MAX means around 68 years,
30 + // more than enough for practical use
31 + if (to1 > LONG_MAX)
32 + return LONG_MAX;
33 + else
34 + to = (long)to1;
35 return to;
36 } else {
37 return NE_TIMEOUT_INVALID;