]> granicus.if.org Git - strace/commitdiff
open.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)
* open.c: Include "xstring.h".
(sprint_open_modes): Replace sprintf with xsnprintf.

open.c

diff --git a/open.c b/open.c
index 28222666d6e60111109e161dfe4caa61f734bd42..ab9e8ef73d5c0962e2109bb4610675702fbf8bf2 100644 (file)
--- a/open.c
+++ b/open.c
@@ -34,6 +34,7 @@
  */
 
 #include "defs.h"
+#include "xstring.h"
 
 #include <fcntl.h>
 
@@ -110,7 +111,7 @@ sprint_open_modes(unsigned int flags)
        }
        /* flags is still nonzero */
        *p++ = sep;
-       sprintf(p, "%#x", flags);
+       xsnprintf(p, sizeof(outstr) - (p - outstr), "%#x", flags);
        return outstr;
 }