Commit 6037a907 authored by Nicolas Ruff's avatar Nicolas Ruff

Check malloc() return value on client->server ClientCutText message. Client...

Check malloc() return value on client->server ClientCutText message. Client can send up to 2**32-1 bytes of text, and such a large allocation is likely to fail in case of high memory pressure. This would in a server crash (write at address 0).
parent 7c9ef637
...@@ -2461,6 +2461,11 @@ rfbProcessClientNormalMessage(rfbClientPtr cl) ...@@ -2461,6 +2461,11 @@ rfbProcessClientNormalMessage(rfbClientPtr cl)
msg.cct.length = Swap32IfLE(msg.cct.length); msg.cct.length = Swap32IfLE(msg.cct.length);
str = (char *)malloc(msg.cct.length); str = (char *)malloc(msg.cct.length);
if (str == NULL) {
rfbLogPerror("rfbProcessClientNormalMessage: not enough memory");
rfbCloseClient(cl);
return;
}
if ((n = rfbReadExact(cl, str, msg.cct.length)) <= 0) { if ((n = rfbReadExact(cl, str, msg.cct.length)) <= 0) {
if (n != 0) if (n != 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment