diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2012-03-14 11:27:30 +0100 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2012-03-14 11:27:30 +0100 |
commit | ee7897d5568535cbe03318debcb71632242f27e6 (patch) | |
tree | 0d11a1c8a74875b7d5eb90aef5dc0ce5a6d3a0d1 /pinguctl.c | |
parent | 1f9f814770fb61f41122e5408bf62b47f718e6a1 (diff) | |
download | pingu-ee7897d5568535cbe03318debcb71632242f27e6.tar.bz2 pingu-ee7897d5568535cbe03318debcb71632242f27e6.tar.xz |
pingu_adm: allow only one command per connection
Diffstat (limited to 'pinguctl.c')
-rw-r--r-- | pinguctl.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -48,12 +48,16 @@ static int adm_send_cmd(int fd, const char *cmd) static int adm_recv(int fd) { char buf[1024]; - int n; + int n, total = 0; - n = recv(fd, buf, sizeof(buf), 0); - if (n > 0) + while (1) { + n = recv(fd, buf, sizeof(buf), 0); + if (n <= 0) + break; write(STDOUT_FILENO, buf, n); - return n; + total += n; + } + return total; } int main(int argc, char *argv[]) |