all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#4992: Invalid use of strcpy() in etags
@ 2009-11-20 15:43 Tobias Ringström
  2009-11-23  9:51 ` Jan Djärv
  2009-11-23 10:00 ` bug#4992: marked as done (Invalid use of strcpy() in etags) Emacs bug Tracking System
  0 siblings, 2 replies; 3+ messages in thread
From: Tobias Ringström @ 2009-11-20 15:43 UTC (permalink / raw)
  To: bug-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 352 bytes --]

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


[-- Attachment #2: emacs-23.1-strcpy-bug.patch --]
[-- Type: text/plain, Size: 688 bytes --]

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-11-23 10:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-20 15:43 bug#4992: Invalid use of strcpy() in etags Tobias Ringström
2009-11-23  9:51 ` Jan Djärv
2009-11-23 10:00 ` bug#4992: marked as done (Invalid use of strcpy() in etags) Emacs bug Tracking System

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.