Skip to content

Commit 7ffb620

Browse files
authored
Merge pull request #559 from cse-sim/fix-include-path-length
Use platform limits for include file name buffer size
2 parents 5a004c2 + 2b9073b commit 7ffb620

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/pp.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2965,7 +2965,7 @@ LOCAL RC FC ppcDoI( // decode/execute preprocessor command inner. call ppctIni(
29652965
// returned error code other than RCFATAL ignored by caller
29662966
{
29672967
SI c, c1, c2, value, noCheckEnd = 0;
2968-
char fnBuf[81], ppcWord[1+32+1], *q;
2968+
char ppcWord[1+32+1], *q;
29692969
RC rc;
29702970

29712971
// syntax verify beginning of command
@@ -3110,21 +3110,22 @@ elifJoins: ; // set compile on or off per 'value'
31103110
if (strchr( "<\"", c1)==NULL)
31113111
return ppErr( MH_P0038); // "'<' or '\"' expected"
31123112
c2 = (c1 == '<') ? '>' : c1;
3113-
for (q = fnBuf; ; ) // scan/copy file name
3113+
char file_name_buffer[CSE_MAX_PATH];
3114+
for (q = file_name_buffer; ; ) // scan/copy file name
31143115
{
31153116
c = ppCNdc(); // get char NOT DECOMMENTED
31163117
if (c==c2) // if expected terminator
31173118
break;
31183119
if (c==EOF) // if end of input
31193120
return ppErr( MH_P0045, c2); // "Closing '%c' not found"
3120-
if (q < fnBuf + sizeof(fnBuf)-1) // truncate at bufSize
3121+
if (q < file_name_buffer + sizeof(file_name_buffer)-1) // truncate at bufSize
31213122
*q++ = (char)c; // copy name so can terminate
31223123
}
31233124
*q = 0;
31243125
CHECKEND; // now: after open, errmsg wd have wrong file
31253126
// execute #include
31263127
// filename syntax check worth the bother?
3127-
if (ppOpI( fnBuf, ".inp") ) // open incl file, pp.cpp
3128+
if (ppOpI( file_name_buffer, ".inp") ) // open incl file, pp.cpp
31283129
return RCBAD; // if file not found or out of memory
31293130
break;
31303131

0 commit comments

Comments
 (0)