GP-7087: Improved the handling of JDOM attribute errors in the PE

LibraryLookupTable (Closes #6288)
This commit is contained in:
Ryan Kurtz
2026-07-21 15:30:12 -04:00
parent 052eaddf41
commit ebb5497940
3 changed files with 14 additions and 8 deletions

View File

@@ -94,7 +94,8 @@ public abstract class AbstractOrdinalSupportLoader extends AbstractLibrarySuppor
log.appendMsg("Created exports file: " + newExportsFile);
}
catch (IOException e) {
log.appendMsg("Unable to create exports file for " + libFsrl);
log.appendMsg(
"Unable to create exports file for %s: %s".formatted(libFsrl, e.getMessage()));
}
}
else {

View File

@@ -19,6 +19,9 @@ import java.io.File;
import java.io.IOException;
import java.util.*;
import org.jdom2.IllegalDataException;
import org.jdom2.IllegalNameException;
import generic.jar.ResourceFile;
import ghidra.app.util.bin.format.pe.ResourceDataDirectory;
import ghidra.app.util.importer.MessageLog;
@@ -173,7 +176,12 @@ public class LibraryLookupTable {
Msg.warn(LibraryLookupTable.class, "Can't write to installation directory");
}
else {
symTab.write(f, new File(program.getExecutablePath()), version);
try {
symTab.write(f, new File(program.getExecutablePath()), version);
}
catch (IllegalNameException | IllegalDataException e) {
throw new IOException(e);
}
}
return file;

View File

@@ -485,7 +485,8 @@ class LibrarySymbolTable {
//}
}
void write(File output, File input, String lversion) throws IOException {
void write(File output, File input, String lversion)
throws IOException, IllegalNameException, IllegalDataException {
Element root = new Element("LIBRARY");
root.setAttribute("NAME", tableName);
@@ -515,16 +516,12 @@ class LibrarySymbolTable {
root.addContent(export);
}
FileOutputStream fos = new FileOutputStream(output);
try {
try (FileOutputStream fos = new FileOutputStream(output)) {
Document doc = new Document(root);
XMLOutputter xmlout = GenericXMLOutputter.getInstance();
xmlout.output(doc, fos);
}
finally {
fos.close();
}
//StringBuffer buffer = new StringBuffer();
//Iterator iter = exportList.iterator();