summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorjim-p <jimp@pfsense.org>2015-12-15 15:14:21 -0500
committerjim-p <jimp@pfsense.org>2015-12-15 15:14:21 -0500
commit84b128b600ca1062b30732d09987031f38e8e4df (patch)
tree0c3818887a3f5438b22d5ea6e5cd6aa2acbe08e8 /src
parentc6c599f6319230a22d7f9a8fcca69e364bbbc068 (diff)
downloadpfsense-84b128b600ca1062b30732d09987031f38e8e4df.zip
pfsense-84b128b600ca1062b30732d09987031f38e8e4df.tar.gz
Fix handling of 0-byte files uploaded to the CP file manager.
Diffstat (limited to 'src')
-rw-r--r--src/etc/inc/captiveportal.inc6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/etc/inc/captiveportal.inc b/src/etc/inc/captiveportal.inc
index daec9b5..6be3ba4 100644
--- a/src/etc/inc/captiveportal.inc
+++ b/src/etc/inc/captiveportal.inc
@@ -1518,7 +1518,11 @@ 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;
}
OpenPOWER on IntegriCloud