Replace sprintf with xsnprintf
authorYao Qi <yao@codesourcery.com>
Mon, 4 Nov 2013 03:16:37 +0000 (11:16 +0800)
committerYao Qi <yao@codesourcery.com>
Wed, 18 Dec 2013 03:46:56 +0000 (11:46 +0800)
gdb:

2013-12-18  Yao Qi  <yao@codesourcery.com>

* linux-nat.c (linux_proc_xfer_partial): Call xsnprintf instead
of sprintf.
(linux_nat_detach, linux_child_pid_to_exec_file): Likewise.
(linux_proc_pending_signals): Likewise.

gdb/ChangeLog
gdb/linux-nat.c

index 6e67bacd84eb683a992382c50598de4fa3b32b81..196bcb011ae53849eaedbea1052a683164c9328d 100644 (file)
@@ -1,3 +1,10 @@
+2013-12-18  Yao Qi  <yao@codesourcery.com>
+
+       * linux-nat.c (linux_proc_xfer_partial): Call xsnprintf instead
+       of sprintf.
+       (linux_nat_detach, linux_child_pid_to_exec_file): Likewise.
+       (linux_proc_pending_signals): Likewise.
+
 2013-12-18  Joel Brobecker  <brobecker@adacore.com>
 
        * value.c (value_entirely_unavailable): ARI fix: Move trailing
index d2091caf91a55344c3cb00252723db0c6df64286..a34b29a11620a9f117fd237b20c4fbbb1fa2dc1f 100644 (file)
@@ -1592,7 +1592,7 @@ linux_nat_detach (struct target_ops *ops, const char *args, int from_tty)
       /* Put the signal number in ARGS so that inf_ptrace_detach will
         pass it along with PTRACE_DETACH.  */
       tem = alloca (8);
-      sprintf (tem, "%d", (int) WSTOPSIG (status));
+      xsnprintf (tem, 8, "%d", (int) WSTOPSIG (status));
       args = tem;
       if (debug_linux_nat)
        fprintf_unfiltered (gdb_stdlog,
@@ -4049,7 +4049,7 @@ linux_child_pid_to_exec_file (int pid)
   make_cleanup (xfree, name2);
   memset (name2, 0, PATH_MAX);
 
-  sprintf (name1, "/proc/%d/exe", pid);
+  xsnprintf (name1, PATH_MAX, "/proc/%d/exe", pid);
   if (readlink (name1, name2, PATH_MAX - 1) > 0)
     return name2;
   else
@@ -4135,7 +4135,8 @@ linux_proc_xfer_partial (struct target_ops *ops, enum target_object object,
 
   /* We could keep this file open and cache it - possibly one per
      thread.  That requires some juggling, but is even faster.  */
-  sprintf (filename, "/proc/%d/mem", ptid_get_pid (inferior_ptid));
+  xsnprintf (filename, sizeof filename, "/proc/%d/mem",
+            ptid_get_pid (inferior_ptid));
   fd = gdb_open_cloexec (filename, O_RDONLY | O_LARGEFILE, 0);
   if (fd == -1)
     return 0;
@@ -4305,7 +4306,7 @@ linux_proc_pending_signals (int pid, sigset_t *pending,
   sigemptyset (pending);
   sigemptyset (blocked);
   sigemptyset (ignored);
-  sprintf (fname, "/proc/%d/status", pid);
+  xsnprintf (fname, sizeof fname, "/proc/%d/status", pid);
   procfile = gdb_fopen_cloexec (fname, "r");
   if (procfile == NULL)
     error (_("Could not open %s"), fname);
This page took 0.049161 seconds and 4 git commands to generate.