]> www.infradead.org Git - users/mchehab/rasdaemon.git/commitdiff
rasdaemon: Fix for a memory out-of-bounds issue and optimized code to remove duplicat...
authorShiju Jose <shiju.jose@huawei.com>
Thu, 28 Apr 2022 21:59:04 +0000 (22:59 +0100)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Sat, 21 Jan 2023 06:30:38 +0000 (07:30 +0100)
Fixed a memory out-of-bounds issue with string pointers and
optimized code structure to remove duplicate function.

Signed-off-by: Lei Feng <fenglei47@h-partners.com>
Signed-off-by: Shiju Jose <shiju.jose@huawei.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
non-standard-hisi_hip08.c
non-standard-hisilicon.c
ras-non-standard-handler.c

index 90921834397fe8bedb8a6494c6e27b4ed6fd5686..4ef47ea6b962e3b7d22468027729ea774ceb1058 100644 (file)
@@ -1014,15 +1014,15 @@ static int decode_hip08_pcie_local_error(struct ras_events *ras,
 
 static struct ras_ns_ev_decoder hip08_ns_ev_decoder[] = {
        {
-               .sec_type = "1f8161e155d641e6bd107afd1dc5f7c5",
+               .sec_type = "1f8161e1-55d6-41e6-bd10-7afd1dc5f7c5",
                .decode = decode_hip08_oem_type1_error,
        },
        {
-               .sec_type = "45534ea6ce2341158535e07ab3aef91d",
+               .sec_type = "45534ea6-ce23-4115-8535-e07ab3aef91d",
                .decode = decode_hip08_oem_type2_error,
        },
        {
-               .sec_type = "b2889fc9e7d74f9da867af42e98be772",
+               .sec_type = "b2889fc9-e7d7-4f9d-a867-af42e98be772",
                .decode = decode_hip08_pcie_local_error,
        },
 };
index d1e1774c83d84c6b91532f8824b10a6c0af57e07..6ee92711aa3616df07847381dd9af6e8ac60e4c8 100644 (file)
@@ -387,7 +387,7 @@ static int decode_hisi_common_section(struct ras_events *ras,
 
 static struct ras_ns_ev_decoder hisi_section_ns_ev_decoder[]  = {
        {
-               .sec_type = "c8b328a899174af69a132e08ab2e7586",
+               .sec_type = "c8b328a8-9917-4af6-9a13-2e08ab2e7586",
                .decode = decode_hisi_common_section,
        },
 };
index 6d5a6f8259791a3afd4ec0c82dcee4002685862f..6932e581245bc9c543cc235523d5c494842a049d 100644 (file)
@@ -52,20 +52,6 @@ static char *uuid_le(const char *uu)
        return uuid;
 }
 
-static int uuid_le_cmp(const char *sec_type, const char *uuid2)
-{
-       static char uuid1[32];
-       char *p = uuid1;
-       int i;
-       static const unsigned char le[16] = {
-                       3, 2, 1, 0, 5, 4, 7, 6, 8, 9, 10, 11, 12, 13, 14, 15};
-
-       for (i = 0; i < 16; i++)
-               p += sprintf(p, "%.2x", (unsigned char) sec_type[le[i]]);
-       *p = 0;
-       return strncmp(uuid1, uuid2, 32);
-}
-
 int register_ns_ev_decoder(struct ras_ns_ev_decoder *ns_ev_decoder)
 {
        struct ras_ns_ev_decoder *list;
@@ -96,7 +82,7 @@ static int find_ns_ev_decoder(const char *sec_type, struct ras_ns_ev_decoder **p
 
        ns_ev_decoder = ras_ns_ev_dec_list;
        while (ns_ev_decoder) {
-               if (uuid_le_cmp(sec_type, ns_ev_decoder->sec_type) == 0) {
+               if (strcmp(uuid_le(sec_type), ns_ev_decoder->sec_type) == 0) {
                        *p_ns_ev_dec = ns_ev_decoder;
                        match  = 1;
                        break;