fixed crash in cmd_NeonServ.mod/cmd_neonserv_mode.c
authorpk910 <philipp@zoelle1.de>
Thu, 4 Apr 2013 21:20:53 +0000 (23:20 +0200)
committerpk910 <philipp@zoelle1.de>
Thu, 4 Apr 2013 21:23:23 +0000 (23:23 +0200)
src/modules/NeonServ.mod/cmd_neonserv_mode.c

index a1a9125..d153ffa 100644 (file)
@@ -92,6 +92,7 @@ static void neonserv_cmd_mode_async1(struct ClientSocket *client, struct ClientS
     arg = 0;
     while(arg < argc) {
         char *modeStr = argv[arg++];
+        char modeStrBuf[3];
         for(i = 0; i < strlen(modeStr); i++) {
             switch(modeStr[i]) {
                 case '+':
@@ -103,7 +104,8 @@ static void neonserv_cmd_mode_async1(struct ClientSocket *client, struct ClientS
                 case 'o':
                 case 'v':
                     if(arg == argc) {
-                        reply(textclient, user, "NS_MODE_INVALID", modeStr[i]);
+                        sprintf(modeStrBuf, "%c%c", (add ? '+' : '-'), modeStr[i]);
+                        reply(textclient, user, "NS_MODE_INVALID", modeStrBuf);
                         return;
                     }
                     carg = argv[arg++];
@@ -152,7 +154,8 @@ static void neonserv_cmd_mode_async1(struct ClientSocket *client, struct ClientS
                     break;
                 case 'b':
                     if(arg == argc) {
-                        reply(textclient, user, "NS_MODE_INVALID", modeStr[i]);
+                        sprintf(modeStrBuf, "%c%c", (add ? '+' : '-'), modeStr[i]);
+                        reply(textclient, user, "NS_MODE_INVALID", modeStrBuf);
                         return;
                     }
                     carg = argv[arg++];
@@ -206,7 +209,8 @@ static void neonserv_cmd_mode_async1(struct ClientSocket *client, struct ClientS
                 default:
                     modetype = getModeType(modelock, modeStr[i]);
                     if(modetype == 0) {
-                        reply(textclient, user, "NS_MODE_INVALID", modeStr);
+                        sprintf(modeStrBuf, "%c%c", (add ? '+' : '-'), modeStr[i]);
+                        reply(textclient, user, "NS_MODE_INVALID", modeStrBuf);
                         return;
                     }
                     if(isModeAffected(modelock, modeStr[i]) && add == !isModeSet(modelock, modeStr[i]) && uaccess < db_enfmodes) {