From 31953ec55d038d75cfe9307bd38abdc953904b07 Mon Sep 17 00:00:00 2001 From: Philip Balister Date: Thu, 17 Mar 2011 05:38:32 -0700 Subject: usrp_e : Check packet length received from FPGA in case of corruption. If the packet length in invalid, do not calculate the checksum to avoid segfaulting. --- host/usrp_e_utils/usrp-e-loopback.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/host/usrp_e_utils/usrp-e-loopback.c b/host/usrp_e_utils/usrp-e-loopback.c index 78e2b5d16..0bd3d3100 100644 --- a/host/usrp_e_utils/usrp-e-loopback.c +++ b/host/usrp_e_utils/usrp-e-loopback.c @@ -38,11 +38,15 @@ static int calc_checksum(struct pkt *p) i = 0; sum = 0; - for (i=0; i < p->len; i++) - sum += p->data[i]; - - sum += p->seq_num; - sum += p->len; + if (p->len < 1016) { + for (i=0; i < p->len; i++) + sum += p->data[i]; + + sum += p->seq_num; + sum += p->len; + } else { + printf("Bad packet length = %d received.\n", p->len); + } return sum; } -- cgit v1.2.3