From: Daan De Meyer Date: Thu, 9 May 2024 10:32:31 +0000 (+0200) Subject: Fix ul_path_read_buffer() X-Git-Tag: archive/raspbian/2.40.2-8+rpi1~1^2^2^2~8 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=a00aa0bf23db347db38c9e53c1f288cbf723ad31;p=util-linux.git Fix ul_path_read_buffer() The current implementation cuts off the last character of the buffer if there is no trailing newline. (cherry picked from commit 6273c12257973cbd3c59a710049ee8a8027bbbb1) Gbp-Pq: Topic upstream Gbp-Pq: Name Fix-ul_path_read_buffer.patch --- diff --git a/lib/path.c b/lib/path.c index 202f19a..f897599 100644 --- a/lib/path.c +++ b/lib/path.c @@ -682,7 +682,7 @@ int ul_path_read_buffer(struct path_cxt *pc, char *buf, size_t bufsz, const char if (*(buf + rc - 1) == '\n') buf[--rc] = '\0'; else - buf[rc - 1] = '\0'; + buf[rc] = '\0'; } return rc;