From 911ed13efce61806301fff21c9c6d48c2e07a702 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Wed, 25 Sep 2024 03:42:15 +0200 Subject: [PATCH] [channels,rdpei] fix integer narrow --- channels/rdpei/rdpei_common.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/channels/rdpei/rdpei_common.c b/channels/rdpei/rdpei_common.c index 4fc826543..a253c462b 100644 --- a/channels/rdpei/rdpei_common.c +++ b/channels/rdpei/rdpei_common.c @@ -93,7 +93,7 @@ BOOL rdpei_read_2byte_signed(wStream* s, INT16* value) negative = (byte & 0x40) ? TRUE : FALSE; - *value = (byte & 0x3F); + const BYTE val = (byte & 0x3F); if (byte & 0x80) { @@ -101,8 +101,10 @@ BOOL rdpei_read_2byte_signed(wStream* s, INT16* value) return FALSE; Stream_Read_UINT8(s, byte); - *value = ((*value & 0xFF) << 8) | byte; + *value = (INT16)((val << 8) | byte); } + else + *value = val; if (negative) *value *= -1;