coverity fixes

This commit is contained in:
iceman1001 2020-09-17 23:08:49 +02:00
parent f00d9c22ef
commit f7e6327fdf

View file

@ -364,16 +364,19 @@ static int read_bmp_rgb(uint8_t *bmp, const size_t bmpsize, uint8_t model_nr, ui
if (pbmpheader->bpp != 24) {
return PM3_ESOFT;
}
if (pbmpheader->B == 'M' || pbmpheader->M == 'B') { //0x4d42
PrintAndLogEx(WARNING, "The file is not a BMP!");
return PM3_ESOFT;
}
PrintAndLogEx(DEBUG, "file size = %d", pbmpheader->fsize);
PrintAndLogEx(DEBUG, "file offset = %d", pbmpheader->offset);
if (pbmpheader->fsize > bmpsize) {
PrintAndLogEx(WARNING, "The file is truncated!");
return PM3_ESOFT;
}
// Get BMP file data pointer
uint32_t offset = pbmpheader->offset;
uint16_t width = pbmpheader->BMP_Width;
@ -383,11 +386,13 @@ static int read_bmp_rgb(uint8_t *bmp, const size_t bmpsize, uint8_t model_nr, ui
if (chanR == NULL) {
return PM3_EMALLOC;
}
int16_t *chanG = calloc(width * height, sizeof(int16_t));
if (chanG == NULL) {
free(chanR);
return PM3_EMALLOC;
}
int16_t *chanB = calloc(width * height, sizeof(int16_t));
if (chanB == NULL) {
free(chanR);
@ -549,15 +554,18 @@ static void read_red(uint32_t i, uint8_t *l, uint8_t model_nr, uint8_t *red) {
static int transceive_blocking( uint8_t* txBuf, uint16_t txBufLen, uint8_t* rxBuf, uint16_t rxBufLen, uint16_t* actLen, bool retransmit ){
uint8_t fail_num = 0;
if (rxBufLen < 2)
if (rxBufLen < 2) {
return PM3_EINVARG;
}
while (1) {
PacketResponseNG resp;
SendCommandMIX(CMD_HF_ISO14443A_READER, ISO14A_RAW | ISO14A_APPEND_CRC | ISO14A_NO_DISCONNECT, txBufLen, 0, txBuf, txBufLen);
rxBuf[0] = 1;
if (WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {
if (resp.oldarg[0] > rxBufLen) {
PrintAndLogEx(WARNING, "Received % bytes, rxBuf too small (%)", resp.oldarg[0], rxBufLen);
PrintAndLogEx(WARNING, "Received %u bytes, rxBuf too small (%u)", resp.oldarg[0], rxBufLen);
memcpy(rxBuf, resp.data.asBytes, rxBufLen);
*actLen = rxBufLen;
return PM3_ESOFT;
@ -565,6 +573,7 @@ static int transceive_blocking( uint8_t* txBuf, uint16_t txBufLen, uint8_t* rxBu
memcpy(rxBuf, resp.data.asBytes, resp.oldarg[0]);
*actLen = resp.oldarg[0];
}
if ((retransmit) && (rxBuf[0] != 0 || rxBuf[1] != 0)) {
fail_num++;
if (fail_num > 10) {