Eric Blake <e...@byu.net> writes:

> +/* Create a symlink, but reject trailing slash.  */
> +int
> +rpl_symlink (char const *contents, char const *name)
> +{
> +  size_t len = strlen (name);
> +  if (name[len - 1] == '/')
> +    {

If name is "" then the "if" statement will reference name[-1].

> +int
> +main ()
> +{
> +  /* Remove any leftovers from a previous partial run.  */
> +  ASSERT (system ("rm -rf " BASE "*") == 0);
> +
> +  if (symlink ("nowhere", BASE "link1"))
> +    {
> +      fputs ("skipping test: symlinks not supported on this filesystem\n",
> +          stderr);

Should this print the specific error that was encountered?  I
suspect that might be handy for debugging.

> +ssize_t
> +rpl_readlink (const char *name, char *buf, size_t bufsize)
> +{
> +  size_t len = strlen (name);
> +  if (name[len - 1] == '/')
> +    {

Again, accesses name[-1] if name is "".
-- 
"The road to hell is paved with convenient shortcuts."
--Peter da Silva



Reply via email to