Explorar o código

Ensure proper ordering in linking negotiation

Bryan Drewery %!s(int64=13) %!d(string=hai) anos
pai
achega
60b098044e
Modificáronse 1 ficheiros con 9 adicións e 0 borrados
  1. 9 0
      src/dcc.c

+ 9 - 0
src/dcc.c

@@ -975,6 +975,15 @@ dcc_chat_pass(int idx, char *buf, int atr)
     if (!strcasecmp(pass, STR("neg!"))) {		/* we're the hub */
       link_parse(idx, buf);
     } else if (!strcasecmp(pass, STR("neg."))) {		/* we're done, link up! */
+      int snum = findanysnum(dcc[idx].sock);
+
+      if (socklist[snum].enclink == -1) {
+	putlog(LOG_WARN, "*", STR("%s attempted to negotiate an encryption out of order."), dcc[idx].nick);
+	killsock(dcc[idx].sock);
+	lostdcc(idx);
+	return;
+      }
+
       dcc[idx].encrypt = 2;
       if (dcc[idx].bot) {
         dcc[idx].type = &DCC_BOT_NEW;