mirror of
https://github.com/pfsense/pfsense.git
synced 2025-10-26 11:38:35 +00:00
Fix handling of 0-byte files uploaded to the CP file manager.
This commit is contained in:
parent
919916d426
commit
012e80df44
@ -1445,12 +1445,17 @@ function captiveportal_write_elements() {
|
||||
if (is_array($cpcfg['element'])) {
|
||||
conf_mount_rw();
|
||||
foreach ($cpcfg['element'] as $data) {
|
||||
if (!@file_put_contents("{$g['captiveportal_element_path']}/{$data['name']}", base64_decode($data['content']))) {
|
||||
/* Do not attempt to decode or write out empty files. */
|
||||
if (empty($data['content']) || empty(base64_decode($data['content']))) {
|
||||
unlink_if_exists("{$g['captiveportal_element_path']}/{$data['name']}");
|
||||
touch("{$g['captiveportal_element_path']}/{$data['name']}");
|
||||
} elseif (!@file_put_contents("{$g['captiveportal_element_path']}/{$data['name']}", base64_decode($data['content']))) {
|
||||
printf(gettext("Error: cannot open '%s' in captiveportal_write_elements()%s"), $data['name'], "\n");
|
||||
return 1;
|
||||
}
|
||||
if (!file_exists("{$g['captiveportal_path']}/{$data['name']}"))
|
||||
if (!file_exists("{$g['captiveportal_path']}/{$data['name']}")) {
|
||||
@symlink("{$g['captiveportal_element_path']}/{$data['name']}", "{$g['captiveportal_path']}/{$data['name']}");
|
||||
}
|
||||
}
|
||||
conf_mount_ro();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user