Re: strcpy versus strncpy

From: Paul McNabb (mcnabb@ARGUS-SYSTEMS.COM)
Date: Thu Mar 05 1998 - 12:33:26 PST

  • Next message: tqbfat_private: "Re: the purpose of dynamic memory allocation"

    >  From: der Mouse <mouseat_private>
    >
    >  >> In your specific example of a file name, most (all?) operating
    >  >> systems already impose a limit to the length of a file name.
    >  > I am sorry, but this this is complete and utter nonsense.  MVS is one
    >  > of the few systems that does impose such a limit and, even then, the
    >  > limit is not as obvious as might appear.  Unix has NO limit, and
    >  > never has had.
    >
    >  I suggest you check your facts.
    >
    >  "file name" can mean (at least) two things: a directory entry (ie, a
    >  single link in the filesystem tree) or an entire path name.
    >
    >  The former has always had a hard limit and likely always will.  This
    >  limit used to be (IIRC) 14 bytes under V7 and older SysV; FFS raised
    >  this to 255.  I have never seen it higher than 256; if you know of a
    >  UNIX-alike with this limit higher than 255 I would love to hear full
    >  details.
    
    Actually, there are two issues here.  It is true that all Unix systems
    I know of actually impose a maximum path length.  But this limit is
    only imposed on the string passed to the kernel in a system call.  But
    the "true path length" of a file, that is, the "/" separated list of all
    directories from the root directory down to the file, is limited only
    by the number of inodes in the file system.  The system will allow you
    to use "." as the first element of a path, and you can follow it with
    a string up to the kernel limit.
    
    It is possible that a program could create a very deep directory tree,
    with the root of that tree itself sitting a hundred directories deep
    from the file system root.  The files could all be handled properly by
    the kernel if the program referenced files in system calls using a
    relative path name.  Internally, however, the program may have stored
    an absolute path name that could exceed the system limit.
    
    paul
    
    ---------------------------------------------------------
    Paul McNabb                     Argus Systems Group, Inc.
    Vice President and CTO          1809 Woodfield Drive
    mcnabb@argus-systems.com        Savoy, IL 61874 USA
    TEL 217-355-6308
    FAX 217-355-1433                "Securing the Future"
    ---------------------------------------------------------
    



    This archive was generated by hypermail 2b30 : Fri Apr 13 2001 - 13:44:21 PDT