X-Git-Url: http://git.dolda2000.com/gitweb/?a=blobdiff_plain;f=daemon%2Fui.c;h=9d10fa2a8792a2dcd9a90b5b6e55f2be1a7c3057;hb=5dce4f6c7d1f5fb0a4d4bcf72c11ee0c91ebcfdf;hp=9c630712fa04d9e86582b080b2b009d1b9d8bc8d;hpb=0e227c1d9f08cee2f7ac474c185d36db7b8097d0;p=doldaconnect.git diff --git a/daemon/ui.c b/daemon/ui.c index 9c63071..9d10fa2 100644 --- a/daemon/ui.c +++ b/daemon/ui.c @@ -34,6 +34,7 @@ #include #include #include +#include #ifdef HAVE_CONFIG_H #include @@ -118,6 +119,7 @@ struct uidata struct uidata *next, *prev; struct socket *sk; struct qcommand *queue, *queuelast; + size_t queuesize; struct authhandle *auth; int close; union @@ -369,7 +371,7 @@ static void cmd_connect(struct socket *sk, struct uidata *data, int argc, wchar_ return; } } - sq(sk, 0, L"201", L"1", L"2", L"Dolda Connect daemon v" VERSION, NULL); + sq(sk, 0, L"201", L"1", L"3", L"Dolda Connect daemon v" VERSION, NULL); } static void cmd_notfound(struct socket *sk, struct uidata *data, int argc, wchar_t **argv) @@ -704,7 +706,7 @@ static void cmd_lspeers(struct socket *sk, struct uidata *data, int argc, wchar_ } if(fn->peers == NULL) { - sq(sk, 0, L"201", L"No peers avaiable", NULL); + sq(sk, 0, L"201", L"No peers available", NULL); } else { for(peer = btreeiter(fn->peers); peer != NULL; peer = npeer) { @@ -1421,6 +1423,7 @@ static struct qcommand *unlinkqcmd(struct uidata *data) qcmd = data->queue; if(qcmd != NULL) { + data->queuesize--; data->queue = qcmd->next; if(qcmd == data->queuelast) data->queuelast = qcmd->next; @@ -1611,6 +1614,7 @@ static void queuecmd(struct uidata *data, struct command *cmd, int argc, wchar_t data->queuelast = new; if(data->queue == NULL) data->queue = new; + data->queuesize++; } static struct uidata *newuidata(struct socket *sk) @@ -1803,6 +1807,11 @@ static void uiread(struct socket *sk, struct uidata *data) break; } } + if(data->cbdata > 16384) + { + /* Kill clients that send us unreasonably long lines */ + data->close = 1; + } } static void uierror(struct socket *sk, int err, struct uidata *data) @@ -2400,6 +2409,15 @@ static int run(void) freequeuecmd(qcmd); return(1); } + if(data->queuesize > 10) + { + /* Clients should not be queue up commands at all, since + * they should not send a new command before receiving a + * reply to the previous command. Therefore, we + * mercilessly massacre clients which are stacking up too + * many commands. */ + data->close = 1; + } } return(0); }