[haiku-bugs] Re: [Haiku] #8481: strncpy doesn't pad the destination string with NULs

  • From: "korli" <trac@xxxxxxxxxxxx>
  • Date: Thu, 19 Apr 2012 17:50:09 -0000

#8481: strncpy doesn't pad the destination string with NULs
---------------------------------+----------------------------
   Reporter:  hamish             |      Owner:  axeld
       Type:  bug                |     Status:  new
   Priority:  normal             |  Milestone:  R1
  Component:  System/libroot.so  |    Version:  R1/Development
 Resolution:                     |   Keywords:  strncpy
 Blocked By:                     |   Blocking:
Has a Patch:  1                  |   Platform:  All
---------------------------------+----------------------------

Comment (by korli):

 What about this?
 {{{
 while (count--) {
         if ((*dest++ = *src++) == '\0') {
                 memset(dest, '\0', count);
                 break;
         }
 }
 }}}

-- 
Ticket URL: <http://dev.haiku-os.org/ticket/8481#comment:5>
Haiku <http://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: