diff --git a/raw.c b/raw.c index 1bfc1bb..795292f 100644 --- a/raw.c +++ b/raw.c @@ -244,6 +244,11 @@ static int raw_recv(struct transport *t, int fd, void *buf, int buflen, cnt = sk_receive(fd, ptr, buflen, hwts, 0); + if (cnt >= 0) + cnt -= hlen; + if (cnt < 0) + return cnt; + if (raw->vlan) { if (ETH_P_1588 == ntohs(hdr->type)) { pr_notice("raw: disabling VLAN mode"); @@ -255,9 +260,6 @@ static int raw_recv(struct transport *t, int fd, void *buf, int buflen, raw->vlan = 1; } } - if (cnt >= hlen) { - cnt -= hlen; - } return cnt; }