Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 17 Apr 96 20:18:49 +0900
From:      Mihoko Tanaka <m_tanaka@pa.yokogawa.co.jp>
To:        hackers@freebsd.org
Subject:   problem of wcstombs.
Message-ID:  <9604171118.AA00657@cabbage.pa.yokogawa.co.jp>

next in thread | raw e-mail | index | archive | help

Hi all,

I have a trouble about 'wcstombs(3)'. I'm using FreeBSD-2.1R.

     size_t
     wcstombs(char *mbstring, const wchar_t *wcstring, size_t nbytes)

It seems that the 'wcstombs(3)' ignores the third argument 'nbyte'.
In fact, when the size of 'mbstring' is smaller than that of
'wcstring', it occurs the segmentation fault or write over the buffer.

It defines in /usr/src/sys/lib/libc/locale/ansi.c .
This file is the same between 2.1.0R and -current.
It may be find the similar problem in -current.

I suggest the following :
--------<patch for /usr/src/sys/lib/libc/locale/ansi.c>------------------
--- ansi.c      Fri May 27 13:56:46 1994
+++ ansi.c.new  Wed Apr 17 20:06:04 1996
@@ -142,6 +142,7 @@
                if (!e)                 /* too long */
                        return (cnt);
                cnt += e - s;
+               n -= e - s;
                s = e;
        }
        return (cnt);
--------<End:/usr/src/sys/lib/libc/locale/ansi.c>----------------------

Is it correct ?


--
Mihoko Tanaka 
<m_tanaka@pa.yokogawa.co.jp>     
	



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9604171118.AA00657>