Entering non-existant RoomID in Exits dialog causes segfault

All and any discussion and development of the Mudlet Mapper.
Post Reply
User avatar
SlySven
Posts: 987
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Entering non-existant RoomID in Exits dialog causes segfault

Post by SlySven »

This is using the latest (2.1) git repository code, as far as I can see the code in the dlgRoomExits::save() function in dlgRoomExits.cpp only checks that the text entered for the room number for each exit is non-zero in length before turning it into an integer to use as the RoomID that the exit goes to. I do not see it checking that the entered value actually exists and I think this is causing me getting a terminal segmentation fault as soon as anything touches the map after the exits dialogue box closes.

Would it be a fix to change the code for each exit in that function from:

Code: Select all

    if( {exit number edit box on exit dialogue}->text().size() > 0 )
        mpHost->mpMap->rooms[mRoomID]->{exit} = {exit number edit box on exit dialogue}->text().toInt();
    else
        mpHost->mpMap->rooms[mRoomID]->{exit} = -1;
to

Code: Select all

    if( {exit number edit box on exit dialogue}->text().size() > 0 )
    {
    	if( mpHost->mpMap->rooms.contains(  {exit number edit box on exit dialogue}->text().toInt() ) )
    	    mpHost->mpMap->rooms[mRoomID]->{exit} = {exit number edit box on exit dialogue}->text().toInt();    
    	else
	    mpHost->mpMap->rooms[mRoomID]->{exit} = -1;    	
    }
    else
        mpHost->mpMap->rooms[mRoomID]->{exit} = -1;
Where {exit number edit box on exit dialogue} is the QLineEdit boxes called "n", "ne", .."out" on the dialogue box, and {exit} is "north", "northeast", .."out" the exits for the Room under consideration.

I would point out that this type of situation is most likely to occur from a typo when entering in an Exit number, resulting say in a repeated digit taking the resulting value outside of the range of existing rooms so it is not a totally unlikely event to happen and the consequences are significant enough, I feel, to require attention.

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: Entering non-existant RoomID in Exits dialog causes segf

Post by Heiko »

Thx. I'll put this on my todo list with high priority.

PS: Welcome to Mudlet development!

User avatar
chris
Posts: 493
Joined: Fri Jun 17, 2011 5:39 am

Re: Entering non-existant RoomID in Exits dialog causes segf

Post by chris »

You should start a fork and get on launchpad.

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: Entering non-existant RoomID in Exits dialog causes segf

Post by Heiko »

This issue has been fixed.

To take part in active development, clone the official Mudlet rep with:
git clone git://mudlet.git.sourceforge.net/gitroot/mudlet/mudlet
and set up your own dev repo at github or gitorious and get a bug tracker account https://bugs.launchpad.net/mudlet

User avatar
SlySven
Posts: 987
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: Entering non-existant RoomID in Exits dialog causes segf

Post by SlySven »

chris wrote:You should start a fork and get on launchpad.
OK I'll look to do that, I've already started to hack around with the exits dialogue box already, trying to add control for stub exits there! ;) Trouble is C++ is not my thing so I'm having to mangle some of what I know for C :lol: also I'm having to split my attention with TinTin++, but if I can help to allow them to interoperate with each other so much the better (understanding each others mapping systems/formats if possible & getting a working MMCP system for Mudlet are primary goals).

User avatar
SlySven
Posts: 987
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: Entering non-existant RoomID in Exits dialog causes segf

Post by SlySven »

Eeek, Heiko your revision 658 doesn't fix the issue!

If you look closely my proposal above includes checking the integers generated from the entered RoomID strings for each exit are in mpHost->mpMap->rooms.contains( ) set to validate them... :o

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: Entering non-existant RoomID in Exits dialog causes segf

Post by Heiko »

Yes, I've overlooked that there's no more auditExit() call as there used to be in earlier versions. toInt() returns 0 if the conversion fails. rooms.contains(0) is always true, but 0 is an illegal room ID by definition. Ergo, we'd need both checks for every exit. Anyways, things are going to change fundamentally now..

It's high time that I restructure the mapper backend. The current impromptu makeshift setup has stayed for so long because I was too lazy to clean it up properly but I have to do this now because the danger of accidentally corrupting the map db is too high the more features and functions get added. The mapper core will change fundamentally in my next commit.

Post Reply