From 0f6ee6621c8e863bd791392b4c2ab67ec74bbefe Mon Sep 17 00:00:00 2001 From: Khairul Azhar Kasmiran Date: Thu, 13 May 2021 18:20:19 +0800 Subject: [PATCH] Fix -Wstringop-truncation warnings (aquynh/capstone#1730) (#2) --- arch/Sparc/SparcInstPrinter.c | 2 +- cs.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/Sparc/SparcInstPrinter.c b/arch/Sparc/SparcInstPrinter.c index da83187441..597bd1103a 100644 --- a/arch/Sparc/SparcInstPrinter.c +++ b/arch/Sparc/SparcInstPrinter.c @@ -358,7 +358,7 @@ void Sparc_printInst(MCInst *MI, SStream *O, void *Info) mnem = printAliasInstr(MI, O, Info); if (mnem) { // fixup instruction id due to the change in alias instruction - strncpy(instr, mnem, sizeof(instr)); + strncpy(instr, mnem, sizeof(instr) - 1); instr[sizeof(instr) - 1] = '\0'; // does this contains hint with a coma? p = strchr(instr, ','); diff --git a/cs.c b/cs.c index 590aa93a13..5e1edeeeb3 100644 --- a/cs.c +++ b/cs.c @@ -576,7 +576,7 @@ static void fill_insn(struct cs_struct *handle, cs_insn *insn, char *buffer, MCI while(tmp) { if (tmp->insn.id == insn->id) { // found this instruction, so copy its mnemonic - (void)strncpy(insn->mnemonic, tmp->insn.mnemonic, sizeof(insn->mnemonic) - 1); + (void)strncpy(insn->mnemonic, tmp->insn.mnemonic, sizeof(insn->mnemonic)); insn->mnemonic[sizeof(insn->mnemonic) - 1] = '\0'; break; }