summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Meissner <marcus@jet.franken.de>2006-12-18 19:28:47 +0000
committerMarcus Meissner <marcus@jet.franken.de>2006-12-18 19:28:47 +0000
commitd67eed9dee6a5616fef3d9a9b802080c80c6e676 (patch)
treea942c40e20af6bac21fd8085cb953f714bceadee
parent484e7a4e9c36e262462ed22347c75a6203d08433 (diff)
downloadlibgphoto2-d67eed9dee6a5616fef3d9a9b802080c80c6e676.tar.gz
forward ported the PTP string fix from libmtp
git-svn-id: https://svn.code.sf.net/p/gphoto/code/branches/libgphoto2-2_3/libgphoto2@9687 67ed7778-7388-44ab-90cf-0a291f65f57c
-rw-r--r--camlibs/ptp2/ChangeLog1
-rw-r--r--camlibs/ptp2/ptp-pack.c11
2 files changed, 5 insertions, 7 deletions
diff --git a/camlibs/ptp2/ChangeLog b/camlibs/ptp2/ChangeLog
index 6e24ad604..4fc63e91c 100644
--- a/camlibs/ptp2/ChangeLog
+++ b/camlibs/ptp2/ChangeLog
@@ -3,6 +3,7 @@
* library.c: Fixed leaking CameraFile + data on Canon and Nikon
capture.
* library.c: Added HP Photosmart E427
+ * ptp-pack.c: Fixed string packing. Include terminating \0.
2006-12-10 Marcus Meissner <marcus@jet.franken.de>
diff --git a/camlibs/ptp2/ptp-pack.c b/camlibs/ptp2/ptp-pack.c
index 2d7104c54..d492b9a34 100644
--- a/camlibs/ptp2/ptp-pack.c
+++ b/camlibs/ptp2/ptp-pack.c
@@ -159,14 +159,15 @@ ptp_pack_string(PTPParams *params, char *string, unsigned char* data, uint16_t o
return;
}
- /* number of characters + leading 0 */
+ /* number of characters including terminating 0 (PTP standard confirmed) */
htod8a(&data[offset],packedlen+1);
for (i=0;i<packedlen && i< PTP_MAXSTRLEN; i++) {
htod16a(&data[offset+i*2+1],ucs2str[i]);
}
+ htod16a(&data[offset+i*2+1],0x0000);
/* The returned length is in number of characters */
- *len = (uint8_t) packedlen;
+ *len = (uint8_t) packedlen+1;
}
static inline unsigned char *
@@ -179,11 +180,7 @@ ptp_get_packed_stringcopy(PTPParams *params, char *string, uint32_t *packed_size
ptp_pack_string(params, string, (unsigned char*) packed, 0, &len);
/* returned length is in characters, then one byte for string length */
plen = len*2 + 1;
- /* Assure proper termination, two zero bytes */
- packed[plen] = 0x00;
- packed[plen+1] = 0x00;
- /* Include terminator */
- plen += 2;
+
retcopy = malloc(plen);
if (!retcopy) {
*packed_size = 0;