Merge pull request #1819 from trufae/fix-cov

Fix unterminated string regression
This commit is contained in:
Wu ChenXu 2022-01-09 09:48:30 +08:00 committed by GitHub
commit 74f7377485
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 4 deletions

9
cs.c
View File

@ -552,17 +552,18 @@ static void fill_insn(struct cs_struct *handle, cs_insn *insn, char *buffer, MCI
postprinter((csh)handle, insn, buffer, mci);
#ifndef CAPSTONE_DIET
char *prefix = strchr (buffer, '|');
char *prefix = strchr(buffer, '|');
if (prefix) {
*prefix = ' ';
}
char *tab = strchr (buffer, '\t');
char *tab = strchr(buffer, '\t');
if (tab) {
*tab = 0;
}
strncpy (insn->mnemonic, buffer, sizeof (insn->mnemonic) - 1);
strncpy(insn->mnemonic, buffer, sizeof(insn->mnemonic) - 1);
if (tab) {
strcpy (insn->op_str, tab + 1);
strncpy(insn->op_str, tab + 1, sizeof(insn->op_str) - 1);
insn->op_str[sizeof(insn->op_str) - 1] = '\0';
}
// we might have customized mnemonic