Bugtraq mailing list archives
Re: strcpy versus strncpy
From: mcnabb () ARGUS-SYSTEMS COM (Paul McNabb)
Date: Thu, 5 Mar 1998 14:33:26 -0600
From: der Mouse <mouse () RODENTS MONTREAL QC CA> >> 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" ---------------------------------------------------------
Current thread:
- Re: strcpy versus strncpy, (continued)
- Re: strcpy versus strncpy Ben Laurie (Mar 03)
- Re: strcpy versus strncpy Chris L. Mason (Mar 03)
- Re: strcpy versus strncpy der Mouse (Mar 04)
- Re: strcpy versus strncpy Aleph One (Mar 04)
- Re: strcpy versus strncpy Aleph One (Mar 04)
- Re: strcpy versus strncpy Aleph One (Mar 04)
- Re: strcpy versus strncpy Aleph One (Mar 04)
- Re: strcpy versus strncpy der Mouse (Mar 05)
- Re: strcpy versus strncpy Nick Maclaren (Mar 05)
- Re: strcpy versus strncpy Steve Bellovin (Mar 05)
- Re: strcpy versus strncpy Paul McNabb (Mar 05)