From d6ce28f9549930199bc45376cc0185d2aa4ee218 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 12 Aug 2013 16:04:08 -0400 Subject: [PATCH] Fix ipmi FRU parser to give up once malformed data is encountered --- xCAT-server/lib/xcat/plugins/ipmi.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index 8126558c8..880b08c9f 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -2772,6 +2772,7 @@ sub parseprod { } $idx+=$currsize; ($currsize,$currdata,$encode)=extractfield(\@area,$idx); + if ($currsize < 0) { last } } return \%info; @@ -2844,6 +2845,7 @@ sub parseboard { } $idx+=$currsize; ($currsize,$currdata,$encode)=extractfield(\@area,$idx); + if ($currsize < 0) { last } } if ($global_sessdata->{isanimm}) { #we can understand more specifically some of the extra fields... $boardinf{frunum}=$boardinf{extra}->[0]->{value}; @@ -2908,6 +2910,7 @@ sub parsechassis { } $idx+=$currsize; ($currsize,$currdata,$encode)=extractfield(\@chassarea,$idx); + if ($currsize < 0) { last } } return \%chassisinf; } @@ -2919,7 +2922,7 @@ sub extractfield { #idx is location of the type/length byte, returns something a my $data; if ($idx >= scalar @$area) { xCAT::SvrUtils::sendmsg([1,"Error parsing FRU data from BMC"],$callback); - return 1,undef,undef; + return -1,undef,undef; } my $size = $area->[$idx] & 0b00111111; my $encoding = ($area->[$idx] & 0b11000000)>>6;