The following commit has been merged in the master branch: commit 1fa4652813ea993928cf4f47cc725da4aad28ed2 Author: Stefan Sperling stsp@stsp.in-berlin.de Date: Wed Nov 1 19:15:34 2006 +0100
Only call strlcpy if there is a buffer to copy to.
diff --git a/bsd.c b/bsd.c index eb68b21..d30d687 100644 --- a/bsd.c +++ b/bsd.c @@ -222,7 +222,8 @@ int open_tun_any(char *dev_name, size_t dev_name_size) for (i = 0; i < 256; i++) { snprintf(tun_dev_name, sizeof(tun_dev_name), "/dev/tun%i", i); if ((fd = open(tun_dev_name, O_RDWR)) >= 0) { - strlcpy(dev_name, tun_dev_name, dev_name_size); + if (dev_name != NULL) + strlcpy(dev_name, tun_dev_name, dev_name_size); return fd; } }