From 2041f82bc4bc0b3882a708befd8d8367baabf3cc Mon Sep 17 00:00:00 2001 From: athomps Date: Thu, 14 Dec 2006 22:30:51 +0000 Subject: [PATCH] Increased MAXLINE and added overflow check in substitute() git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@193 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/input.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/input.cpp b/src/input.cpp index 91d293f391..d374bfc881 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -46,7 +46,7 @@ #undef AtomInclude #undef CommandInclude -#define MAXLINE 1024 +#define MAXLINE 2048 #define DELTA 4 /* ---------------------------------------------------------------------- */ @@ -358,7 +358,15 @@ void Input::substitute(char *str, int flag) *ptr = '\0'; strcpy(work,str); + if (strlen(work)+strlen(value) >= MAXLINE) { + sprintf(str,"Input line too long after variable substitution: %s %s",work,value); + error->one(str); + } strcat(work,value); + if (strlen(work)+strlen(beyond) >= MAXLINE) { + sprintf(str,"Input line too long after variable substitution: %s %s",work,beyond); + error->one(str); + } strcat(work,beyond); strcpy(str,work); ptr += strlen(value);