From ca8f418267a5fa32589226834a1fec1b015f26f5 Mon Sep 17 00:00:00 2001 From: brynet Date: Sat, 1 Jul 2017 21:07:13 +0000 Subject: [PATCH] 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(-) 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); } -- 2.20.1