From 6b97d35e8bf91fabdba1e5af71c26c9e097d9ebd Mon Sep 17 00:00:00 2001 From: Bryan Steele Date: Sat, 1 Jul 2017 21:07:14 +0000 Subject: close open fd after testing files, ensuring that fd isn't stdin. ok nicm@ --- usr.bin/file/file.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'usr.bin/file/file.c') diff --git a/usr.bin/file/file.c b/usr.bin/file/file.c index bd1cddd29fe..b98643dfe3d 100644 --- a/usr.bin/file/file.c +++ b/usr.bin/file/file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: file.c,v 1.63 2017/06/28 17:14:15 brynet Exp $ */ +/* $OpenBSD: file.c,v 1.64 2017/07/01 21:07:13 brynet Exp $ */ /* * Copyright (c) 2015 Nicholas Marriott @@ -208,6 +208,8 @@ main(int argc, char **argv) for (idx = 0; idx < argc; idx++) { inf[idx].m = m; test_file(&inf[idx], width); + if (inf[idx].fd != -1 && inf[idx].fd != STDIN_FILENO) + close(inf[idx].fd); } exit(0); } -- cgit v1.2.3