diff --git a/camlibs/ptp2/ptp-pack.c b/camlibs/ptp2/ptp-pack.c index 305180c90..3aa874f24 100644 --- a/camlibs/ptp2/ptp-pack.c +++ b/camlibs/ptp2/ptp-pack.c @@ -34,6 +34,13 @@ #include #endif +#ifndef MAX +# define MAX(a, b) ((a) > (b) ? (a) : (b)) +#endif +#ifndef MIN +# define MIN(a, b) ((a) < (b) ? (a) : (b)) +#endif + static inline uint16_t htod16p (PTPParams *params, uint16_t var) { @@ -2628,12 +2635,11 @@ static unsigned int olcsizes[0x15][13] = { olcver = sizeof(olcsizes)/sizeof(olcsizes[0])-1; } - ptp_debug (params, "event %d: OLC version is 0x%02x", i, olcver); - ptp_debug (params, "event %d: EOS event OLCInfoChanged (size %d)", i, size); + mask = size >= 14 ? dtoh16a(curdata+8+4) : 0; + ptp_debug (params, "event %d: EOS event OLCInfoChanged (size %d, version 0x%02x, mask 0x%04x)", i, size, olcver, mask); if (size >= 0x8) { /* event info */ - unsigned int k; - for (k=8;k size) break; if (!(mask & curmask)) continue; - if (curoff+olcsizes[olcver][j] > size) { - ptp_debug (params, "event %d: mask 0x%x size of olc entry %d exceeds total size %d", i, mask, curoff+olcsizes[olcver][j], size); - break; - } - ptp_debug (params, "event %d: olcmask 0x%04x", i, curmask); - for (k=0;k