ObjFW  Check-in [e061c2b66e]

Overview
Comment:OFSystemInfo: Fix \0 in +[CPUModel] on macOS
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: e061c2b66e539d230798b5716afa6a5c4e0f56998de7ee47a5c120b39a1832a2
User & Date: js on 2024-10-27 23:38:18
Other Links: manifest | tags
Context
2024-10-27
23:48
Allow \u0000 in JSON check-in: d7bbf983f0 user: js tags: trunk
23:38
OFSystemInfo: Fix \0 in +[CPUModel] on macOS check-in: e061c2b66e user: js tags: trunk
22:27
Allow strings to contain \0 check-in: 6fbc3b18c7 user: js tags: trunk
Changes

Modified src/OFSystemInfo.m from [4ca3a2659e] to [0061e74320].

803
804
805
806
807
808
809



810
811
812
813
814
815
816
#elif defined(OF_MACOS) || defined(OF_IOS)
	char buffer[128];
	size_t length = sizeof(buffer);

	if (sysctlbyname("machdep.cpu.brand_string", &buffer, &length,
	    NULL, 0) != 0)
		return nil;




	return [OFString stringWithCString: buffer
				  encoding: [OFLocale encoding]
				    length: length];
#elif defined(OF_AMIGAOS4)
	CONST_STRPTR model, version;








>
>
>







803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
#elif defined(OF_MACOS) || defined(OF_IOS)
	char buffer[128];
	size_t length = sizeof(buffer);

	if (sysctlbyname("machdep.cpu.brand_string", &buffer, &length,
	    NULL, 0) != 0)
		return nil;

	if (length > 0 && buffer[length - 1] == '\0')
		length--;

	return [OFString stringWithCString: buffer
				  encoding: [OFLocale encoding]
				    length: length];
#elif defined(OF_AMIGAOS4)
	CONST_STRPTR model, version;