* nscd/Makefile (nscd-cflags): Add _FORTIFY_SOURCE.

* nscd/connections.c: Fix a few wur warnings.
This commit is contained in:
Ulrich Drepper 2005-07-18 22:28:46 +00:00
parent 9f3731cf7f
commit 233399bce2
3 changed files with 16 additions and 6 deletions

View File

@ -1,5 +1,9 @@
2005-07-18 Ulrich Drepper <drepper@redhat.com> 2005-07-18 Ulrich Drepper <drepper@redhat.com>
* nscd/Makefile (nscd-cflags): Add _FORTIFY_SOURCE.
* nscd/connections.c: Fix a few wur warnings.
* nscd/grpcache.c (cache_addgr): Use correct maximum for group ID * nscd/grpcache.c (cache_addgr): Use correct maximum for group ID
length. Patch by Ivan Gyurdiev <ivg2@cornell.edu>. length. Patch by Ivan Gyurdiev <ivg2@cornell.edu>.

View File

@ -84,7 +84,7 @@ CFLAGS-nscd_gethst_r.c = -fexceptions
CFLAGS-nscd_getai.c = -fexceptions CFLAGS-nscd_getai.c = -fexceptions
CFLAGS-nscd_initgroups.c = -fexceptions CFLAGS-nscd_initgroups.c = -fexceptions
nscd-cflags = -DIS_IN_nscd=1 nscd-cflags = -DIS_IN_nscd=1 -D_FORTIFY_SOURCE=2
ifeq (yesyes,$(have-fpie)$(build-shared)) ifeq (yesyes,$(have-fpie)$(build-shared))
nscd-cflags += -fpie nscd-cflags += -fpie
endif endif

View File

@ -393,20 +393,23 @@ cannot create read-only descriptor for \"%s\"; no mmap"),
if (offset % ps != 0) if (offset % ps != 0)
{ {
towrite = MIN (remaining, ps - (offset % ps)); towrite = MIN (remaining, ps - (offset % ps));
pwrite (fd, tmpbuf, towrite, offset); if (pwrite (fd, tmpbuf, towrite, offset) != towrite)
goto write_fail;
offset += towrite; offset += towrite;
remaining -= towrite; remaining -= towrite;
} }
while (remaining > ps) while (remaining > ps)
{ {
pwrite (fd, tmpbuf, ps, offset); if (pwrite (fd, tmpbuf, ps, offset) == -1)
goto write_fail;
offset += ps; offset += ps;
remaining -= ps; remaining -= ps;
} }
if (remaining > 0) if (remaining > 0
pwrite (fd, tmpbuf, remaining, offset); && pwrite (fd, tmpbuf, remaining, offset) != remaining)
goto write_fail;
/* Create the header of the file. */ /* Create the header of the file. */
struct database_pers_head head = 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, || (mem = mmap (NULL, total, PROT_READ | PROT_WRITE,
MAP_SHARED, fd, 0)) == MAP_FAILED) MAP_SHARED, fd, 0)) == MAP_FAILED)
{ {
write_fail:
unlink (dbs[cnt].db_filename); unlink (dbs[cnt].db_filename);
dbg_log (_("cannot write to database file %s: %s"), dbg_log (_("cannot write to database file %s: %s"),
dbs[cnt].db_filename, strerror (errno)); dbs[cnt].db_filename, strerror (errno));
@ -965,7 +969,9 @@ cannot change to old working directory: %s; disabling paranoia mode"),
setuid (server_uid); setuid (server_uid);
setgid (server_gid); setgid (server_gid);
} }
chdir ("/"); if (chdir ("/") != 0)
dbg_log (_("cannot change current working directory to \"/\": %s"),
strerror (errno));
paranoia = 0; paranoia = 0;
} }