Re: readlink.2 query

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

 



Hello Jonny

On Thu, Oct 9, 2014 at 1:22 PM, Jonny Grant <jg@xxxxxxxx> wrote:
> Hello
> Just looking at readlink.2 I have a query
>
> http://man7.org/linux/man-pages/man2/readlink.2.html
>
> r = readlink(argv[1], linkname, sb.st_size + 1);
>
> Would this example be better without +1 ? We need to save that byte
> for nul terminator.

No -- it;s needed to detect the case

    if (r > sb.st_size) {

> Nicer to add: free(linkname);

Added.

> Also, re ENOMEM is this really kernel memory error?

I'm not sure. No time to check. Do you have some pointer that
indicates that it is wrong?

Thanks,

Michael

-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
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