diff options
author | 2009-01-30 21:00:42 +0000 | |
---|---|---|
committer | 2009-01-30 21:00:42 +0000 | |
commit | 624a12c104ab850e955efd7887e50a59e982fd2d (patch) | |
tree | 816da1d28850dcea60ba06d82054eb1e8cbb22eb | |
parent | When don't-fragment packets need to get fragemnted some code tries to (diff) | |
download | wireguard-openbsd-624a12c104ab850e955efd7887e50a59e982fd2d.tar.xz wireguard-openbsd-624a12c104ab850e955efd7887e50a59e982fd2d.zip |
avoid an alloc/free loop while looking for a bpf.
ok mbalmer@
-rw-r--r-- | usr.sbin/wake/wake.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/usr.sbin/wake/wake.c b/usr.sbin/wake/wake.c index 3feefc608b7..4e27bdf6040 100644 --- a/usr.sbin/wake/wake.c +++ b/usr.sbin/wake/wake.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wake.c,v 1.11 2009/01/29 15:50:03 mbalmer Exp $ */ +/* $OpenBSD: wake.c,v 1.12 2009/01/30 21:00:42 pyr Exp $ */ /* * Copyright (C) 2006,2007,2008,2009 Marc Balmer <mbalmer@openbsd.org> @@ -27,6 +27,7 @@ */ #include <sys/types.h> +#include <sys/param.h> #include <sys/queue.h> #include <sys/ioctl.h> #include <sys/socket.h> @@ -100,14 +101,13 @@ int get_bpf(void) { int i, fd; - char *path; + char path[MAXPATHLEN]; for (i = 0;; i++) { - if (asprintf(&path, BPF_PATH_FORMAT, i) == -1) + if (snprintf(path, sizeof(path), BPF_PATH_FORMAT, i) == -1) return -1; fd = open(path, O_RDWR); - free(path); if (fd != -1) return fd; if (errno == EBUSY) |