* [PATCH v1 1/1] fs/proc/array.c: set overflow flag in case of error
@ 2015-09-18 8:27 Andy Shevchenko
0 siblings, 0 replies; only message in thread
From: Andy Shevchenko @ 2015-09-18 8:27 UTC (permalink / raw)
To: Andrew Morton, linux-kernel, Alexander Viro; +Cc: Andy Shevchenko
For now in task_name() we ignore the return code of string_escape_str() call.
This is not good if buffer suddenly becomes not big enough. Do the proper error
handling there.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
fs/proc/array.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/fs/proc/array.c b/fs/proc/array.c
index f60f012..21d2d30 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -91,18 +91,17 @@
static inline void task_name(struct seq_file *m, struct task_struct *p)
{
char *buf;
+ size_t size = seq_get_buf(m, &buf);
char tcomm[sizeof(p->comm)];
+ int ret;
get_task_comm(tcomm, p);
seq_puts(m, "Name:\t");
- buf = m->buf + m->count;
- /* Ignore error for now */
- buf += string_escape_str(tcomm, buf, m->size - m->count,
- ESCAPE_SPACE | ESCAPE_SPECIAL, "\n\\");
+ ret = string_escape_str(tcomm, buf, size, ESCAPE_SPACE | ESCAPE_SPECIAL, "\n\\");
+ seq_commit(m, ret < size ? ret : -1);
- m->count = buf - m->buf;
seq_putc(m, '\n');
}
--
2.5.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-09-18 8:28 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-18 8:27 [PATCH v1 1/1] fs/proc/array.c: set overflow flag in case of error Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®