Skip to content

Commit

Permalink
data size is detached from the read size, so validate it (afl)
Browse files Browse the repository at this point in the history
  • Loading branch information
msmeissn committed Oct 27, 2024
1 parent cfed7e4 commit 2e36b40
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion camlibs/ptp2/ptp.c
Original file line number Diff line number Diff line change
Expand Up @@ -4067,9 +4067,15 @@ uint16_t
ptp_canon_getviewfinderimage (PTPParams* params, unsigned char** image, uint32_t* size)
{
PTPContainer ptp;
unsigned int datasize = 0;

PTP_CNT_INIT(ptp, PTP_OC_CANON_GetViewfinderImage);
CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, image, NULL));
CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, image, &datasize));
if (ptp.Param1 > datasize) {
ptp_debug (params, "param1 is %d, but size is only %d", ptp.Param1, datasize);
free(image);
return PTP_RC_GeneralError;
}
*size=ptp.Param1;
return PTP_RC_OK;
}
Expand Down

0 comments on commit 2e36b40

Please sign in to comment.