From aa5164ede47d4585d29d28e2b71a0544a7b674b0 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Thu, 16 May 2019 12:40:54 +0200 Subject: [PATCH] Fix protocol code handling new licenses s_seek() is a macro, so it is dangerous to use complex expressions in it as they may be evaluated multiple times and at incorrect times. In this case we ended up trying to jump to an incorrect offset. Work around this by having a dedicated variable for the target offset. --- licence.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/licence.c b/licence.c index 4acac8d..a86de22 100644 --- a/licence.c +++ b/licence.c @@ -278,6 +278,7 @@ static void licence_process_new_license(STREAM s) { unsigned char *data; + size_t before; RDSSL_RC4 crypt_key; uint32 length; int i; @@ -287,12 +288,13 @@ licence_process_new_license(STREAM s) if (!s_check_rem(s, length)) return; + before = s_tell(s); inout_uint8p(s, data, length); rdssl_rc4_set_key(&crypt_key, g_licence_key, 16); rdssl_rc4_crypt(&crypt_key, data, data, length); - s_seek(s, s_tell(s) - length); + s_seek(s, before); /* Parse NEW_LICENSE_INFO block */ in_uint8s(s, 4); // skip dwVersion