ElfLinker::init() zero length implies 0x4000 blank bytes

This commit is contained in:
jreiser@BitWagon.com 2016-09-05 20:36:07 -07:00 committed by Markus F.X.J. Oberhumer
parent 98b428a8be
commit 1197beaa13

View File

@ -184,23 +184,25 @@ void ElfLinker::init(const void *pdata_v, int plen)
} }
input[inputlen] = 0; // NUL terminate input[inputlen] = 0; // NUL terminate
output = new upx_byte[inputlen]; output = new upx_byte[inputlen ? inputlen : 0x4000];
outputlen = 0; outputlen = 0;
int pos = find(input, inputlen, "Sections:\n", 10); if ((int)strlen("Sections:\n" "SYMBOL TABLE:\n" "RELOCATION RECORDS FOR ") < inputlen) {
assert(pos != -1); int pos = find(input, inputlen, "Sections:\n", 10);
char *psections = (char *) input + pos; assert(pos != -1);
char *psections = (char *) input + pos;
char *psymbols = strstr(psections, "SYMBOL TABLE:\n"); char *psymbols = strstr(psections, "SYMBOL TABLE:\n");
assert(psymbols != NULL); assert(psymbols != NULL);
char *prelocs = strstr(psymbols, "RELOCATION RECORDS FOR "); char *prelocs = strstr(psymbols, "RELOCATION RECORDS FOR ");
assert(prelocs != NULL); assert(prelocs != NULL);
preprocessSections(psections, psymbols); preprocessSections(psections, psymbols);
preprocessSymbols(psymbols, prelocs); preprocessSymbols(psymbols, prelocs);
preprocessRelocations(prelocs, (char*) input + inputlen); preprocessRelocations(prelocs, (char*) input + inputlen);
addLoader("*UND*"); addLoader("*UND*");
}
} }
void ElfLinker::preprocessSections(char *start, char *end) void ElfLinker::preprocessSections(char *start, char *end)