Fix crash in rtspcl_auth_setup when response body is empty #47
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
When connecting to Shairport Sync devices that return an empty body (Content-Length: 0) for the
/auth-setuprequest, thersppointer was never assigned but was still freed at the end of the function, causing a malloc error:pointer being freed was not allocated.The Fix
Initialize
rsptoNULLandrsp_lento0inrtspcl_auth_setup(), so thatfree(rsp)is safe when no response body is received.Testing
Tested successfully with JukeAudio whole-house audio systems running Shairport Sync 4.1.1. Before the fix, cliraop would crash immediately when trying to stream. After the fix, streaming works correctly.
Root Cause Analysis
The issue occurs in
src/rtsp_client.clines 503-504:When Shairport Sync returns a 200 OK with
Content-Length: 0to the auth-setup request, theexec_requestfunction never assignsrsp(since there's no body to read). However, line 529 still callsfree(rsp), which tries to free an uninitialized pointer.