bzopen_or_bzdopen() - Open files with O_CLOEXEC with the "e" mode

This commit is contained in:
Federico Mena Quintero 2019-06-04 18:58:52 -05:00
parent 39fddb72e8
commit cebe990273
2 changed files with 8 additions and 8 deletions

10
bzlib.c
View File

@ -1414,8 +1414,14 @@ BZFILE * bzopen_or_bzdopen
}
mode++;
}
strcat(mode2, writing ? "w" : "r" );
strcat(mode2,"b"); /* binary mode */
strcat(mode2, writing ? "wb" : "rb" );
/* open fds with O_CLOEXEC _only_ when we are the initiator
* aka. bzopen() but not bzdopen() */
if(open_mode == 0) {
strcat (mode2, writing ? "e" : "e" );
}
if (open_mode==0) {
if (path==NULL || strcmp(path,"")==0) {

View File

@ -5,9 +5,3 @@ repository:
bzip2-doc package instead of the bzip2.txt file from the source
distribution. This is suitable for distributions which repackage
the original files into different packages.
* bzip2-ocloexec.patch - Adds an "e" to the open mode string for
fopen(), with the intention of using O_CLOEXEC for bzopen() but not
for bzdopen(). This is a Linux-ism; maybe this needs to be done
with fcntl() on other systems?