[or-cvs] betcha didn"t know strncpy could leave an unterminated string

Ben Laurie ben at algroup.co.uk
Wed Dec 17 13:52:43 UTC 2003


Roger Dingledine wrote:

> Update of /home/or/cvsroot/src/or
> In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or
> 
> Modified Files:
> 	dirserv.c dns.c 
> Log Message:
> betcha didn't know strncpy could leave an unterminated string

Did actually - that's why you should use strlcpy and strlcat instead. 
Another thing that's bad about strncpy is it NUL _fills_ which can be a 
significant cost if you use large buffers.

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-commits mailing list