From 7705e88b57111156cb552a254abd926ca2be76a9 Mon Sep 17 00:00:00 2001 From: Liam Date: Sun, 28 Dec 2008 23:45:18 -0500 Subject: [PATCH] Prevented blank/empty admins from being created. (Bug 3431 r=dvander) --- core/AdminCache.cpp | 5 +++++ plugins/admin-flatfile/admin-simple.sp | 3 ++- plugins/admin-flatfile/admin-users.sp | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/core/AdminCache.cpp b/core/AdminCache.cpp index 2dfd5fc3..af3470c9 100644 --- a/core/AdminCache.cpp +++ b/core/AdminCache.cpp @@ -1170,6 +1170,11 @@ bool AdminCache::GetMethodIndex(const char *name, unsigned int *_index) bool AdminCache::BindAdminIdentity(AdminId id, const char *auth, const char *ident) { + if (ident == NULL || ident[0] == '\0') + { + return false; + } + AdminUser *pUser = (AdminUser *)m_pMemory->GetAddress(id); if (!pUser || pUser->magic != USR_MAGIC_SET) { diff --git a/plugins/admin-flatfile/admin-simple.sp b/plugins/admin-flatfile/admin-simple.sp index fbf89803..507a41d7 100644 --- a/plugins/admin-flatfile/admin-simple.sp +++ b/plugins/admin-flatfile/admin-simple.sp @@ -216,7 +216,8 @@ ReadAdminLine(const String:line[]) if (!BindAdminIdentity(admin, auth_method, auth[auth_offset])) { /* We should never reach here */ - ParseError("Failed to bind identity %s (method %s)", auth[auth_offset], auth_method); + RemoveAdmin(admin); + ParseError("Failed to bind identity %s (method %s)", auth[auth_offset], auth_method); } } } diff --git a/plugins/admin-flatfile/admin-users.sp b/plugins/admin-flatfile/admin-users.sp index 923ef186..c8c978e5 100644 --- a/plugins/admin-flatfile/admin-users.sp +++ b/plugins/admin-flatfile/admin-users.sp @@ -162,7 +162,9 @@ public SMCResult:ReadUsers_EndSection(Handle:smc) id = CreateAdmin(g_CurName); if (!BindAdminIdentity(id, g_CurAuth, g_CurIdent)) { + RemoveAdmin(id); ParseError("Failed to bind auth \"%s\" to identity \"%s\"", g_CurAuth, g_CurIdent); + return SMCParse_Continue; } }