Blame SOURCES/0004-fix-Error-CONSTANT_EXPRESSION_RESULT-detected-by-cov.patch

b52212
From ea6cd1d0b631da5bf64b2b0ab7c5e1d4e0e95562 Mon Sep 17 00:00:00 2001
b52212
From: Coiby Xu <coiby.xu@gmail.com>
b52212
Date: Tue, 15 Jun 2021 10:47:03 +0800
b52212
Subject: [PATCH 4/8] fix Error: CONSTANT_EXPRESSION_RESULT detected by covscan
b52212
b52212
This commit fixes the following error found by conscan,
b52212
b52212
    Error: CONSTANT_EXPRESSION_RESULT (CWE-569): [#def1]
b52212
    python-dmidecode-3.12.2/src/dmidecode.c:225: logical_vs_bitwise: The expression "16 && i < h->length - (row << 4)" is suspicious because it performs a Boolean operation on a constant other than 0 or 1.
b52212
    #  223|                   memset(tmp_s, 0, (h->length * 2) + 2);
b52212
    #  224|
b52212
    #  225|->                 for(i = 0; i < (16 && i < h->length - (row << 4)); i++) {
b52212
    #  226|                           snprintf(tmp_s + strlen(tmp_s), (h->length * 2)-strlen(tmp_s),
b52212
    #  227|                                    "0x%02x", (h->data)[(row << 4) + i]);
b52212
b52212
Signed-off-by: Coiby Xu <coiby.xu@gmail.com>
b52212
---
b52212
 src/dmidecode.c | 2 +-
b52212
 1 file changed, 1 insertion(+), 1 deletion(-)
b52212
b52212
diff --git a/src/dmidecode.c b/src/dmidecode.c
b52212
index d2bed53..9efab60 100644
b52212
--- a/src/dmidecode.c
b52212
+++ b/src/dmidecode.c
b52212
@@ -222,7 +222,7 @@ void dmi_dump(xmlNode *node, struct dmi_header * h)
b52212
         for(row = 0; row < ((h->length - 1) >> 4) + 1; row++) {
b52212
                 memset(tmp_s, 0, (h->length * 2) + 2);
b52212
 
b52212
-                for(i = 0; i < (16 && i < h->length - (row << 4)); i++) {
b52212
+                for(i = 0; i < 16 && (i < h->length - (row << 4)); i++) {
b52212
                         snprintf(tmp_s + strlen(tmp_s), (h->length * 2)-strlen(tmp_s),
b52212
                                  "0x%02x", (h->data)[(row << 4) + i]);
b52212
                 }
b52212
-- 
b52212
2.31.1
b52212