From b52f2e0ca7069886bf322b9107279562b3f56551 Mon Sep 17 00:00:00 2001 From: Alistair Buxton Date: Wed, 6 Feb 2013 22:12:42 +0000 Subject: [PATCH] Bail out of packet eater if less than 4 bytes available. Without this, packlen will be initialized with undefined data. This causes "oversize packet" errors. --- src/micro/uSynergy.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/micro/uSynergy.c b/src/micro/uSynergy.c index a8d01da4..ffdf504c 100644 --- a/src/micro/uSynergy.c +++ b/src/micro/uSynergy.c @@ -514,6 +514,10 @@ static void sUpdateContext(uSynergyContext *context) /* Eat packets */ for (;;) { + /* If less than 4 bytes left in buffer, we can't even get the next packet length yet */ + if(context->m_receiveOfs < 4) + return; + /* Grab packet length and bail out if the packet goes beyond the end of the buffer */ packlen = sNetToNative32(context->m_receiveBuffer); if (packlen+4 > context->m_receiveOfs)