mirror of
https://github.com/rsyslog/rsyslog.git
synced 2025-12-17 21:00:42 +01:00
gnutls: fixed memory leak when gtlsRecordRecv returned a failure.
When the connection was broken and gtlsRecordRecv returned a failure, pszRcvBuf was not freed. The code to free pszRcvBuf has been moved to finalize_it if iRet is not RS_RET_OK.
This commit is contained in:
parent
68d4b0a255
commit
1394e0bec2
@ -1576,14 +1576,6 @@ Rcv(nsd_t *pNsd, uchar *pBuf, ssize_t *pLenBuf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(pThis->lenRcvBuf == 0) { /* EOS */
|
if(pThis->lenRcvBuf == 0) { /* EOS */
|
||||||
*pLenBuf = 0;
|
|
||||||
/* in this case, we also need to free the receive buffer, if we
|
|
||||||
* allocated one. -- rgerhards, 2008-12-03
|
|
||||||
*/
|
|
||||||
if(pThis->pszRcvBuf != NULL) {
|
|
||||||
free(pThis->pszRcvBuf);
|
|
||||||
pThis->pszRcvBuf = NULL;
|
|
||||||
}
|
|
||||||
ABORT_FINALIZE(RS_RET_CLOSED);
|
ABORT_FINALIZE(RS_RET_CLOSED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1600,6 +1592,14 @@ Rcv(nsd_t *pNsd, uchar *pBuf, ssize_t *pLenBuf)
|
|||||||
*pLenBuf = iBytesCopy;
|
*pLenBuf = iBytesCopy;
|
||||||
|
|
||||||
finalize_it:
|
finalize_it:
|
||||||
|
if (iRet != RS_RET_OK) {
|
||||||
|
/* in this case, we also need to free the receive buffer, if we
|
||||||
|
* allocated one. -- rgerhards, 2008-12-03 -- moved here by alorbach, 2015-12-01
|
||||||
|
*/
|
||||||
|
*pLenBuf = 0;
|
||||||
|
free(pThis->pszRcvBuf);
|
||||||
|
pThis->pszRcvBuf = NULL;
|
||||||
|
}
|
||||||
dbgprintf("gtlsRcv return. nsd %p, iRet %d, lenRcvBuf %d, ptrRcvBuf %d\n", pThis, iRet, pThis->lenRcvBuf, pThis->ptrRcvBuf);
|
dbgprintf("gtlsRcv return. nsd %p, iRet %d, lenRcvBuf %d, ptrRcvBuf %d\n", pThis, iRet, pThis->lenRcvBuf, pThis->ptrRcvBuf);
|
||||||
RETiRet;
|
RETiRet;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user