From: Michael Kerrisk Date: Wed, 30 Dec 2020 13:55:38 +0000 (+0100) Subject: readlink.2: Emphasize that the returned buffer is not null-terminated X-Git-Tag: man-pages-5.11~440 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ab4001e286f8a613b57b2d593cbc0e55e404f313;p=thirdparty%2Fman-pages.git readlink.2: Emphasize that the returned buffer is not null-terminated Reported-by: Jonny Grant Signed-off-by: Michael Kerrisk --- diff --git a/man2/readlink.2 b/man2/readlink.2 index 6a1767caa1..a078deb4f2 100644 --- a/man2/readlink.2 +++ b/man2/readlink.2 @@ -93,7 +93,7 @@ in the buffer which has size .IR bufsiz . .BR readlink () -does not append a null byte to +does not append a terminating null byte to .IR buf . It will (silently) truncate the contents (to a length of .I bufsiz @@ -332,6 +332,8 @@ main(int argc, char *argv[]) exit(EXIT_FAILURE); } + /* Print only \(aqnbytes\(aq of \(aqbuf\(aq, as it doesn't contain a terminating + null byte (\(aq\e0\(aq). */ printf("\(aq%s\(aq points to \(aq%.*s\(aq\en", argv[1], (int) nbytes, buf); /* If the return value was equal to the buffer size, then the