ObjFW  Check-in [ba552986b4]

Overview
Comment:OFSocketAddressMakeUNIX: Better length calculation
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | trunk
Files: files | file ages | folders
SHA3-256: ba552986b412dfa4943c8e2d469abfdfcb3197c4cc6497eda356c16da747b25d
User & Date: js on 2021-10-24 22:36:57
Other Links: manifest | tags
Context
2021-10-24
22:36
OFSocketAddressMakeUNIX: Better length calculation Leaf check-in: ba552986b4 user: js tags: trunk
22:29
Merge support for UNIX sockets check-in: d2f5000bb1 user: js tags: trunk
Changes

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

547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
	OFSocketAddress ret;

	if (length > sizeof(ret.sockaddr.un.sun_path))
		@throw [OFOutOfRangeException exception];

	memset(&ret, '\0', sizeof(ret));
	ret.family = OFSocketAddressFamilyUNIX;
	ret.length = (socklen_t)(sizeof(ret.sockaddr.un) -
	    (sizeof(ret.sockaddr.un.sun_path) - length));

#ifdef AF_UNIX
	ret.sockaddr.un.sun_family = AF_UNIX;
#else
	ret.sockaddr.un.sun_family = AF_UNSPEC;
#endif
	memcpy(ret.sockaddr.un.sun_path,







|
|







547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
	OFSocketAddress ret;

	if (length > sizeof(ret.sockaddr.un.sun_path))
		@throw [OFOutOfRangeException exception];

	memset(&ret, '\0', sizeof(ret));
	ret.family = OFSocketAddressFamilyUNIX;
	ret.length = (socklen_t)
	    (offsetof(struct sockaddr_un, sun_path) + length);

#ifdef AF_UNIX
	ret.sockaddr.un.sun_family = AF_UNIX;
#else
	ret.sockaddr.un.sun_family = AF_UNSPEC;
#endif
	memcpy(ret.sockaddr.un.sun_path,

Modified src/OFUNIXDatagramSocket.m from [b4a4c54b03] to [58573398fb].

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#include <errno.h>

#ifdef HAVE_FCNTL_H
# include <fcntl.h>
#endif

#import "OFUNIXDatagramSocket.h"
#import "OFSocket.h"
#import "OFSocket+Private.h"







<
<







11
12
13
14
15
16
17


18
19
20
21
22
23
24
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"



#ifdef HAVE_FCNTL_H
# include <fcntl.h>
#endif

#import "OFUNIXDatagramSocket.h"
#import "OFSocket.h"
#import "OFSocket+Private.h"

Modified src/OFUNIXStreamSocket.m from [14bddbd499] to [c12cfa9084].

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#include <errno.h>

#ifdef HAVE_FCNTL_H
# include <fcntl.h>
#endif

#import "OFUNIXStreamSocket.h"
#import "OFSocket.h"
#import "OFSocket+Private.h"







<
<







11
12
13
14
15
16
17


18
19
20
21
22
23
24
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"



#ifdef HAVE_FCNTL_H
# include <fcntl.h>
#endif

#import "OFUNIXStreamSocket.h"
#import "OFSocket.h"
#import "OFSocket+Private.h"