strcpy Without Bounds Checking
This commit is contained in:
@ -44,10 +44,10 @@ void Printer::print(Drive *drive)
|
|||||||
|
|
||||||
snprintf(msgQueueData.driveData.caDriveIndex, STR_BUFFER_SIZE, "%i", drive->u16DriveIndex);
|
snprintf(msgQueueData.driveData.caDriveIndex, STR_BUFFER_SIZE, "%i", drive->u16DriveIndex);
|
||||||
snprintf(msgQueueData.driveData.caDriveState, STR_BUFFER_SIZE, "shredded");
|
snprintf(msgQueueData.driveData.caDriveState, STR_BUFFER_SIZE, "shredded");
|
||||||
strcpy(msgQueueData.driveData.caDriveModelFamily, drive->getModelFamily().c_str());
|
snprintf(msgQueueData.driveData.caDriveModelFamily, STR_BUFFER_SIZE, "%s", drive->getModelFamily().c_str());
|
||||||
strcpy(msgQueueData.driveData.caDriveModelName, drive->getModelName().c_str());
|
snprintf(msgQueueData.driveData.caDriveModelName, STR_BUFFER_SIZE, "%s", drive->getModelName().c_str());
|
||||||
snprintf(msgQueueData.driveData.caDriveCapacity, STR_BUFFER_SIZE, "%li", drive->getCapacity());
|
snprintf(msgQueueData.driveData.caDriveCapacity, STR_BUFFER_SIZE, "%li", drive->getCapacity());
|
||||||
strcpy(msgQueueData.driveData.caDriveSerialnumber, drive->getSerial().c_str());
|
snprintf(msgQueueData.driveData.caDriveSerialnumber, STR_BUFFER_SIZE, "%s", drive->getSerial().c_str());
|
||||||
snprintf(msgQueueData.driveData.caDriveHours, STR_BUFFER_SIZE, "%i", drive->getPowerOnHours());
|
snprintf(msgQueueData.driveData.caDriveHours, STR_BUFFER_SIZE, "%i", drive->getPowerOnHours());
|
||||||
snprintf(msgQueueData.driveData.caDriveCycles, STR_BUFFER_SIZE, "%i", drive->getPowerCycles());
|
snprintf(msgQueueData.driveData.caDriveCycles, STR_BUFFER_SIZE, "%i", drive->getPowerCycles());
|
||||||
snprintf(msgQueueData.driveData.caDriveErrors, STR_BUFFER_SIZE, "%i", drive->getErrorCount());
|
snprintf(msgQueueData.driveData.caDriveErrors, STR_BUFFER_SIZE, "%i", drive->getErrorCount());
|
||||||
@ -57,17 +57,17 @@ void Printer::print(Drive *drive)
|
|||||||
switch (drive->connectionType)
|
switch (drive->connectionType)
|
||||||
{
|
{
|
||||||
case Drive::USB:
|
case Drive::USB:
|
||||||
strcpy(msgQueueData.driveData.caDriveConnectionType, "usb");
|
strncpy(msgQueueData.driveData.caDriveConnectionType, "usb", STR_BUFFER_SIZE);
|
||||||
break;
|
break;
|
||||||
case Drive::SATA:
|
case Drive::SATA:
|
||||||
strcpy(msgQueueData.driveData.caDriveConnectionType, "sata");
|
strncpy(msgQueueData.driveData.caDriveConnectionType, "sata", STR_BUFFER_SIZE);
|
||||||
break;
|
break;
|
||||||
case Drive::NVME:
|
case Drive::NVME:
|
||||||
strcpy(msgQueueData.driveData.caDriveConnectionType, "nvme");
|
strncpy(msgQueueData.driveData.caDriveConnectionType, "nvme", STR_BUFFER_SIZE);
|
||||||
break;
|
break;
|
||||||
case Drive::UNKNOWN:
|
case Drive::UNKNOWN:
|
||||||
default:
|
default:
|
||||||
strcpy(msgQueueData.driveData.caDriveConnectionType, "na");
|
strncpy(msgQueueData.driveData.caDriveConnectionType, "na", STR_BUFFER_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(msgQueueData.driveData.caDriveReHddVersion, STR_BUFFER_SIZE, "%s", REHDD_VERSION);
|
snprintf(msgQueueData.driveData.caDriveReHddVersion, STR_BUFFER_SIZE, "%s", REHDD_VERSION);
|
||||||
|
|||||||
Reference in New Issue
Block a user