[Pkg-clamav-commits] [SCM] Debian repository for ClamAV branch, debian/unstable, updated. debian/0.95+dfsg-1-6156-g094ec9b

aCaB acab at clamav.net
Sun Apr 4 01:07:38 UTC 2010


The following commit has been merged in the debian/unstable branch:
commit b0fc218f6eccf30ab38b3eb28020cece729e77b4
Author: aCaB <acab at clamav.net>
Date:   Sat Oct 10 20:46:05 2009 +0200

    fmap: win32 fixes

diff --git a/ChangeLog b/ChangeLog
index bcfdc06..d0d5598 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Sat Oct 10 20:22:10 CEST 2009 (acab)
+------------------------------------
+ * libclamav: completed merge of fmap4all
+
 Thu Oct  8 19:03:57 CEST 2009 (tk)
 ----------------------------------
  * libclamav/matcher-bm.c: don't use mpool (bb#1710, #1715)
diff --git a/libclamav/fmap.c b/libclamav/fmap.c
index 704ad95..07a26c6 100644
--- a/libclamav/fmap.c
+++ b/libclamav/fmap.c
@@ -41,8 +41,11 @@
 #include "others.h"
 #include "cltypes.h"
 
+static inline unsigned int fmap_align_items(unsigned int sz, unsigned int al);
+static inline unsigned int fmap_align_to(unsigned int sz, unsigned int al);
+static inline unsigned int fmap_which_page(fmap_t *m, size_t at);
 
-#ifndef __WIN32
+#ifndef _WIN32
 /* vvvvv POSIX STUFF BELOW vvvvv */
 
 #define FM_MASK_COUNT 0x3fffffff
@@ -86,19 +89,6 @@ pthread_mutex_t fmap_mutex = PTHREAD_MUTEX_INITIALIZER;
    which may in turn prevent some mmap constants to be defined */
 ssize_t pread(int fd, void *buf, size_t count, off_t offset);
 
-static inline unsigned int fmap_align_items(unsigned int sz, unsigned int al) {
-    return sz / al + (sz % al != 0);
-}
-
-static inline unsigned int fmap_align_to(unsigned int sz, unsigned int al) {
-    return al * fmap_align_items(sz, al);
-}
-
-static inline unsigned int fmap_which_page(fmap_t *m, size_t at) {
-    return at / m->pgsz;
-}
-
-
 fmap_t *fmap(int fd, off_t offset, size_t len) {
     unsigned int pages, mapsz, hdrsz, dumb = 1;
     int pgsz = cli_getpagesize();
@@ -501,7 +491,7 @@ void *fmap_gets(fmap_t *m, char *dst, size_t *at, size_t max_len) {
 
 /* ^^^^^ POSIX STUFF AVOVE ^^^^^ */
 
-#else /* __WIN32 */
+#else /* _WIN32 */
 
 /* vvvvv WIN32 STUFF BELOW vvvvv */
 
@@ -528,11 +518,15 @@ fmap_t *fmap(int fd, off_t offset, size_t len) { /* WIN32 */
 	cli_warnmsg("fmap: attempted oof mapping\n");
 	return NULL;
     }
+
+    pages = fmap_align_items(len, pgsz);
+    hdrsz = fmap_align_to(sizeof(fmap_t);
+
     if(!(m = (fmap_t *)cli_malloc(sizeof(fmap_t)))) {
 	cli_errmsg("fmap: canot allocate fmap_t\n", fd);
 	return NULL;
     }
-    if((m->fh = _get_osfhandle(fd)) == INVALID_HANDLE_VALUE) {
+    if((m->fh = (HANDLE)_get_osfhandle(fd)) == INVALID_HANDLE_VALUE) {
 	cli_errmsg("fmap: cannot get a valid handle for descriptor %d\n", fd);
 	free(m);
 	return NULL;
@@ -623,7 +617,7 @@ void *fmap_gets(fmap_t *m, char *dst, size_t *at, size_t max_len) { /* WIN32 */
 	return NULL;
     }
 
-    if((endptr = memchr(*src, '\n', len))) {
+    if((endptr = memchr(src, '\n', len))) {
 	endptr++;
 	memcpy(dst, src, endptr - src);
 	dst[endptr - src] = '\0';
@@ -636,7 +630,7 @@ void *fmap_gets(fmap_t *m, char *dst, size_t *at, size_t max_len) { /* WIN32 */
     return dst;
 }
 
-#endif /* __WIN32 */
+#endif /* _WIN32 */
 
 
 /* vvvvv SHARED STUFF BELOW vvvvv */
@@ -655,3 +649,14 @@ int fmap_readn(fmap_t *m, void *dst, size_t at, size_t len) {
     return len;
 }
 
+static inline unsigned int fmap_align_items(unsigned int sz, unsigned int al) {
+    return sz / al + (sz % al != 0);
+}
+
+static inline unsigned int fmap_align_to(unsigned int sz, unsigned int al) {
+    return al * fmap_align_items(sz, al);
+}
+
+static inline unsigned int fmap_which_page(fmap_t *m, size_t at) {
+    return at / m->pgsz;
+}
diff --git a/libclamav/fmap.h b/libclamav/fmap.h
index 7ffa164..5153348 100644
--- a/libclamav/fmap.h
+++ b/libclamav/fmap.h
@@ -33,7 +33,7 @@ typedef struct {
     unsigned int hdrsz;
     unsigned int pgsz;
     unsigned int paged;
-#ifdef __WIN32
+#ifdef _WIN32
     HANDLE fh;
     HANDLE mh;
     void *data;
diff --git a/libclamav/others.h b/libclamav/others.h
index 2d179fb..7f57866 100644
--- a/libclamav/others.h
+++ b/libclamav/others.h
@@ -362,13 +362,13 @@ void cli_dbgmsg_internal(const char *str, ...);
 #undef HAVE_CLI_GETPAGESIZE
 #endif
 
-#ifdef __WIN32
-int cli_getpagesize(void) {
+#ifdef _WIN32
+static inline int cli_getpagesize(void) {
     SYSTEM_INFO si;
     GetSystemInfo(&si);
     return si.dwPageSize;
 }
-#else /* ! __WIN32 */
+#else /* ! _WIN32 */
 #if HAVE_SYSCONF_SC_PAGESIZE
 static inline int cli_getpagesize(void) { return sysconf(_SC_PAGESIZE); }
 #define HAVE_CLI_GETPAGESIZE 1
@@ -378,7 +378,7 @@ static inline int cli_getpagesize(void) { return getpagesize(); }
 #define HAVE_CLI_GETPAGESIZE 1
 #endif /* HAVE_GETPAGESIZE */
 #endif /* HAVE_SYSCONF_SC_PAGESIZE */
-#endif /* __WIN32 */
+#endif /* _WIN32 */
 
 void *cli_malloc(size_t nmemb);
 void *cli_calloc(size_t nmemb, size_t size);

-- 
Debian repository for ClamAV



More information about the Pkg-clamav-commits mailing list