httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ben Laurie <...@algroup.co.uk>
Subject Re: "locale" project
Date Mon, 22 Dec 1997 11:53:39 GMT
Martin Kraemer wrote:
> 
> On Fri, Dec 19, 1997 at 12:17:28PM -0800, Dean Gaudet wrote:
> > You can find similar lame examples using strncpy,
> > and strncat.
> 
> Yes, but we could certainly eliminate assignments like
> 
>     strncpy(server_root, HTTPD_ROOT, sizeof(server_root) - 1);
> 
> today. What use is there in filling in the HTTPD_ROOT, and then filling
> up all the rest (up to HUGE_STRING_LEN-sizeof(HTTPD_ROOT) bytes) with
> zero characters? The functionality of strncpy() is totally broken: the
> only use for it is in the directory entry fill-in code of the
> 14-char-length Sys5 file system (there, the file names must be padded to
> length 14 with binary zeros, unless their length is 14 already. But
> probably, that's also the only place where it _isn't_ used...). For
> everyday use, strncpy() is the wrong candidate. What's needed is a
> "bounded strcpy()", something like:
>     strncat(strcpy(dest,""), srce, length);

Good grief. I'd never noticed that strncpy did zero fill!

Cheers,

Ben.

-- 
Ben Laurie            |Phone: +44 (181) 735 0686|Apache Group member
Freelance Consultant  |Fax:   +44 (181) 735 0689|http://www.apache.org
and Technical Director|Email: ben@algroup.co.uk |Apache-SSL author
A.L. Digital Ltd,     |http://www.algroup.co.uk/Apache-SSL
London, England.      |"Apache: TDG" http://www.ora.com/catalog/apache

Mime
View raw message