Subject: Invalid use of strcpy() in etags

From: Tobias Ringström <[email-masked]>
Date: Fri, 20 Nov 2009 16:43:05 +0100

The function absolute_filename() lib-src/etags.c has two invalid calls 
to strcpy() with overlapping arguments. It's undefined C that often 
happens to work, but breaks very badly for at least gcc 4.4.2 and glibc 
2.11 on x86_64, which is default for Fedora 12.

The attached patch replaces the bogus strcpy() calls with calls to 
memmove().

/Tobias

diff -ru emacs-23.1.orig/lib-src/etags.c emacs-23.1/lib-src/etags.c
--- emacs-23.1.orig/lib-src/etags.c	2009-06-21 06:37:34.000000000 +0200
+++ emacs-23.1/lib-src/etags.c	2009-11-20 16:35:09.638200192 +0100
@@ -6695,13 +6695,13 @@
 	      else if (cp[0] != '/')
 		cp = slashp;
 #endif
-	      strcpy (cp, slashp + 3);
+	      memmove (cp, slashp + 3, strlen (slashp + 2));
 	      slashp = cp;
 	      continue;
 	    }
 	  else if (slashp[2] == '/' || slashp[2] == '\0')
 	    {
-	      strcpy (slashp, slashp + 2);
+	      memmove (slashp, slashp + 2, strlen (slashp + 1));
 	      continue;
 	    }
 	}
Only in emacs-23.1/lib-src: etags.c.orig
Only in emacs-23.1/lib-src: etags.c.rej