0
0

More than 1 year has passed since last update.

PHPでNullバイトアタック対策

Posted at

 新年初めてのコード書き始めを行っていて。とりあえず、PHPのNullチェックを作ってみた

class Secure {
    // Null Byte Check.
    public function sanitizer($arr) {
        array_walk_recursive($arr, function($val, $key) {
            if (preg_match('/\0/', $val) === 1) {
                // エラー処理.
            }
        });
    }
}

 良くある、array_mapのルーチンよりかはスマートかと。「Nullバイトがあるデータがあるのが変なので、そのデータは弾け」おじさんが居たので、そう実装してみました。手動で簡単なテストもしてます

 今年も、よろしくお願いします:blush:

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0