summaryrefslogtreecommitdiff
path: root/accel-pptpd/cli/tcp.c
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2010-11-15 16:02:37 +0300
committerDmitry Kozlov <xeb@mail.ru>2010-11-15 16:02:37 +0300
commitb85986e561d4fc6532c0666e38014b51b66f485a (patch)
treed541d77a0aa95e756276b20ba14b8a097a863e30 /accel-pptpd/cli/tcp.c
parenta49ab300966aa7fa58c75662dfce16b409b17751 (diff)
downloadaccel-ppp-b85986e561d4fc6532c0666e38014b51b66f485a.tar.gz
accel-ppp-b85986e561d4fc6532c0666e38014b51b66f485a.zip
cli: fixed incorrect read procedure
Diffstat (limited to 'accel-pptpd/cli/tcp.c')
-rw-r--r--accel-pptpd/cli/tcp.c38
1 files changed, 21 insertions, 17 deletions
diff --git a/accel-pptpd/cli/tcp.c b/accel-pptpd/cli/tcp.c
index 7b44da77..687c97f4 100644
--- a/accel-pptpd/cli/tcp.c
+++ b/accel-pptpd/cli/tcp.c
@@ -154,31 +154,35 @@ static int cln_read(struct triton_md_handler_t *h)
}
cln->recv_pos += n;
-
- d = strchr((char *)cln->cmdline, '\n');
- if (!d) {
- if (cln->recv_pos == RECV_BUF_SIZE) {
- log_warn("cli: tcp: recv buffer overflow\n");
+
+ while (cln->recv_pos) {
+ d = strchr((char *)cln->cmdline, '\n');
+ if (!d) {
+ if (cln->recv_pos == RECV_BUF_SIZE) {
+ log_warn("cli: tcp: recv buffer overflow\n");
+ goto drop;
+ }
break;
}
- continue;
- }
- *d = 0;
+ *d = 0;
- if (!cln->auth) {
- if (strcmp((char *)cln->cmdline, conf_cli_passwd))
- break;
- cln->auth = 1;
- } else
- cli_process_cmd(&cln->cli_client);
+ if (!cln->auth) {
+ if (strcmp((char *)cln->cmdline, conf_cli_passwd))
+ goto drop;
+ cln->auth = 1;
+ } else
+ cli_process_cmd(&cln->cli_client);
- if (cln->disconnect)
- break;
+ if (cln->disconnect)
+ goto drop;
- memmove(cln->cmdline, d + 1, cln->recv_pos - ((uint8_t *)d + 1 - cln->cmdline));
+ cln->recv_pos -= (uint8_t *)d + 1 - cln->cmdline;
+ memmove(cln->cmdline, d + 1, cln->recv_pos);
+ }
}
+drop:
disconnect(cln);
return 0;
}