[dlls/dbghelp/module.c] Elimination of lstrcpyn + bug
Peter Berg Larsen
pebl at math.ku.dk
Fri Apr 15 16:43:02 CDT 2005
I do not understand why the ptr >= in condition was the last tested, bug?
Why was there an if condition that always where true?
Changelog:
Elimination of lstrcpyn, and corrected a potential pointer
bug.
Index: dlls/dbghelp/module.c
===================================================================
RCS file: /home/wine/wine/dlls/dbghelp/module.c,v
retrieving revision 1.11
diff -u -r1.11 module.c
--- dlls/dbghelp/module.c 29 Mar 2005 13:14:08 -0000 1.11
+++ dlls/dbghelp/module.c 15 Apr 2005 20:13:49 -0000
@@ -35,15 +35,17 @@
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';
More information about the wine-patches
mailing list