Correct use of strncpy function (#1247)
The last argument should be the max size of the destination, not the source buffer. A null byte is added to the end of the destination buffer since strncpy only adds one if it does not truncate the source. This fixes the -Wstringop-overflow warning on GCC.
This commit is contained in:
parent
d70e2b286a
commit
e2c1cd46c0
|
@ -358,8 +358,8 @@ void Sparc_printInst(MCInst *MI, SStream *O, void *Info)
|
||||||
mnem = printAliasInstr(MI, O, Info);
|
mnem = printAliasInstr(MI, O, Info);
|
||||||
if (mnem) {
|
if (mnem) {
|
||||||
// fixup instruction id due to the change in alias instruction
|
// fixup instruction id due to the change in alias instruction
|
||||||
strncpy(instr, mnem, strlen(mnem));
|
strncpy(instr, mnem, sizeof(instr));
|
||||||
instr[strlen(mnem)] = '\0';
|
instr[sizeof(instr) - 1] = '\0';
|
||||||
// does this contains hint with a coma?
|
// does this contains hint with a coma?
|
||||||
p = strchr(instr, ',');
|
p = strchr(instr, ',');
|
||||||
if (p)
|
if (p)
|
||||||
|
|
Loading…
Reference in New Issue