From 0633108e742e43866a67391cdd79d527e9fe30dd Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Fri, 28 Dec 2007 10:01:35 +0000 Subject: [PATCH] Fix the sqlite3 addition: Newly registered nicks shouldn't interfere with already registered ones. git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@377 db0b04b0-f4d1-0310-9a6d-de3e77497b0e --- dgamelaunch.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dgamelaunch.c b/dgamelaunch.c index 7b34c6f..3c017e7 100644 --- a/dgamelaunch.c +++ b/dgamelaunch.c @@ -1327,7 +1327,11 @@ userexist (char *cname, int isnew) char tmpbuf[32]; strncpy(tmpbuf, cname, (isnew ? globalconfig.max_newnick_len : 20)); - qbuf = sqlite3_mprintf("select * from dglusers where username='%q' limit 1", tmpbuf); + /* Check that the nick doesn't interfere with already registered nicks */ + if (isnew && (strlen(cname) >= globalconfig.max_newnick_len)) + strcat(tmpbuf, "%"); + + qbuf = sqlite3_mprintf("select * from dglusers where username like '%q' limit 1", tmpbuf); ret = sqlite3_open(DGL_SQLITE_DB, &db); /* FIXME: use globalconfig->passwd? */ if (ret) {