diff options
author | Bryan Drewery <bryan@shatow.net> | 2022-06-23 19:38:26 +0300 |
---|---|---|
committer | Bryan Drewery <bryan@shatow.net> | 2022-07-13 19:35:06 +0300 |
commit | 5c38de2d6dbe6ecf4d563ff1c17633a1dba89d65 (patch) | |
tree | 4b4adde1900795d79f6707b092e04764f15eaea9 | |
parent | 419ffeb4e5e5a4d0e9a8a43c3532fdbd9c7a7365 (diff) |
touch: Import freebsd/freebsd@cb54c500d0 to fix touch fd leak
-rw-r--r-- | src/poudriere-sh/touch.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/poudriere-sh/touch.c b/src/poudriere-sh/touch.c index d7327764..a43fbf83 100644 --- a/src/poudriere-sh/touch.c +++ b/src/poudriere-sh/touch.c @@ -1,4 +1,6 @@ -/* +/*- + * SPDX-License-Identifier: BSD-3-Clause + * * Copyright (c) 1993 * The Regents of the University of California. All rights reserved. * @@ -181,11 +183,19 @@ main(int argc, char *argv[]) /* Create the file. */ fd = open(*argv, O_WRONLY | O_CREAT, DEFFILEMODE); - if (fd == -1 || fstat(fd, &sb) || close(fd)) { + if (fd == -1) { rval = 1; warn("%s", *argv); continue; } + if (fstat(fd, &sb) < 0) { + warn("%s", *argv); + rval = 1; + } + if (close(fd) < 0) { + warn("%s", *argv); + rval = 1; + } /* If using the current time, we're done. */ if (!timeset) |