Ignore:
Timestamp:
Sep 10, 2013, 8:48:23 AM (6 years ago)
Author:
Ralf Kirchner <ralf.kirchner@…>
Branches:
4.11, master
Children:
b6657c39
Parents:
f55215a
git-author:
Ralf Kirchner <ralf.kirchner@…> (09/10/13 08:48:23)
git-committer:
Sebastian Huber <sebastian.huber@…> (09/10/13 12:48:51)
Message:

dosfs: Correct handling of iconv() return value

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libfs/src/dosfs/msdos_conv_utf8.c

    rf55215a r3dbb68d  
    5353)
    5454{
    55   int     eno = 0;
     55  int     eno;
    5656  size_t  inbytes_left = src_size;
    5757  size_t  outbytes_left = *dst_size;
    5858  char   *inbuf = (void *) (uintptr_t) src;
    5959  char   *outbuf = dst;
    60   ssize_t iconv_status;
     60  size_t iconv_status;
    6161
    6262  iconv_status = iconv(
     
    7070  *dst_size -= outbytes_left;
    7171
    72   if ( iconv_status > 0 ) {
     72  if ( iconv_status == 0 ) {
     73    eno = 0;
     74  } else if ( iconv_status == (size_t) -1 ) {
     75    /*
     76     * iconv() has detected an error.  The most likely reason seems to be a too
     77     * small outbuf.
     78    */
     79    eno = ENOMEM;
     80  } else {
     81    /*
     82     * The iconv_status contains the number of characters converted in a
     83     * non-reversible way.  We want to use reversible conversions only.
     84     * Characters permitted within DOSFS names seem to be reversible.
     85     */
    7386    eno = EINVAL;
    74   } else if ( iconv_status < 0 ) {
    75     eno = ENOMEM;
    7687  }
    7788
Note: See TracChangeset for help on using the changeset viewer.