ObjFW  Check-in [24ffb76ae2]

Overview
Comment:Fix OFSocketAddressUNIXPath
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | unix-sockets
Files: files | file ages | folders
SHA3-256: 24ffb76ae28a44e725d332c68e827f459951d3a0becd27faba09ff4dec3bcb1b
User & Date: js on 2021-10-24 22:09:37
Other Links: branch diff | manifest | tags
Context
2021-10-24
22:21
OFUNIXStreamSocketTests: Fix test description Closed-Leaf check-in: 4416be270e user: js tags: unix-sockets
22:09
Fix OFSocketAddressUNIXPath check-in: 24ffb76ae2 user: js tags: unix-sockets
21:15
Add OFUNIXStreamSocket check-in: aaf477fc88 user: js tags: unix-sockets
Changes

Modified src/OFSocket.m from [0370baa1c4] to [626dd6d6ed].

904
905
906
907
908
909
910
911
912
913
914
915
916
917



918
919
920
921
922
923
924
925
926
927
928
929
930

	memcpy(node, address->sockaddr.ipx.sipx_node, IPX_NODE_LEN);
}

OFString *
OFSocketAddressUNIXPath(const OFSocketAddress *_Nonnull address)
{
	const socklen_t maxLength = (socklen_t)sizeof(address->sockaddr.un);
	size_t length;

	if (address->family != OFSocketAddressFamilyUNIX ||
	    address->length > maxLength)
		@throw [OFInvalidArgumentException exception];




	length = sizeof(address->sockaddr.un.sun_path) -
	    (maxLength - address->length);

	if (length == 0)
		return nil;

	while (address->sockaddr.un.sun_path[length - 1] == '\0')
		length--;

	return [OFString stringWithCString: address->sockaddr.un.sun_path
				  encoding: [OFLocale encoding]
				    length: length];
}







<
|

|
<


>
>
>
|
|

|

<
<
<





904
905
906
907
908
909
910

911
912
913

914
915
916
917
918
919
920
921
922
923



924
925
926
927
928

	memcpy(node, address->sockaddr.ipx.sipx_node, IPX_NODE_LEN);
}

OFString *
OFSocketAddressUNIXPath(const OFSocketAddress *_Nonnull address)
{

	socklen_t length;

	if (address->family != OFSocketAddressFamilyUNIX)

		@throw [OFInvalidArgumentException exception];

	length = address->length - offsetof(struct sockaddr_un, sun_path);

	for (socklen_t i = 0; i < length; i++)
		if (address->sockaddr.un.sun_path[i] == 0)
			length = i;

	if (length <= 0)
		return nil;




	return [OFString stringWithCString: address->sockaddr.un.sun_path
				  encoding: [OFLocale encoding]
				    length: length];
}