1 | #!/usr/bin/env bash
|
---|
2 |
|
---|
3 | input=$(mktemp)
|
---|
4 | binary=$(mktemp)
|
---|
5 |
|
---|
6 | trap "rm -f $input $binary" EXIT
|
---|
7 |
|
---|
8 | function sseq()
|
---|
9 | {
|
---|
10 | for ((i = $1; i < $2; i=i<<1)); do
|
---|
11 | echo $i
|
---|
12 | done
|
---|
13 | }
|
---|
14 |
|
---|
15 | function do_base64()
|
---|
16 | {
|
---|
17 | if [ -n "$(type -p base64)" ]; then
|
---|
18 | base64 $1
|
---|
19 | elif [ -n "$(type -p uuencode)" ]; then
|
---|
20 | uuencode -m $1 data | sed 1d | sed '$d'
|
---|
21 | else
|
---|
22 | echo "No tool found for base64 encoding." >&2
|
---|
23 | exit 1
|
---|
24 | fi
|
---|
25 | }
|
---|
26 |
|
---|
27 | for i in $(sseq 1 1024) 2048 10240;
|
---|
28 | do
|
---|
29 | echo $i
|
---|
30 | dd if=/dev/urandom of=$binary bs=1 count=$i &>/dev/null
|
---|
31 | echo "-----BEGIN INITSTATE-----" > $input
|
---|
32 | do_base64 $binary >> $input
|
---|
33 | echo "-----END INITSTATE-----" >> $input
|
---|
34 | ./base64decode $input $binary
|
---|
35 | if [ $? -ne 0 ]; then
|
---|
36 | exit 1
|
---|
37 | fi
|
---|
38 | done
|
---|