Re: [PATCH] readlink.2: Document using st_size to allocate the buffer

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

 



Hi!

On Tue, 2011-09-20 at 08:51:41 +0200, Michael Kerrisk wrote:
> I made some edits to your patch, and placed the added explanatory text
> in NOTES, rather than DESCRIPTION. Modified patch below.
> 
> The change will be in 3.34.

Thanks! Looks good.

> diff --git a/man2/readlink.2 b/man2/readlink.2
> index c9f6d92..051a870 100644
> --- a/man2/readlink.2
> +++ b/man2/readlink.2
> @@ -1,4 +1,5 @@
>  .\" Copyright (c) 1983, 1991 The Regents of the University of California.
> +.\" Adn Copyright (C) 2011 Guillem Jover <guillem@xxxxxxxxxxx>

Small typo: Adn → And.

> +    r = readlink(argv[1], linkname, sb.st_size + 1);
> +
> +    if (r < 0) {
> +        perror("lstat");
> +        exit(EXIT_FAILURE);
> +    }
> +
> +    if (r != sb.st_size) {
> +        fprintf(stderr, "symlink increased in size "
> +                        "between lstat() and readlink()\\n");
> +        exit(EXIT_FAILURE);
> +    }

You might want to change the check condition to “r > sb.st_size” to
match the new error string.

thanks,
guillem
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux