Skip to content

Commit e0ccfda

Browse files
EmmaLiedtke
authored andcommitted
Fixed Fuzzilli macOS swift build (#515)
Renamed `socket_t` to `libsocket_t` to resolve swift build issue
1 parent da36bc9 commit e0ccfda

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

Sources/Fuzzilli/Modules/NetworkSync.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ fileprivate protocol MessageHandler {
4848
/// A connection to a network peer that speaks the above protocol.
4949
fileprivate class Connection {
5050
/// The file descriptor on POSIX or SOCKET handle on Windows of the socket.
51-
let socket: libsocket.socket_t
51+
let socket: libsocket.libsocket_t
5252

5353
/// The UUID of the remote end.
5454
let localId: UUID
@@ -78,7 +78,7 @@ fileprivate class Connection {
7878
/// Pending outgoing data. Must only be accessed on this connection's dispatch queue.
7979
private var sendQueue: [Data] = []
8080

81-
init?(socket: libsocket.socket_t, localId: UUID, handler: MessageHandler) {
81+
init?(socket: libsocket.libsocket_t, localId: UUID, handler: MessageHandler) {
8282
self.socket = socket
8383
self.localId = localId
8484
self.handler = handler
@@ -331,7 +331,7 @@ public class NetworkParent: DistributedFuzzingParentNode {
331331
unowned let fuzzer: Fuzzer
332332

333333
/// File descriptor or SOCKET handle of the server socket.
334-
private var serverFd: libsocket.socket_t = INVALID_SOCKET
334+
private var serverFd: libsocket.libsocket_t = INVALID_SOCKET
335335

336336
/// Address and port on which to listen for connections.
337337
private let address: String
@@ -346,7 +346,7 @@ public class NetworkParent: DistributedFuzzingParentNode {
346346
private var serverQueue: DispatchQueue? = nil
347347

348348
/// Active workers indexed by the socket used to communicate with them.
349-
private var clientsBySocket = [libsocket.socket_t: Client]()
349+
private var clientsBySocket = [libsocket.libsocket_t: Client]()
350350

351351
/// Active workers indexed by their id.
352352
private var clientsById = [UUID: Client]()
@@ -445,7 +445,7 @@ public class NetworkParent: DistributedFuzzingParentNode {
445445
onChildDisconnectedCallback = callback
446446
}
447447

448-
private func handleNewConnection(_ socket: libsocket.socket_t) {
448+
private func handleNewConnection(_ socket: libsocket.libsocket_t) {
449449
guard socket > 0 else {
450450
return logger.error("Failed to accept client connection")
451451
}

Sources/libsocket/include/libsocket.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,18 @@ typedef __typeof__(_Generic((size_t)0, \
3636
unsigned char : (char)0)) ssize_t;
3737
#endif
3838
#else
39-
typedef int socket_t;
39+
typedef int libsocket_t;
4040
#define INVALID_SOCKET (-1)
4141
#endif
4242

43-
socket_t socket_listen(const char* address, uint16_t port);
44-
socket_t socket_accept(socket_t socket);
45-
socket_t socket_connect(const char* address, uint16_t port);
43+
libsocket_t socket_listen(const char* address, uint16_t port);
44+
libsocket_t socket_accept(libsocket_t socket);
45+
libsocket_t socket_connect(const char* address, uint16_t port);
4646

47-
ssize_t socket_send(socket_t socket, const uint8_t* data, size_t length);
48-
ssize_t socket_recv(socket_t socket, uint8_t* buffer, size_t length);
47+
ssize_t socket_send(libsocket_t socket, const uint8_t* data, size_t length);
48+
ssize_t socket_recv(libsocket_t socket, uint8_t* buffer, size_t length);
4949

50-
int socket_shutdown(socket_t socket);
51-
int socket_close(socket_t socket);
50+
int socket_shutdown(libsocket_t socket);
51+
int socket_close(libsocket_t socket);
5252

5353
#endif

Sources/libsocket/socket-posix.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
#include <string.h>
2525
#include <unistd.h>
2626

27-
socket_t socket_listen(const char* address, uint16_t port) {
28-
socket_t fd = socket(AF_INET, SOCK_STREAM, 0);
27+
libsocket_t socket_listen(const char* address, uint16_t port) {
28+
libsocket_t fd = socket(AF_INET, SOCK_STREAM, 0);
2929
if (fd < 0) {
3030
return INVALID_SOCKET;
3131
}
@@ -54,8 +54,8 @@ socket_t socket_listen(const char* address, uint16_t port) {
5454
return fd;
5555
}
5656

57-
socket_t socket_accept(socket_t fd) {
58-
socket_t client_fd = accept(fd, NULL, 0);
57+
libsocket_t socket_accept(libsocket_t fd) {
58+
libsocket_t client_fd = accept(fd, NULL, 0);
5959
if (client_fd < 0) {
6060
return INVALID_SOCKET;
6161
}
@@ -78,7 +78,7 @@ socket_t socket_accept(socket_t fd) {
7878
return client_fd;
7979
}
8080

81-
socket_t socket_connect(const char* address, uint16_t port) {
81+
libsocket_t socket_connect(const char* address, uint16_t port) {
8282
struct addrinfo hint;
8383
memset(&hint, 0, sizeof(hint));
8484
hint.ai_family = AF_UNSPEC;
@@ -93,7 +93,7 @@ socket_t socket_connect(const char* address, uint16_t port) {
9393
return INVALID_SOCKET;
9494
}
9595

96-
socket_t fd;
96+
libsocket_t fd;
9797
struct addrinfo* addr;
9898
for (addr = result; addr != NULL; addr = addr->ai_next) {
9999
fd = socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol);
@@ -133,7 +133,7 @@ socket_t socket_connect(const char* address, uint16_t port) {
133133
return fd;
134134
}
135135

136-
ssize_t socket_send(socket_t fd, const uint8_t* data, size_t length) {
136+
ssize_t socket_send(libsocket_t fd, const uint8_t* data, size_t length) {
137137
ssize_t remaining = length;
138138
while (remaining > 0) {
139139
#ifdef __APPLE__
@@ -154,15 +154,15 @@ ssize_t socket_send(socket_t fd, const uint8_t* data, size_t length) {
154154
return length;
155155
}
156156

157-
ssize_t socket_recv(socket_t fd, uint8_t* data, size_t length) {
157+
ssize_t socket_recv(libsocket_t fd, uint8_t* data, size_t length) {
158158
return read(fd, data, length);
159159
}
160160

161-
int socket_shutdown(socket_t socket) {
161+
int socket_shutdown(libsocket_t socket) {
162162
return shutdown(socket, SHUT_RDWR);
163163
}
164164

165-
int socket_close(socket_t fd) {
165+
int socket_close(libsocket_t fd) {
166166
return close(fd);
167167
}
168168

0 commit comments

Comments
 (0)