From f2a2cf53ec71de9db13def2dc78cbdfc6b814d64 Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Sat, 21 Dec 2013 14:17:40 +0000 Subject: [PATCH] one more consistency check git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@14601 67ed7778-7388-44ab-90cf-0a291f65f57c --- camlibs/ptp2/ptp-pack.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/camlibs/ptp2/ptp-pack.c b/camlibs/ptp2/ptp-pack.c index 2252392bd..64a63359c 100644 --- a/camlibs/ptp2/ptp-pack.c +++ b/camlibs/ptp2/ptp-pack.c @@ -1201,13 +1201,18 @@ ptp_unpack_OPL (PTPParams *params, unsigned char* data, MTPProperties **pprops, static inline void ptp_unpack_EC (PTPParams *params, unsigned char* data, PTPContainer *ec, unsigned int len) { - int length; + unsigned int length; int type; if (data==NULL) return; memset(ec,0,sizeof(*ec)); + length=dtoh32a(&data[PTP_ec_Length]); + if (length > len) { + ptp_debug (params, "length %d in container, but data only %d bytes?!", length, len); + return; + } type = dtoh16a(&data[PTP_ec_Type]); ec->Code=dtoh16a(&data[PTP_ec_Code]);