- 追加された行はこの色です。
- 削除された行はこの色です。
#author("2022-12-24T13:58:01+09:00","default:user","user")
#author("2022-12-27T23:47:08+09:00","","")
* auth.php: PHP8.0で必須になったcryptの$saltが指定されていない場所がある [#d96b8cb3]
- ページ: [[BugTrack]]
- 投稿者: [[ぬぺぺ]]
- 優先順位: 低
- 状態: 提案
- カテゴリー: 本体バグ
- 投稿日: 2022-12-24 (土) 10:47:59
- バージョン: 1.5.4
** メッセージ [#ba699333]
PHP8.0でcrypt関数の$salt引数はオプションではなくなり必須になったらしいのですが、
auth.phpで省略されたままです。
参考:https://www.php.net/manual/ja/function.crypt.php
あまり読み込んでないのでどういう意図の記述なのかは理解しきれてないのですが…~
とりあえず、pukiwiki.ini.phpでのパスワードの定義で
$adminpass = '{x-php-crypt}' . '';
というようにすると、凍結などの管理者パスワードを入力したあとのパスワードチェックの処理で
Fatal error: Uncaught ArgumentCountError: crypt() expects exactly 2 arguments, 1 given in /**/lib/auth.php:67 Stack trace: ~~ #6 {main} thrown in /**/lib/auth.php on line 67
となります。
***対処法案 [#e70b94d9]
($salt != '' ? crypt($phrase, $salt) : crypt($phrase))
となっていますが、どうせ空文字列なんですしそのまま
(crypt($phrase, $salt))
でいいんじゃないでしょうか。
PHP5とPHP7の環境(Wandbox)で適当に確認しましたが、引数を渡さない場合と空文字列を渡した場合は同じ結果になるみたいです。
in
$br = "\n";
echo "crypt('qwerty'): " . crypt('qwerty') . $br;
echo "crypt('qwerty'): " . crypt('qwerty') . $br;
echo "crypt('qwerty', ''): " . crypt('qwerty', '') . $br;
echo "crypt('qwerty', ''): " . crypt('qwerty', '') . $br;
echo "crypt('qwerty', null): " . crypt('qwerty', null) . $br;
echo "crypt('qwerty', null): " . crypt('qwerty', null) . $br;
echo "crypt('qwerty', 'qw'): " . crypt('qwerty', 'qw') . $br;
echo "crypt('qwerty', 'qw'): " . crypt('qwerty', 'qw') . $br;
out
crypt('qwerty'): $1$nZuf80oX$ydbPyJRKp69Dj15Pm5j8n/
crypt('qwerty'): $1$Ks0/OT4J$iVB.NzaDBYI5qijc2gROI.
crypt('qwerty', ''): $1$oapwvXW6$7vbEIIA.emSYB.FXoCKWh1
crypt('qwerty', ''): $1$7/Rg8h7Z$c8BSuNj.drF1hzHzc83Lt.
crypt('qwerty', null): $1$FxaVjEZR$3qKqcnsYYefTcCC0chC0D0
crypt('qwerty', null): $1$8bdqDZ5v$dB4nj4wJjuC3SFsNIZKqV.
crypt('qwerty', 'qw'): qwDyM1db9iOPI
crypt('qwerty', 'qw'): qwDyM1db9iOPI
なお、PHP8ではcrypt("~", '')は文字列'*0'を返すようです
in
$br = "\n";
echo "crypt('qwerty', ''): " . crypt('qwerty', '') . $br;
echo "crypt('qwerty', ''): " . crypt('qwerty', '') . $br;
out
crypt('qwerty', ''): *0
crypt('qwerty', ''): *0
--------
- 空文字列だったらdieしてもいいような気もします -- [[ぬぺぺ]] &new{2022-12-27 (火) 23:47:08};
#comment