Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/sbin/ifconfig



fix incorrect usage of strncpy() to (an internal implementation of)
estrlcpy().

        void
        estrlcpy(char *dst, char *src, size_t len)
        {
                if (strlcpy(dst, src, len) >= len) {
                        errno = ENAMETOOLONG;
                        err(1, "Cannot copy `%s'", src);
                }
        }

This seems to be a bit of a pun on ENAMETOOLONG, which is defined
(by SUS and us) to be filename-specific, and to mean precisely that
a component of a pathname exceeded NAME_MAX(resp. MAXNAMELEN) or that
the entire path exceeded PATH_MAX(resp. MAXPATHLEN-1).

Obviously the function doesn't return, so it isn't a matter of
misleading the caller, but it will still print the message "File name
too long" which is a little odd and could send a user down the wrong
track trying to figure out why the utility might have failed. Would it
be bad to use errx and a specific message?

-Chap



Home | Main Index | Thread Index | Old Index