[Server] Restrict FileSessionStore::gc() to owned session files (#479)
This commit is contained in:
parent
d59950f1ac
commit
c36e805086
1 changed files with 28 additions and 5 deletions
|
|
@ -128,6 +128,11 @@ class FileSessionStore implements SessionStoreInterface
|
|||
continue;
|
||||
}
|
||||
|
||||
// Only delete files this store owns: sessions are named by their RFC 4122 UUID
|
||||
if (!Uuid::isValid($entry)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$path = $this->directory.\DIRECTORY_SEPARATOR.$entry;
|
||||
if (!is_file($path)) {
|
||||
continue;
|
||||
|
|
@ -136,11 +141,7 @@ class FileSessionStore implements SessionStoreInterface
|
|||
$mtime = @filemtime($path) ?: 0;
|
||||
if (($now - $mtime) > $this->ttl) {
|
||||
@unlink($path);
|
||||
try {
|
||||
$deleted[] = Uuid::fromString($entry);
|
||||
} catch (\Throwable) {
|
||||
// ignore non-UUID file names
|
||||
}
|
||||
$deleted[] = Uuid::fromString($entry);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue