Blame SOURCES/cvsps-2.2b1-bufferoverflow.patch

fc0301
--- cvsps-2.2b1/cvsps.c	2010-09-07 18:13:42.760727491 +0200
fc0301
+++ cvsps-2.2b1_/cvsps.c	2010-09-07 18:05:11.083729441 +0200
fc0301
@@ -1065,17 +1065,16 @@ static CvsFile * parse_file(const char *
fc0301
 {
fc0301
     CvsFile * retval;
fc0301
     char fn[PATH_MAX];
fc0301
-    int len = strlen(buff + 10);
fc0301
+    size_t len = strlen(buff + 10);
fc0301
     char * p;
fc0301
 
fc0301
     /* once a single file has been parsed ok we set this */
fc0301
     static int path_ok;
fc0301
-    
fc0301
+
fc0301
     /* chop the ",v" string and the "LF" */
fc0301
     len -= 3;
fc0301
     memcpy(fn, buff + 10, len);
fc0301
     fn[len] = 0;
fc0301
-    
fc0301
     if (strncmp(fn, strip_path, strip_path_len) != 0)
fc0301
     {
fc0301
 	/* if the very first file fails the strip path,
fc0301
@@ -1096,10 +1095,10 @@ static CvsFile * parse_file(const char *
fc0301
 
fc0301
 	    while ((p = strstr(p, repository_path)))
fc0301
 		lastp = p++;
fc0301
-      
fc0301
+
fc0301
 	    if (lastp)
fc0301
 	    {
fc0301
-		int len = strlen(repository_path);
fc0301
+		size_t len = strlen(repository_path);
fc0301
 		memcpy(strip_path, fn, lastp - fn + len + 1);
fc0301
 		strip_path_len = lastp - fn + len + 1;
fc0301
 		strip_path[strip_path_len] = 0;
fc0301
@@ -1114,16 +1113,26 @@ static CvsFile * parse_file(const char *
fc0301
 	 *
fc0301
 	 * For now just ignore such files
fc0301
 	 */
fc0301
-	debug(DEBUG_APPMSG1, "WARNING: file %s doesn't match strip_path %s. ignoring", 
fc0301
+	debug(DEBUG_APPMSG1, "WARNING: file %s doesn't match strip_path %s. ignoring",
fc0301
 	      fn, strip_path);
fc0301
 	return NULL;
fc0301
     }
fc0301
 
fc0301
  ok:
fc0301
-    path_ok = 1;
fc0301
-
fc0301
+     /*
fc0301
+     fix for rhbz#576076
fc0301
+     ./cvsps --norc -q --cvs-direct -u -A --root :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot NSS
fc0301
+     */
fc0301
+    if(len <= strip_path_len)
fc0301
+    {
fc0301
+        debug(DEBUG_APPMSG1, "WARNING: file %s doesn't match strip_path %s. ignoring",
fc0301
+	      fn, strip_path);
fc0301
+        return NULL;
fc0301
+    }
fc0301
     /* remove from beginning the 'strip_path' string */
fc0301
     len -= strip_path_len;
fc0301
+    path_ok = 1;
fc0301
+
fc0301
     memmove(fn, fn + strip_path_len, len);
fc0301
     fn[len] = 0;
fc0301