TLSProxy/Record.pm: add is_fatal_alert method.
(resolve uninitialized variable warning and harmonize output).
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5975)
Andy Polyakov
6 years ago
66 | 66 | |
67 | 67 | my $recnum = 1; |
68 | 68 | while (length ($packet) > 0) { |
69 | print " Record $recnum"; | |
70 | if ($server) { | |
71 | print " (server -> client)\n"; | |
72 | } else { | |
73 | print " (client -> server)\n"; | |
74 | } | |
69 | print " Record $recnum ", $server ? "(server -> client)\n" | |
70 | : "(client -> server)\n"; | |
75 | 71 | |
76 | 72 | #Get the record header (unpack can't fail if $packet is too short) |
77 | 73 | my ($content_type, $version, $len) = unpack('Cnn', $packet); |
78 | 74 | |
79 | if (length($packet) < TLS_RECORD_HEADER_LENGTH + $len) { | |
75 | if (length($packet) < TLS_RECORD_HEADER_LENGTH + ($len // 0)) { | |
80 | 76 | print "Partial data : ".length($packet)." bytes\n"; |
81 | 77 | $partial = $packet; |
82 | 78 | last; |
388 | 384 | } |
389 | 385 | return $self->{outer_content_type}; |
390 | 386 | } |
387 | sub is_fatal_alert | |
388 | { | |
389 | my $self = shift; | |
390 | my $server = shift; | |
391 | ||
392 | if (($self->{flight} & 1) == $server | |
393 | && $self->{content_type} == TLSProxy::Record::RT_ALERT) { | |
394 | my ($level, $alert) = unpack('CC', $self->decrypt_data); | |
395 | return $alert if ($level == 2); | |
396 | } | |
397 | return 0; | |
398 | } | |
391 | 399 | 1; |