httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Kraemer <>
Subject Re: "locale" project
Date Mon, 22 Dec 1997 11:48:25 GMT
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);

| S I E M E N S |  <>  |      Siemens Nixdorf
| ------------- |   Voice: +49-89-636-46021     |  Informationssysteme AG
| N I X D O R F |   FAX:   +49-89-636-44994     |   81730 Munich, Germany
~~~~~~~~~~~~~~~~My opinions only, of course; pgp key available on request

View raw message