diff --git a/bzlib.c b/bzlib.c index 8aa6ae7..d202f71 100644 --- a/bzlib.c +++ b/bzlib.c @@ -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) { diff --git a/patches-not-included.txt b/patches-not-included.txt index 2e67d06..9811aef 100644 --- a/patches-not-included.txt +++ b/patches-not-included.txt @@ -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? -