Fixed a bug in GetIdbPath() when working in an IDA instance that has dealt with more than one IDB.

idaapi.cvar.database_idb seems to point to a realloc'ed buffer. When IDA is working on an IDB stored in a directory with a long path and a second IDB with a shorter path is loaded, the buffer will be overwritten with the new path to the IDB, which will end in "\x00" and the leftovers of the older, longer path will follow.
The problem with GetIdbPath() is that it returns the whole bufer, NULL and "leftovers" included, which leads to trouble in Python. Specifically some functions like os.path.splitext which will look for the extension starting from the end of the buffer and will return an invalid split.
The patch simply post-processes the contents of idaapi.cvar.database_idb returning a Python string with all characters up to the "\x00"
This commit is contained in:
ero.carrera@gmail.com 2010-09-23 18:57:37 +00:00
parent 80896bc1d9
commit faf5063818

View File

@ -1635,7 +1635,8 @@ def GetIdbPath():
This function returns full path of the current IDB database This function returns full path of the current IDB database
""" """
return idaapi.cvar.database_idb idb_path = idaapi.cvar.database_idb + '\x00'
return idb_path[ : idb_path.find('\x00') ]
def GetInputMD5(): def GetInputMD5():