Hi Gedare,
Please find the patch against the current master head attached.

Kind Regards
        Ralf Kirchner

Am 06.09.2013 18:53, schrieb Gedare Bloom:
> OK. Can you send the patch against the current master head (rather
> than revert)? I am not able to commit today, but maybe someone else
> can.
> 
> -Gedare
> 
> On Fri, Sep 6, 2013 at 12:46 PM, Ralf Kirchner
> <[email protected]> wrote:
>> Hi Gedare,
>> Iconv() does not return any negative values. It returns "(size_t)-1" in
>> case of an error and the number of non-reversibly converted characters
>> in case of success.
>>
>> Thus please revert to size_t for the return value type and in addition
>> apply this patch:
>>
>> ---
>>  cpukit/libfs/src/dosfs/msdos_conv_utf8.c |   11 ++++++++---
>>  1 Datei geändert, 8 Zeilen hinzugefügt(+), 3 Zeilen entfernt(-)
>>
>> diff --git a/cpukit/libfs/src/dosfs/msdos_conv_utf8.c
>> b/cpukit/libfs/src/dosfs/msdos_conv_utf8.c
>> index 18aebc6..6760d2e 100644
>> --- a/cpukit/libfs/src/dosfs/msdos_conv_utf8.c
>> +++ b/cpukit/libfs/src/dosfs/msdos_conv_utf8.c
>> @@ -69,10 +69,15 @@ 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 == (size_t)-1 ) {
>> +    /* iconv() has detected an error. The most likely reason seems to +
>>       be a too small outbuf */
>>      eno = ENOMEM;
>> +  } else if ( iconv_status > 0 ) {
>> +    /* 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;
>> --
>> 1.7.10.4
>>
>> Am 05.09.2013 19:18, schrieb Gedare Bloom:
>>> On Thu, Sep 5, 2013 at 1:17 PM, Gedare Bloom <[email protected]> wrote:
>>>> Change the type for storing the return from iconv to be signed.
>>>> ---
>>>>  cpukit/libfs/src/dosfs/msdos_conv_utf8.c |    2 +-
>>>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>>>
>>>> diff --git a/cpukit/libfs/src/dosfs/msdos_conv_utf8.c 
>>>> b/cpukit/libfs/src/dosfs/msdos_conv_utf8.c
>>>> index a80db7e..18aebc6 100644
>>>> --- a/cpukit/libfs/src/dosfs/msdos_conv_utf8.c
>>>> +++ b/cpukit/libfs/src/dosfs/msdos_conv_utf8.c
>>>> @@ -57,7 +57,7 @@ static int msdos_utf8_convert_with_iconv(
>>>>    size_t  outbytes_left = *dst_size;
>>>>    char   *inbuf = (void *) (uintptr_t) src;
>>>>    char   *outbuf = dst;
>>>> -  size_t  iconv_status;
>>>> +  ssize_t iconv_status;
>>>>
>>>>    iconv_status = iconv(
>>> Note that iconv returns a size_t. Perhaps the return value should be
>>> cast explicitly to make this clear. newlib returns (size_t)-1 in case
>>> of an error in iconv.
>>>
>>>>      desc,
>>>> --
>>>> 1.7.1
>>>>
>>> _______________________________________________
>>> rtems-devel mailing list
>>> [email protected]
>>> http://www.rtems.org/mailman/listinfo/rtems-devel
>>>
>>
>>
>> --
>> --------------------------------------------
>> Embedded Brains GmbH
>> Ralf Kirchner          Dornierstr. 4
>> D-82178 Puchheim       Germany
>> email: [email protected]
>> Phone: +49-89-18 94 741-17
>> Fax:   +49-89-18 94 741-08
>>
>> Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.


-- 
--------------------------------------------
Embedded Brains GmbH
Ralf Kirchner          Dornierstr. 4
D-82178 Puchheim       Germany
email: [email protected]
Phone: +49-89-18 94 741-17
Fax:   +49-89-18 94 741-08

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
>From cab8095b14d05133a27cd881a69466d7c18d4690 Mon Sep 17 00:00:00 2001
From: Ralf Kirchner <[email protected]>
Date: Tue, 10 Sep 2013 10:48:23 +0200
Subject: [PATCH] dosfs: Correct handling of iconv() return value

---
 cpukit/libfs/src/dosfs/msdos_conv_utf8.c |   13 +++++++++----
 1 Datei geändert, 9 Zeilen hinzugefügt(+), 4 Zeilen entfernt(-)

diff --git a/cpukit/libfs/src/dosfs/msdos_conv_utf8.c b/cpukit/libfs/src/dosfs/msdos_conv_utf8.c
index 18aebc6..9c4446d 100644
--- a/cpukit/libfs/src/dosfs/msdos_conv_utf8.c
+++ b/cpukit/libfs/src/dosfs/msdos_conv_utf8.c
@@ -57,7 +57,7 @@ static int msdos_utf8_convert_with_iconv(
   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,15 @@ 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 == (size_t)-1 ) {
+    /* iconv() has detected an error. The most likely reason seems to be a 
+       too small outbuf */
     eno = ENOMEM;
+  } else if ( iconv_status > 0 ) {
+    /* 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;
-- 
1.7.10.4

_______________________________________________
rtems-devel mailing list
[email protected]
http://www.rtems.org/mailman/listinfo/rtems-devel

Reply via email to