Flush all output before reading a login command, not just some
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 11 Mar 2012 10:43:38 +0000 (11:43 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Thu, 26 Apr 2012 17:43:41 +0000 (19:43 +0200)
Before, a client could theoretically make the output queue grow
without bounds.

src/lib/player/login.c

index db517e354b1ada56ebffc3f69027ea6c0717a407..31afa27af762ec415a36853923183fdf8bb1aff4 100644 (file)
@@ -87,7 +87,11 @@ player_login(void *ud)
     pr_id(player, C_INIT, "Empire server ready\n");
 
     for (;;) {
-       io_output(player->iop, (time_t)-1);
+       if (io_outputwaiting(player->iop)) {
+           if (io_output(player->iop, (time_t)-1) <= 0)
+               break;
+           continue;
+       }
        if (io_gets(player->iop, buf, sizeof(buf)) < 0) {
            res = io_input(player->iop, player->curup + minutes(max_idle));
            if (res <= 0) {