From f4254cba0986bb4dc65244e1c2d51df273e5e9ee Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Tue, 20 Aug 2019 16:47:43 -0600 Subject: [PATCH] Use snprintf instead of sprintf --- src/library.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/library.cpp b/src/library.cpp index 7cf0e0f01f..54497970ad 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -1596,7 +1596,7 @@ void lammps_create_atoms(void *ptr, int n, tagint *id, int *type, if (lmp->atom->natoms != natoms_prev + n) { char str[128]; - sprintf(str,"Library warning in lammps_create_atoms, " + snprintf(str, 128, "Library warning in lammps_create_atoms, " "invalid total atoms " BIGINT_FORMAT " " BIGINT_FORMAT, lmp->atom->natoms,natoms_prev+n); if (lmp->comm->me == 0) @@ -1621,7 +1621,7 @@ void lammps_set_fix_external_callback(void *ptr, char *id, FixExternalFnPtr call int ifix = lmp->modify->find_fix(id); if (ifix < 0) { char str[50]; - sprintf(str, "Can not find fix with ID '%s'!", id); + snprintf(str, 50, "Can not find fix with ID '%s'!", id); lmp->error->all(FLERR,str); } @@ -1629,7 +1629,7 @@ void lammps_set_fix_external_callback(void *ptr, char *id, FixExternalFnPtr call if (strcmp("external",fix->style) != 0){ char str[50]; - sprintf(str, "Fix '%s' is not of style external!", id); + snprintf(str, 50, "Fix '%s' is not of style external!", id); lmp->error->all(FLERR,str); }