mirror of
https://github.com/rsyslog/rsyslog.git
synced 2026-06-19 18:42:59 +02:00
ratelimit: free dropped TCP messages on helper errors
Why The previous change kept TCP batch processing alive on ratelimit helper errors, but it left message ownership with the caller in those error paths. Continuing without cleanup leaks the message object. Impact Unexpected ratelimit helper errors now drop and free the current message before processing continues. Before/After Before, non-discard helper errors could leak `pMsg` in imptcp and the generic TCP session path. After, both paths destroy the unqueued message before returning success to the caller. Technical Overview `ratelimitAddMsg()` and `ratelimitAddMsgPerSource()` only take ownership of a message when they enqueue or explicitly discard it internally. When they return an unexpected error, ownership remains with the caller. Add `msgDestruct(&pMsg)` in the non-discard error branch for `imptcp` and `tcps_sess`, and update the debug text to reflect that the message is being dropped before batch processing continues. This preserves the non-fatal caller behavior while closing the memory leak identified by gemini-code-assist and cubic. With the help of AI-Agents: Codex
This commit is contained in:
parent
9aa45c684f
commit
e0dc6d52a4
@ -972,7 +972,8 @@ static rsRetVal doSubmitMsg(ptcpsess_t *pThis, struct syslogTime *stTime, time_t
|
||||
DBGPRINTF("imptcp: message discarded by ratelimit helper\n");
|
||||
iRet = RS_RET_OK;
|
||||
} else {
|
||||
DBGPRINTF("imptcp: ratelimit helper returned error %d, continuing\n", localRet);
|
||||
DBGPRINTF("imptcp: ratelimit helper returned error %d, dropping message and continuing\n", localRet);
|
||||
msgDestruct(&pMsg);
|
||||
iRet = RS_RET_OK;
|
||||
}
|
||||
|
||||
|
||||
@ -448,7 +448,8 @@ static rsRetVal defaultDoSubmitMessage(tcps_sess_t *pThis,
|
||||
DBGPRINTF("tcps_sess: message discarded by ratelimit helper\n");
|
||||
iRet = RS_RET_OK;
|
||||
} else {
|
||||
DBGPRINTF("tcps_sess: ratelimit helper returned error %d, continuing\n", localRet);
|
||||
DBGPRINTF("tcps_sess: ratelimit helper returned error %d, dropping message and continuing\n", localRet);
|
||||
msgDestruct(&pMsg);
|
||||
iRet = RS_RET_OK;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user