Skip to content

Commit

Permalink
Fixed the crashing of acf-can-listener when receiving other ACF packe…
Browse files Browse the repository at this point in the history
…ts in parallel.

Signed-off-by: Naresh Nayak <[email protected]>
  • Loading branch information
nayakned committed Sep 3, 2024
1 parent e7fba30 commit 9c6f41f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions examples/acf-can/acf-can-listener.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ static int new_packet(int sk_fd, int can_socket) {

if (res < 0 || res > MAX_PDU_SIZE) {
perror("Failed to receive data");
return -1;
return 0;
}

if (use_udp) {
Expand All @@ -204,14 +204,14 @@ static int new_packet(int sk_fd, int can_socket) {
res = Avtp_CommonHeader_GetField((Avtp_CommonHeader_t*)cf_pdu, AVTP_COMMON_HEADER_FIELD_SUBTYPE, &subtype);
if (res < 0) {
fprintf(stderr, "Failed to get subtype field: %d\n", res);
return -1;
return 0;
}

if (!((subtype == AVTP_SUBTYPE_NTSCF) ||
(subtype == AVTP_SUBTYPE_TSCF))) {
fprintf(stderr, "Subtype mismatch: expected %u or %u, got %"PRIu64". Dropping packet\n",
AVTP_SUBTYPE_NTSCF, AVTP_SUBTYPE_TSCF, subtype);
return -1;
return 0;
}

if(subtype == AVTP_SUBTYPE_TSCF){
Expand All @@ -228,7 +228,7 @@ static int new_packet(int sk_fd, int can_socket) {

if (!is_valid_acf_packet(acf_pdu)) {
fprintf(stderr, "Error: Invalid ACF packet.\n");
return -1;
return 0;
}

Avtp_Can_GetField((Avtp_Can_t*)acf_pdu, AVTP_CAN_FIELD_CAN_IDENTIFIER,
Expand All @@ -242,7 +242,7 @@ static int new_packet(int sk_fd, int can_socket) {
Avtp_Can_GetField((Avtp_Can_t*)acf_pdu, AVTP_CAN_FIELD_EFF, &flag);
if (can_id > 0x7FF && !flag) {
fprintf(stderr, "Error: CAN ID is > 0x7FF but the EFF bit is not set.\n");
return -1;
return 0;
}
if (flag) can_id |= CAN_EFF_FLAG;

Expand Down

0 comments on commit 9c6f41f

Please sign in to comment.