diff options
author | Lars-Dominik Braun <PromyLOPh@lavabit.com> | 2010-03-05 18:08:11 +0100 |
---|---|---|
committer | Lars-Dominik Braun <PromyLOPh@lavabit.com> | 2010-03-05 18:08:11 +0100 |
commit | b4e293558266d9ae2f7971c682ac0846972005f8 (patch) | |
tree | ebd4c134c4a6dd0ad50c8d49c50e63767cd83d3f /libwaitress/src/waitress.c | |
parent | 859d2c1cb12f8752fb416eb275ef8282cff10ea4 (diff) | |
download | pianobar-b4e293558266d9ae2f7971c682ac0846972005f8.tar.gz pianobar-b4e293558266d9ae2f7971c682ac0846972005f8.tar.bz2 pianobar-b4e293558266d9ae2f7971c682ac0846972005f8.zip |
waitress: Abort reading if server closes connection
Caused infinite loops under certain circumstances.
Diffstat (limited to 'libwaitress/src/waitress.c')
-rw-r--r-- | libwaitress/src/waitress.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/libwaitress/src/waitress.c b/libwaitress/src/waitress.c index 26ed493..70a1547 100644 --- a/libwaitress/src/waitress.c +++ b/libwaitress/src/waitress.c @@ -394,6 +394,10 @@ WaitressReturn_t WaitressFetchCall (WaitressHandle_t *waith) { nextLine = recvBuf; while (hdrParseMode != HDRM_FINISHED) { READ_RET (recvBuf+bufFilled, sizeof (recvBuf)-1 - bufFilled, &recvSize); + if (recvSize == 0) { + /* connection closed too early */ + CLOSE_RET (WAITRESS_RET_CONNECTION_CLOSED); + } bufFilled += recvSize; memset (recvBuf+bufFilled, 0, sizeof (recvBuf) - bufFilled); thisLine = recvBuf; |