Skip to content

Commit

Permalink
Prevent misaddressing in SanitizeMsg()
Browse files Browse the repository at this point in the history
An invalid access occurs for a message consisting only of a single
zero byte.
  • Loading branch information
theinric committed Jun 8, 2015
1 parent f7a6bf7 commit c298a7e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion runtime/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,8 @@ SanitizeMsg(msg_t *pMsg)
* compatible to recent IETF developments, we allow the user to
* turn on/off this handling. rgerhards, 2007-07-23
*/
if(glbl.GetParserDropTrailingLFOnReception() && pszMsg[lenMsg-1] == '\n') {
if(glbl.GetParserDropTrailingLFOnReception()
&& lenMsg > 0 && pszMsg[lenMsg-1] == '\n') {
DBGPRINTF("dropped LF at very end of message (DropTrailingLF is set)\n");
lenMsg--;
pszMsg[lenMsg] = '\0';
Expand Down

0 comments on commit c298a7e

Please sign in to comment.