Eric Pouech : dbghelp: Correct handling for all module names.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Dec 22 07:07:33 CST 2005


Module: wine
Branch: refs/heads/master
Commit: 87ab6e6cd85901f8b87dec8a234ac45dbe27c00a
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=87ab6e6cd85901f8b87dec8a234ac45dbe27c00a

Author: Eric Pouech <eric.pouech at wanadoo.fr>
Date:   Thu Dec 22 11:11:39 2005 +0100

dbghelp: Correct handling for all module names.

---

 dlls/dbghelp/module.c |   44 +++++++++++++++++++++++++++-----------------
 1 files changed, 27 insertions(+), 17 deletions(-)

diff --git a/dlls/dbghelp/module.c b/dlls/dbghelp/module.c
index c00cc74..2b0de8c 100644
--- a/dlls/dbghelp/module.c
+++ b/dlls/dbghelp/module.c
@@ -33,10 +33,27 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
 
-static void module_fill_module(const char* in, char* out, unsigned size)
+static const char* ext[] = {".acm", ".dll", ".drv", ".exe", ".ocx", ".vxd", NULL};
+
+static int match_ext(const char* ptr, size_t len)
+{
+    const char**e;
+    size_t      l;
+
+    for (e = ext; *e; e++)
+    {
+        l = strlen(*e);
+        if (l >= len) return FALSE;
+        if (strncasecmp(&ptr[len - l], *e, l)) continue;
+        return l;
+    }
+    return 0;
+}
+        
+static void module_fill_module(const char* in, char* out, size_t size)
 {
-    const char          *ptr,*endptr;
-    unsigned            len;
+    const char  *ptr,*endptr;
+    size_t      len, l;
 
     endptr = in + strlen(in);
     for (ptr = endptr - 1;
@@ -46,24 +63,17 @@ static void module_fill_module(const cha
     len = min(endptr-ptr,size-1);
     memcpy(out, ptr, len);
     out[len] = '\0';
-    if (len > 4 && 
-        (!strcasecmp(&out[len - 4], ".dll") || !strcasecmp(&out[len - 4], ".exe")))
-        out[len - 4] = '\0';
-    else if (((len > 12 && out[len - 13] == '/') || len == 12) && 
+    if (len > 4 && (l = match_ext(out, len)))
+        out[len - l] = '\0';
+    else if (len > 12 &&
              (!strcasecmp(out + len - 12, "wine-pthread") || 
               !strcasecmp(out + len - 12, "wine-kthread")))
-        lstrcpynA(out, "<wine-loader>",size);
+        lstrcpynA(out, "<wine-loader>", size);
     else
     {
-        if (len > 7 && 
-            (!strcasecmp(&out[len - 7], ".dll.so") || !strcasecmp(&out[len - 7], ".exe.so")))
-            strcpy(&out[len - 7], "<elf>");
-        else if (len > 7 &&
-                 out[len - 7] == '.' && !strcasecmp(&out[len - 3], ".so"))
-        {
-            if (len + 3 < size) strcpy(&out[len - 3], "<elf>");
-            else WARN("Buffer too short: %s\n", out);
-        }
+        if (len > 3 && !strcasecmp(&out[len - 3], ".so") &&
+            (l = match_ext(out, len - 3)))
+            strcpy(&out[len - l - 3], "<elf>");
     }
     while ((*out = tolower(*out))) out++;
 }




More information about the wine-cvs mailing list