about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ngircd/irc-login.c40
-rw-r--r--src/ngircd/ngircd.c2
-rwxr-xr-xsrc/testsuite/getpid.sh2
3 files changed, 25 insertions, 19 deletions
diff --git a/src/ngircd/irc-login.c b/src/ngircd/irc-login.c
index c90a7c1c..edaefd61 100644
--- a/src/ngircd/irc-login.c
+++ b/src/ngircd/irc-login.c
@@ -653,32 +653,37 @@ IRC_QUIT( CLIENT *Client, REQUEST *Req )
 	CLIENT *target;
 	char quitmsg[LINE_LEN];
 
-	assert( Client != NULL );
-	assert( Req != NULL );
+	assert(Client != NULL);
+	assert(Req != NULL);
 
 	/* Wrong number of arguments? */
-	if( Req->argc > 1 )
-		return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
+	if (Req->argc > 1)
+		return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
+					  Client_ID(Client), Req->command);
 
 	if (Req->argc == 1)
 		strlcpy(quitmsg, Req->argv[0], sizeof quitmsg);
 
-	if ( Client_Type( Client ) == CLIENT_SERVER )
-	{
+	if (Client_Type(Client) == CLIENT_SERVER) {
 		/* Server */
-		target = Client_Search( Req->prefix );
-		if( ! target )
-		{
-			Log( LOG_WARNING, "Got QUIT from %s for unknown client!?", Client_ID( Client ));
+		target = Client_Search(Req->prefix);
+		if (!target) {
+			Log(LOG_WARNING,
+			    "Got QUIT from %s for unknown client!?",
+			    Client_ID(Client));
 			return CONNECTED;
 		}
 
-		Client_Destroy( target, "Got QUIT command.", Req->argc == 1 ? quitmsg : NULL, true);
-
-		return CONNECTED;
-	}
-	else
-	{
+		if (target != Client) {
+			Client_Destroy(target, "Got QUIT command.",
+				       Req->argc == 1 ? quitmsg : NULL, true);
+			return CONNECTED;
+		} else {
+			Conn_Close(Client_Conn(Client), "Got QUIT command.",
+				   Req->argc == 1 ? quitmsg : NULL, true);
+			return DISCONNECTED;
+		}
+	} else {
 		if (Req->argc == 1 && quitmsg[0] != '\"') {
 			/* " " to avoid confusion */
 			strlcpy(quitmsg, "\"", sizeof quitmsg);
@@ -687,7 +692,8 @@ IRC_QUIT( CLIENT *Client, REQUEST *Req )
 		}
 
 		/* User, Service, or not yet registered */
-		Conn_Close( Client_Conn( Client ), "Got QUIT command.", Req->argc == 1 ? quitmsg : NULL, true);
+		Conn_Close(Client_Conn(Client), "Got QUIT command.",
+			   Req->argc == 1 ? quitmsg : NULL, true);
 
 		return DISCONNECTED;
 	}
diff --git a/src/ngircd/ngircd.c b/src/ngircd/ngircd.c
index 500d1288..2135ec4d 100644
--- a/src/ngircd/ngircd.c
+++ b/src/ngircd/ngircd.c
@@ -593,7 +593,7 @@ Random_Init(void)
 		return;
 	if (Random_Init_Kern("/dev/arandom"))
 		return;
-	srand(rand() ^ getpid() ^ time(NULL));
+	srand(rand() ^ (unsigned)getpid() ^ (unsigned)time(NULL));
 }
 
 
diff --git a/src/testsuite/getpid.sh b/src/testsuite/getpid.sh
index 5e169175..fd3b3422 100755
--- a/src/testsuite/getpid.sh
+++ b/src/testsuite/getpid.sh
@@ -16,7 +16,7 @@ elif [ $UNAME = "GNU" ]; then
 elif [ $UNAME = "SunOS" ]; then
   PS_FLAGS="-af"; PS_PIDCOL=2; HEAD_FLAGS="-n 1"
 else
-  PS_FLAGS="-f"; PS_PIDCOL="2"; HEAD_FLAGS="-n 1"
+  PS_FLAGS="-af"; PS_PIDCOL="2"; HEAD_FLAGS="-n 1"
   ps $PS_FLAGS > /dev/null 2>&1
   if [ $? -ne 0 ]; then PS_FLAGS="a"; PS_PIDCOL="1"; fi
 fi