aboutsummaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
authorPhilip Balister <philip@opensdr.com>2011-03-17 05:38:32 -0700
committerPhilip Balister <philip@opensdr.com>2011-03-17 05:38:32 -0700
commit31953ec55d038d75cfe9307bd38abdc953904b07 (patch)
tree22912967b2edc46bce0db66eca06f93d2b1f5001 /host
parenta57310606c581addc5bafdb9c645eb7b46cb4a79 (diff)
downloaduhd-31953ec55d038d75cfe9307bd38abdc953904b07.tar.gz
uhd-31953ec55d038d75cfe9307bd38abdc953904b07.tar.bz2
uhd-31953ec55d038d75cfe9307bd38abdc953904b07.zip
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.
Diffstat (limited to 'host')
-rw-r--r--host/usrp_e_utils/usrp-e-loopback.c14
1 files 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;
}