summaryrefslogtreecommitdiffstats
path: root/usr.bin/sdiff
diff options
context:
space:
mode:
authorray <ray@openbsd.org>2009-06-07 13:06:02 +0000
committerray <ray@openbsd.org>2009-06-07 13:06:02 +0000
commit675d97c0badf66b676dfc10c835ecaa319f051c7 (patch)
treeb782ac87d453b74c0e169291365f9d242333b093 /usr.bin/sdiff
parentRemove outdated comment. (diff)
downloadwireguard-openbsd-675d97c0badf66b676dfc10c835ecaa319f051c7.tar.xz
wireguard-openbsd-675d97c0badf66b676dfc10c835ecaa319f051c7.zip
Plug file descriptor leak when diffing regular files.
Diffstat (limited to 'usr.bin/sdiff')
-rw-r--r--usr.bin/sdiff/sdiff.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/usr.bin/sdiff/sdiff.c b/usr.bin/sdiff/sdiff.c
index 0cabe5c39a7..f5537210c50 100644
--- a/usr.bin/sdiff/sdiff.c
+++ b/usr.bin/sdiff/sdiff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sdiff.c,v 1.24 2009/06/07 12:39:40 ray Exp $ */
+/* $OpenBSD: sdiff.c,v 1.25 2009/06/07 13:06:02 ray Exp $ */
/*
* Written by Raymond Lai <ray@cyth.net>.
@@ -109,8 +109,10 @@ mktmpcpy(const char *source_file)
err(2, "error getting file status from %s", source_file);
/* Regular file. */
- if (S_ISREG(sb.st_mode))
+ if (S_ISREG(sb.st_mode)) {
+ close(ifd);
return (NULL);
+ }
} else {
/* If ``-'' does not exist the user meant stdin. */
if (errno == ENOENT && strcmp(source_file, "-") == 0)