mirror of
https://github.com/OISF/suricata.git
synced 2026-10-11 22:09:53 +00:00
util/log-redis: guard SCCalloc result for redis stream format
When Redis output is configured in stream/xadd mode with a positive stream-maxlen, SCConfLogOpenRedis() allocates redis_setup.stream_format and immediately passes it to snprintf(). If SCCalloc() fails, snprintf() receives a NULL destination pointer and the process can crash during Redis output initialization. Handle this unrecoverable setup failure with FatalError(), matching the surrounding Redis initialization error handling. Ticket: 8588
This commit is contained in:
committed by
Victor Julien
parent
39688a6252
commit
b2cd08bb91
@@ -673,6 +673,9 @@ int SCConfLogOpenRedis(SCConfNode *redis_node, void *lf_ctx)
|
||||
format string, whose length is limited by the length of the
|
||||
maxlen integer formatted as a string */
|
||||
log_ctx->redis_setup.stream_format = SCCalloc(100, sizeof(char));
|
||||
if (unlikely(log_ctx->redis_setup.stream_format == NULL)) {
|
||||
FatalError("Unable to allocate redis stream format");
|
||||
}
|
||||
snprintf(log_ctx->redis_setup.stream_format, 100, redis_stream_format_maxlen_tmpl, "%s",
|
||||
"%s", exact ? '=' : '~', maxlen, "%s");
|
||||
log_ctx->redis_setup.format = log_ctx->redis_setup.stream_format;
|
||||
|
||||
Reference in New Issue
Block a user