Skip to content

Commit

Permalink
Fix -Wstringop-truncation warnings (capstone-engine#1730) (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
kazarmy authored May 13, 2021
1 parent 48ed89e commit 0f6ee66
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion arch/Sparc/SparcInstPrinter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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, ',');
Expand Down
2 changes: 1 addition & 1 deletion cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 0f6ee66

Please sign in to comment.