From 4d60f2b270d37f9dd11b34aaf4d8839c03233873 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 30 Apr 2014 10:30:36 -0400 Subject: [PATCH] Fix inifinite loop on well formed and malformed multirecrd areas There were mistakes in the parsing of multirecord IPMI fru area. Most critically, the index never advanced. Additionally, ensure that the index always increases and check against the length of the structure so that a malformed area would not send our parser into an infinite loop. --- xCAT-server/lib/xcat/plugins/ipmi.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index bac6e2880..61d6b5582 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -2971,12 +2971,13 @@ sub parsefru { my $currsize; if ($bytes->[$curridx] <= 5) { #don't even try to parse unknown stuff #some records don't comply to any SPEC - while (not $last) { + while (not $last and $curridx < (scalar @$bytes)) { if ($bytes->[$curridx+1] & 128) { $last=1; } $currsize=$bytes->[$curridx+2]; - push @{$fruhash->{extra}},$bytes->[$curridx..$curridx+4+$currsize-1]; + push @{$fruhash->{extra}},@{$bytes}[$curridx..$curridx+4+$currsize-1]; + $curridx += 5 + $currsize; } } }