head 1.2; access; symbols pkgsrc-2013Q2:1.2.0.18 pkgsrc-2013Q2-base:1.2 pkgsrc-2012Q4:1.2.0.16 pkgsrc-2012Q4-base:1.2 pkgsrc-2011Q4:1.2.0.14 pkgsrc-2011Q4-base:1.2 pkgsrc-2011Q2:1.2.0.12 pkgsrc-2011Q2-base:1.2 pkgsrc-2009Q4:1.2.0.10 pkgsrc-2009Q4-base:1.2 pkgsrc-2008Q4:1.2.0.8 pkgsrc-2008Q4-base:1.2 pkgsrc-2008Q3:1.2.0.6 pkgsrc-2008Q3-base:1.2 cube-native-xorg:1.2.0.4 cube-native-xorg-base:1.2 pkgsrc-2008Q2:1.2.0.2 pkgsrc-2008Q2-base:1.2 pkgsrc-2008Q1:1.1.0.8 pkgsrc-2008Q1-base:1.1 pkgsrc-2007Q4:1.1.0.6 pkgsrc-2007Q4-base:1.1 pkgsrc-2007Q3:1.1.0.4 pkgsrc-2007Q3-base:1.1 pkgsrc-2007Q2:1.1.0.2 pkgsrc-2007Q2-base:1.1; locks; strict; comment @# @; 1.2 date 2008.04.29.09.31.09; author sborrill; state dead; branches; next 1.1; 1.1 date 2007.04.25.13.36.18; author sborrill; state Exp; branches; next ; desc @@ 1.2 log @Changes: libgphoto2 2.4.1 This is a 2.4 release branch update. Package / System integration: * HAL FDI files now use "info.subsystem" instead of "info.bus", required by hal after March 2008. * Suppress another Olympus camera in FDI file that is better of done using Mass Storage only. libgphoto2_port: * Suppress more known network filesystems in "disk" autodetection * disabled usb_reset for Canon cameras in "usb", broke EOS cameras. PTP2 driver: * Merged all new Camera IDs from TRUNK. * Configuration bugfix for multiple options with the same name. * Capture bugfix for Nikon Coolpix * Various small bugfixes. Canon driver: * Increased the event timeout, so operations work again. * Fixed a bug in interval capture * some additional configuration values for newer cameras Mars driver: * Synced with SVN TRUNK (1:1 copy). * Better whitebalance postprocessing * Camera ids added * Decompression fixes Digigr8 driver: * Synced with SVN TRUNK (1:1 copy). * bugfixes Sonix driver: * Synced with SVN TRUNK (1:1 copy). * bugfixes + changes from 2.3.x @ text @$NetBSD: patch-ag,v 1.1 2007/04/25 13:36:18 sborrill Exp $ --- camlibs/ptp2/ptp-pack.c.orig 2007-01-30 20:06:47.000000000 -0500 +++ camlibs/ptp2/ptp-pack.c 2007-01-30 21:32:05.000000000 -0500 @@@@ -89,41 +89,38 @@@@ static inline char* ptp_unpack_string(PTPParams *params, unsigned char* data, uint16_t offset, uint8_t *len) { - int i; - uint8_t loclen; + uint8_t length; + uint16_t string[PTP_MAXSTRLEN+1]; + /* allow for UTF-8: max of 3 bytes per UCS-2 char, plus final null */ + char loclstr[PTP_MAXSTRLEN*3+1]; + size_t nconv, srclen, destlen; + char *src, *dest; + + length = dtoh8a(&data[offset]); /* PTP_MAXSTRLEN == 255, 8 bit len */ + *len = length; + if (length == 0) /* nothing to do? */ + return(NULL); + + /* copy to string[] to ensure correct alignment for iconv(3) */ + memcpy(string, &data[offset+1], length * sizeof(string[0])); + string[length] = 0x0000U; /* be paranoid! add a terminator. */ + loclstr[0] = '\0'; + + /* convert from camera UCS-2 to our locale */ + src = (char *)string; + srclen = length * sizeof(string[0]); + dest = loclstr; + destlen = sizeof(loclstr)-1; + nconv = iconv(params->cd_ucs2_to_locale, &src, &srclen, + &dest, &destlen); + if (nconv == (size_t) -1) + return(NULL); - /* Cannot exceed 255 (PTP_MAXSTRLEN) since it is a single byte, duh ... */ - loclen = dtoh8a(&data[offset]); - /* This len is used to advance the buffer pointer */ - *len = loclen; - if (loclen) { - uint16_t string[PTP_MAXSTRLEN+1]; - char *stringp = (char *) string; - char loclstr[PTP_MAXSTRLEN*3+1]; /* UTF-8 encoding is max 3 bytes per UCS2 char. */ - char *locp = loclstr; - size_t nconv; - size_t convlen = loclen * 2; /* UCS-2 is 16 bit wide */ - size_t convmax = PTP_MAXSTRLEN*3; - - for (i=0;icd_ucs2_to_locale, &stringp, &convlen, &locp, &convmax); - /* FIXME: handle size errors */ - loclstr[PTP_MAXSTRLEN*3] = '\0'; - if (nconv == (size_t) -1) - return NULL; - return strdup(loclstr); - } - return NULL; + *dest = '\0'; + loclstr[sizeof(loclstr)-1] = '\0'; /* be safe? */ + return(strdup(loclstr)); } - static inline int ucs2strlen(uint16_t const * const unicstr) { @@@@ -138,7 +135,6 @@@@ static inline void ptp_pack_string(PTPParams *params, char *string, unsigned char* data, uint16_t offset, uint8_t *len) { - int i; int packedlen; uint16_t ucs2str[PTP_MAXSTRLEN+1]; char *ucs2strp = (char *) ucs2str; @@@@ -148,11 +144,15 @@@@ size_t convmax = PTP_MAXSTRLEN * 2; /* Includes the terminator */ /* Cannot exceed 255 (PTP_MAXSTRLEN) since it is a single byte, duh ... */ - ucs2str[0] = 0x0000U; - memset(ucs2strp, 0, PTP_MAXSTRLEN*2+2); - nconv = iconv (params->cd_locale_to_ucs2, &stringp, &convlen, &ucs2strp, &convmax); + memset(ucs2strp, 0, sizeof(ucs2str)); /* XXX: necessary? */ + nconv = iconv(params->cd_locale_to_ucs2, &stringp, &convlen, + &ucs2strp, &convmax); if (nconv == (size_t) -1) ucs2str[0] = 0x0000U; + /* + * XXX: isn't packedlen just ( (uint16_t *)ucs2strp - ucs2str )? + * why do we need ucs2strlen()? + */ packedlen = ucs2strlen(ucs2str); if (packedlen > PTP_MAXSTRLEN-1) { *len=0; @@@@ -161,10 +161,8 @@@@ /* number of characters including terminating 0 (PTP standard confirmed) */ htod8a(&data[offset],packedlen+1); - for (i=0;i