Remove use of tempnam function and fix bug (bad check of rename return)
This commit is contained in:
parent
f568b5d3a8
commit
4f9b2de5a5
|
@ -114,16 +114,16 @@ public:
|
||||||
// Use temp file for PDF
|
// Use temp file for PDF
|
||||||
if (type == gourou::DRMProcessor::ITEM_TYPE::PDF)
|
if (type == gourou::DRMProcessor::ITEM_TYPE::PDF)
|
||||||
{
|
{
|
||||||
char* tempFile = tempnam("/tmp", NULL);
|
std::string tempFile = filename + ".tmp";
|
||||||
processor.removeDRM(inputFile, tempFile, type, encryptionKey, encryptionKeySize);
|
/* Be sure there is not already a temp file */
|
||||||
|
unlink(tempFile.c_str());
|
||||||
|
processor.removeDRM(filename, tempFile, type, encryptionKey, encryptionKeySize);
|
||||||
/* Original file must be removed before doing a copy... */
|
/* Original file must be removed before doing a copy... */
|
||||||
unlink(inputFile);
|
unlink(filename.c_str());
|
||||||
if (!rename(tempFile, filename.c_str()))
|
if (rename(tempFile.c_str(), filename.c_str()))
|
||||||
{
|
{
|
||||||
free(tempFile);
|
|
||||||
EXCEPTION(gourou::DRM_FILE_ERROR, "Unable to copy " << tempFile << " into " << filename);
|
EXCEPTION(gourou::DRM_FILE_ERROR, "Unable to copy " << tempFile << " into " << filename);
|
||||||
}
|
}
|
||||||
free(tempFile);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
processor.removeDRM(inputFile, filename, type, encryptionKey, encryptionKeySize);
|
processor.removeDRM(inputFile, filename, type, encryptionKey, encryptionKeySize);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user