Author: Kev <klmitch@mit.edu>
[ircu2.10.12-pk.git] / ircd / m_squit.c
index 791b4b595bd069972b208ec2cdcc75dfdd3c4741..c0282fec811f9d2252b0c24ea5c0f416929cb95f 100644 (file)
@@ -60,7 +60,7 @@ int ms_squit(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 {
   const char* server = parv[1];
   struct Client *acptr;
-  time_t timestamp;
+  time_t timestamp = 0;
   char *comment = 0;
   
   if (parc < 2) 
@@ -71,10 +71,10 @@ int ms_squit(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   if (BadPtr(parv[parc - 1]))
        comment = cli_name(sptr);
        
-  acptr = FindNServer(server);
+  acptr = FindServer(server);
 
   if (!acptr)
-    acptr = FindServer(server);
+    acptr = FindNServer(server);
 
   if (!acptr) {
     Debug((DEBUG_NOTICE, "Ignoring SQUIT to an unknown server"));
@@ -82,17 +82,19 @@ int ms_squit(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   }
   
   /* If they are squitting me, we reverse it */
-  if (IsMe(acptr)) {
-       cptr = acptr;
-       acptr = &me;
-  }
-       
-  timestamp = atoi(parv[2]);
+  if (IsMe(acptr))
+    acptr = cptr; /* Bugfix by Prefect */
+
+  if (parc > 2)
+    timestamp = atoi(parv[2]);
+  else
+    protocol_violation(cptr, "SQUIT with no timestamp/reason");
 
   /* If atoi(parv[2]) == 0 we must indeed squit !
    * It will be our neighbour.
    */
-  if ( timestamp != 0 && timestamp != cli_serv(acptr)->timestamp) {
+  if ( timestamp != 0 && timestamp != cli_serv(acptr)->timestamp)
+  {
     Debug((DEBUG_NOTICE, "Ignoring SQUIT with the wrong timestamp"));
     return 0;
   }
@@ -155,5 +157,3 @@ int mo_squit(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 
   return exit_client(cptr, acptr, sptr, comment);
 }
-
-