X-Git-Url: http://tinc-vpn.org/git/browse?a=blobdiff_plain;ds=sidebyside;f=src%2Fprotocol.c;h=79d52733b881027470f112a7fa1c25d2574f8fe2;hb=3a316823b971396a428f020f401b9fe41252d98d;hp=f533a932c6e94dfee216073260db53e0155e59ae;hpb=7e6b2dd1ea51057b7135139c200d97a9e8f9c9cb;p=tinc diff --git a/src/protocol.c b/src/protocol.c index f533a932..79d52733 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -72,10 +72,11 @@ bool send_request(connection_t *c, const char *format, ...) { input buffer anyway */ va_start(args, format); - len = vsnprintf(request, MAXBUFSIZE, format, args); + len = vsnprintf(request, sizeof(request), format, args); + request[sizeof(request) - 1] = 0; va_end(args); - if(len < 0 || len > MAXBUFSIZE - 1) { + if(len < 0 || len > sizeof(request) - 1) { logger(DEBUG_ALWAYS, LOG_ERR, "Output buffer overflow while sending request to %s (%s)", c->name, c->hostname); return false; @@ -100,7 +101,7 @@ void forward_request(connection_t *from, const char *request) { char tmp[len + 1]; memcpy(tmp, request, len); tmp[len] = '\n'; - broadcast_meta(from, tmp, sizeof tmp); + broadcast_meta(from, tmp, sizeof(tmp)); } bool receive_request(connection_t *c, const char *request) { @@ -187,7 +188,7 @@ bool seen_request(const char *request) { logger(DEBUG_SCARY_THINGS, LOG_DEBUG, "Already seen request"); return true; } else { - new = xmalloc(sizeof *new); + new = xmalloc(sizeof(*new)); new->request = xstrdup(request); new->firstseen = now.tv_sec; splay_insert(past_request_tree, new);