From 07a2a6732b43465144ee35255e9590b98d377286 Mon Sep 17 00:00:00 2001 From: sin Date: Wed, 17 Sep 2014 17:04:44 +0100 Subject: Remember to ftruncate() before dprintf() --- ratatox.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ratatox.c b/ratatox.c index e823b48..c4c4b33 100644 --- a/ratatox.c +++ b/ratatox.c @@ -633,6 +633,7 @@ localinit(void) if (r > sizeof(name) - 1) r = sizeof(name) - 1; name[r] = '\0'; + ftruncate(gslots[NAME].fd[OUT], 0); dprintf(gslots[NAME].fd[OUT], "%s\n", name); /* Dump status message */ @@ -641,6 +642,7 @@ localinit(void) if (r > sizeof(statusmsg) - 1) r = sizeof(statusmsg) - 1; statusmsg[r] = '\0'; + ftruncate(gslots[STATUS].fd[OUT], 0); dprintf(gslots[STATUS].fd[OUT], "%s\n", name); /* Dump ID */ @@ -927,6 +929,7 @@ again: tox_set_name(tox, name, r); datasave(); printout("Changed name to %s\n", name); + ftruncate(gslots[NAME].fd[OUT], 0); dprintf(gslots[NAME].fd[OUT], "%s\n", name); } @@ -952,6 +955,7 @@ again: tox_set_status_message(tox, statusmsg, r); datasave(); printout("Changed status message to %s\n", statusmsg); + ftruncate(gslots[STATUS].fd[OUT], 0); dprintf(gslots[STATUS].fd[OUT], "%s\n", statusmsg); } @@ -989,6 +993,8 @@ again: str2id(buf, id); r = tox_add_friend(tox, id, buf, strlen(buf)); + if (r < 0) + ftruncate(gslots[REQUEST].fd[ERR], 0); switch (r) { case TOX_FAERR_TOOLONG: dprintf(gslots[REQUEST].fd[ERR], "Message is too long\n"); -- cgit v1.2.3