Re: [AD] strcat strcpy etc.. BUG found!

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


> > Well, both strncat() and strncpy() are not very nice either, the first
> > one because it can write more characters than prescribed
>
> really? why?

7.15.3.2  The strncat function

Synopsis

       [#1]

               #include <string.h>
               char *strncat(char * restrict s1,
                       const char * restrict s2,
                       size_t n);

Description

       [#2] The strncat function appends not more than n characters
       (a  null  character  and  characters  that follow it are not
       appended) from the array pointed to by s2 to the end of  the
       string  pointed  to  by  s1.   The  initial  character of s2
       overwrites  the  null  character  at  the  end  of  s1.    A
       terminating   null  character  is  always  appended  to  the
       result.234  If copying  takes  place  between  objects  that
       overlap, the behavior is undefined.

Returns

       [#3] The strncat function returns the value of s1.


 234. Thus, the maximum number of characters that can end  up
           in the array pointed to by s1 is strlen(s1)+n+1.

-- 
Eric Botcazou



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/