Skip to content

Ghidra is a software reverse engineering (SRE) framework

Escape overlay address space names

caheckman8be023ada956
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/op.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/op.cc
index d80da176cd..af89c583ac 100644
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/op.cc
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/op.cc
@@ -415,8 +415,9 @@ void PcodeOp::saveXml(ostream &s) const
else if (vn->getSpace()->getType()==IPTR_CONSTANT) {
if ((i==0)&&((code()==CPUI_STORE)||(code()==CPUI_LOAD))) {
AddrSpace *spc = Address::getSpaceFromConst(vn->getAddr());
- s << "<spaceid name=\"";
- s << spc->getName() << "\"/>\n";
+ s << "<spaceid";
+ a_v(s,"name",spc->getName());
+ s << "/>\n";
}
else
s << "<addr ref=\"0x" << hex << vn->getCreateIndex() << "\"/>\n";
diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/prettyprint.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/prettyprint.cc
index 4b687b53f1..fac4c0ca13 100644
--- a/Ghidra/Features/Decompiler/src/decompile/cpp/prettyprint.cc
+++ b/Ghidra/Features/Decompiler/src/decompile/cpp/prettyprint.cc
@@ -259,8 +259,9 @@ void EmitXml::tagField(const char *ptr,syntax_highlight hl,const Datatype *ct,in
void EmitXml::tagComment(const char *ptr,syntax_highlight hl,
const AddrSpace *spc,uintb off) {
*s << "<comment " << highlight[(int4)hl];
- *s << " space=\"" << spc->getName();
- *s << "\" off=\"0x" << hex << off << "\">";
+ a_v(*s,"space",spc->getName());
+ a_v_u(*s,"off",off);
+ *s << '>';
xml_escape(*s,ptr);
*s << "</comment>";
}
@@ -276,8 +277,9 @@ void EmitXml::tagComment(const char *ptr,syntax_highlight hl,
void EmitXml::tagLabel(const char *ptr,syntax_highlight hl,
const AddrSpace *spc,uintb off) {
*s << "<label " << highlight[(int4)hl];
- *s << " space=\"" << spc->getName();
- *s << "\" off=\"0x" << hex << off << "\">";
+ a_v(*s,"space",spc->getName());
+ a_v_u(*s,"off",off);
+ *s << '>';
xml_escape(*s,ptr);
*s << "</label>";
}
diff --git a/Ghidra/Features/Decompiler/src/decompile/datatests/convert.xml b/Ghidra/Features/Decompiler/src/decompile/datatests/convert.xml
index 7c9823c426..467bd18f80 100644
--- a/Ghidra/Features/Decompiler/src/decompile/datatests/convert.xml
+++ b/Ghidra/Features/Decompiler/src/decompile/datatests/convert.xml
@@ -62,5 +62,5 @@ ffffffbfdff7ffffe811ffffffbf6100
<stringmatch name="Convert #14" min="1" max="1">recv_signed\(-0b1100110011001100\)</stringmatch>
<stringmatch name="Convert #15" min="1" max="1">recv_unsigned\(0b1110111011101110\)</stringmatch>
<stringmatch name="Convert #16" min="1" max="1">recv_unsigned\(0b11111111111111111111011111011111\)</stringmatch>
-<stringmatch name="Convert #17" min="1" max="1">recv_signed\('a'\)</stringmatch>
+<stringmatch name="Convert #17" min="1" max="1">recv_signed\(L'a'\)</stringmatch>
</decompilertest>
diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/plugin/processors/sleigh/SleighLanguage.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/plugin/processors/sleigh/SleighLanguage.java
index db679bc9be..9311adf11b 100644
--- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/plugin/processors/sleigh/SleighLanguage.java
+++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/plugin/processors/sleigh/SleighLanguage.java
@@ -1433,7 +1433,7 @@ public class SleighLanguage implements Language {
if ((element instanceof OverlayAddressSpace)) {
OverlayAddressSpace ospace = (OverlayAddressSpace) element;
resBuf.append("<space_overlay");
- SpecXmlUtils.encodeStringAttribute(resBuf, "name", ospace.getName());
+ SpecXmlUtils.xmlEscapeAttribute(resBuf, "name", ospace.getName());
SpecXmlUtils.encodeSignedIntegerAttribute(resBuf, "index", ospace.getUnique());
SpecXmlUtils.encodeStringAttribute(resBuf, "base",
ospace.getOverlayedSpace().getName());