Re: strcpy versus strncpy

From: Joe Zbiciak (j-zbiciak1at_private)
Date: Mon Mar 02 1998 - 23:25:06 PST

  • Next message: Niall Smart: "Vulnerabilites in some versions of info2www CGI"

    'Dean Gaudet' said previously:
    |
    | You forgot:
    |
    | 4. strncpy is required to zero-fill the entire destination, which can be
    | quite a performance pig if the destination is big and the strncpy is
    | executed frequently.
    
    and
    
    5. strncpy may not zero-terminate the resulting string, leading to other
       interesting problems if you don't ensure that the resulting string
       is zero terminated yourself.
    
    (AT&T SVR4 had a lot of bugs in this vein regarding utmp, since their
    utmp structure only allowed 8 characters for login names.  If you had
    an 8 character login name, programs like "who" would show garbage after
    the login name because they'd assume that ut_user[] was zero terminated
    when it isn't necessarily.)
    
    Regards,
    
    --Joe
    
    --
     +----------- Joseph Zbiciak ----------+  Eliminate idle cycles!
     | - - - -  j-zbiciak1at_private  - - - - |  http://www.distributed.net/
     |- http://www.primenet.com/~im14u2c/ -|
     | - - -Texas Instruments, Dallas- - - |  "I feel as much like I did
     +-----#include "std_disclaimer.h"-----+   yesterday as I do today."
    



    This archive was generated by hypermail 2b30 : Fri Apr 13 2001 - 13:43:39 PDT