diff options
author | Sebastian Hahn <sebastian@torproject.org> | 2015-02-07 14:54:21 +0100 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2015-02-11 15:59:34 -0500 |
commit | 6ecd6e27dab79f7b6ee913edca1bec219f1cd2a0 (patch) | |
tree | 1d9f09cca40fd7f09150e114984a95e4e0b31d88 /src/test | |
parent | 0a0c5d7c0e6d45789f4351c0b56511c80f13eaa0 (diff) | |
download | tor-6ecd6e27dab79f7b6ee913edca1bec219f1cd2a0.tar.gz tor-6ecd6e27dab79f7b6ee913edca1bec219f1cd2a0.zip |
Avoid undefined behaviour of test
Fixes part of bug #14478, patch idea suggested by an anonymous
contributor. Thanks!
Diffstat (limited to 'src/test')
-rwxr-xr-x | src/test/zero_length_keys.sh | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/test/zero_length_keys.sh b/src/test/zero_length_keys.sh index 0dd67c1780..cd1b60d065 100755 --- a/src/test/zero_length_keys.sh +++ b/src/test/zero_length_keys.sh @@ -30,7 +30,8 @@ if [ -z "$DATA_DIR" ]; then echo "Failure: mktemp invocation returned empty string" exit 255 fi -if [ -d "$DATA_DIR" ]; then +if [ ! -d "$DATA_DIR" ]; then + echo "$DATA_DIR" echo "Failure: mktemp invocation result doesn't point to directory" exit 255 fi @@ -40,7 +41,8 @@ trap "rm -rf '$DATA_DIR'" 0 # 'ExitRelay 0' suppresses a warning. TOR="./src/or/tor --hush --DisableNetwork 1 --ShutdownWaitLength 0 --ORPort 12345 --ExitRelay 0" -if [ -s "$DATA_DIR"/keys/secret_id_key -a -s "$DATA_DIR"/keys/secret_onion_key -a -s "$DATA_DIR"/keys/secret_onion_key_ntor ]; then +if [ -s "$DATA_DIR"/keys/secret_id_key ] && [ -s "$DATA_DIR"/keys/secret_onion_key ] && + [ -s "$DATA_DIR"/keys/secret_onion_key_ntor ]; then echo "Failure: Previous tor keys present in tor data directory" exit 255 else @@ -53,7 +55,8 @@ else wait $TOR_PID # tor must successfully generate non-zero-length key files - if [ -s "$DATA_DIR"/keys/secret_id_key -a -s "$DATA_DIR"/keys/secret_onion_key -a -s "$DATA_DIR"/keys/secret_onion_key_ntor ]; then + if [ -s "$DATA_DIR"/keys/secret_id_key ] && [ -s "$DATA_DIR"/keys/secret_onion_key ] && + [ -s "$DATA_DIR"/keys/secret_onion_key_ntor ]; then true #echo "tor generated the initial key files" else echo "Failure: tor failed to generate the initial key files" @@ -96,7 +99,8 @@ wait $TOR_PID #ls -lh "$DATA_DIR"/keys/ || exit 255 # tor must always have non-zero-length key files -if [ -s "$DATA_DIR"/keys/secret_id_key -a -s "$DATA_DIR"/keys/secret_onion_key -a -s "$DATA_DIR"/keys/secret_onion_key_ntor ]; then +if [ -s "$DATA_DIR"/keys/secret_id_key ] && [ -s "$DATA_DIR"/keys/secret_onion_key ] && + [ -s "$DATA_DIR"/keys/secret_onion_key_ntor ]; then # check if the keys are different to the old ones diff -q -r "$DATA_DIR"/keys "$DATA_DIR"/keys.old > /dev/null SAME_KEYS=$? |