Page MenuHomePhabricator

Crash in mbilog.cpp
Closed, ResolvedPublic

Description

From the mailing list:

I was trying to check out the new MITK. Unfortunately it crashes immediately (ExtApp as well as CoreApp) due to a bug in mpilog.cpp.
In line 517 std::size_t size = path.size() - 3 has an underflow if path.size() < 3 which causes an out-of-bounds index in line 518. This happens for me since I have got the string "." in the path vector. I am using the latest trunk version (rev 20708). Is there a fix/workaround? I have no idea what this function is supposed to do...

bool search2p2(char *a,char *b,bool optimize=true)
{

517 std::size_t size = path.size() - 3;

for(std::size_t r=0;r<size;r++)

518 if(path[r].compare(a)==0 && path[r+1].compare(b)==0)

    {
      pos = r+2;
      category = concat(simplify(path[pos]),simplify(path[path.size()-1]),optimize);
      return true;
    }
  return false;
}

Related Objects

Duplicates Merged Here
T3128: mbilog crashes

Event Timeline

Markus,

can you fix this?
Setting the type of size to int won't help, because then the for loop will be messed up if size is negative.

Also, some documentation would be helpful.

fixed in commit #20711

there was unsigned compares when it should have been signed compares,
(in the condition of the for-constructs of the search*p* methods)
now using int again instead of std::size_t,
but with static_cast<int>()s for fixing 64bit compiler warnings.

Merging "Utilities" component into "Other"