]> granicus.if.org Git - strace/commitdiff
xlat.c: use xsnprintf instead of sprintf
authorDmitry V. Levin <ldv@altlinux.org>
Sat, 6 Jan 2018 01:45:16 +0000 (01:45 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Sun, 7 Jan 2018 00:05:42 +0000 (00:05 +0000)
* xlat.c: Include "xstring.h".
(sprintflags): Replace sprintf with xsnprintf.

xlat.c

diff --git a/xlat.c b/xlat.c
index ad49720dcfe7924e6d64e222f3b5395670d1946e..5e2dfff80cd3061a7bf693487dc2f2bfbc4a9390 100644 (file)
--- a/xlat.c
+++ b/xlat.c
@@ -30,6 +30,7 @@
  */
 
 #include "defs.h"
+#include "xstring.h"
 #include <stdarg.h>
 
 const char *
@@ -175,7 +176,8 @@ sprintflags(const char *prefix, const struct xlat *xlat, uint64_t flags)
        if (flags) {
                if (found)
                        *outptr++ = '|';
-               outptr += sprintf(outptr, "%#" PRIx64, flags);
+               outptr += xsnprintf(outptr, sizeof(outstr) - (outptr - outstr),
+                                   "%#" PRIx64, flags);
        }
 
        return outstr;