Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Chris January <chris.january@allinea.com>
To: gdb-patches@sourceware.org
Subject: [PATCH] Fix incorrect use of strcpy.
Date: Thu, 08 Mar 2012 14:21:00 -0000	[thread overview]
Message-ID: <1331216484.2742.7.camel@gumtree> (raw)

The strings passed to strcpy may not overlap, but &p and &p[len + 1]
clearly do. memmove allows overlapping memory area.

2012-03-08  Chris January  <chris.january@allinea.com>

        * source.c (add_path): Use memmove instead of strcpy because the
        strings overlap.
---
diff --git a/gdb/source.c b/gdb/source.c
index cfdf81b..7505309 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -588,7 +588,7 @@ add_path (char *dirname, char **which_path, int
parse_separators)
 		  p--;		/* Back over leading separator.  */
 		if (prefix > p - *which_path)
 		  goto skip_dup;	/* Same dir twice in one cmd.  */
-		strcpy (p, &p[len + 1]);	/* Copy from next \0 or  : */
+		memmove (p, &p[len + 1], strlen(&p[len + 1]) + 1);	/* Copy from next
\0 or  : */
 	      }
 	    p = strchr (p, DIRNAME_SEPARATOR);
 	    if (p != 0)




             reply	other threads:[~2012-03-08 14:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-08 14:21 Chris January [this message]
2012-03-08 18:17 ` Tom Tromey
2012-03-16 11:20   ` Chris January
2012-03-16 18:20     ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1331216484.2742.7.camel@gumtree \
    --to=chris.january@allinea.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox