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

Gerald Pfeifer gerald at pfeifer.com
Sat Mar 23 19:52:23 CDT 2013


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?)

Gerald

---
 programs/xcopy/xcopy.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

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