public inbox for libc-locales@sourceware.org
 help / color / mirror / Atom feed
* [Bug localedata/17596] New: mblen() does not return -1 for invalid input
@ 2014-11-15  0:51 raji at linux dot vnet.ibm.com
  2014-11-15  0:51 ` [Bug localedata/17596] " raji at linux dot vnet.ibm.com
  2014-11-20 18:50 ` raji at linux dot vnet.ibm.com
  0 siblings, 2 replies; 3+ messages in thread
From: raji at linux dot vnet.ibm.com @ 2014-11-15  0:51 UTC (permalink / raw)
  To: libc-locales

https://sourceware.org/bugzilla/show_bug.cgi?id=17596

            Bug ID: 17596
           Summary: mblen() does not return -1 for invalid input
           Product: glibc
           Version: 2.21
            Status: NEW
          Severity: minor
          Priority: P2
         Component: localedata
          Assignee: unassigned at sourceware dot org
          Reporter: raji at linux dot vnet.ibm.com
                CC: libc-locales at sourceware dot org

The standard document for mblen() states:

#include <stdlib.h>
int mblen(const char *s, size_t n);

The standard states:
"If s is a null pointer, the mblen function returns a nonzero or zero value, if
multibyte character encodings, respectively,
 do or do not have state-dependent encodings. If s is not a null pointer, the
mblen function either returns 0
(if s points to the null character), or returns the number of bytes that are
contained in the multibyte character
(if the next n or fewer bytes form a valid multibyte character), or returns -1
(if they do not form a valid multibyte character). "


The case n=0 is not explicitly mentioned in the standards document and is also
not handled in the code(stdlib/mblen.c)
When compiled on AIX (v6.1 and other releases) mblen() returns -1.

$ cat mblen_t.c
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>

main() {
     char sbcs_st[]  = "12345";

     if ( setlocale( LC_ALL, "" ) == NULL ) {
        printf( "setlocale() failed\n" );
     }
     printf("RC is %d\n", mblen(sbcs_st, 0));
}

$ gcc -o mblen_t mblen_t.c;./mblen_t
RC is 0


https://sourceware.org/ml/libc-alpha/2014-11/msg00191.html

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug localedata/17596] mblen() does not return -1 for invalid input
  2014-11-15  0:51 [Bug localedata/17596] New: mblen() does not return -1 for invalid input raji at linux dot vnet.ibm.com
@ 2014-11-15  0:51 ` raji at linux dot vnet.ibm.com
  2014-11-20 18:50 ` raji at linux dot vnet.ibm.com
  1 sibling, 0 replies; 3+ messages in thread
From: raji at linux dot vnet.ibm.com @ 2014-11-15  0:51 UTC (permalink / raw)
  To: libc-locales

https://sourceware.org/bugzilla/show_bug.cgi?id=17596

Rajalakshmi <raji at linux dot vnet.ibm.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at sourceware dot org   |raji at linux dot vnet.ibm.com

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug localedata/17596] mblen() does not return -1 for invalid input
  2014-11-15  0:51 [Bug localedata/17596] New: mblen() does not return -1 for invalid input raji at linux dot vnet.ibm.com
  2014-11-15  0:51 ` [Bug localedata/17596] " raji at linux dot vnet.ibm.com
@ 2014-11-20 18:50 ` raji at linux dot vnet.ibm.com
  1 sibling, 0 replies; 3+ messages in thread
From: raji at linux dot vnet.ibm.com @ 2014-11-20 18:50 UTC (permalink / raw)
  To: libc-locales

https://sourceware.org/bugzilla/show_bug.cgi?id=17596

Rajalakshmi <raji at linux dot vnet.ibm.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID

--- Comment #1 from Rajalakshmi <raji at linux dot vnet.ibm.com> ---
Some of the functions to calculate the length like strnlen,wcsnlen,wcswidth
return zero when input size n is passed as 0. Considering that, mblen(str, 0)
returning 0 seems to be valid.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-11-20 18:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-15  0:51 [Bug localedata/17596] New: mblen() does not return -1 for invalid input raji at linux dot vnet.ibm.com
2014-11-15  0:51 ` [Bug localedata/17596] " raji at linux dot vnet.ibm.com
2014-11-20 18:50 ` raji at linux dot vnet.ibm.com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).