Make allocations based on var size, not struct size - it's safer
This commit is contained in:
@@ -64,7 +64,7 @@ int main(int count, char *strings[])
|
||||
}
|
||||
printf("Connected with %s encryption\n", SSL_get_cipher(ssl));
|
||||
show_certs(ssl);
|
||||
if (!(args = (struct job_args*)calloc(1, sizeof(struct job_args) * MAX_AGENT_JOBS))) {
|
||||
if (!(args = calloc(1, sizeof(*args) * MAX_AGENT_JOBS))) {
|
||||
fprintf( stderr,
|
||||
"Failed to calloc() %d bytes for job_args! Exiting...\n",
|
||||
(int)sizeof(struct job_args) * MAX_AGENT_JOBS );
|
||||
@@ -74,7 +74,7 @@ int main(int count, char *strings[])
|
||||
SSL_CTX_free(ctx);
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
if (!(job_thread = (pthread_t*)calloc(1, sizeof(pthread_t) * MAX_AGENT_JOBS))) {
|
||||
if (!(job_thread = calloc(1, sizeof(*job_thread) * MAX_AGENT_JOBS))) {
|
||||
fprintf( stderr,
|
||||
"Failed to calloc() %d bytes for job_threads! Exiting...\n",
|
||||
(int)sizeof(pthread_t) * MAX_AGENT_JOBS );
|
||||
|
||||
Reference in New Issue
Block a user