diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | socketio.c | 11 |
2 files changed, 8 insertions, 5 deletions
@@ -1,3 +1,3 @@ -CFLAGS=-D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 +CFLAGS=-D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -Wall LDLIBS=-lnetfs -lfshelp -liohelp -lports -lshouldbeinlibc all: socketio diff --git a/socketio.c b/socketio.c index 9d578f344..0bcf29b21 100644 --- a/socketio.c +++ b/socketio.c @@ -191,7 +191,7 @@ xgethostbyname (char *hostname, struct hostent *hostaddr, char **buf) char *tmp_hostbuf; int herr, err; - hostbuf_len = 8; + hostbuf_len = 64; tmp_hostbuf = malloc (hostbuf_len); if (! tmp_hostbuf) return ENOMEM; @@ -373,7 +373,7 @@ node_socket_open (struct iouser *user, struct node *np, char *netport_s, { uint16_t netport = strtol (netport_s, NULL, 10); char *hostname = np->nn->hostname; - socket_t sock; + socket_t sock = MACH_PORT_NULL; error_t err; int style; @@ -385,6 +385,8 @@ node_socket_open (struct iouser *user, struct node *np, char *netport_s, case PROTOCOL_ID_UDP: style = SOCK_DGRAM; break; + default: + return EINVAL; } err = socket_open (style, hostname, netport, &sock); @@ -435,9 +437,10 @@ socket_open (int style, char *hostname, uint16_t netport, char *buf; err = xgethostbyname (hostname, &hostaddr, &buf); - if (! err) + if (! err) { sockaddr_init (addr, AF_INET, &hostaddr, netport); - free (buf); + free (buf); + } if (! err) err = socket_create (socket_server, style, 0, &sock); if (! err) |