From: Andy Polyakov Date: Mon, 16 Apr 2018 12:08:35 +0000 (+0200) Subject: TLSProxy/Record.pm: add is_fatal_alert method. X-Git-Tag: OpenSSL_1_1_1-pre6~89 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=3f1f62b97b795d973d40c32735eedee70140731c;p=oweals%2Fopenssl.git TLSProxy/Record.pm: add is_fatal_alert method. (resolve uninitialized variable warning and harmonize output). Reviewed-by: Richard Levitte (Merged from https://github.com/openssl/openssl/pull/5975) --- diff --git a/util/perl/TLSProxy/Record.pm b/util/perl/TLSProxy/Record.pm index 49a0084d36..8ff948b82f 100644 --- a/util/perl/TLSProxy/Record.pm +++ b/util/perl/TLSProxy/Record.pm @@ -67,17 +67,13 @@ sub get_records my $recnum = 1; while (length ($packet) > 0) { - print " Record $recnum"; - if ($server) { - print " (server -> client)\n"; - } else { - print " (client -> server)\n"; - } + print " Record $recnum ", $server ? "(server -> client)\n" + : "(client -> server)\n"; #Get the record header (unpack can't fail if $packet is too short) my ($content_type, $version, $len) = unpack('Cnn', $packet); - if (length($packet) < TLS_RECORD_HEADER_LENGTH + $len) { + if (length($packet) < TLS_RECORD_HEADER_LENGTH + ($len // 0)) { print "Partial data : ".length($packet)." bytes\n"; $partial = $packet; last; @@ -389,4 +385,16 @@ sub outer_content_type } return $self->{outer_content_type}; } +sub is_fatal_alert +{ + my $self = shift; + my $server = shift; + + if (($self->{flight} & 1) == $server + && $self->{content_type} == TLSProxy::Record::RT_ALERT) { + my ($level, $alert) = unpack('CC', $self->decrypt_data); + return $alert if ($level == 2); + } + return 0; +} 1;