wm: ircd

Download patch

ref: 99243e943d21dfb244ccd2e6653f7091e8482f09
parent: e296dd80a20b44b2f91b4cbc39fed36b7532c403
author: mkf <mkf@cloud9p.org>
date: Wed Sep 27 11:53:42 EDT 2023

fix some double-frees in pass

--- a/ircd.c
+++ b/ircd.c
@@ -550,14 +550,12 @@
 setprefix(Client *c)
 {
 	/* fatal */
-	if(password != nil && !c->passok){
-		delclient(c);
-		return 1;
-	}
+	if(password != nil && !c->passok)
+		return 0;
 
 	/* not fatal */
 	if(c->user == nil || c->nick == nil)
-		return 0;
+		return 1;
 
 	if(c->prefix != nil)
 		free(c->prefix);
@@ -565,7 +563,7 @@
 	c->prefix = smprint("%s!~%s@%s", c->nick, c->user, c->conninfo->rsys);
 	if(c->prefix == nil)
 		sysfatal("setprefix: smprint: %r");
-	return 0;
+	return 1;
 }
 
 /* allowed chars: [0-9A-Za-z_] */
@@ -621,7 +619,7 @@
 	qlock(&clock);
 	c->user = estrdup(user);
 	
-	if(setprefix(c))
+	if(!setprefix(c))
 		return 0;
 
 	qunlock(&clock);
@@ -1041,14 +1039,13 @@
 	if(password == nil)
 		return 1;
 
-	if(c->passok){
-		close(c->fd);
+	if(c->passok)
 		return 0;
-	}else{
+	else{
 		if(strcmp(p, password) != 0){
 			r.code = ERR_PASSWDMISMATCH;
 			reply(c, &r);
-			delclient(c);
+			return 0;
 		}else
 			c->passok = 1;
 	}