[前][次][番号順一覧][スレッド一覧]

ruby-changes:68929

From: Noah <ko1@a...>
Date: Thu, 21 Oct 2021 08:16:37 +0900 (JST)
Subject: [ruby-changes:68929] db02d73e5e (master): Change strcpy of a static string to strncpy

https://git.ruby-lang.org/ruby.git/commit/?id=db02d73e5e

From db02d73e5e0489dd2028ea4b9572361ed5aa2cc9 Mon Sep 17 00:00:00 2001
From: Noah Gibbs <noah.gibbs@s...>
Date: Tue, 29 Jun 2021 19:34:05 +0100
Subject: Change strcpy of a static string to strncpy

---
 yjit_iface.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/yjit_iface.c b/yjit_iface.c
index 83ca0b4e82..ed47112052 100644
--- a/yjit_iface.c
+++ b/yjit_iface.c
@@ -766,7 +766,7 @@ get_yjit_stats(rb_execution_context_t *ec, VALUE self) https://github.com/ruby/ruby/blob/trunk/yjit_iface.c#L766
         // where the value is the count of side exits for that instruction.
 
         char key_string[rb_vm_max_insn_name_size + 6]; // Leave room for "exit_" and a final NUL
-        strcpy(key_string, "exit_");
+        strncpy(key_string, "exit_", 6);               // Copy 6 characters to include the NUL.
         for (int i = 0; i < VM_INSTRUCTION_SIZE; i++) {
             const char *i_name = insn_name(i); // Look up Ruby's NUL-terminated insn name string
             strncpy(key_string + 5, i_name, rb_vm_max_insn_name_size + 1);
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]