version 1.7, 2003/11/17 09:45:39 |
version 1.8, 2005/05/24 17:32:43 |
|
|
ssh_msg_recv(int fd, Buffer *m) |
ssh_msg_recv(int fd, Buffer *m) |
{ |
{ |
u_char buf[4]; |
u_char buf[4]; |
ssize_t res; |
|
u_int msg_len; |
u_int msg_len; |
|
|
debug3("ssh_msg_recv entering"); |
debug3("ssh_msg_recv entering"); |
|
|
res = atomicio(read, fd, buf, sizeof(buf)); |
if (atomicio(read, fd, buf, sizeof(buf)) != sizeof(buf)) { |
if (res != sizeof(buf)) { |
if (errno != EPIPE) |
if (res != 0) |
error("ssh_msg_recv: read: header"); |
error("ssh_msg_recv: read: header %ld", (long)res); |
|
return (-1); |
return (-1); |
} |
} |
msg_len = GET_32BIT(buf); |
msg_len = GET_32BIT(buf); |
|
|
} |
} |
buffer_clear(m); |
buffer_clear(m); |
buffer_append_space(m, msg_len); |
buffer_append_space(m, msg_len); |
res = atomicio(read, fd, buffer_ptr(m), msg_len); |
if (atomicio(read, fd, buffer_ptr(m), msg_len) != msg_len) { |
if (res != msg_len) { |
error("ssh_msg_recv: read: %s", strerror(errno)); |
error("ssh_msg_recv: read: %ld != msg_len", (long)res); |
|
return (-1); |
return (-1); |
} |
} |
return (0); |
return (0); |