readlink.2: Emphasize that the returned buffer is not null-terminated

Reported-by: Jonny Grant <jg@jguk.org>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
Michael Kerrisk 2020-12-30 14:55:38 +01:00
parent 5bd94cbd31
commit ab4001e286
1 changed files with 3 additions and 1 deletions

View File

@ -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