storage: Don't allow "." and ".." paths, enforce '/' dir separators.

Also clarify what characters are valid for Storage paths in the category docs.

Fixes #11079.
Fixes #11370.
Fixes #11369.
This commit is contained in:
Ryan C. Gordon
2025-01-15 20:16:10 -05:00
parent 67664a0427
commit 874c07f8de
4 changed files with 162 additions and 40 deletions

View File

@@ -222,6 +222,22 @@
* playing on another PC (and vice versa) with the save data fully
* synchronized across all devices, allowing for a seamless experience without
* having to do full restarts of the program.
*
* ## Notes on valid paths
*
* All paths in the Storage API use Unix-style path separators ('/'). Using a
* different path separator will not work, even if the underlying platform
* would otherwise accept it. This is to keep code using the Storage API
* portable between platforms and Storage implementations and simplify app
* code.
*
* Paths with relative directories ("." and "..") are forbidden by the Storage
* API.
*
* All valid UTF-8 strings (discounting the NULL terminator character and the
* '/' path separator) are usable for filenames, however, an underlying
* Storage implementation may not support particularly strange sequences and
* refuse to create files with those names, etc.
*/
#ifndef SDL_storage_h_