Fix client simulation

In `create_client_simulation_tls_clienthello()` the variable `sni_extension_found` should be set if the ClientHello includes an SNI extension. Instead it was being set if and only if the ClientHello included some extension other than SNI.

This bug wasn't detected before for two reasons:

* It is rare to have a ClientHello that includes an SNI extension, but no other extensions.

* The code still works correctly if `sni_extension_found` is set even if there is no SNI in the ClientHello.

So, the bug only creates a problem if the browser's ClientHello include an SNI extension and no other extensions (see "BingPreview Jun 2014" in the client_simulation branch).
This commit is contained in:
David Cooper 2017-03-24 11:37:06 -04:00 committed by GitHub
parent 3514c9d98d
commit 9a86825ec2
1 changed files with 19 additions and 17 deletions

View File

@ -3394,12 +3394,13 @@ create_client_simulation_tls_clienthello() {
if [[ "$extension_type" != "0000" ]]; then if [[ "$extension_type" != "0000" ]]; then
# The extension will just be copied into the revised ClientHello # The extension will just be copied into the revised ClientHello
sni_extension_found=true
offset=$offset-4 offset=$offset-4
len=$len_extension+8 len=$len_extension+8
tls_extensions+="${tls_handshake_ascii:$offset:$len}" tls_extensions+="${tls_handshake_ascii:$offset:$len}"
offset=$offset+$len offset=$offset+$len
elif [[ -n "$SNI" ]]; then else
sni_extension_found=true
if [[ -n "$SNI" ]]; then
# Create a server name extension that corresponds to $SNI # Create a server name extension that corresponds to $SNI
len_servername=${#NODE} len_servername=${#NODE}
hexdump_format_str="$len_servername/1 \"%02x\"" hexdump_format_str="$len_servername/1 \"%02x\""
@ -3411,6 +3412,7 @@ create_client_simulation_tls_clienthello() {
tls_extensions+="000000${len_sni_ext}00${len_sni_listlen}0000${len_servername_hex}${servername_hexstr}" tls_extensions+="000000${len_sni_ext}00${len_sni_listlen}0000${len_servername_hex}${servername_hexstr}"
offset=$offset+$len_extension+4 offset=$offset+$len_extension+4
fi fi
fi
done done
if ! $sni_extension_found; then if ! $sni_extension_found; then