Skip to content

Commit

Permalink
recover: Work around use-after-free
Browse files Browse the repository at this point in the history
Inode::_FindPath() always deletes the inode it uses regardless
the source, including when it's from the HashtableInodeSource.

But the later returned the inode object directly from the hashtable
when it's inside, so it gets deleted bu _FindPath… then reused later on
when searching the hashtable again.

I'm not sure it's the correct solution but at least malloc_debug doesn't
complain anymore.
  • Loading branch information
mmuman committed Mar 27, 2018
1 parent b45e8b1 commit 4498948
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/bin/bfs_tools/recover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,10 @@ class HashtableInodeSource : public Inode::Source {
{
Inode *inode;
if ((inode = gLogged.Get(run)) != NULL)
return inode;
return Inode::Factory(&fDisk, inode, false);

if ((inode = gMissing.Get(run)) != NULL)
return inode;
return Inode::Factory(&fDisk, inode, false);

if (gMainInodes.find(run) == gMainInodes.end())
return NULL;
Expand Down

0 comments on commit 4498948

Please sign in to comment.