1
0
Fork 0

DBG+BRIDGE+GUI: fixed various issues (thanks to Coverity!)

This commit is contained in:
mrexodia 2016-06-23 00:20:02 +02:00
parent c7ed20da1f
commit 89017073a6
No known key found for this signature in database
GPG Key ID: D72F9A4FAA0073B4
10 changed files with 23 additions and 7 deletions

View File

@ -249,11 +249,13 @@ BRIDGE_IMPEXP int BridgeGetDbgVersion()
BRIDGE_IMPEXP bool DbgMemRead(duint va, unsigned char* dest, duint size)
{
#ifdef _DEBUG
if(IsBadWritePtr(dest, size))
{
GuiAddLogMessage("DbgMemRead with invalid boundaries!\n");
return false;
}
#endif //_DEBUG
if(!_dbg_memread(va, dest, size, 0))
{
@ -267,11 +269,13 @@ BRIDGE_IMPEXP bool DbgMemRead(duint va, unsigned char* dest, duint size)
BRIDGE_IMPEXP bool DbgMemWrite(duint va, const unsigned char* src, duint size)
{
#ifdef _DEBUG
if(IsBadReadPtr(src, size))
{
GuiAddLogMessage("DbgMemWrite with invalid boundaries!\n");
return false;
}
#endif //_DEBUG
return _dbg_memwrite(va, src, size, 0);
}

View File

@ -217,7 +217,7 @@ bool DirExists(const char* dir)
bool GetFileNameFromHandle(HANDLE hFile, char* szFileName)
{
wchar_t wszFileName[MAX_PATH] = L"";
if(!PathFromFileHandleW(hFile, wszFileName, sizeof(wszFileName)))
if(!PathFromFileHandleW(hFile, wszFileName, _countof(wszFileName)))
return false;
strcpy_s(szFileName, MAX_PATH, StringUtils::Utf16ToUtf8(wszFileName).c_str());
return true;

View File

@ -14,6 +14,11 @@ AdvancedAnalysis::AdvancedAnalysis(duint base, duint size, bool dump)
memset(mEncMap, 0, size);
}
AdvancedAnalysis::~AdvancedAnalysis()
{
delete[] mEncMap;
}
void AdvancedAnalysis::Analyse()
{
linearXrefPass();

View File

@ -6,6 +6,7 @@ class AdvancedAnalysis : public Analysis
{
public:
explicit AdvancedAnalysis(duint base, duint size, bool dump = false);
~AdvancedAnalysis();
void Analyse() override;
void SetMarkers() override;

View File

@ -107,7 +107,7 @@ bool ModLoad(duint Base, duint Size, const char* FullPath)
// Determine whether the module is located in system
wchar_t sysdir[MAX_PATH];
GetEnvironmentVariableW(L"windir", sysdir, sizeof(sysdir));
GetEnvironmentVariableW(L"windir", sysdir, _countof(sysdir));
String Utf8Sysdir = StringUtils::Utf16ToUtf8(sysdir);
Utf8Sysdir.append("\\");
if(_memicmp(Utf8Sysdir.c_str(), FullPath, Utf8Sysdir.size()) == 0)

View File

@ -146,7 +146,6 @@ void PatchDelRange(duint Start, duint End, bool Restore)
bool PatchEnum(PATCHINFO* List, size_t* Size)
{
ASSERT_DEBUGGING("Export call");
if(!DbgIsDebugging())
return false;
ASSERT_FALSE(!List && !Size);

View File

@ -393,7 +393,7 @@ QString Disassembly::paintContent(QPainter* painter, dsint rowBase, int rowOffse
{
indicator = "$";
}
else if(funcType != FUNC_NONE)
else if(funcType != Function_none)
{
indicator = ".";
}
@ -1292,6 +1292,9 @@ Instruction_t Disassembly::DisassembleAt(dsint rva)
wMaxByteCountToRead += mCodeFoldingManager->getFoldedSize(rvaToVa(rva), rvaToVa(rva + wMaxByteCountToRead));
wBuffer.resize(wMaxByteCountToRead);
if(!wMaxByteCountToRead)
wMaxByteCountToRead = 1;
mMemPage->read(reinterpret_cast<byte_t*>(wBuffer.data()), rva, wMaxByteCountToRead);
return mDisasm->DisassembleAt(reinterpret_cast<byte_t*>(wBuffer.data()), wMaxByteCountToRead, 0, base, rva, mTmpCodeCount, mTmpCodeList);

View File

@ -695,7 +695,7 @@ void CPUSideBar::AllocateJumpOffsets(std::vector<JumpLine> & jumpLines)
numLines[j] = jmp.jumpOffset;
}
}
delete numLines;
delete[] numLines;
}
int CPUSideBar::isFoldingGraphicsPresent(int line)

View File

@ -144,6 +144,8 @@ MainWindow::MainWindow(QWidget* parent)
// Snowman view (decompiler)
mSnowmanView = CreateSnowman(this);
if(!mSnowmanView)
mSnowmanView = (SnowmanView*)new QLabel("<center>Snowman is disabled...</center>", this);
mSnowmanView->setWindowTitle(tr("Snowman"));
mSnowmanView->setWindowIcon(QIcon(":/icons/images/snowman.png"));

View File

@ -16,8 +16,10 @@ XrefBrowseDialog::XrefBrowseDialog(QWidget* parent, duint address) :
setWindowTitle(QString(tr("xrefs at %1")).arg(ToHexString(address)));
for(duint i = 0; i < mXrefInfo.refcount; i++)
{
GuiGetDisassembly(mXrefInfo.references[i].addr, disasm);
ui->listWidget->addItem(disasm);
if(GuiGetDisassembly(mXrefInfo.references[i].addr, disasm))
ui->listWidget->addItem(disasm);
else
ui->listWidget->addItem("???");
}
mPrevSelectionSize = 0;
ui->listWidget->setCurrentRow(0);