summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRalf Kirchner <ralf.kirchner@embedded-brains.de>2013-09-10 10:48:23 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2013-09-10 14:48:51 +0200
commit3dbb68d99177dc9682ffca3c3d42802c319e4975 (patch)
treee5a0b62f1f6657fe9d297bac06fa3af4f10d1db9
parentbsps: Fix cache manager support (diff)
downloadrtems-3dbb68d99177dc9682ffca3c3d42802c319e4975.tar.bz2
dosfs: Correct handling of iconv() return value
-rw-r--r--cpukit/libfs/src/dosfs/msdos_conv_utf8.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/cpukit/libfs/src/dosfs/msdos_conv_utf8.c b/cpukit/libfs/src/dosfs/msdos_conv_utf8.c
index 18aebc6b3d..1399734a6f 100644
--- a/cpukit/libfs/src/dosfs/msdos_conv_utf8.c
+++ b/cpukit/libfs/src/dosfs/msdos_conv_utf8.c
@@ -52,12 +52,12 @@ static int msdos_utf8_convert_with_iconv(
size_t *dst_size
)
{
- int eno = 0;
+ int eno;
size_t inbytes_left = src_size;
size_t outbytes_left = *dst_size;
char *inbuf = (void *) (uintptr_t) src;
char *outbuf = dst;
- ssize_t iconv_status;
+ size_t iconv_status;
iconv_status = iconv(
desc,
@@ -69,10 +69,21 @@ static int msdos_utf8_convert_with_iconv(
*dst_size -= outbytes_left;
- if ( iconv_status > 0 ) {
- eno = EINVAL;
- } else if ( iconv_status < 0 ) {
+ if ( iconv_status == 0 ) {
+ eno = 0;
+ } else if ( iconv_status == (size_t) -1 ) {
+ /*
+ * iconv() has detected an error. The most likely reason seems to be a too
+ * small outbuf.
+ */
eno = ENOMEM;
+ } else {
+ /*
+ * The iconv_status contains the number of characters converted in a
+ * non-reversible way. We want to use reversible conversions only.
+ * Characters permitted within DOSFS names seem to be reversible.
+ */
+ eno = EINVAL;
}
return eno;