Peter N Lewis wrote:
One thing for users to watch out for given this (copying by length, not capacity, which is good) is to be very careful if you store such strings in a file on disk in an unpacked manner (ie, you store the entire string). This sort of thing can leak sensitive information like passwords or financial data or whatever happens to be sitting around in memory and care should be taken to avoid such leakage
Indeed.
(this was a common problem with Word documents of old).
Not only old from what I read. (Except that maybe today they can leak only data from other documents within the application, not from other processes as they did in old Windows versions.)
I'm not really familiar with Pascal I/O (since I always use native Mac file I/O or POSIX file I/O), but it'd be interesting to know what a "file of String(255)" writes to the file if you write a string with a short length and garbage in the spare bytes...
Such files will write just what's there, i.e. the garbage. Furthermore, such files are (very much) compiler-dependent, and (quite a bit) platform dependent (since the size of the capacity and length fields and possibly the alignment varies, and because of endianness).
If you cannot use a text file, you might want to look at routines such as WriteStringLittleEndian which take care of all these issues.
Frank