[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:08:39 UTC 2010
The following commit has been merged in the debian/unstable branch:
commit 7988623295548b4ad8d6f0476cf9b23d5cb3a749
Author: aCaB <acab at clamav.net>
Date: Thu Oct 29 17:29:47 2009 +0100
win32: don't use . and .. in UNC names
diff --git a/ChangeLog b/ChangeLog
index a181dbe..1be0de2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Thu Oct 29 17:27:40 CET 2009 (acab)
+-----------------------------------
+ * win32: don't use . or .. in UNC names
+
Wed Oct 28 15:15:05 EET 2009 (edwin)
------------------------------------
* clamd/thrmgr.c: use a double instead of integer to avoid negative time (bb #1731).
diff --git a/win32/compat/w32_stat.c b/win32/compat/w32_stat.c
index 0eb7465..fabfcee 100644
--- a/win32/compat/w32_stat.c
+++ b/win32/compat/w32_stat.c
@@ -29,7 +29,7 @@
wchar_t *uncpath(const char *path) {
DWORD len = 0;
- wchar_t *dest = cli_malloc((PATH_MAX + 1) * sizeof(wchar_t));
+ wchar_t *stripme, *strip_from, *dest = cli_malloc((PATH_MAX + 1) * sizeof(wchar_t));
if(!dest)
return NULL;
@@ -64,11 +64,37 @@ wchar_t *uncpath(const char *path) {
}
len = wcslen(dest);
- if(len == 6 && !wcsncmp(dest, L"\\\\?\\", 4) && (dest[5] == L':') && ((dest[4] >= L'A' && dest[4] <= L'Z') || (dest[4] >= L'a' && dest[4] <= L'z'))) {
- dest[6] = L'\\';
- dest[7] = L'\0';
+ strip_from = &dest[3];
+ /* append a backslash to naked drives and get rid of . and .. */
+ if(!wcsncmp(dest, L"\\\\?\\", 4) && (dest[5] == L':') && ((dest[4] >= L'A' && dest[4] <= L'Z') || (dest[4] >= L'a' && dest[4] <= L'z'))) {
+ if(len == 6) {
+ dest[6] = L'\\';
+ dest[7] = L'\0';
+ }
+ strip_from = &dest[6];
+ }
+ while((stripme = wcsstr(strip_from, L"\\."))) {
+ wchar_t *copy_from, *copy_to;
+ if(stripme[2] == L'\\') {
+ copy_from = &stripme[2];
+ copy_to = stripme;
+ } else if (stripme[2] == L'.' && stripme[3] == L'\\') {
+ *stripme = L'\0';
+ copy_from = &stripme[3];
+ copy_to = wcsrchr(strip_from, L'\\');
+ if(!copy_to)
+ copy_to = strip_from;
+ } else {
+ strip_from = &stripme[1];
+ continue;
+ }
+ while(1) {
+ *copy_to = *copy_from;
+ if(!*copy_from) break;
+ copy_to++;
+ copy_from++;
+ }
}
-
return dest;
}
@@ -101,9 +127,6 @@ w32_stat(const char *path, struct stat *buf) {
if(!wpath)
return -1;
- len = wcslen(wpath);
- if(len > 2 && wpath[len-1] == L'.' && wpath[len-2] == L'\\')
- wpath[len-2] = L'\0'; /* windoze can't stat '.' ... */
len = GetFileAttributesExW(wpath, GetFileExInfoStandard, &attrs);
free(wpath);
if(!len) {
--
Debian repository for ClamAV
More information about the Pkg-clamav-commits
mailing list