std.file functions and embedded NUL characters [CWE-158]

kdevel kdevel at vogtner.de
Thu Jul 31 21:55:03 UTC 2025


On Thursday, 31 July 2025 at 21:25:44 UTC, Doigt wrote:
> [...]
> Do you actually have a source or an example program that D 
> actually does anything with the null terminator

I did not argue that D "does" something "with the null 
terminator".
D like perl or Ada ignores the potential occurrence of NUL in the
string data when calling the underlying C functions for file 
system
operations.

    import std;

    void main ()
    {
       File ("abc", "w");
       std.file.rename ("abc", "ab\0c");
    }

Instead of throwing as the python code does this D program leaves
a file named "ab" in the filesystem.


More information about the Digitalmars-d mailing list