Skip to content

Commit

Permalink
sources/scram.c: handle malloc failure (#553)
Browse files Browse the repository at this point in the history
  • Loading branch information
chipitsine authored Jan 12, 2024
1 parent 20b4981 commit 360f52d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion sources/scram.c
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,9 @@ int od_scram_read_client_final_message(machine_io_t *io,
strlen("p=tls-server-end-point,,"); /* p=type,, */
cbind_input_len = cbind_header_len + cbind_data_len;
cbind_input = malloc(cbind_input_len);
if (cbind_input == NULL) {
goto error;
}
snprintf(cbind_input, cbind_input_len,
"p=tls-server-end-point,,");
memcpy(cbind_input + cbind_header_len, cbind_data,
Expand All @@ -661,6 +664,9 @@ int od_scram_read_client_final_message(machine_io_t *io,
b64_message_len = pg_b64_enc_len(cbind_input_len);
/* don't forget the zero-terminator */
b64_message = malloc(b64_message_len + 1);
if (b64_message == NULL) {
goto error;
}
b64_message_len = od_b64_encode(cbind_input, cbind_input_len,
b64_message, b64_message_len);
if (b64_message_len < 0) {
Expand Down Expand Up @@ -885,4 +891,4 @@ od_scram_create_server_final_message(od_scram_state_t *scram_state)
free(result);

return NULL;
}
}

0 comments on commit 360f52d

Please sign in to comment.