dmidecode-osx icon indicating copy to clipboard operation
dmidecode-osx copied to clipboard

Assert failure on Ventura

Open mstone2001 opened this issue 1 year ago • 2 comments

When running on macOS Ventura I get the following assertion failure:

dmidecode 3.1

Getting SMBIOS data from Apple SMBIOS service. Assertion failed: (range.location + range.length <= dataLength), function __CFDataValidateRange, file CFData.c, line 235. zsh: abort dmidecode

Tracing this back the root cause was the CFDataRef was 31 bytes instead of 32. Viewing the apple documentation the correct fix is it should use the CFDataGetLength call to get the actual size rather than hardcoding it. I also had to add an ifdef to remove the Problematic CFRelease(properties) as per the comments. I believe this should be a compile option for the Makefile, as I don't need a signed binary. Here is a diff of my version:

diff --git a/dmidecode.c b/dmidecode.c
index bb651da..194108c 100644
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -4811,8 +4811,10 @@ static void dmi_table(off_t base, u32 len, u16 num, u32 ver, const char *devmem,
 		 * This CFRelease throws 'Segmentation fault: 11' since macOS 10.12, if
 		 * the compiled binary is not signed with an Apple developer profile.
 		 */
+		#ifdef SIGNED_BINARY  // So don't do that unless you signed it
 		if (NULL != properties)
 			CFRelease(properties);
+		#endif
 
 		IOObjectRelease(service);
 	}
@@ -5147,7 +5149,7 @@ int main(int argc, char * const argv[])
 		goto exit_free;
 	}
 
-	CFDataGetBytes(dataRef, CFRangeMake(0, 0x20), (UInt8*)buf);
+	CFDataGetBytes(dataRef, CFRangeMake(0, CFDataGetLength(dataRef)), (UInt8*)buf);
 
 	if (NULL != dataRef)
 		CFRelease(dataRef);

mstone2001 avatar Sep 02 '23 20:09 mstone2001

Fix worked for my case! thx @mstone2001 for sharing and work!

igavrysh avatar Oct 15 '23 14:10 igavrysh

@igavrysh You are welcome. I have forked this repo myself and submitted a pull request, but I have not heard anything, so I wanted to at least share my fix.

mstone2001 avatar Oct 21 '23 17:10 mstone2001