diff options
author | jdp <jdp@FreeBSD.org> | 1998-09-06 20:43:25 +0000 |
---|---|---|
committer | jdp <jdp@FreeBSD.org> | 1998-09-06 20:43:25 +0000 |
commit | 705eaef8b847e2fe924e76b18cb4d5064650d3ce (patch) | |
tree | 5b26cb83bc9d9d206d9df630e428f33d560585c7 /sbin/ldconfig | |
parent | e08529ca69b292c3c8e18e47ed49bfa82f03fbef (diff) | |
download | FreeBSD-src-705eaef8b847e2fe924e76b18cb4d5064650d3ce.zip FreeBSD-src-705eaef8b847e2fe924e76b18cb4d5064650d3ce.tar.gz |
Fix calls to mmap. It returns void *, and on failure it returns
MAP_FAILED.
Don't try to extend the mapping in place if it is too short.
There's no guarantee it will be possible. Remap the file instead.
Put in a few style fixes.
Submitted by: Bruce Evans <bde>
Diffstat (limited to 'sbin/ldconfig')
-rw-r--r-- | sbin/ldconfig/ldconfig.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/sbin/ldconfig/ldconfig.c b/sbin/ldconfig/ldconfig.c index e26c61c..2206c0b 100644 --- a/sbin/ldconfig/ldconfig.c +++ b/sbin/ldconfig/ldconfig.c @@ -30,7 +30,7 @@ #ifndef lint static const char rcsid[] = - "$Id: ldconfig.c,v 1.25 1998/09/05 03:30:54 jdp Exp $"; + "$Id: ldconfig.c,v 1.26 1998/09/05 16:20:15 jdp Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -169,12 +169,10 @@ char *argv[]; if (stat(argv[i], &stbuf) == -1) { warn("%s", argv[i]); rval = -1; - } - else if (!strcmp(argv[i], "/usr/lib")) { + } else if (strcmp(argv[i], "/usr/lib") == 0) { warnx("WARNING! '%s' can not be used", argv[i]); rval = -1; - } - else { + } else { /* * See if this is a directory-containing * file instead of a directory @@ -573,7 +571,8 @@ static int readhints() { int fd; - caddr_t addr; + void *addr; + long fsize; long msize; struct hints_header *hdr; struct hints_bucket *blist; @@ -589,7 +588,7 @@ readhints() msize = PAGE_SIZE; addr = mmap(0, msize, PROT_READ, MAP_COPY, fd, 0); - if (addr == (caddr_t)-1) { + if (addr == MAP_FAILED) { warn("%s", hints_file); return -1; } @@ -608,13 +607,14 @@ readhints() } if (hdr->hh_ehints > msize) { - if (mmap(addr+msize, hdr->hh_ehints - msize, - PROT_READ, MAP_COPY|MAP_FIXED, - fd, msize) != (caddr_t)(addr+msize)) { - + fsize = hdr->hh_ehints; + munmap(addr, msize); + addr = mmap(0, fsize, PROT_READ, MAP_COPY, fd, 0); + if (addr == MAP_FAILED) { warn("%s", hints_file); return -1; } + hdr = (struct hints_header *)addr; } close(fd); |