953 amd64 mdb chews arguments to ::run?
authorAlexander Eremin <a.eremin@nexenta.com>
Tue, 17 May 2011 12:36:01 -0400
changeset 13375 5e6d930c0c9b
parent 13374 b156817e002c
child 13376 c3f168efd1e4
953 amd64 mdb chews arguments to ::run? Reviewed by: Dan McDonald <[email protected]> Reviewed by: Garrett D'Amore <[email protected]> Reviewed by: Adam Leventhal <[email protected]> Reviewed by: Richard Lowe <[email protected]> Approved by: Gordon Ross <[email protected]>
usr/src/cmd/mdb/common/mdb/mdb_lex.l
--- a/usr/src/cmd/mdb/common/mdb/mdb_lex.l	Tue May 17 11:08:25 2011 -0400
+++ b/usr/src/cmd/mdb/common/mdb/mdb_lex.l	Tue May 17 12:36:01 2011 -0400
@@ -25,6 +25,10 @@
  * Use is subject to license terms.
  */
 
+/*
+ * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
+ */
+
 #include <sys/types.h>
 #include <sys/isa_defs.h>
 
@@ -673,7 +677,8 @@
 		 * the destination buffer past what we skipped.
 		 */
 		if (p > o) {
-			(void) strncpy(s, o, p - o);
+			/* Using memmove to prevent possible overlap. */
+			(void) memmove(s, o, p - o);
 			s += p - o;
 		}
 
@@ -696,7 +701,7 @@
 		 * and convert escape sequences if *p is double-quote.
 		 */
 		if (q > p + 1) {
-			(void) strncpy(s, p + 1, q - p - 1);
+			(void) memmove(s, p + 1, q - p - 1);
 			if (c == '"') {
                                 s[q - p - 1] = '\0';
 				s += stresc2chr(s);
@@ -707,7 +712,7 @@
 		p = q + 1; /* Advance p past matching quote */
 	}
 
-	(void) strcpy(s, o);
+	(void) memmove(s, o, strlen(o) + 1);
 }
 
 /*