From abe89bf315961f78a417617fb138e73ac088f9dd Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Sat, 6 Jan 2018 01:45:16 +0000 Subject: [PATCH] poll.c: use xs*printf instead of sprintf * poll.c: Include "xstring.h". (decode_poll_exiting): Replace sprintf with xsnprintf and xsprintf. --- poll.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/poll.c b/poll.c index e3b497ca..a937e0da 100644 --- a/poll.c +++ b/poll.c @@ -29,6 +29,7 @@ #include "defs.h" #include +#include "xstring.h" #include "xlat/pollflags.h" @@ -96,7 +97,9 @@ decode_poll_exiting(struct tcb *const tcp, const kernel_ulong_t pts) *outptr++ = '['; else outptr = stpcpy(outptr, ", "); - outptr += sprintf(outptr, "%#" PRI_klx, cur); + outptr += xsnprintf(outptr, + sizeof(outstr) - (outptr - outstr), + "%#" PRI_klx, cur); break; } if (!fds.revents) @@ -112,7 +115,7 @@ decode_poll_exiting(struct tcb *const tcp, const kernel_ulong_t pts) static const char fmt[] = "{fd=%d, revents="; char fdstr[sizeof(fmt) + sizeof(int) * 3]; - sprintf(fdstr, fmt, fds.fd); + xsprintf(fdstr, fmt, fds.fd); const char *flagstr = sprintflags("", pollflags, (unsigned short) fds.revents); -- 2.40.0