summaryrefslogtreecommitdiff
path: root/accel-pptpd/cli
diff options
context:
space:
mode:
Diffstat (limited to 'accel-pptpd/cli')
-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;
}