diff options
author | Nathan Kinder <nkinder@redhat.com> | 2010-09-08 09:51:21 -0700 |
---|---|---|
committer | Nathan Kinder <nkinder@redhat.com> | 2010-09-08 10:15:47 -0700 |
commit | cd99e197f22f7a26fae930d72b507a92e06313a8 (patch) | |
tree | 04be16331e0cef46e9eeb0b1dc6fc525152796c5 /ldap/servers | |
parent | 57edbb0f52649d2d4c643b58da360619ae078b7d (diff) | |
download | ds-cd99e197f22f7a26fae930d72b507a92e06313a8.tar.gz ds-cd99e197f22f7a26fae930d72b507a92e06313a8.tar.xz ds-cd99e197f22f7a26fae930d72b507a92e06313a8.zip |
Bug 630093 - (cov#15518) Need to intialize fd in ldbm2ldif code
Currently, the ldbm_back_ldbm2ldif() function could bail due to an
error before fd is set. We then attempt to close the file that fd
refers to. We should initialize fd to STDOUT_FILENUM, as we skip
calling close() if fd is set to STDOUT_FILENUM.
Additionally, I noticed that we could call close() when fd is
negative or if it is STDERR or STDIN. I fixed this so close() is
not called in those cases.
Diffstat (limited to 'ldap/servers')
-rw-r--r-- | ldap/servers/slapd/back-ldbm/ldif2ldbm.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c index 1b7b7ae4..f1b50ae3 100644 --- a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c +++ b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c @@ -885,7 +885,6 @@ static IDList *ldbm_fetch_subtrees(backend *be, char **include, int *err) return idltotal; } -#define FD_STDOUT 1 static int export_one_entry(struct ldbminfo *li, @@ -999,7 +998,7 @@ ldbm_back_ldbm2ldif( Slapi_PBlock *pb ) int decrypt = 0; int dump_replica = 0; int dump_uniqueid = 1; - int fd; + int fd = STDOUT_FILENO; IDList *idl = NULL; /* optimization for -s include lists */ int cnt = 0, lastcnt = 0; int options = 0; @@ -1168,7 +1167,7 @@ ldbm_back_ldbm2ldif( Slapi_PBlock *pb ) goto bye; } } else { /* '-' */ - fd = FD_STDOUT; + fd = STDOUT_FILENO; } if ( we_start_the_backends ) { @@ -1516,7 +1515,7 @@ bye: dblayer_release_id2entry( be, db ); - if (fd != FD_STDOUT) { + if (fd > STDERR_FILENO) { close(fd); } |