2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-05-01 00:19:00 +00:00

00_FBAHAHTTP.pm: Possible fix for execution denial (Forum #95913)

git-svn-id: https://svn.fhem.de/fhem/trunk@18400 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2019-01-24 13:57:31 +00:00
parent 62899b14d6
commit 90017e622f

View File

@ -70,9 +70,9 @@ FBAHAHTTP_Delete($)
} }
sub sub
FBAHAHTTP_connect($) FBAHAHTTP_connect($$)
{ {
my ($hash) = @_; my ($hash, $doProcess) = @_;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
my $dev = $hash->{DEF}; my $dev = $hash->{DEF};
@ -103,6 +103,7 @@ FBAHAHTTP_connect($)
$hash->{".SID"} = $sid; $hash->{".SID"} = $sid;
$hash->{STATE} = "connected"; $hash->{STATE} = "connected";
Log3 $name, 4, "FBAHAHTTP_connect $name: got SID $sid"; Log3 $name, 4, "FBAHAHTTP_connect $name: got SID $sid";
FBAHAHTTP_ProcessStack($hash) if($doProcess && int(@{$hash->{CmdStack}}));
return undef; return undef;
} }
@ -129,7 +130,7 @@ FBAHAHTTP_Poll($)
return if(IsDisabled($name)); return if(IsDisabled($name));
if(!$hash->{".SID"}) { if(!$hash->{".SID"}) {
my $ret = FBAHAHTTP_connect($hash); my $ret = FBAHAHTTP_connect($hash, 0);
return $ret if($ret); return $ret if($ret);
} }
my $sid = $hash->{".SID"}; my $sid = $hash->{".SID"};
@ -242,14 +243,16 @@ FBAHAHTTP_ProcessStack($)
return; return;
} }
Log3 $name, 5, "FBAHAHTTP_Write reply for $name: $_[2]"; my $ret = (defined($_[2]) ? $_[2] : "") ;
if(!defined($_[2]) || $_[2] eq "") { $ret =~ s/[\r\n]//g;
Log3 $name, 5, "FBAHAHTTP_Write reply for $name: $ret";
if($ret eq "") {
if($hash->{RetriedCmd}) { if($hash->{RetriedCmd}) {
Log3 $name, 1, "No sensible respone after reconnect, giving up"; Log3 $name, 1, "No sensible respone after reconnect, giving up";
$hash->{CmdStack} = (); $hash->{CmdStack} = ();
return; return;
} }
return if(FBAHAHTTP_connect($hash)); return if(FBAHAHTTP_connect($hash, 0));
$hash->{RetriedCmd} = $msg; $hash->{RetriedCmd} = $msg;
FBAHAHTTP_ProcessStack($hash); FBAHAHTTP_ProcessStack($hash);
return; return;
@ -278,7 +281,7 @@ FBAHAHTTP_Write($$$)
my $sid = $hash->{".SID"}; my $sid = $hash->{".SID"};
if(!$sid) { if(!$sid) {
my $ret = FBAHAHTTP_connect($hash); # try to reconnect my $ret = FBAHAHTTP_connect($hash, 1); # try to reconnect
return $ret if($ret); return $ret if($ret);
$sid = $hash->{".SID"}; $sid = $hash->{".SID"};
} }