From f8d49ca9dfebf179382b1ddc3a47d503d719be11 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sun, 20 Feb 2011 09:45:40 +0800 Subject: [PATCH] Committing local changes --- src/server/server.c | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/src/server/server.c b/src/server/server.c index 04f1c39..9691b69 100644 --- a/src/server/server.c +++ b/src/server/server.c @@ -186,11 +186,12 @@ void Server_Start(void) switch( ntohl( client_addr.sin_addr.s_addr ) ) { case 0x7F000001: // 127.0.0.1 localhost - // case 0x825E0D00: // 130.95.13.0 - case 0x825E0D07: // 130.95.13.7 motsugo - case 0x825E0D11: // 130.95.13.17 mermaid - case 0x825E0D12: // 130.95.13.18 mussel - case 0x825E0D17: // 130.95.13.23 martello + // case 0x825F0D00: // 130.95.13.0 + case 0x825F0D07: // 130.95.13.7 motsugo + case 0x825F0D11: // 130.95.13.17 mermaid + case 0x825F0D12: // 130.95.13.18 mussel + case 0x825F0D17: // 130.95.13.23 martello + case 0x825F0D42: // 130.95.13.66 heathred bTrusted = 1; break; default: @@ -303,6 +304,7 @@ void Server_ParseClientCommand(tClient *Client, char *CommandString) if( Server_int_ParseArgs(1, CommandString, &command, &args, NULL) ) { + printf("command=%s, args=%s\n", command, args); // Is this an error? (just ignore for now) args = ""; } @@ -332,7 +334,11 @@ void Server_Cmd_USER(tClient *Client, char *Args) { char *username; - Server_int_ParseArgs(0, Args, &username, NULL); + if( Server_int_ParseArgs(0, Args, &username, NULL) ) + { + sendf(Client->Socket, "407 USER takes 1 argument\n"); + return ; + } // Debug! if( giDebugLevel ) @@ -371,7 +377,11 @@ void Server_Cmd_PASS(tClient *Client, char *Args) { char *passhash; - Server_int_ParseArgs(0, Args, &passhash, NULL); + if( Server_int_ParseArgs(0, Args, &passhash, NULL) ) + { + sendf(Client->Socket, "407 PASS takes 1 argument\n"); + return ; + } // Pass on to cokebank Client->UID = Bank_GetUserAuth(Client->Salt, Client->Username, passhash); @@ -394,7 +404,11 @@ void Server_Cmd_AUTOAUTH(tClient *Client, char *Args) { char *username; - Server_int_ParseArgs(0, Args, &username, NULL); + if( Server_int_ParseArgs(0, Args, &username, NULL) ) + { + sendf(Client->Socket, "407 AUTOAUTH takes 1 argument\n"); + return ; + } // Check if trusted if( !Client->bIsTrusted ) { @@ -435,7 +449,11 @@ void Server_Cmd_SETEUSER(tClient *Client, char *Args) { char *username; - Server_int_ParseArgs(0, Args, &username, NULL); + if( Server_int_ParseArgs(0, Args, &username, NULL) ) + { + sendf(Client->Socket, "407 SETEUSER takes 1 argument\n"); + return ; + } if( !strlen(Args) ) { sendf(Client->Socket, "407 SETEUSER expects an argument\n"); @@ -1166,9 +1184,12 @@ int Server_int_ParseArgs(int bUseLongLast, char *ArgStr, ...) char savedChar = *ArgStr; char **dest; va_start(args, ArgStr); + + printf("Server_int_ParseArgs: ArgStr = '%s'\n", ArgStr); while( (dest = va_arg(args, char **)) ) { + printf(" dest = %p\n", dest); // Trim leading spaces while( *ArgStr == ' ' || *ArgStr == '\t' ) ArgStr ++; @@ -1200,6 +1221,7 @@ int Server_int_ParseArgs(int bUseLongLast, char *ArgStr, ...) } savedChar = *ArgStr; // savedChar is used to un-mangle the last string *ArgStr = '\0'; + ArgStr ++; } // Oops, extra arguments, and greedy not set @@ -1207,8 +1229,10 @@ int Server_int_ParseArgs(int bUseLongLast, char *ArgStr, ...) return -1; // Un-mangle last - if(bUseLongLast) + if(bUseLongLast) { + ArgStr --; *ArgStr = savedChar; + } va_end(args); -- 2.20.1