Skip to content

Commit 2e36b40

Browse files
committed
data size is detached from the read size, so validate it (afl)
1 parent cfed7e4 commit 2e36b40

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

camlibs/ptp2/ptp.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4067,9 +4067,15 @@ uint16_t
40674067
ptp_canon_getviewfinderimage (PTPParams* params, unsigned char** image, uint32_t* size)
40684068
{
40694069
PTPContainer ptp;
4070+
unsigned int datasize = 0;
40704071

40714072
PTP_CNT_INIT(ptp, PTP_OC_CANON_GetViewfinderImage);
4072-
CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, image, NULL));
4073+
CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, image, &datasize));
4074+
if (ptp.Param1 > datasize) {
4075+
ptp_debug (params, "param1 is %d, but size is only %d", ptp.Param1, datasize);
4076+
free(image);
4077+
return PTP_RC_GeneralError;
4078+
}
40734079
*size=ptp.Param1;
40744080
return PTP_RC_OK;
40754081
}

0 commit comments

Comments
 (0)