summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2009-09-08 09:47:12 +0200
committerDavid Kalnischkies <kalnischkies@gmail.com>2009-09-08 09:47:12 +0200
commit1f99b6d338186efe80e314268db44600d3c94a1e (patch)
treeae2c0b7dd1dd1fc9602ba3acb0a792c93f875353 /apt-pkg
parentc914647fb05653878a14ae391f52b5e94cc73b26 (diff)
replace unknown multibytes with ? in UTF8ToCharset (Closes: #545208)
instead of ignoring the returncode and truncating the string on error
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/contrib/strutl.cc15
1 files changed, 13 insertions, 2 deletions
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc
index 1683868c8..4c05f2df8 100644
--- a/apt-pkg/contrib/strutl.cc
+++ b/apt-pkg/contrib/strutl.cc
@@ -67,9 +67,20 @@ bool UTF8ToCodeset(const char *codeset, const string &orig, string *dest)
outbuf = new char[insize+1];
outptr = outbuf;
- iconv(cd, &inptr, &insize, &outptr, &outsize);
- *outptr = '\0';
+ while (insize != 0)
+ {
+ size_t const err = iconv(cd, &inptr, &insize, &outptr, &outsize);
+ if (err == (size_t)(-1))
+ {
+ insize--;
+ outsize++;
+ inptr++;
+ *outptr = '?';
+ outptr++;
+ }
+ }
+ *outptr = '\0';
*dest = outbuf;
delete[] outbuf;