Browse code

Use memcpy rather than strcpy

git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@796 77e5149b-7576-45b1-b177-96237e5ba77b

Nigel Horne authored on 2004/08/25 21:33:06
Showing 2 changed files
... ...
@@ -1,6 +1,10 @@
1
+Wed Aug 25 13:32:22 BST 2004 (njh)
2
+----------------------------------
3
+  * libclamav/line.c:	Small code optimisation
4
+
1 5
 Wed Aug 25 12:45:53 BST 2004 (njh)
2 6
 ----------------------------------
3
-  * clamav-milter Give hint about what do to if the running as root warning
7
+  * clamav-milter: Give hint about what do to if the running as root warning
4 8
 			appears
5 9
 		Optimise the sending of headers to clamd
6 10
 		Give better SMTP status message when asking for retransmit
... ...
@@ -16,6 +16,9 @@
16 16
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 17
  *
18 18
  * $Log: line.c,v $
19
+ * Revision 1.3  2004/08/25 12:30:36  nigelhorne
20
+ * Use memcpy rather than strcpy
21
+ *
19 22
  * Revision 1.2  2004/08/21 11:57:57  nigelhorne
20 23
  * Use line.[ch]
21 24
  *
... ...
@@ -24,7 +27,7 @@
24 24
  *
25 25
  */
26 26
 
27
-static	char	const	rcsid[] = "$Id: line.c,v 1.2 2004/08/21 11:57:57 nigelhorne Exp $";
27
+static	char	const	rcsid[] = "$Id: line.c,v 1.3 2004/08/25 12:30:36 nigelhorne Exp $";
28 28
 
29 29
 #if HAVE_CONFIG_H
30 30
 #include "clamav-config.h"
... ...
@@ -84,13 +87,16 @@ lineGetData(const line_t *line)
84 84
 line_t *
85 85
 lineCreate(const char *data)
86 86
 {
87
-	line_t *ret = (line_t *)cli_malloc(strlen(data) + 2);
87
+	const size_t size = strlen(data);
88
+	line_t *ret = (line_t *)cli_malloc(size + 2);
88 89
 
89 90
 	if(ret == NULL)
90 91
 		return NULL;
91 92
 
92 93
 	ret[0] = (char)1;
93
-	strcpy(&ret[1], data);
94
+	/*strcpy(&ret[1], data);*/
95
+	memcpy(&ret[1], data, size);
96
+	ret[size + 1] = '\0';
94 97
 
95 98
 	return ret;
96 99
 }