summaryrefslogtreecommitdiff
path: root/src/libcharon/plugins/vici/perl
diff options
context:
space:
mode:
authorYves-Alexis Perez <corsac@debian.org>2018-06-04 09:59:21 +0200
committerYves-Alexis Perez <corsac@debian.org>2018-06-04 09:59:21 +0200
commit51a71ee15c1bcf0e82f363a16898f571e211f9c3 (patch)
tree2a03e117d072c55cfe2863d26b73e64d933e7ad8 /src/libcharon/plugins/vici/perl
parent7793611ee71b576dd9c66dee327349fa64e38740 (diff)
downloadvyos-strongswan-51a71ee15c1bcf0e82f363a16898f571e211f9c3.tar.gz
vyos-strongswan-51a71ee15c1bcf0e82f363a16898f571e211f9c3.zip
New upstream version 5.6.3
Diffstat (limited to 'src/libcharon/plugins/vici/perl')
-rw-r--r--src/libcharon/plugins/vici/perl/Vici-Session/lib/Vici/Transport.pm23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/libcharon/plugins/vici/perl/Vici-Session/lib/Vici/Transport.pm b/src/libcharon/plugins/vici/perl/Vici-Session/lib/Vici/Transport.pm
index 6524bf76d..b0a7b6285 100644
--- a/src/libcharon/plugins/vici/perl/Vici-Session/lib/Vici/Transport.pm
+++ b/src/libcharon/plugins/vici/perl/Vici-Session/lib/Vici/Transport.pm
@@ -22,12 +22,27 @@ sub send {
sub receive {
my $self = shift;
my $packet_header;
- my $data;
- $self->{'Socket'}->recv($packet_header, 4);
+ $packet_header = $self->_recv_all(4);
my $packet_len = unpack('N', $packet_header);
- $self->{'Socket'}->recv($data, $packet_len);
- return $data;
+ return $self->_recv_all($packet_len);
+}
+
+sub _recv_all {
+ my ($self, $len) = @_;
+ my $data;
+
+ while ($len)
+ {
+ my $buf;
+ unless (defined $self->{'Socket'}->recv($buf, $len))
+ {
+ die "error reading from socket\n";
+ }
+ $len -= length($buf);
+ $data .= $buf;
+ }
+ return $data;
}
1;