Skip to content

Instantly share code, notes, and snippets.

View alexdowad's full-sized avatar

Alex Dowad alexdowad

View GitHub Profile
View config.fuzz
#!/bin/sh
CFLAGS='-g' LDFLAGS='-v' CC=clang CXX=clang++ \
./configure \
--disable-all \
--enable-fuzzer \
--with-pic \
--enable-debug-assertions \
--enable-undefined-sanitizer \
--enable-address-sanitizer \
@alexdowad
alexdowad / bench_detect_encoding.php
Created March 18, 2023 08:46
Script for benchmarking mb_detect_encoding
View bench_detect_encoding.php
<?php
$path = explode('/', readlink('/proc/self/exe'));
$GLOBALS['commit'] = str_replace('php-', '', array_pop($path));
$GLOBALS['iterations_per_test'] = 5000;
function bench($func, $arg, $iterations) {
$t1 = microtime(true);
while ($iterations-- > 0) {
$func($arg);
@alexdowad
alexdowad / bench_check_encoding.php
Created March 18, 2023 08:38
Script for benchmarking mb_check_encoding
View bench_check_encoding.php
<?php
$path = explode('/', readlink('/proc/self/exe'));
$GLOBALS['commit'] = str_replace('php-', '', array_pop($path));
$GLOBALS['iterations_per_test'] = 10000;
function bench($func, $arg, $iterations) {
$t1 = microtime(true);
while ($iterations-- > 0) {
$func($arg);
@alexdowad
alexdowad / mbstring_fuzz.rb
Created November 24, 2021 12:06
Little bare-bones fuzzer for text conversion via PHP's mbstring library
View mbstring_fuzz.rb
#!/usr/bin/env ruby
$oldphp = File.join(__dir__, '../../sapi/cli/php-9308974f8c')
$newphp = File.join(__dir__, '../../sapi/cli/php-a14a5ef07f')
require 'fileutils'
include FileUtils
# UTF-8
encodings = %w{UTF-7 UTF-16 UTF-16BE UTF-16LE UTF-32 UTF-32BE UTF-32LE UCS-2 UCS-2BE UCS-2LE UCS-4 UCS-4BE UCS-4LE SJIS ISO-2022-JP EUC-JP}