From a06f48a6cd5567e6e173f275127dbaa26da7cfcb Mon Sep 17 00:00:00 2001 From: Ryan Long Date: Wed, 11 Aug 2021 13:43:18 -0400 Subject: TraceWriterQEMU.cc: Change strncpy to memcpy CID 1506207: Buffer not null terminated Closes #4491 --- tester/covoar/TraceWriterQEMU.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tester/covoar') diff --git a/tester/covoar/TraceWriterQEMU.cc b/tester/covoar/TraceWriterQEMU.cc index 177b77f..0f1ea67 100644 --- a/tester/covoar/TraceWriterQEMU.cc +++ b/tester/covoar/TraceWriterQEMU.cc @@ -106,7 +106,9 @@ namespace Trace { // // Write the Header to the file // - strncpy( header.magic, QEMU_TRACE_MAGIC, sizeof(header.magic) ); + // The header.magic field is actually 12 bytes, but QEMU_TRACE_MAGIC is + // 13 bytes including the NULL. + memcpy( header.magic, QEMU_TRACE_MAGIC, sizeof(header.magic) ); header.version = QEMU_TRACE_VERSION; header.kind = QEMU_TRACE_KIND_RAW; // XXX ?? header.sizeof_target_pc = 32; -- cgit v1.2.3