HomePortalFAQSearchMemberlistUsergroupsRegisterLog in
Making threads to link to banned members content grants an automatic ban
Meet the new KITO admins & hear their plans here.
You can use google search to find threads and posts here now. Example

Share | 
 

 Fix(?): Loginserver crash, banlist corruption/clearing

View previous topic View next topic Go down 
AuthorMessage
Myz
Coder
Coder


Server : Last Moon(http://lastmoon.org), Dawn of Eternity(http://dawn-of-eternity.com)
Posts : 150
Join date : 2012-11-18

PostSubject: Fix(?): Loginserver crash, banlist corruption/clearing   Sun Feb 10, 2013 9:14 pm

I'm not sure if this is an actual fix since the bansystem is a fucking mess and I have no idea what it's really supposed to be doing, I'm probably going to remake the whole thing later.

The problem:
The loginserver will crash, corrupt/clear the banlist data every 4 hours(or whatever your MAINTENANCE_PERIOD is set to) or whenever the server tries to save the banlist. It's because of some overflow going on in the saveBanList().
Code:

char tYear[6] = "";
char tDay[6] = "";
sin << banlist[i].year;
std::string val = sin.str();
strcpy(tYear,val.c_str());
sin << banlist[i].yDay;
val = sin.str();
strcpy(tDay,val.c_str());
I guess the problems start occurring when you ban people for long period of times? I can't be bothered to test it because I can't even be bothered to figure out what year and yDay means.

The fix:
Haven't done any real testing, I've just changed the code to do what I think it's supposed to be doing and it has stopped the problems for me so far.

Replace your saveBanlist() method in MagixMainServer.cpp with this one:
Code:

    void saveBanlist()
    {
      std::ofstream outFile("banlist.txt");
      string tBuffer;
      for(int i = 0; i < (int)banlist.size(); i++)
      {
         std::ostringstream ssYear, ssDay;
                         
         tBuffer = string(banlist[i].name);

         tBuffer.append(";");
                         
         // Add year????
         ssYear << banlist[i].year;
         tBuffer.append(ssYear.str());
         tBuffer.append(";");
                         
         // Add day???
         ssDay << banlist[i].yDay;
         tBuffer.append(ssDay.str());
         tBuffer.append("|");
                           
         outFile.write(tBuffer.c_str(), tBuffer.length());
         for(int j = 0; j < (int)banlist[i].IPList.size(); j++)
         {
            tBuffer = banlist[i].IPList[j] + ";";
            outFile.write(tBuffer.c_str(),tBuffer.length());
         }
         tBuffer = "\n";
         outFile.write(tBuffer.c_str(),tBuffer.length());
      }
      outFile.close();
    }
Back to top Go down
RedEye
Retired
avatar

Game username : -redeye-
Server : KITO
Male Posts : 2575
Join date : 2011-07-24
Age : 30

PostSubject: Re: Fix(?): Loginserver crash, banlist corruption/clearing   Sun Feb 10, 2013 9:27 pm

There was reported an error in saving bans, so this will probably fix the issue

________________________________
Retired
Back to top Go down
lazyzim

™
avatar

Server : Dragon's Den
Male Posts : 740
Join date : 2011-11-27

PostSubject: Re: Fix(?): Loginserver crash, banlist corruption/clearing   Mon Feb 11, 2013 3:51 am

Thank you Myz for the code update.
I have added it to my compile and will advise of any issues.
I am currently testing with this alteration

Hope this fixes your Loginserver issues.

~Lazyzim~

Just a 24 hour update. The login Server at Dragon's Den appears to be working fine with this fix.
Thanks again Myz. ~Lazyzim~
Back to top Go down
Revaen
Very Helpful
Very Helpful


Male Posts : 314
Join date : 2013-07-21
Age : 16

PostSubject: Re: Fix(?): Loginserver crash, banlist corruption/clearing   Mon Jan 20, 2014 11:30 pm

Great work.
Thanks for this repair.
-Pandemonium
Back to top Go down
 
Fix(?): Loginserver crash, banlist corruption/clearing
View previous topic View next topic Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
Keeping I.T. Open :: START HERE :: KITO's IT Source Code :: Bugs & Patches-
Jump to: