diff options
author | Jakub Jelinek <jakub@redhat.com> | 2005-07-21 08:25:57 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2005-07-21 08:25:57 +0000 |
commit | 736e2ab430e006ba09a2fe34d7887d3812ac808f (patch) | |
tree | f2d5948776e91112fcfd9199a757cd58e1be867a /nscd/connections.c | |
parent | 366c71f353afc163b8d31c9db6e90919b5c2e1c0 (diff) | |
download | glibc-736e2ab430e006ba09a2fe34d7887d3812ac808f.tar glibc-736e2ab430e006ba09a2fe34d7887d3812ac808f.tar.gz glibc-736e2ab430e006ba09a2fe34d7887d3812ac808f.tar.bz2 glibc-736e2ab430e006ba09a2fe34d7887d3812ac808f.zip |
Updated to fedora-glibc-20050721T0814
Diffstat (limited to 'nscd/connections.c')
-rw-r--r-- | nscd/connections.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/nscd/connections.c b/nscd/connections.c index 0ca7585f14..d18851f828 100644 --- a/nscd/connections.c +++ b/nscd/connections.c @@ -393,20 +393,23 @@ cannot create read-only descriptor for \"%s\"; no mmap"), if (offset % ps != 0) { towrite = MIN (remaining, ps - (offset % ps)); - pwrite (fd, tmpbuf, towrite, offset); + if (pwrite (fd, tmpbuf, towrite, offset) != towrite) + goto write_fail; offset += towrite; remaining -= towrite; } while (remaining > ps) { - pwrite (fd, tmpbuf, ps, offset); + if (pwrite (fd, tmpbuf, ps, offset) == -1) + goto write_fail; offset += ps; remaining -= ps; } - if (remaining > 0) - pwrite (fd, tmpbuf, remaining, offset); + if (remaining > 0 + && pwrite (fd, tmpbuf, remaining, offset) != remaining) + goto write_fail; /* Create the header of the file. */ struct database_pers_head head = @@ -426,6 +429,7 @@ cannot create read-only descriptor for \"%s\"; no mmap"), || (mem = mmap (NULL, total, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)) == MAP_FAILED) { + write_fail: unlink (dbs[cnt].db_filename); dbg_log (_("cannot write to database file %s: %s"), dbs[cnt].db_filename, strerror (errno)); @@ -604,9 +608,14 @@ send_ro_fd (struct database_dyn *db, char *key, int fd) iov[0].iov_len = strlen (key) + 1; /* Prepare the control message to transfer the descriptor. */ - char buf[CMSG_SPACE (sizeof (int))]; + union + { + struct cmsghdr hdr; + char bytes[CMSG_SPACE (sizeof (int))]; + } buf; struct msghdr msg = { .msg_iov = iov, .msg_iovlen = 1, - .msg_control = buf, .msg_controllen = sizeof (buf) }; + .msg_control = buf.bytes, + .msg_controllen = sizeof (buf) }; struct cmsghdr *cmsg = CMSG_FIRSTHDR (&msg); cmsg->cmsg_level = SOL_SOCKET; @@ -960,7 +969,9 @@ cannot change to old working directory: %s; disabling paranoia mode"), setuid (server_uid); setgid (server_gid); } - chdir ("/"); + if (chdir ("/") != 0) + dbg_log (_("cannot change current working directory to \"/\": %s"), + strerror (errno)); paranoia = 0; } |