On 2010-10-15, Chris Torek <nos...@torek.net> wrote: >>> On 2010-10-15, Grant Edwards <inva...@invalid.invalid> wrote: >>>> How do you create a [Unix] file with a name that contains a NULL byte? > >>On 2010-10-15, Seebs <usenet-nos...@seebs.net> wrote: >>> So far as I know, in canonical Unix, you don't -- the syscalls all work >>> with something like C strings under the hood, meaning that no matter what >>> path name you send, the first null byte actually terminates it. > > In article <i9a84m$rp...@reader1.panix.com> Grant Edwards > <inva...@invalid.invalid> wrote: > >>Yes, all of the Unix syscalls use NULL-terminated path parameters (AKA >>"C strings"). What I don't know is whether the underlying filesystem >>code also uses NULL-terminated strings for filenames or if they have >>explicit lengths. If the latter, there might be some way to bypass >>the normal Unix syscalls and actually create a file with a NULL in its >>name -- a file that then couldn't be accessed via the normal Unix >>system calls. My _guess_ is that the underlying filesystem code in >>most all Unices also uses NULL-terminated strings, but I haven't >>looked yet. > > Multiple common on-disk formats (BSD's UFS variants and Linux's EXTs, > for instance) use counted strings, so it is possible -- via disk > corruption or similar -- to get "impossible" file names (those > containing either an embedded NUL or an embedded '/').
That appeared it might be the case after a quick browsing of some of the fs source code, but I wasn't sure. > More notoriously, earlier versions of NFS could create files with > embedded slashes when serving non-Unix clients. These were easily > removed with the same non-Unix client, but not on the server! :-) > > None of this has anything to do with the original problem, No, we left that track miles back... -- Grant Edwards grant.b.edwards Yow! I'm having an at emotional outburst!! gmail.com -- http://mail.python.org/mailman/listinfo/python-list