mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 19:42:36 +02:00
Escape XML chars for file, exe, and guid strings
This commit is contained in:
parent
fb5ab7569d
commit
19fb47a909
2 changed files with 10 additions and 5 deletions
|
@ -313,6 +313,7 @@ void dumpFunctionLines( IDiaSymbol& symbol, IDiaSession& session )
|
|||
|
||||
bstr_t sourceFileName;
|
||||
pSrc->get_fileName(sourceFileName.GetAddress());
|
||||
std::wstring wsSourceFileName(sourceFileName.GetBSTR(), SysStringLen(sourceFileName));
|
||||
|
||||
DWORD addr = 0;
|
||||
pLine->get_relativeVirtualAddress( &addr );
|
||||
|
@ -323,7 +324,7 @@ void dumpFunctionLines( IDiaSymbol& symbol, IDiaSession& session )
|
|||
pLine->get_lineNumberEnd( &end );
|
||||
|
||||
printf("%S<line_number source_file=\"%ws\" start=\"%d\" end=\"%d\" addr=\"0x%x\" /> \n",
|
||||
indent(12).c_str(), escapeXmlEntities(sourceFileName.GetBSTR()).data(), start, end, addr);
|
||||
indent(12).c_str(), escapeXmlEntities(wsSourceFileName).c_str(), start, end, addr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -400,7 +401,8 @@ void iterateSourceFiles(IDiaEnumSourceFiles * pSourceFiles) {
|
|||
bstr_t name;
|
||||
DWORD id = 0;
|
||||
if( (pSourceFile->get_fileName( name.GetAddress() ) == S_OK) && (pSourceFile->get_uniqueId( &id ) == S_OK) ) {
|
||||
printf("%S<source_file name=\"%ws\" id=\"0x%x\" /> \n", indent(12).c_str(), escapeXmlEntities(name.GetBSTR()).data(), id);
|
||||
std::wstring wsName(name.GetBSTR(), SysStringLen(name));
|
||||
printf("%S<source_file name=\"%ws\" id=\"0x%x\" /> \n", indent(12).c_str(), escapeXmlEntities(wsName).c_str(), id);
|
||||
}
|
||||
pSourceFile = NULL;
|
||||
}
|
||||
|
@ -490,9 +492,11 @@ void iterateInjectedSource(IDiaEnumInjectedSources * pInjectedSrcs) {
|
|||
|
||||
bstr_t filename;
|
||||
pInjectedSrc->get_filename(filename.GetAddress());
|
||||
std::wstring wsFileName(filename.GetBSTR(), SysStringLen(filename));
|
||||
|
||||
bstr_t objectname;
|
||||
pInjectedSrc->get_objectFilename(objectname.GetAddress());
|
||||
std::wstring wsObjectname(objectname.GetBSTR(), SysStringLen(objectname));
|
||||
|
||||
DWORD crc;
|
||||
pInjectedSrc->get_crc(&crc);
|
||||
|
@ -502,8 +506,8 @@ void iterateInjectedSource(IDiaEnumInjectedSources * pInjectedSrcs) {
|
|||
|
||||
printf("%S<injected_source filename=\"%ws\" objectname=\"%ws\" crc=\"0x%x\" length=\"0x%I64x\" />\n",
|
||||
indent(8).c_str(),
|
||||
filename.GetBSTR(),
|
||||
objectname.GetBSTR(),
|
||||
escapeXmlEntities(wsFileName).c_str(),
|
||||
escapeXmlEntities(wsObjectname).c_str(),
|
||||
crc,
|
||||
length);
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "find.h"
|
||||
#include "print.h"
|
||||
#include "symbol.h"
|
||||
#include "xml.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
PDBApiContext::PDBApiContext(const std::wstring& szFilename, const std::wstring& szSignature, const std::wstring& szAge)
|
||||
|
@ -112,7 +113,7 @@ int PDBApiContext::init(const std::wstring& szFilename, const std::wstring& szSi
|
|||
fatal("Unable to get GUID\n");
|
||||
}
|
||||
|
||||
printf("<pdb file=\"%S\" exe=\"%S\" guid=\"%S\" age=\"%ld\">\n", szFilename.c_str(), exename.c_str(), guidStr.c_str(), currAge);
|
||||
printf("<pdb file=\"%S\" exe=\"%S\" guid=\"%S\" age=\"%ld\">\n", escapeXmlEntities(szFilename).c_str(), escapeXmlEntities(exename).c_str(), escapeXmlEntities(guidStr).c_str(), currAge);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue