Skip to content

Commit 228911c

Browse files
authored
Merge pull request #36691 from nextcloud/fix/25175/fix-config-truncating
add a disk_free_space check before writing config
2 parents a747be3 + 3757b34 commit 228911c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/private/Config.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,13 @@ private function writeData() {
285285
'This can usually be fixed by giving the webserver write access to the config directory.');
286286
}
287287

288+
// Never write file back if disk space should be too low
289+
$df = disk_free_space($this->configDir);
290+
$size = strlen($content) + 10240;
291+
if ($df !== false && (int)$df < $size) {
292+
throw new \Exception($this->configDir . " does not have enough space for writing the config file! Not writing it back!");
293+
}
294+
288295
// Try to acquire a file lock
289296
if (!flock($filePointer, LOCK_EX)) {
290297
throw new \Exception(sprintf('Could not acquire an exclusive lock on the config file %s', $this->configFilePath));

0 commit comments

Comments
 (0)