fix bond/react buffer overflow: must not use sprintf to write to char variable
This commit is contained in:
@ -1966,12 +1966,11 @@ int FixBondReact::check_constraints()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (nconstraints[rxnID] > 0) {
|
if (nconstraints[rxnID] > 0) {
|
||||||
char evalstr[MAXLINE],*ptr,valstr;
|
char evalstr[MAXLINE],*ptr;
|
||||||
strcpy(evalstr,constraintstr[rxnID]);
|
strcpy(evalstr,constraintstr[rxnID]);
|
||||||
for (int i = 0; i < nconstraints[rxnID]; i++) {
|
for (int i = 0; i < nconstraints[rxnID]; i++) {
|
||||||
sprintf(&valstr,"%d", satisfied[i]);
|
|
||||||
ptr = strchr(evalstr,'C');
|
ptr = strchr(evalstr,'C');
|
||||||
*ptr = valstr;
|
*ptr = satisfied[i] ? '1' : '0';
|
||||||
}
|
}
|
||||||
double verdict = input->variable->evaluate_boolean(evalstr);
|
double verdict = input->variable->evaluate_boolean(evalstr);
|
||||||
if (verdict == 0.0) return 0;
|
if (verdict == 0.0) return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user