From 2048fe709808fc2658de070dd3ad98659508b041 Mon Sep 17 00:00:00 2001 From: Matt Macy Date: Mon, 30 Sep 2019 21:53:26 +0000 Subject: [PATCH] dd: Check result of close(2) for errors close(2) can return errors from previous operations which should not be ignored. PR: 229616 Submitted by: Thomas Hurst Reported by: Thomas Hurst Reviewed by: mmacy@ Obtained from: Ryan Moeller MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D21376 --- bin/dd/dd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/dd/dd.c b/bin/dd/dd.c index e3916fe7dcc0..64484bd7d564 100644 --- a/bin/dd/dd.c +++ b/bin/dd/dd.c @@ -124,7 +124,8 @@ main(int argc __unused, char *argv[]) * descriptor explicitly so that the summary handler (called * from an atexit() hook) includes this work. */ - close(out.fd); + if (close(out.fd) == -1 && errno != EINTR) + err(1, "close"); exit(0); }