Commit d2f5d424 authored by Adam Reichold's avatar Adam Reichold Committed by Albert Astals Cid

pdfdetach: Check for valid file name of embedded file before using it to determine save path.

Closes #660
parent 77a30e94
Pipeline #7744 passed with stage
in 14 minutes and 50 seconds
......@@ -191,14 +191,18 @@ int main(int argc, char *argv[]) {
fileSpec = static_cast<FileSpec *>(embeddedFiles->get(i));
printf("%d: ", i+1);
s1 = fileSpec->getFileName();
if ((s1->getChar(0) & 0xff) == 0xfe && (s1->getChar(1) & 0xff) == 0xff) {
if (!s1) {
exitCode = 3;
goto err2;
}
if (s1->hasUnicodeMarker()) {
isUnicode = true;
j = 2;
} else {
isUnicode = false;
j = 0;
}
while (j < fileSpec->getFileName()->getLength()) {
while (j < s1->getLength()) {
if (isUnicode) {
u = ((s1->getChar(j) & 0xff) << 8) | (s1->getChar(j+1) & 0xff);
j += 2;
......@@ -228,14 +232,18 @@ int main(int argc, char *argv[]) {
p = path;
}
s1 = fileSpec->getFileName();
if ((s1->getChar(0) & 0xff) == 0xfe && (s1->getChar(1) & 0xff) == 0xff) {
if (!s1) {
exitCode = 3;
goto err2;
}
if (s1->hasUnicodeMarker()) {
isUnicode = true;
j = 2;
} else {
isUnicode = false;
j = 0;
}
while (j < fileSpec->getFileName()->getLength()) {
while (j < s1->getLength()) {
if (isUnicode) {
u = ((s1->getChar(j) & 0xff) << 8) | (s1->getChar(j+1) & 0xff);
j += 2;
......@@ -276,14 +284,18 @@ int main(int argc, char *argv[]) {
} else {
p = path;
s1 = fileSpec->getFileName();
if ((s1->getChar(0) & 0xff) == 0xfe && (s1->getChar(1) & 0xff) == 0xff) {
if (!s1) {
exitCode = 3;
goto err2;
}
if (s1->hasUnicodeMarker()) {
isUnicode = true;
j = 2;
} else {
isUnicode = false;
j = 0;
}
while (j < fileSpec->getFileName()->getLength()) {
while (j < s1->getLength()) {
if (isUnicode) {
u = ((s1->getChar(j) & 0xff) << 8) | (s1->getChar(j+1) & 0xff);
j += 2;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment