--- 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 #endif +#ifdef HAVE_ERRNO_H +#include +#endif + #include /* 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: + // 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;