mirror of
https://github.com/BertoldVdb/ZoneDetect.git
synced 2026-04-27 14:57:40 +00:00
Support relative strings in metadata
This commit is contained in:
parent
069c4cd546
commit
2ef229ff01
1 changed files with 17 additions and 4 deletions
|
|
@ -101,21 +101,34 @@ static char* ZDParseString(ZoneDetect* library, uint32_t* index) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(strLength > 1024) {
|
uint32_t strOffset = *index;
|
||||||
|
unsigned int remoteStr = 0;
|
||||||
|
if(strLength >= 256) {
|
||||||
|
strOffset = library->metadataOffset + strLength - 256;
|
||||||
|
remoteStr = 1;
|
||||||
|
|
||||||
|
if(!ZDDecodeVariableLengthUnsigned(library, &strOffset, &strLength)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(strLength > 256) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
char* str = malloc(strLength + 1);
|
char* str = malloc(strLength + 1);
|
||||||
|
|
||||||
if(str) {
|
if(str) {
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
for(i=0; i<strLength; i++) {
|
for(i=0; i<strLength; i++) {
|
||||||
str[i] = library->mapping[*index+i] ^ 0x80;
|
str[i] = library->mapping[strOffset+i] ^ 0x80;
|
||||||
}
|
}
|
||||||
str[strLength] = 0;
|
str[strLength] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!remoteStr) {
|
||||||
*index += strLength;
|
*index += strLength;
|
||||||
|
}
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue