check neighbour existance before adding to tpm

This commit is contained in:
dmtar 2025-06-02 17:02:08 +01:00
parent 37bded5fe6
commit f1aedd9239
1 changed files with 12 additions and 8 deletions

View File

@ -271,10 +271,12 @@ int tpm_pay(tolling_info_t* info, void** security_socket, uint8_t* neighbour, ui
npr->network.choice.gn.securityProfile.encrypt = true; npr->network.choice.gn.securityProfile.encrypt = true;
npr->network.choice.gn.securityProfile.sign = true; npr->network.choice.gn.securityProfile.sign = true;
npr->network.choice.gn.securityNeighbour = calloc(1, sizeof(OCTET_STRING_t)); if(neighbour){
npr->network.choice.gn.securityNeighbour->size = 8; npr->network.choice.gn.securityNeighbour = calloc(1, sizeof(OCTET_STRING_t));
npr->network.choice.gn.securityNeighbour->buf = malloc(8); npr->network.choice.gn.securityNeighbour->size = 8;
memcpy(npr->network.choice.gn.securityNeighbour->buf, neighbour, 8); npr->network.choice.gn.securityNeighbour->buf = malloc(8);
memcpy(npr->network.choice.gn.securityNeighbour->buf, neighbour, 8);
}
npr->data.size = tpm_uper_len; npr->data.size = tpm_uper_len;
npr->data.buf = malloc(tpm_uper_len); npr->data.buf = malloc(tpm_uper_len);
@ -889,10 +891,12 @@ static int rsu_handle_recv(EI1_TPM_t* tpm_rx, void** security_socket, uint8_t* n
npr->network.choice.gn.securityProfile.encrypt = true; npr->network.choice.gn.securityProfile.encrypt = true;
npr->network.choice.gn.securityProfile.sign = true; npr->network.choice.gn.securityProfile.sign = true;
npr->network.choice.gn.securityNeighbour = calloc(1, sizeof(OCTET_STRING_t)); if(neighbour){
npr->network.choice.gn.securityNeighbour->size = 8; npr->network.choice.gn.securityNeighbour = calloc(1, sizeof(OCTET_STRING_t));
npr->network.choice.gn.securityNeighbour->buf = malloc(8); npr->network.choice.gn.securityNeighbour->size = 8;
memcpy(npr->network.choice.gn.securityNeighbour->buf, neighbour, 8); npr->network.choice.gn.securityNeighbour->buf = malloc(8);
memcpy(npr->network.choice.gn.securityNeighbour->buf, neighbour, 8);
}
npr->data.size = tpm_uper_len; npr->data.size = tpm_uper_len;
npr->data.buf = malloc(tpm_uper_len); npr->data.buf = malloc(tpm_uper_len);