From 6a8b4cfc2c9a8a770346f8777ca9da8130b2171d Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Tue, 29 Nov 2022 09:01:32 +0100 Subject: Revert "ptp_pack_string: check string length for no iconv situation" was not correct, see discussion in https://github.com/libmtp/libmtp/commit/2ada8d587bbfb077f3b7155ebd0dfa8db65e935d This reverts commit 45b29802d7473a969cbc268a4c64e0797c7911c2. --- src/ptp-pack.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ptp-pack.c b/src/ptp-pack.c index d5e9488..0616996 100644 --- a/src/ptp-pack.c +++ b/src/ptp-pack.c @@ -212,13 +212,13 @@ ptp_pack_string(PTPParams *params, char *string, unsigned char* data, uint16_t o uint16_t ucs2str[PTP_MAXSTRLEN+1]; char *ucs2strp = (char *) ucs2str; size_t convlen = strlen(string); - size_t convmax = PTP_MAXSTRLEN * 2; /* Includes the terminator */ /* Cannot exceed 255 (PTP_MAXSTRLEN) since it is a single byte, duh ... */ memset(ucs2strp, 0, sizeof(ucs2str)); /* XXX: necessary? */ #if defined(HAVE_ICONV) && defined(HAVE_LANGINFO_H) if (params->cd_locale_to_ucs2 != (iconv_t)-1) { size_t nconv; + size_t convmax = PTP_MAXSTRLEN * 2; /* Includes the terminator */ char *stringp = string; nconv = iconv(params->cd_locale_to_ucs2, &stringp, &convlen, @@ -230,10 +230,10 @@ ptp_pack_string(PTPParams *params, char *string, unsigned char* data, uint16_t o { unsigned int i; - for (i=0;i