Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/config Add missed munmap(2) in extract_config
details: https://anonhg.NetBSD.org/src/rev/9c222c6b1a88
branches: trunk
changeset: 809903:9c222c6b1a88
user: shm <shm%NetBSD.org@localhost>
date: Sat Aug 08 15:52:41 2015 +0000
description:
Add missed munmap(2) in extract_config
diffstat:
usr.bin/config/main.c | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
diffs (50 lines):
diff -r 4b45f4641ee8 -r 9c222c6b1a88 usr.bin/config/main.c
--- a/usr.bin/config/main.c Sat Aug 08 15:36:39 2015 +0000
+++ b/usr.bin/config/main.c Sat Aug 08 15:52:41 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.75 2015/06/16 21:12:19 christos Exp $ */
+/* $NetBSD: main.c,v 1.76 2015/08/08 15:52:41 shm Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: main.c,v 1.75 2015/06/16 21:12:19 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.76 2015/08/08 15:52:41 shm Exp $");
#ifndef MAKE_BOOTSTRAP
#include <sys/cdefs.h>
@@ -1582,6 +1582,7 @@
extract_config(const char *kname, const char *cname, int cfd)
{
char *ptr;
+ void *base;
int found, kfd;
struct stat st;
off_t i;
@@ -1594,10 +1595,11 @@
err(EXIT_FAILURE, "cannot open %s", kname);
if (fstat(kfd, &st) == -1)
err(EXIT_FAILURE, "cannot stat %s", kname);
- ptr = mmap(0, (size_t)st.st_size, PROT_READ, MAP_FILE | MAP_SHARED,
+ base = mmap(0, (size_t)st.st_size, PROT_READ, MAP_FILE | MAP_SHARED,
kfd, 0);
- if (ptr == MAP_FAILED)
+ if (base == MAP_FAILED)
err(EXIT_FAILURE, "cannot mmap %s", kname);
+ ptr = base;
/* Scan mmap(2)'ed region, extracting kernel configuration */
for (i = 0; i < st.st_size; i++) {
@@ -1629,7 +1631,8 @@
}
(void)close(kfd);
-
+ (void)munmap(base, (size_t)st.st_size);
+
return found;
}
Home |
Main Index |
Thread Index |
Old Index