]> granicus.if.org Git - procps-ng/commitdiff
procio: use the user-supplied delimiter to split large input
authorPatrick Steinhardt <ps@pks.im>
Fri, 8 Jun 2018 11:27:20 +0000 (13:27 +0200)
committerCraig Small <csmall@enc.com.au>
Mon, 4 Mar 2019 10:54:43 +0000 (21:54 +1100)
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

index 7d96964401a61055b0baf2f720c5fba0ce47bda8..5cc7af66f4f0a94241dafafde1cfa07fa5312743 100644 (file)
@@ -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)