mirror of
https://github.com/vgough/encfs.git
synced 2025-02-16 17:50:53 +01:00
Replace tmpnam with secure alternative. (Issue #200)
This commit is contained in:
parent
644a0b2d78
commit
65fa9f863b
@ -175,18 +175,25 @@ bool runTests(const std::shared_ptr<Cipher> &cipher, bool verbose) {
|
|||||||
cfg.assignKeyData(keyBuf, encodedKeySize);
|
cfg.assignKeyData(keyBuf, encodedKeySize);
|
||||||
|
|
||||||
// save config
|
// save config
|
||||||
auto name = std::tmpnam(nullptr);
|
//Creation of a temporary file should be more platform independent. On c++17 we could use std::filesystem.
|
||||||
|
string name = "/tmp/encfstestXXXXXX";
|
||||||
|
int tmpFd = mkstemp(&name[0]);
|
||||||
|
rAssert(-1 != tmpFd);
|
||||||
|
//mkstemp opens the temporary file, but we only need its name -> close it
|
||||||
|
rAssert(0 == close(tmpFd));
|
||||||
{
|
{
|
||||||
auto ok = writeV6Config(name, &cfg);
|
auto ok = writeV6Config(name.c_str(), &cfg);
|
||||||
rAssert(ok == true);
|
rAssert(ok == true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// read back in and check everything..
|
// read back in and check everything..
|
||||||
EncFSConfig cfg2;
|
EncFSConfig cfg2;
|
||||||
{
|
{
|
||||||
auto ok = readV6Config(name, &cfg2, nullptr);
|
auto ok = readV6Config(name.c_str(), &cfg2, nullptr);
|
||||||
rAssert(ok == true);
|
rAssert(ok == true);
|
||||||
}
|
}
|
||||||
|
//delete the temporary file where we stored the config
|
||||||
|
rAssert(0 == unlink(name.c_str()));
|
||||||
|
|
||||||
// check..
|
// check..
|
||||||
rAssert(cfg.cipherIface.implements(cfg2.cipherIface));
|
rAssert(cfg.cipherIface.implements(cfg2.cipherIface));
|
||||||
|
Loading…
Reference in New Issue
Block a user