if(!n) {
// It might be from a 1.1 node, which might have a source ID in the packet.
pkt->offset = 2 * sizeof(node_id_t);
- from = lookup_node_id(SRCID(pkt));
- if(from && from->status.sptps && !memcmp(DSTID(pkt), &nullid, sizeof(nullid))) {
- if(sptps_verify_datagram(&from->sptps, DATA(pkt), pkt->len - 2 * sizeof(node_id_t))) {
- n = from;
- } else {
- goto skip_harder;
+ if(pkt->len >= pkt->offset) {
+ from = lookup_node_id(SRCID(pkt));
+
+ if(from && from->status.sptps && !memcmp(DSTID(pkt), &nullid, sizeof(nullid))) {
+ if(sptps_verify_datagram(&from->sptps, DATA(pkt), pkt->len - 2 * sizeof(node_id_t))) {
+ n = from;
+ } else {
+ goto skip_harder;
+ }
}
}
}
skip_harder:
if(!n) {
- if(debug_level >= DEBUG_PROTOCOL) {
+ if(debug_level >= DEBUG_TRAFFIC) {
hostname = sockaddr2hostname(addr);
- logger(DEBUG_PROTOCOL, LOG_WARNING, "Received UDP packet from unknown source %s", hostname);
+ logger(DEBUG_TRAFFIC, LOG_WARNING, "Received UDP packet from unknown source %s", hostname);
free(hostname);
}
if(relay_enabled) {
pkt->offset = 2 * sizeof(node_id_t);
+
+ if(pkt->offset > pkt->len) {
+ logger(DEBUG_TRAFFIC, LOG_WARNING, "Got too short packet from %s (%s)", n->name, n->hostname);
+ return;
+ }
+
pkt->len -= pkt->offset;
}
}
if(!from || !to) {
- logger(DEBUG_PROTOCOL, LOG_WARNING, "Received UDP packet from %s (%s) with unknown source and/or destination ID", n->name, n->hostname);
+ logger(DEBUG_TRAFFIC, LOG_WARNING, "Received UDP packet from %s (%s) with unknown source and/or destination ID", n->name, n->hostname);
return;
}