[PATCH v1 10/12] nfsd: Avoid non-flexible API in seq_quote_mem()
From: Andy Shevchenko
Date: Mon May 03 2021 - 16:49:34 EST
string_escape_mem_ascii() followed by seq_escape_mem_ascii() is completely
non-flexible and shouldn't be exist from day 1.
Replace it with properly called string_escape_mem().
Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
---
fs/nfsd/nfs4state.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index b517a8794400..15535589e5e4 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -2350,8 +2350,14 @@ static struct nfs4_client *get_nfsdfs_clp(struct inode *inode)
static void seq_quote_mem(struct seq_file *m, char *data, int len)
{
+ char *buf;
+ size_t size = seq_get_buf(m, &buf);
+ const char *only = "\"\\";
+ int ret;
+
seq_printf(m, "\"");
- seq_escape_mem_ascii(m, data, len);
+ ret = string_escape_mem(data, len, buf, size, ESCAPE_HEX | ESCAPE_APPEND, only);
+ seq_commit(m, ret < size ? ret : -1);
seq_printf(m, "\"");
}
--
2.30.2