$NetBSD: patch-ac,v 1.1 2005/01/05 15:52:52 drochner Exp $ --- camlibs/ptp2/ptp.c.orig 2004-12-19 17:23:14.000000000 +0100 +++ camlibs/ptp2/ptp.c @@ -336,6 +336,9 @@ static inline uint16_t ptp_usb_event (PTPParams* params, PTPContainer* event, int wait) { uint16_t ret; + uint32_t packetlen; + size_t toread; + unsigned char *bp; unsigned int rlen; PTPUSBEventContainer usbevent; PTP_CNT_INIT(usbevent); @@ -345,8 +348,24 @@ ptp_usb_event (PTPParams* params, PTPCon switch(wait) { case PTP_EVENT_CHECK: - ret=params->check_int_func((unsigned char*)&usbevent, - sizeof(usbevent), params->data, &rlen); + ret=params->check_int_func((unsigned char*)&packetlen, + sizeof(packetlen), params->data, &rlen); + if (ret!=PTP_RC_OK) + break; + if (rlen != sizeof(packetlen)) { + ret = PTP_ERROR_IO; + break; + } + toread = dtoh32(packetlen) - sizeof(packetlen); + bp = (unsigned char*)&usbevent.type; + while (toread > 0) { + ret=params->check_int_func(bp, + toread, params->data, &rlen); + if (ret!=PTP_RC_OK) + break; + toread -= rlen; + bp += rlen; + } break; case PTP_EVENT_CHECK_FAST: ret=params->check_int_fast_func((unsigned char*)