From bbd5d5633abfb070ed40b8452808029cc775f02a Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Thu, 6 Dec 2012 17:05:15 +0100 Subject: [PATCH] Fixed logic error in pci_open() Previously, pci_open() sometimes crashed with ID list names shorter than 3 characters. --- lib/names-parse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/names-parse.c b/lib/names-parse.c index 58ab578..4997b58 100644 --- a/lib/names-parse.c +++ b/lib/names-parse.c @@ -30,7 +30,7 @@ static pci_file pci_open(struct pci_access *a) if (result) return result; len = strlen(a->id_file_name); - if (len >= 3 && memcmp(a->id_file_name + len - 3, ".gz", 3) != 0) + if (len < 3 || memcmp(a->id_file_name + len - 3, ".gz", 3) != 0) return result; new_name = malloc(len - 2); memcpy(new_name, a->id_file_name, len - 3); -- 2.39.2