diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2009-06-14 10:16:11 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2009-06-14 10:16:11 +0800 |
commit | f316447abf988cb1df29b5a1cdcdfed9df8e253d (patch) | |
tree | 4247cb4a1e9b164bf4b15ae676a09d47a489da73 /common | |
parent | 70b74ad55dc292a6898b18f4e57836e476a47ab2 (diff) | |
download | pttbbs-f316447abf988cb1df29b5a1cdcdfed9df8e253d.tar pttbbs-f316447abf988cb1df29b5a1cdcdfed9df8e253d.tar.gz pttbbs-f316447abf988cb1df29b5a1cdcdfed9df8e253d.tar.bz2 pttbbs-f316447abf988cb1df29b5a1cdcdfed9df8e253d.tar.lz pttbbs-f316447abf988cb1df29b5a1cdcdfed9df8e253d.tar.xz pttbbs-f316447abf988cb1df29b5a1cdcdfed9df8e253d.tar.zst pttbbs-f316447abf988cb1df29b5a1cdcdfed9df8e253d.zip |
* more checks on net system
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4606 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'common')
-rw-r--r-- | common/sys/net.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/common/sys/net.c b/common/sys/net.c index 232d5bb1..efeda16a 100644 --- a/common/sys/net.c +++ b/common/sys/net.c @@ -188,9 +188,11 @@ int toread(int fd, void *buf, int len) { int l; for( l = 0 ; len > 0 ; ) - if( (l = read(fd, buf, len)) <= 0 ) + if( (l = read(fd, buf, len)) <= 0 ) { + if (errno == EINTR || errno == EAGAIN) + continue; return -1; - else{ + }else{ buf += l; len -= l; } @@ -204,9 +206,11 @@ int towrite(int fd, const void *buf, int len) { int l; for( l = 0 ; len > 0 ; ) - if( (l = write(fd, buf, len)) <= 0 ) + if( (l = write(fd, buf, len)) <= 0){ + if (errno == EINTR || errno == EAGAIN) + continue; return -1; - else{ + }else{ buf += l; len -= l; } @@ -293,9 +297,17 @@ int recv_remote_fd(int tunnel, const char *tunnel_path) } cmsg = CMSG_FIRSTHDR(&msg); + if (!cmsg) { + // kernel indicates there's no ancillary data + return -1; + } + assert(cmsg->cmsg_type == SCM_RIGHTS); if (cmsg->cmsg_type != SCM_RIGHTS) + { + // invalid message!? return -1; + } return *(int*)CMSG_DATA(cmsg); } |