From 7a14dfebbb18724a017517c00be9ce0129fee87a Mon Sep 17 00:00:00 2001 From: Simon Kelley Date: Fri, 20 Apr 2012 20:50:42 +0100 Subject: [PATCH] Tidy previous commit. --- src/tftp.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/tftp.c b/src/tftp.c index c26abbb..a67fcaa 100644 --- a/src/tftp.c +++ b/src/tftp.c @@ -529,13 +529,7 @@ void check_tftp_listeners(fd_set *rset, time_t now) if (!err) err = ""; else - { - unsigned char *q, *r; - for (q = r = (unsigned char *)err; *r; r++) - if (isprint(*r)) - *(q++) = *r; - *q = 0; - } + sanitise(err); my_syslog(MS_TFTP | LOG_ERR, _("error %d %s received from %s"), (int)ntohs(mess->block), err, @@ -620,12 +614,13 @@ static char *next(char **p, char *end) static void sanitise(char *buf) { - char *end = buf + strlen(buf); + unsigned char *q, *r; + for (q = r = (unsigned char *)buf; *r; r++) + if (isprint(*r)) + *(q++) = *r; + *q = 0; - while (*(buf++)) - if (!isprint(*buf)) - memmove(buf, buf + 1, end - buf); -} +} static ssize_t tftp_err(int err, char *packet, char *message, char *file) {