[or-cvs] Fix argument to strncpy.

Ben Laurie ben at algroup.co.uk
Wed Nov 24 05:57:23 UTC 2004


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



More information about the tor-dev mailing list