diff --git a/client/src/cmdhfwaveshare.c b/client/src/cmdhfwaveshare.c index bbcee4e18..b41ecefea 100644 --- a/client/src/cmdhfwaveshare.c +++ b/client/src/cmdhfwaveshare.c @@ -364,31 +364,36 @@ 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; uint16_t height = pbmpheader->BMP_Height; - int16_t *chanR = calloc(width*height, sizeof(int16_t)); + int16_t *chanR = calloc(width * height, sizeof(int16_t)); if (chanR == NULL) { return PM3_EMALLOC; } - int16_t *chanG = calloc(width*height, sizeof(int16_t)); + + 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)); + + int16_t *chanB = calloc(width * height, sizeof(int16_t)); if (chanB == NULL) { free(chanR); free(chanG); @@ -396,26 +401,26 @@ static int read_bmp_rgb(uint8_t *bmp, const size_t bmpsize, uint8_t model_nr, ui } // Extracting BMP chans - for (uint16_t Y=0; Yoffset; - for (uint16_t Y=0; Yoffset; - for (uint16_t Y=0; Y 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) {