From 743c2f69744fe3f0dac11e467a92ff5e4d80280b Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Tue, 22 Aug 2017 17:38:44 +0200 Subject: lib: Fix CRC check and add frct_clear This adds the CRC check by default on outgoing SDUs. It fixes some errors in the serialization and deserialization of the SDU. frct_clear was added to avoid bad initialization of the array of FRCT instances. --- src/lib/frct_pci.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/lib/frct_pci.c') diff --git a/src/lib/frct_pci.c b/src/lib/frct_pci.c index 392e11c6..5ee14829 100644 --- a/src/lib/frct_pci.c +++ b/src/lib/frct_pci.c @@ -24,6 +24,9 @@ #include #include +#define OUROBOROS_PREFIX "frct-pci" +#include + #include #include @@ -73,6 +76,7 @@ int frct_pci_des(struct shm_du_buff * sdb, uint8_t * head; uint8_t * tail; uint32_t crc; + uint32_t crc2; assert(sdb); assert(pci); @@ -89,10 +93,14 @@ int frct_pci_des(struct shm_du_buff * sdb, if (tail == NULL) return -EPERM; - mem_hash(HASH_CRC32, &crc, head, tail - head); + mem_hash(HASH_CRC32, &crc, head, + tail - head - hash_len(HASH_CRC32)); + + memcpy(&crc2, tail - hash_len(HASH_CRC32), + hash_len(HASH_CRC32)); /* Corrupted SDU */ - if (crc != 0) + if (crc != crc2) return -1; shm_du_buff_tail_release(sdb, hash_len(HASH_CRC32)); -- cgit v1.2.3