The File encryption and decryption make heavy use of ftell() to measure file sizes and get the current position within the file. Does this make it vulnerable to any sort of TOCTTOU attacks?
Some ideas:
- What if we've opened a file in read-only mode and some other process has it open in append-only mode, and the size changes after we've measured it?
- Others?
What guarantees does "the operating system" provide once we have a file resource? Note that "the operating system" is every operating system PHP runs on, so we have to look at the lowest common denominator.