procps-ng/procio-use-the-user-supplied-delimiter-to-split-larg.patch
2019-12-25 17:13:31 +08:00

34 lines
1.1 KiB
Diff

From 32720b2ee6c36b84005a002def17e79e3ab009e1 Mon Sep 17 00:00:00 2001
From: Patrick Steinhardt <ps@pks.im>
Date: Fri, 8 Jun 2018 13:27:20 +0200
Subject: [PATCH 61/65] 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.
---
procio.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/procio.c b/procio.c
index ad9b4de..2813cd5 100644
--- a/procio.c
+++ b/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)
--
2.6.4.windows.1