X-Git-Url: https://www.tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fdropin.c;h=74e5676ffe6630d7fb51f42bfd648850c8d0060a;hb=696dc2ad9743c62e56a6d21addb8c4e8efbffec1;hp=c7b558a4288bad7a06041ab575ad47b3a86b8300;hpb=e16ab7b89948c24a2c47652e8eb1a817a4b1424c;p=tinc diff --git a/src/dropin.c b/src/dropin.c index c7b558a4..74e5676f 100644 --- a/src/dropin.c +++ b/src/dropin.c @@ -50,8 +50,9 @@ int daemon(int nochdir, int noclose) { } /* If we are the parent, terminate */ - if(pid) + if(pid) { exit(0); + } /* Detach by becoming the new process group leader */ if(setsid() < 0) { @@ -106,14 +107,14 @@ int vasprintf(char **buf, const char *fmt, va_list ap) { va_copy(aq, ap); status = vsnprintf(*buf, len, fmt, aq); - buf[len - 1] = 0; va_end(aq); - if(status >= 0) + if(status >= 0) { *buf = xrealloc(*buf, status + 1); + } if(status > len - 1) { - len = status; + len = status + 1; va_copy(aq, ap); status = vsnprintf(*buf, len, fmt, aq); va_end(aq);