[svn] dirmngr - r346 - trunk/src
svn author wk
cvs at cvs.gnupg.org
Tue Dec 14 20:22:32 CET 2010
Author: wk
Date: 2010-12-14 20:22:32 +0100 (Tue, 14 Dec 2010)
New Revision: 346
Modified:
trunk/src/ChangeLog
trunk/src/cdb.h
trunk/src/cdblib.c
Log:
Fix bug#1010.
Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog 2010-11-16 09:24:21 UTC (rev 345)
+++ trunk/src/ChangeLog 2010-12-14 19:22:32 UTC (rev 346)
@@ -1,3 +1,10 @@
+2010-12-14 Werner Koch <wk at g10code.com>
+
+ * cdb.h (struct cdb) [W32]: Add field CDB_MAPPING.
+ * cdblib.c (cdb_init) [W32]: Save mapping handle.
+ (cdb_free) [W32]: Don't leak the mapping handle from cdb_init by
+ using the saved one. Fixes bug#1010.
+
2010-11-16 Werner Koch <wk at g10code.com>
Change license to GPLv3+. This is required because we are using
Modified: trunk/src/cdb.h
===================================================================
--- trunk/src/cdb.h 2010-11-16 09:24:21 UTC (rev 345)
+++ trunk/src/cdb.h 2010-12-14 19:22:32 UTC (rev 346)
@@ -20,6 +20,9 @@
struct cdb {
int cdb_fd; /* file descriptor */
/* private members */
+#ifdef HAVE_W32_SYSTEM
+ void *cdb_mapping; /* Mapping handle. */
+#endif
cdbi_t cdb_fsize; /* datafile size */
const unsigned char *cdb_mem; /* mmap'ed file memory */
cdbi_t cdb_vpos, cdb_vlen; /* found data */
Modified: trunk/src/cdblib.c
===================================================================
--- trunk/src/cdblib.c 2010-11-16 09:24:21 UTC (rev 345)
+++ trunk/src/cdblib.c 2010-12-14 19:22:32 UTC (rev 346)
@@ -138,6 +138,7 @@
mem = (unsigned char *)MapViewOfFile(hMapping, FILE_MAP_READ, 0, 0, 0);
if (!mem)
return -1;
+ cdbp->cdb_mapping = hMapping;
#else
mem = (unsigned char*)mmap(NULL, fsize, PROT_READ, MAP_SHARED, fd, 0);
if (mem == MAP_FAILED)
@@ -174,13 +175,9 @@
{
if (cdbp->cdb_mem) {
#ifdef _WIN32
- HANDLE hFile, hMapping;
-#endif
-#ifdef _WIN32
- hFile = (HANDLE) _get_osfhandle(cdbp->cdb_fd);
- hMapping = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
UnmapViewOfFile((void*) cdbp->cdb_mem);
- CloseHandle(hMapping);
+ CloseHandle (cdbp->cdb_mapping);
+ cdbp->cdb_mapping = NULL;
#else
munmap((void*)cdbp->cdb_mem, cdbp->cdb_fsize);
#endif /* _WIN32 */
More information about the Gnupg-commits
mailing list