[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [or-cvs] Fix argument to strncpy.
- To: or-dev@freehaven.net
- Subject: Re: [or-cvs] Fix argument to strncpy.
- From: Ben Laurie <ben@algroup.co.uk>
- Date: Wed, 24 Nov 2004 05:57:23 +0000
- Cc: or-cvs@freehaven.net
- Delivered-to: archiver@seul.org
- Delivered-to: or-dev-outgoing@seul.org
- Delivered-to: or-dev@seul.org
- Delivery-date: Wed, 24 Nov 2004 00:57:58 -0500
- In-reply-to: <20041112211454.1047F33D09@moria.seul.org>
- References: <20041112211454.1047F33D09@moria.seul.org>
- Reply-to: or-dev@freehaven.net
- Sender: owner-or-dev@freehaven.net
- User-agent: Mozilla Thunderbird 0.9 (Windows/20041103)
Nick Mathewson wrote:
Update of /home/or/cvsroot/src/common
In directory moria.mit.edu:/tmp/cvs-serv10041/src/common
Modified Files:
util.c
Log Message:
Fix argument to strncpy.
Index: util.c
===================================================================
RCS file: /home/or/cvsroot/src/common/util.c,v
retrieving revision 1.179
retrieving revision 1.180
diff -u -d -r1.179 -r1.180
--- util.c 12 Nov 2004 20:41:03 -0000 1.179
+++ util.c 12 Nov 2004 21:14:51 -0000 1.180
@@ -171,7 +171,7 @@
* this function gets called a whole lot, and platform strncpy is
* much faster than strlcpy when strlen(s) is much longer than n.
*/
- strncpy(dup, s, n+1);
+ strncpy(dup, s, n);
dup[n]='\0';
return dup;
}
But strncpy is much slower when n >> strlen(s).
Cheers,
Ben.
--
http://www.apache-ssl.org/ben.html http://www.thebunker.net/
"There is no limit to what a man can do or how far he can go if he
doesn't mind who gets the credit." - Robert Woodruff