Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
c2f0864f
Commit
c2f0864f
authored
Apr 03, 2018
by
Mark OLESEN
Browse files
ENH: remove size limit when reading verbatim strings (issue
#785
)
parent
b854ce22
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/OpenFOAM/db/IOstreams/Sstreams/ISstream.C
View file @
c2f0864f
...
...
@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2017
-2018
OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -471,8 +471,8 @@ Foam::Istream& Foam::ISstream::read(word& str)
<<
buf
<<
nl
<<
endl
;
}
// Finalize
str
=
buf
;
// Finalize
: content already validated, assign without additional checks.
str
.
assign
(
buf
,
nChar
)
;
putback
(
c
);
return
*
this
;
...
...
@@ -568,7 +568,7 @@ Foam::Istream& Foam::ISstream::read(string& str)
}
//
d
on't worry about a dangling backslash if string terminated prematurely
//
D
on't worry about a dangling backslash if string terminated prematurely
buf
[
errLen
]
=
buf
[
nChar
]
=
'\0'
;
FatalIOErrorInFunction
(
*
this
)
...
...
@@ -711,6 +711,7 @@ Foam::Istream& Foam::ISstream::readVerbatim(string& str)
unsigned
nChar
=
0
;
char
c
;
str
.
clear
();
while
(
get
(
c
))
{
if
(
c
==
token
::
HASH
)
...
...
@@ -720,8 +721,7 @@ Foam::Istream& Foam::ISstream::readVerbatim(string& str)
if
(
nextC
==
token
::
END_BLOCK
)
{
// The closing "#}" found
buf
[
nChar
]
=
'\0'
;
str
=
buf
;
str
.
append
(
buf
,
nChar
);
return
*
this
;
}
else
...
...
@@ -733,19 +733,13 @@ Foam::Istream& Foam::ISstream::readVerbatim(string& str)
buf
[
nChar
++
]
=
c
;
if
(
nChar
==
maxLen
)
{
buf
[
errLen
]
=
'\0'
;
FatalIOErrorInFunction
(
*
this
)
<<
"string
\"
"
<<
buf
<<
"...
\"\n
"
<<
" is too long (max. "
<<
maxLen
<<
" characters)"
<<
exit
(
FatalIOError
);
return
*
this
;
str
.
append
(
buf
,
nChar
);
nChar
=
0
;
}
}
//
d
on't worry about a dangling backslash if string terminated prematurely
//
D
on't worry about a dangling backslash if string terminated prematurely
buf
[
errLen
]
=
buf
[
nChar
]
=
'\0'
;
FatalIOErrorInFunction
(
*
this
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment