diff --git a/src/tpm.c b/src/tpm.c index d3b898d..22308f3 100644 --- a/src/tpm.c +++ b/src/tpm.c @@ -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.sign = true; - npr->network.choice.gn.securityNeighbour = calloc(1, sizeof(OCTET_STRING_t)); - npr->network.choice.gn.securityNeighbour->size = 8; - npr->network.choice.gn.securityNeighbour->buf = malloc(8); - memcpy(npr->network.choice.gn.securityNeighbour->buf, neighbour, 8); + if(neighbour){ + npr->network.choice.gn.securityNeighbour = calloc(1, sizeof(OCTET_STRING_t)); + npr->network.choice.gn.securityNeighbour->size = 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.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.sign = true; - npr->network.choice.gn.securityNeighbour = calloc(1, sizeof(OCTET_STRING_t)); - npr->network.choice.gn.securityNeighbour->size = 8; - npr->network.choice.gn.securityNeighbour->buf = malloc(8); - memcpy(npr->network.choice.gn.securityNeighbour->buf, neighbour, 8); + if(neighbour){ + npr->network.choice.gn.securityNeighbour = calloc(1, sizeof(OCTET_STRING_t)); + npr->network.choice.gn.securityNeighbour->size = 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.buf = malloc(tpm_uper_len);