Hi Michael On 10 October 2014 21:26, Michael Kerrisk (man-pages) <mtk.manpages@xxxxxxxxx> wrote: > 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) { Ok, I understand now. It lets you catch that the size of the link has increased, by that 1 byte overrun (that we didn't expect) I guess could even just check against st_size: if (r != sb.st_size) { fprintf(stderr, "symlink changed size " "between lstat() and readlink()\n"); exit(EXIT_FAILURE); } Regards, Jonny -- 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