~mdw
/
sgt
/
putty
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Redo a mis-fix of a memory leak in r9919: I added sfree(data)
[sgt/putty]
/
unix
/
uxnet.c
diff --git
a/unix/uxnet.c
b/unix/uxnet.c
index
fef4c43
..
02894bd
100644
(file)
--- a/
unix/uxnet.c
+++ b/
unix/uxnet.c
@@
-540,7
+540,7
@@
static int try_connect(Actual_Socket sock)
const union sockaddr_union *sa;
int err = 0;
short localport;
const union sockaddr_union *sa;
int err = 0;
short localport;
- int
fl,
salen, family;
+ int salen, family;
/*
* Remove the socket from the tree before we overwrite its
/*
* Remove the socket from the tree before we overwrite its
@@
-572,17
+572,32
@@
static int try_connect(Actual_Socket sock)
if (sock->oobinline) {
int b = TRUE;
if (sock->oobinline) {
int b = TRUE;
- setsockopt(s, SOL_SOCKET, SO_OOBINLINE, (void *) &b, sizeof(b));
+ if (setsockopt(s, SOL_SOCKET, SO_OOBINLINE,
+ (void *) &b, sizeof(b)) < 0) {
+ err = errno;
+ close(s);
+ goto ret;
+ }
}
if (sock->nodelay) {
int b = TRUE;
}
if (sock->nodelay) {
int b = TRUE;
- setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (void *) &b, sizeof(b));
+ if (setsockopt(s, IPPROTO_TCP, TCP_NODELAY,
+ (void *) &b, sizeof(b)) < 0) {
+ err = errno;
+ close(s);
+ goto ret;
+ }
}
if (sock->keepalive) {
int b = TRUE;
}
if (sock->keepalive) {
int b = TRUE;
- setsockopt(s, SOL_SOCKET, SO_KEEPALIVE, (void *) &b, sizeof(b));
+ if (setsockopt(s, SOL_SOCKET, SO_KEEPALIVE,
+ (void *) &b, sizeof(b)) < 0) {
+ err = errno;
+ close(s);
+ goto ret;
+ }
}
/*
}
/*
@@
-680,9
+695,7
@@
static int try_connect(Actual_Socket sock)
exit(1); /* XXX: GCC doesn't understand assert() on some systems. */
}
exit(1); /* XXX: GCC doesn't understand assert() on some systems. */
}
- fl = fcntl(s, F_GETFL);
- if (fl != -1)
- fcntl(s, F_SETFL, fl | O_NONBLOCK);
+ nonblock(s);
if ((connect(s, &(sa->sa), salen)) < 0) {
if ( errno != EINPROGRESS ) {
if ((connect(s, &(sa->sa), salen)) < 0) {
if ( errno != EINPROGRESS ) {
@@
-835,7
+848,12
@@
Socket sk_newlistener(char *srcaddr, int port, Plug plug, int local_host_only, i
ret->oobinline = 0;
ret->oobinline = 0;
- setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (const char *)&on, sizeof(on));
+ if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR,
+ (const char *)&on, sizeof(on)) < 0) {
+ ret->error = strerror(errno);
+ close(s);
+ return (Socket) ret;
+ }
retcode = -1;
addr = NULL; addrlen = -1; /* placate optimiser */
retcode = -1;
addr = NULL; addrlen = -1; /* placate optimiser */
@@
-1235,7
+1253,6
@@
static int net_select_result(int fd, int event)
union sockaddr_union su;
socklen_t addrlen = sizeof(su);
int t; /* socket of connection */
union sockaddr_union su;
socklen_t addrlen = sizeof(su);
int t; /* socket of connection */
- int fl;
memset(&su, 0, addrlen);
t = accept(s->s, &su.sa, &addrlen);
memset(&su, 0, addrlen);
t = accept(s->s, &su.sa, &addrlen);
@@
-1243,9
+1260,7
@@
static int net_select_result(int fd, int event)
break;
}
break;
}
- fl = fcntl(t, F_GETFL);
- if (fl != -1)
- fcntl(t, F_SETFL, fl | O_NONBLOCK);
+ nonblock(t);
if (s->localhost_only &&
!sockaddr_is_loopback(&su.sa)) {
if (s->localhost_only &&
!sockaddr_is_loopback(&su.sa)) {