From 1b935b8776d69db6e7cbdd4b96cb4e463eff5cdf Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Sat, 1 Apr 2023 00:20:40 +0700 Subject: [PATCH] Fixed Binary-unsafe 'fopen(...)' usage (#84) --- admin/admin_attachments.php | 4 ++-- library/includes/classes/emailer.php | 2 +- library/includes/functions_atom.php | 2 +- library/includes/functions_torrent.php | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/admin/admin_attachments.php b/admin/admin_attachments.php index 3d0d9335..be730ef2 100644 --- a/admin/admin_attachments.php +++ b/admin/admin_attachments.php @@ -252,7 +252,7 @@ if ($check_upload) if (!$error) { - if ( !($fp = @fopen($upload_dir . '/0_000000.000', 'w')) ) + if ( !($fp = @fopen($upload_dir . '/0_000000.000', 'wb')) ) { $error = TRUE; $error_msg = sprintf($lang['DIRECTORY_NOT_WRITEABLE'], $attach_config['upload_dir']) . '
'; @@ -441,7 +441,7 @@ if ($check_image_cat) if (!$error) { - if ( !($fp = @fopen($upload_dir . '/0_000000.000', 'w')) ) + if ( !($fp = @fopen($upload_dir . '/0_000000.000', 'wb')) ) { $error = TRUE; $error_msg = sprintf($lang['DIRECTORY_NOT_WRITEABLE'], $upload_dir) . '
'; diff --git a/library/includes/classes/emailer.php b/library/includes/classes/emailer.php index 7b031387..bda92f41 100644 --- a/library/includes/classes/emailer.php +++ b/library/includes/classes/emailer.php @@ -110,7 +110,7 @@ class emailer } } - if (!($fd = @fopen($tpl_file, 'r'))) + if (!($fd = @fopen($tpl_file, 'rb'))) { bb_die('Failed opening template file :: ' . $tpl_file); } diff --git a/library/includes/functions_atom.php b/library/includes/functions_atom.php index 0c3c4f2e..7583f6e1 100644 --- a/library/includes/functions_atom.php +++ b/library/includes/functions_atom.php @@ -179,7 +179,7 @@ function create_atom ($file_path, $mode, $id, $title, $topics) } $atom .= ""; @unlink($file_path); - $fp = fopen($file_path, "w"); + $fp = fopen($file_path, "wb"); fwrite($fp, $atom); fclose ($fp); return true; diff --git a/library/includes/functions_torrent.php b/library/includes/functions_torrent.php index 6c047219..721d6633 100644 --- a/library/includes/functions_torrent.php +++ b/library/includes/functions_torrent.php @@ -268,7 +268,7 @@ function tracker_register ($attach_id, $mode = '', $tor_status = TOR_NOT_APPROVE if ($bb_cfg['bt_disable_dht']) { $tor['info']['private'] = (int) 1; - $fp = fopen($filename, 'w+'); + $fp = fopen($filename, 'wb+'); fwrite ($fp, bencode($tor)); fclose ($fp); }