From 716bf4d6fbdd9c0709a1f6e80d7f0d92265dacae Mon Sep 17 00:00:00 2001 From: Peter Berg Larsen Date: Mon, 18 Apr 2005 15:33:31 +0000 Subject: [PATCH] Elimination of lstrcpyn, and corrected a potential pointer bug. --- dlls/dbghelp/module.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/dlls/dbghelp/module.c b/dlls/dbghelp/module.c index eae5d75e154..208c84cd249 100644 --- a/dlls/dbghelp/module.c +++ b/dlls/dbghelp/module.c @@ -35,15 +35,17 @@ WINE_DEFAULT_DEBUG_CHANNEL(dbghelp); static void module_fill_module(const char* in, char* out, unsigned size) { - const char* ptr; + const char *ptr,*endptr; unsigned len; - for (ptr = in + strlen(in) - 1; - *ptr != '/' && *ptr != '\\' && ptr >= in; + endptr = in + strlen(in); + for (ptr = endptr - 1; + ptr >= in && *ptr != '/' && *ptr != '\\'; ptr--); - if (ptr < in || *ptr == '/' || *ptr == '\\') ptr++; - lstrcpynA(out, ptr, size); - len = strlen(out); + ptr++; + 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';