Skip to content

Commit

Permalink
fix a bunch of memory leaks and potential SEGFAULTs in ptp.c
Browse files Browse the repository at this point in the history
  • Loading branch information
axxel committed Sep 9, 2024
1 parent ffa8d5d commit e717460
Show file tree
Hide file tree
Showing 2 changed files with 137 additions and 115 deletions.
5 changes: 4 additions & 1 deletion camlibs/ptp2/ptp-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,9 @@ ptp_unpack_Sony_DPD (PTPParams *params, unsigned char* data, PTPDevicePropDesc *
unsigned int ret;
unsigned int isenabled, getset;

if (!data || dpdlen < PTP_dpd_Sony_FactoryDefaultValue)
return 0;

memset (dpd, 0, sizeof(*dpd));
dpd->DevicePropertyCode=dtoh16a(&data[PTP_dpd_Sony_DevicePropertyCode]);
dpd->DataType=dtoh16a(&data[PTP_dpd_Sony_DataType]);
Expand Down Expand Up @@ -3245,7 +3248,7 @@ ptp_unpack_ptp11_manifest (
unsigned int curoffset;
PTPObjectFilesystemInfo *xoifs;

if (datalen < 8)
if (!data || datalen < 8)
return 0;
numberoifs = dtoh64ap(params,data);
curoffset = 8;
Expand Down
Loading

0 comments on commit e717460

Please sign in to comment.