Skip to content

Commit

Permalink
Fix file descriptor leak that might lead to errors on packages with l…
Browse files Browse the repository at this point in the history
…ots of files

PR:		215544
Submitted by:	pasokondokoro@gmail.com
  • Loading branch information
bapt committed Dec 25, 2016
1 parent 83b3b0e commit 55c9964
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions ports-mgmt/pkg/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

PORTNAME= pkg
DISTVERSION= 1.9.4
PORTREVISION= 1
_PKG_VERSION= ${DISTVERSION}
CATEGORIES= ports-mgmt
MASTER_SITES= \
Expand Down
22 changes: 22 additions & 0 deletions ports-mgmt/pkg/files/patch-libpkg_pkg__add.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--- libpkg/pkg_add.c.orig 2016-12-25 15:12:01 UTC
+++ libpkg/pkg_add.c
@@ -1344,8 +1344,10 @@ pkg_add_fromdir(struct pkg *pkg, const c
}
kh_find(hls, hardlinks, st.st_ino, path);
if (path != NULL) {
- if (create_hardlink(pkg, f, path) == EPKG_FATAL)
+ if (create_hardlink(pkg, f, path) == EPKG_FATAL) {
+ close(fd);
return (EPKG_FATAL);
+ }
} else {
if (create_regfile(pkg, f, NULL, NULL, fd, NULL) == EPKG_FATAL) {
close(fd);
@@ -1353,6 +1355,7 @@ pkg_add_fromdir(struct pkg *pkg, const c
}
kh_safe_add(hls, hardlinks, f->path, st.st_ino);
}
+ close(fd);
} else {
pkg_emit_error("Invalid file type");
return (EPKG_FATAL);

0 comments on commit 55c9964

Please sign in to comment.