git: 718e4558933b - main - sysutils/dmidecode: Fix segmentation fault in dmi_hp_240_attr()

From: Mateusz Piotrowski <0mp_at_FreeBSD.org>
Date: Fri, 16 Sep 2022 13:04:54 UTC
The branch main has been updated by 0mp:

URL: https://cgit.FreeBSD.org/ports/commit/?id=718e4558933b64d71a2491a20fea337a8ec76d9b

commit 718e4558933b64d71a2491a20fea337a8ec76d9b
Author:     Mateusz Piotrowski <0mp@FreeBSD.org>
AuthorDate: 2022-09-16 12:51:28 +0000
Commit:     Mateusz Piotrowski <0mp@FreeBSD.org>
CommitDate: 2022-09-16 12:51:28 +0000

    sysutils/dmidecode: Fix segmentation fault in dmi_hp_240_attr()
    
    Back port a patch from the dmidecode upsteam that resolves a crash when
    reading the Attribute #240 on some HP hardware.
    
    See
    https://git.savannah.nongnu.org/cgit/dmidecode.git/commit/?id=c3357b532941a8df387618e692e522cc7a43b3e8
    
    Approved by:    portmgr blanket
    Sponsored by:   Klara Inc.
---
 sysutils/dmidecode/Makefile             |  2 +-
 sysutils/dmidecode/files/patch-dmioem.c | 21 +++++++++++++++++++--
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/sysutils/dmidecode/Makefile b/sysutils/dmidecode/Makefile
index d3c39e4e3381..b8e0575986e4 100644
--- a/sysutils/dmidecode/Makefile
+++ b/sysutils/dmidecode/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	dmidecode
 PORTVERSION=	3.4
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	sysutils
 MASTER_SITES=	SAVANNAH
 
diff --git a/sysutils/dmidecode/files/patch-dmioem.c b/sysutils/dmidecode/files/patch-dmioem.c
index 21d4ec2e5b5c..4726367ec947 100644
--- a/sysutils/dmidecode/files/patch-dmioem.c
+++ b/sysutils/dmidecode/files/patch-dmioem.c
@@ -2,7 +2,24 @@ Obtained from:	https://git.savannah.gnu.org/cgit/dmidecode.git/commit/?id=a1a225
 
 --- dmioem.c.orig	2022-06-27 15:06:32 UTC
 +++ dmioem.c
-@@ -299,6 +299,96 @@ static void dmi_hp_203_devloc(const char *fname, unsig
+@@ -198,13 +198,14 @@ static void dmi_hp_240_attr(u64 defined, u64 set)
+ 	};
+ 	unsigned int i;
+ 
+-	pr_attr("Attributes Defined/Set", NULL);
++	pr_list_start("Attributes Defined/Set", NULL);
+ 	for (i = 0; i < ARRAY_SIZE(attributes); i++)
+ 	{
+ 		if (!(defined.l & (1UL << i)))
+ 			continue;
+-		pr_subattr(attributes[i], "%s", set.l & (1UL << i) ? "Yes" : "No");
++		pr_list_item("%s: %s", attributes[i], set.l & (1UL << i) ? "Yes" : "No");
+ 	}
++	pr_list_end();
+ }
+ 
+ static void dmi_hp_203_assoc_hndl(const char *fname, u16 num)
+@@ -299,6 +300,96 @@ static void dmi_hp_203_devloc(const char *fname, unsig
  	pr_attr(fname, "%s", str);
  }
  
@@ -99,7 +116,7 @@ Obtained from:	https://git.savannah.gnu.org/cgit/dmidecode.git/commit/?id=a1a225
  static void dmi_hp_238_loc(const char *fname, unsigned int code)
  {
  	const char *str = "Reserved";
-@@ -597,6 +687,36 @@ static int dmi_decode_hp(const struct dmi_header *h)
+@@ -597,6 +688,36 @@ static int dmi_decode_hp(const struct dmi_header *h)
  			pr_attr("Misc. Features", "0x%08x", feat);
  			pr_subattr("iCRU", "%s", feat & 0x0001 ? "Yes" : "No");
  			pr_subattr("UEFI", "%s", feat & 0x1400 ? "Yes" : "No");