tdf#90249 fix lock timeout in neon for Windows platform.

According to RFC 4918 the value used for lock timeout is unsigned
32 bit, see:
<http://tools.ietf.org/html/rfc4918#section-10.7>
for info.

This patch fix the way the timeout element of lock response
payload is parsed in Windows.

Change-Id: I335a1cb884c3ef1c2362b00981a2784d9232b23e
Reviewed-on: https://gerrit.libreoffice.org/19867
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Giuseppe Castagno
2015-11-08 11:48:31 +01:00
committed by Caolán McNamara
parent e3bd0951e6
commit f75c1966a6
2 changed files with 38 additions and 0 deletions

View File

@@ -17,6 +17,16 @@ $(eval $(call gb_UnpackedTarball_add_files,neon,src,\
$(eval $(call gb_UnpackedTarball_set_patchlevel,neon,0))
ifeq ($(OS),WNT)
$(eval $(call gb_UnpackedTarball_add_patches,neon,\
external/neon/neon.patch \
external/neon/neon_ne_set_request_flag.patch \
external/neon/neon_with_gnutls.patch \
external/neon/ubsan.patch \
external/neon/neon_fix_lock_token_on_if.patch \
external/neon/neon_fix_lock_timeout_windows.patch \
))
else
$(eval $(call gb_UnpackedTarball_add_patches,neon,\
external/neon/neon.patch \
external/neon/neon_ne_set_request_flag.patch \
@@ -24,5 +34,6 @@ $(eval $(call gb_UnpackedTarball_add_patches,neon,\
external/neon/ubsan.patch \
external/neon/neon_fix_lock_token_on_if.patch \
))
endif
# vim: set noet sw=4 ts=4:

View File

@@ -0,0 +1,27 @@
--- src.origin/ne_locks.c 2007-02-05 11:09:27.000000000 +0100
+++ src/ne_locks.c 2015-11-08 17:21:52.968561488 +0100
@@ -428,10 +428,20 @@
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)
- return NE_TIMEOUT_INVALID;
- return to;
+ // 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
+ // LONG_MAX means around 68 years.
+ unsigned long to1 = strtoul(timeout+7, NULL, 10);
+ long to;
+ if (to1 >= LONG_MAX)
+ to = LONG_MAX - 1;
+ else
+ to = (long)to1;
+ NE_DEBUG(NE_DBG_LOCKS, "Received lock timeout: %ld\n", to);
+ if (to == LONG_MIN || to == LONG_MAX)
+ return NE_TIMEOUT_INVALID;
+ return to;
} else {
return NE_TIMEOUT_INVALID;
}