summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbrynet <brynet@openbsd.org>2017-06-28 17:14:15 +0000
committerbrynet <brynet@openbsd.org>2017-06-28 17:14:15 +0000
commit86abb43ab7103460f915ce2687a7f4ac43a20577 (patch)
tree19c21b6d5850e2f8eebb1bca30f2d8e55675371d
parentOnly pass required fields of interface_info to priv_* functions (diff)
downloadwireguard-openbsd-86abb43ab7103460f915ce2687a7f4ac43a20577.tar.xz
wireguard-openbsd-86abb43ab7103460f915ce2687a7f4ac43a20577.zip
Fix stdin file read support, accidentally broken in my last commit.
-rw-r--r--usr.bin/file/file.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/usr.bin/file/file.c b/usr.bin/file/file.c
index d14e62ac0ee..bd1cddd29fe 100644
--- a/usr.bin/file/file.c
+++ b/usr.bin/file/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.62 2017/06/28 15:42:49 deraadt Exp $ */
+/* $OpenBSD: file.c,v 1.63 2017/06/28 17:14:15 brynet Exp $ */
/*
* Copyright (c) 2015 Nicholas Marriott <nicm@openbsd.org>
@@ -217,12 +217,16 @@ prepare_input(struct input_file *inf, const char *path)
{
int fd, mode, error;
+ inf->path = path;
+
if (strcmp(path, "-") == 0) {
if (fstat(STDIN_FILENO, &inf->sb) == -1) {
inf->error = errno;
inf->fd = -1;
+ return;
}
inf->fd = STDIN_FILENO;
+ return;
}
if (Lflag)
@@ -232,6 +236,7 @@ prepare_input(struct input_file *inf, const char *path)
if (error == -1) {
inf->error = errno;
inf->fd = -1;
+ return;
}
/* We don't need them, so don't open directories or symlinks. */
@@ -245,7 +250,6 @@ prepare_input(struct input_file *inf, const char *path)
if (S_ISLNK(mode))
read_link(inf, path);
inf->fd = fd;
- inf->path = path;
}
static void