diff --git a/emulator/phy.c b/emulator/phy.c
index 4517ad1..2ae6ad3 100644
--- a/emulator/phy.c
+++ b/emulator/phy.c
if (fd < 0)
return -1;
- setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));
+ if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) < 0) {
+ close(fd);
+ return -1;
+ }
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
if (fd < 0)
return -1;
- setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &opt, sizeof(opt));
+ if (setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &opt, sizeof(opt)) < 0) {
+ close(fd);
+ return -1;
+ }
return fd;
}
diff --git a/emulator/server.c b/emulator/server.c
index 3b07a71..ceb417a 100644
--- a/emulator/server.c
+++ b/emulator/server.c
return -1;
}
- setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));
+ if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) < 0) {
+ perror("Failed to set socket option");
+ close(fd);
+ return -1;
+ }
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;