xcopy: Add an explicit check to avoid an out of array access. access. (RESEND)

Gerald Pfeifer gerald at pfeifer.com
Mon Sep 9 16:29:01 CDT 2013


On Sun, 24 Mar 2013, Gerald Pfeifer wrote:
> This _may_ not be necessary, strictly speaking, but new versions of
> GCC (GCC 4.8) complain about this. (And there might be a fringe case?)

How about this patch?  I see it was not applied, but also did not
see a response.

Gerald


diff --git a/programs/xcopy/xcopy.c b/programs/xcopy/xcopy.c
index 7a68831..83ef973 100644
--- a/programs/xcopy/xcopy.c
+++ b/programs/xcopy/xcopy.c
@@ -272,7 +272,8 @@ static BOOL XCOPY_ProcessExcludeFile(WCHAR* filename, WCHAR* endOfName) {
         int length = lstrlenW(buffer);
 
         /* Strip CRLF */
-        buffer[length-1] = 0x00;
+        if( length > 0 )
+          buffer[length-1] = 0x00;
 
         /* If more than CRLF */
         if (length > 1) {
-- 
1.8.1.3



More information about the wine-patches mailing list