Skip to content

Commit

Permalink
Fixed Binary-unsafe 'fopen(...)' usage (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
belomaxorka authored Mar 31, 2023
1 parent c9bcb37 commit 1b935b8
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions admin/admin_attachments.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@

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']) . '<br />';
Expand Down Expand Up @@ -441,7 +441,7 @@

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) . '<br />';
Expand Down
2 changes: 1 addition & 1 deletion library/includes/classes/emailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function use_template ($template_file, $template_lang = '')
}
}

if (!($fd = @fopen($tpl_file, 'r')))
if (!($fd = @fopen($tpl_file, 'rb')))
{
bb_die('Failed opening template file :: ' . $tpl_file);
}
Expand Down
2 changes: 1 addition & 1 deletion library/includes/functions_atom.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ function create_atom ($file_path, $mode, $id, $title, $topics)
}
$atom .= "</feed>";
@unlink($file_path);
$fp = fopen($file_path, "w");
$fp = fopen($file_path, "wb");
fwrite($fp, $atom);
fclose ($fp);
return true;
Expand Down
2 changes: 1 addition & 1 deletion library/includes/functions_torrent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 1b935b8

Please sign in to comment.