Skip to content

Commit d4116da

Browse files
committed
Fix NULL pointer dereference in stringify_headers() error path
Add NULL check after stringify_headers() call to prevent undefined behavior when malloc fails inside the function. Return error code 3 to maintain consistency with existing error handling. This is a follow-up fix to PR #1092.
1 parent 61ca4f1 commit d4116da

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

hydra-http.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ int32_t start_http(int32_t s, char *ip, int32_t port, unsigned char options, cha
8181
add_header(&ptr_head, "Content-Length", "0", HEADER_TYPE_DEFAULT);
8282

8383
header = stringify_headers(&ptr_head);
84+
if (header == NULL)
85+
return 3;
8486

8587
buffer_size = strlen(header) + 500;
8688
if (!(buffer = malloc(buffer_size))) {

0 commit comments

Comments
 (0)