strcpy(&tmp->key, my_public_key_base36);
fw = lookup_conn(to);
+
+ if(!fw)
+ {
+ syslog(LOG_ERR, "Attempting to send key answer to " IP_ADDR_S ", which does not exist?",
+ IP_ADDR_V(to));
+ return -1;
+ }
+
if(debug_lvl > 2)
syslog(LOG_DEBUG, "Sending public key to " IP_ADDR_S,
IP_ADDR_V(fw->nexthop->vpn_ip));
{
if(request_handlers[d[1]] == NULL)
syslog(LOG_ERR, "Unknown request %d.", d[1]);
- if(request_handlers[d[1]](cl, d, len - 1) < 0)
+ if(request_handlers[d[1]](cl, d + 1, len - 1) < 0)
return -1;
}
/*
again, i'm cheating here. see the comment in ack_h.
+ Naughty zarq! Now you see what cheating will get you... [GS]
*/
if(len > sizeof(add_host_t)) /* Another ADD_HOST follows */
{
if(request_handlers[d[sizeof(add_host_t)]] == NULL)
syslog(LOG_ERR, "Unknown request %d.", d[sizeof(add_host_t)]);
- if(request_handlers[d[sizeof(add_host_t)]](cl, d, len - sizeof(add_host_t)) < 0)
+ if(request_handlers[d[sizeof(add_host_t)]](cl, d + sizeof(add_host_t), len - sizeof(add_host_t)) < 0)
return -1;
}
}
fw = lookup_conn(tmp->to);
+
+ if(!fw)
+ {
+ syslog(LOG_ERR, "Attempting to forward key request to " IP_ADDR_S ", which does not exist?",
+ IP_ADDR_V(tmp->to));
+ return -1;
+ }
+
if(debug_lvl > 3)
syslog(LOG_DEBUG, "Forwarding request for public key to " IP_ADDR_S,
IP_ADDR_V(fw->nexthop->vpn_ip));
if(debug_lvl > 2)
syslog(LOG_DEBUG, "Yeah! key arrived. Now do something with it.");
gk = lookup_conn(tmp->from);
+
+ if(!gk)
+ {
+ syslog(LOG_ERR, "Receiving key from " IP_ADDR_S ", which does not exist?",
+ IP_ADDR_V(tmp->from));
+ return -1;
+ }
+
set_keys(gk, tmp);
gk->status.validkey = 1;
gk->status.waitingforkey = 0;
}
fw = lookup_conn(tmp->to);
+
+ if(!fw)
+ {
+ syslog(LOG_ERR, "Attempting to forward key to " IP_ADDR_S ", which does not exist?",
+ IP_ADDR_V(tmp->to));
+ return -1;
+ }
+
if(debug_lvl > 2)
syslog(LOG_DEBUG, "Forwarding public key to " IP_ADDR_S,
IP_ADDR_V(fw->nexthop->vpn_ip));
IP_ADDR_V(tmp->from));
ik = lookup_conn(tmp->from);
+
+ if(!ik)
+ {
+ syslog(LOG_ERR, "Got changed key from " IP_ADDR_S ", which does not exist?",
+ IP_ADDR_V(tmp->from));
+ return -1;
+ }
+
ik->status.validkey = 0;
ik->status.waitingforkey = 0;