Replace some sprintf with snprintf to prevent from buffer-overflow.

This commit is contained in:
Romuald Conty
2010-04-21 10:23:11 +00:00
parent ce6f7f2c84
commit d9ec086beb
2 changed files with 4 additions and 5 deletions

View File

@@ -195,9 +195,9 @@ nfc_device_t* nfc_connect(nfc_device_desc_t* pndd)
// Add the firmware revision to the device name, PN531 gives 2 bytes info, but PN532 gives 4
switch(pnd->nc)
{
case NC_PN531: sprintf(pnd->acName,"%s - PN531 v%d.%d",pnd->acName,abtFw[0],abtFw[1]); break;
case NC_PN532: sprintf(pnd->acName,"%s - PN532 v%d.%d (0x%02x)",pnd->acName,abtFw[1],abtFw[2],abtFw[3]); break;
case NC_PN533: sprintf(pnd->acName,"%s - PN533 v%d.%d (0x%02x)",pnd->acName,abtFw[1],abtFw[2],abtFw[3]); break;
case NC_PN531: snprintf(pnd->acName,DEVICE_NAME_LENGTH - 1,"%s - PN531 v%d.%d",pnd->acName,abtFw[0],abtFw[1]); break;
case NC_PN532: snprintf(pnd->acName,DEVICE_NAME_LENGTH - 1,"%s - PN532 v%d.%d (0x%02x)",pnd->acName,abtFw[1],abtFw[2],abtFw[3]); break;
case NC_PN533: snprintf(pnd->acName,DEVICE_NAME_LENGTH - 1,"%s - PN533 v%d.%d (0x%02x)",pnd->acName,abtFw[1],abtFw[2],abtFw[3]); break;
}
// Reset the ending transmission bits register, it is unknown what the last tranmission used there