aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--glougloud/user.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/glougloud/user.c b/glougloud/user.c
index 38caae7..998f666 100644
--- a/glougloud/user.c
+++ b/glougloud/user.c
@@ -202,7 +202,7 @@ user_init(int fd[2], pcap_t *pcap)
* 'pend' is a pointer to the end of the captured IP packet
* 'wirelen' is the size of the IP packet off the wire
*/
-#define NOTCAPTURED(v) ((u_char *)v > pend - sizeof(*v))
+#define NOTCAPTURED(v) ((u_char *)v > (u_char *)pend - sizeof(*v))
#define NOTRECEIVED(v) (wirelen < sizeof(v))
static void
ip_handle(struct ip *ip, const u_char *pend, u_int wirelen)
@@ -218,7 +218,8 @@ ip_handle(struct ip *ip, const u_char *pend, u_int wirelen)
struct conn *c, *conn;
if (NOTCAPTURED(ip)) {
- log_pinvalid("user: ip truncated");
+ log_pinvalid("user: ip truncated (ip %x pend %x sizeof(ip) %d",
+ ip, pend, sizeof(ip));
cap->ptruncated++;
return;
}
@@ -568,6 +569,7 @@ phandler_ether(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
pend = p + h->caplen;
len = h->len - sizeof(struct ether_header);
+
ether_type = ntohs(ep->ether_type);
if (ether_type <= ETHERMTU)
log_tmp("llc packet !");
@@ -575,7 +577,7 @@ phandler_ether(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
switch (ether_type) {
case ETHERTYPE_IP:
log_tmp("ether IP");
- ip = (struct ip *)(ep + sizeof(struct ether_header));
+ ip = (struct ip *)((u_char *)ep + sizeof(struct ether_header));
ip_handle(ip, pend, len);
break;
default:
@@ -625,8 +627,8 @@ phandler_loop(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
switch (ether_type) {
case ETHERTYPE_IP:
log_tmp("loop family AF_LINK IP");
- ip = (struct ip *)(ep + sizeof(*ep));
- len -= NULL_HDRLEN + sizeof (*ep);
+ ip = (struct ip *)((u_char *)ep + sizeof(*ep));
+ len -= NULL_HDRLEN + sizeof(*ep);
ip_handle(ip, pend, len);
break;
default: