Skip to content

Commit

Permalink
Merge pull request #137 from triwav/prevent_incomplete_requests_being…
Browse files Browse the repository at this point in the history
…_handled

Prevent incomplete requests from being handled by also checking string payload size in addition to binary size
  • Loading branch information
triwav authored Apr 8, 2024
2 parents 7b6c93f + 4d4fb04 commit 6234327
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions device/components/RTA_OnDeviceComponentTask.brs
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,10 @@ function receiveDataForRequest(request as Object, socket as Object) as Boolean
closeSocket(request.socketId)
end if
request.stringPayload += receivedString
end if

if request.binaryLength = request.binaryBytesReceived then
' Doing extra check here to avoid an extra socket event if empty binary request (most are)
return true
if request.stringPayload.len() = request.stringLength AND request.binaryLength = request.binaryBytesReceived then
' Doing extra check here to avoid an extra socket event if empty binary request (most are)
return true
end if
end if

return false
Expand Down

0 comments on commit 6234327

Please sign in to comment.