"Yasushi Shinjo" <yas@is.tsukuba.ac.jp> wrote in message
news:YAS.04Jan9214824@kirk.is.tsukuba.ac.jp...
> DESCRIPTION
>      The strlcpy() and strlcat() functions copy and concatenate strings
>
>      larger than 0).  Note that you should include a byte for the NUL in
size.

>
>      The strlcpy() function copies up to size - 1 characters from the
NUL-ter-
>      minated string src to dst, NUL-terminating the result.

>
>      The strlcat() function appends the NUL-terminated string src to the
end
>      of dst. It will append at most size - strlen(dst) - 1
bytes,NUL-termi-
>      nating the result.
>

> RETURN VALUES
>      The strlcpy() and strlcat() functions return the total length of the
>      string they tried to create.

> 後ろが切れてはいけないなら、こうします。
> ------------------------------------------------------------
>            char *dir, *file, pname[MAXPATHNAMELEN];
>            ...
>            if (strlcpy(pname, dir, sizeof(pname)) >= sizeof(pname))
>                    goto toolong;
>            if (strlcat(pname, file, sizeof(pname)) >= sizeof(pname))
>                    goto toolong;
> ------------------------------------------------------------

些細なことなんですが,(strlcpy/strlcatが無いので確認できないので)。FreeBSD
のマニュアルマニュアルのNote that you should include a byte
for the NUL in size.等から言えば,上のは
          if (strlcpy(pname, dir, sizeof(pname)) >= sizeof(pname) - 1)
                  goto toolong;
          if (strlcat(pname, file, sizeof(pname)) >= sizeof(pname) - 1)
                  goto toolong;

となるような気がするんですが。どうなんでしょうか。

-- 
******************************
   keizi kounoike
******************************