-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix null pointer dereferences found by malloc-error-check cocci #15560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
04d073b
0a704b1
62cbdcf
ae4fa81
2690c5c
2e61587
d54ce83
2f60a59
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1158,7 +1158,10 @@ static Packet *BuildIpv4TestPacket( | |
| if (unlikely(p == NULL)) | ||
| return NULL; | ||
|
|
||
| PacketInit(p); | ||
| if (!PacketInit(p)) { | ||
| SCFree(p); | ||
| return NULL; | ||
| } | ||
|
Comment on lines
+1161
to
+1164
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know what we prefer, if this approach or the one in the next function (line 1228), but we should be consistent. |
||
|
|
||
| struct timeval tval; | ||
| gettimeofday(&tval, NULL); | ||
|
|
@@ -1222,7 +1225,7 @@ static int BuildIpv4TestPacketWithContent(Packet **packet, uint8_t proto, uint16 | |
| p = SCCalloc(1, sizeof(*p) + default_packet_size); | ||
| FAIL_IF_NULL(p); | ||
|
|
||
| PacketInit(p); | ||
| FAIL_IF(!PacketInit(p)); | ||
|
|
||
| struct timeval tval; | ||
| gettimeofday(&tval, NULL); | ||
|
|
@@ -1277,7 +1280,10 @@ static Packet *BuildIpv6TestPacket( | |
| if (unlikely(p == NULL)) | ||
| return NULL; | ||
|
|
||
| PacketInit(p); | ||
| if (!PacketInit(p)) { | ||
| SCFree(p); | ||
| return NULL; | ||
| } | ||
|
|
||
| struct timeval tval; | ||
| gettimeofday(&tval, NULL); | ||
|
|
@@ -1347,7 +1353,10 @@ static Packet *BuildIpv6TestPacketWithContent( | |
| if (unlikely(p == NULL)) | ||
| return NULL; | ||
|
|
||
| PacketInit(p); | ||
| if (!PacketInit(p)) { | ||
| SCFree(p); | ||
| return NULL; | ||
| } | ||
|
|
||
| struct timeval tval; | ||
| gettimeofday(&tval, NULL); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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"); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jasonish is this ok to FatalError here ?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I think it as a relevant to a fatal error as the ones just below it. |
||
| } | ||
| 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; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The commit message should not mention
FatalErrorwhich is not the case in main right now