mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-24 04:03:03 +01:00
Avoid negative offsets in case of malformed network packet
This commit is contained in:
parent
5182ebc4aa
commit
e293f86fad
@ -498,7 +498,7 @@ static int getNumericInfo(const UCHAR** ptr, const UCHAR* bufferEnd)
|
||||
{
|
||||
fb_assert(bufferEnd - *ptr >= 2);
|
||||
|
||||
const SSHORT len = static_cast<SSHORT>(gds__vax_integer(*ptr, 2));
|
||||
const USHORT len = static_cast<USHORT>(gds__vax_integer(*ptr, 2));
|
||||
*ptr += 2;
|
||||
|
||||
fb_assert(bufferEnd - *ptr >= len);
|
||||
@ -513,20 +513,13 @@ static void getStringInfo(const UCHAR** ptr, const UCHAR* bufferEnd, string* str
|
||||
{
|
||||
fb_assert(bufferEnd - *ptr >= 2);
|
||||
|
||||
const UCHAR* p = *ptr;
|
||||
SSHORT len = static_cast<SSHORT>(gds__vax_integer(p, 2));
|
||||
const USHORT len = static_cast<USHORT>(gds__vax_integer(*ptr, 2));
|
||||
*ptr += 2;
|
||||
|
||||
fb_assert(bufferEnd - *ptr >= len);
|
||||
|
||||
// CVC: What else can we do here?
|
||||
if (len < 0)
|
||||
len = 0;
|
||||
|
||||
str->assign(*ptr, len);
|
||||
*ptr += len;
|
||||
p += 2;
|
||||
|
||||
str->assign(p, len);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user