From edb505b8c0e560c1e85f6bb3d608539142c3dbfe Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Thu, 11 Aug 2011 13:36:25 +0200 Subject: [PATCH] Off-by-one(two) error in form factor detection Indexing of chassis_map array has to be done like that: chassis_map[chassis_type * 2 - 1] because if not, everything is shifted by one. When (e.g.) chassis_type is 0x04 result should be "Low Profile Desktop" => "desktop" (not a "Pizza Box" => "server"). Lets see the 2.6.1 document on: http://www.dmtf.org/standards/smbios --- plugins/formfactor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/formfactor.c b/plugins/formfactor.c index 33a8b32cd..3b3192778 100644 --- a/plugins/formfactor.c +++ b/plugins/formfactor.c @@ -104,7 +104,7 @@ static int formfactor_probe(struct btd_adapter *adapter) return 0; } - formfactor = chassis_map[chassis_type * 2 + 1]; + formfactor = chassis_map[chassis_type * 2 - 1]; if (formfactor != NULL) { if (g_str_equal(formfactor, "laptop") == TRUE) minor |= (1 << 2) | (1 << 3); -- 2.47.3