Skip to content

Commit b4199d5

Browse files
committed
libvncclient: handle negative payload sizes for ultra encoding
Spotted by Lukas Kupczyk, thanks!
1 parent a452ef3 commit b4199d5

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

libvncclient/ultra.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ HandleUltraBPP (rfbClient* client, int rx, int ry, int rw, int rh)
4545
toRead = rfbClientSwap32IfLE(hdr.nBytes);
4646
if (toRead==0) return TRUE;
4747

48+
if (toRead < 0) {
49+
rfbClientErr("ultra error: remote sent negative payload size\n");
50+
return FALSE;
51+
}
52+
4853
if (uncompressedBytes==0)
4954
{
5055
rfbClientLog("ultra error: rectangle has 0 uncomressed bytes ((%dw * %dh) * (%d / 8))\n", rw, rh, BPP);
@@ -131,6 +136,11 @@ HandleUltraZipBPP (rfbClient* client, int rx, int ry, int rw, int rh)
131136

132137
if (toRead==0) return TRUE;
133138

139+
if (toRead < 0) {
140+
rfbClientErr("ultrazip error: remote sent negative payload size\n");
141+
return FALSE;
142+
}
143+
134144
if (uncompressedBytes==0)
135145
{
136146
rfbClientLog("ultrazip error: rectangle has 0 uncomressed bytes (%dy + (%dw * 65535)) (%d rectangles)\n", ry, rw, rx);

0 commit comments

Comments
 (0)