From 70ed1a72adda188de106c76d0604fc332016e9a2 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Fri, 8 Jun 2018 13:27:20 +0200 Subject: [PATCH] procio: use the user-supplied delimiter to split large input The `fprocopen` function allows users to specify a delimiter chacter that is used to split very large input lines into smaller chunks. While the code checks that the caller did actually supply the delimiter, it is in fact never used to split the string. Instead, the hardcoded default character ',' is always used to split the string. Fix the issue by using `cookie->delim` instead. --- lib/procio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/procio.c b/lib/procio.c index 7d969644..5cc7af66 100644 --- a/lib/procio.c +++ b/lib/procio.c @@ -249,7 +249,7 @@ ssize_t proc_write(void *c, const char *buf, size_t count) do { token = NULL; if (cookie->offset > LINELEN) - token = (char*)memrchr(cookie->buf+offset, ',', LINELEN); + token = (char*)memrchr(cookie->buf+offset, cookie->delim, LINELEN); else token = (char*)memrchr(cookie->buf+offset, '\n', LINELEN); if (token)