summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjim-p <jimp@pfsense.org>2015-12-15 15:12:25 -0500
committerjim-p <jimp@pfsense.org>2015-12-15 15:12:25 -0500
commit012e80df44cc2db67e976e00e89ccc69202349ef (patch)
tree95b449431e351ec58b13ee05ead8633722362733
parent919916d426a6fc060c74c20d231ab1b33c34eedc (diff)
downloadpfsense-012e80df44cc2db67e976e00e89ccc69202349ef.zip
pfsense-012e80df44cc2db67e976e00e89ccc69202349ef.tar.gz
Fix handling of 0-byte files uploaded to the CP file manager.
-rw-r--r--etc/inc/captiveportal.inc9
1 files changed, 7 insertions, 2 deletions
diff --git a/etc/inc/captiveportal.inc b/etc/inc/captiveportal.inc
index 0145962..497b6f1 100644
--- a/etc/inc/captiveportal.inc
+++ b/etc/inc/captiveportal.inc
@@ -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();
}
OpenPOWER on IntegriCloud