add check that allows only %f and %g conversions in variable format strings

This commit is contained in:
Axel Kohlmeyer
2019-05-30 14:46:07 -04:00
parent 8dcd6fc48c
commit 1a5c3c6dcb
5 changed files with 24 additions and 0 deletions

View File

@ -50,6 +50,7 @@
#include "accelerator_kokkos.h"
#include "error.h"
#include "memory.h"
#include "utils.h"
#ifdef _OPENMP
#include <omp.h>
@ -526,6 +527,11 @@ void Input::substitute(char *&str, char *&str2, int &max, int &max2, int flag)
*fmtflag='\0';
}
// quick check for proper format string
if (!utils::strmatch(fmtstr,"%[0-9 ]*\\.[0-9]+[fg]"))
error->all(FLERR,"Incorrect conversion in format string");
snprintf(immediate,256,fmtstr,variable->compute_equal(var));
value = immediate;