Unchecked strerror() with Invalid Errno
This commit is contained in:
@ -60,7 +60,7 @@ int Shred::shredDrive(Drive *drive, int *ipSignalFd)
|
||||
randomSrcFileDiscr = open(randomsrc, O_RDONLY | O_LARGEFILE);
|
||||
if (randomSrcFileDiscr == -1)
|
||||
{
|
||||
std::string errorMsg(strerror(randomSrcFileDiscr));
|
||||
std::string errorMsg(strerror(errno));
|
||||
Logger::logThis()->error("Shred-Task: Open random source failed! " + errorMsg + " - Drive: " + drive->getSerial());
|
||||
perror(randomsrc);
|
||||
cleanup();
|
||||
@ -71,7 +71,7 @@ int Shred::shredDrive(Drive *drive, int *ipSignalFd)
|
||||
driveFileDiscr = open(cpDrivePath, O_RDWR | O_LARGEFILE);
|
||||
if (driveFileDiscr == -1)
|
||||
{
|
||||
std::string errorMsg(strerror(driveFileDiscr));
|
||||
std::string errorMsg(strerror(errno));
|
||||
Logger::logThis()->error("Shred-Task: Open drive failed! " + errorMsg + " - Drive: " + drive->getSerial());
|
||||
perror(cpDrivePath);
|
||||
cleanup();
|
||||
@ -82,7 +82,7 @@ int Shred::shredDrive(Drive *drive, int *ipSignalFd)
|
||||
ssize_t readRet = read(randomSrcFileDiscr, ucKey, sizeof(ucKey));
|
||||
if (readRet <= 0)
|
||||
{
|
||||
std::string errorMsg(strerror(readRet));
|
||||
std::string errorMsg(strerror(errno));
|
||||
Logger::logThis()->error("Shred-Task: Read random key failed! " + errorMsg + " - Drive: " + drive->getSerial());
|
||||
perror(randomsrc);
|
||||
cleanup();
|
||||
@ -132,7 +132,7 @@ int Shred::shredDrive(Drive *drive, int *ipSignalFd)
|
||||
|
||||
if (iByteShredded <= 0)
|
||||
{
|
||||
std::string errorMsg(strerror(iByteShredded));
|
||||
std::string errorMsg(strerror(errno));
|
||||
Logger::logThis()->error("Shred-Task: Write to drive failed! " + errorMsg + " - Drive: " + drive->getSerial());
|
||||
perror("unable to write random data");
|
||||
cleanup();
|
||||
|
||||
Reference in New Issue
Block a user