mirror of
https://github.com/Samsung/escargot.git
synced 2026-06-22 10:01:50 +00:00
Fix buffer overflow error in builtinHelperFileRead method
Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
This commit is contained in:
parent
bccdc4225e
commit
5ee4a5bd4e
2 changed files with 18 additions and 8 deletions
|
|
@ -251,12 +251,17 @@ static OptionalRef<StringRef> builtinHelperFileRead(OptionalRef<ExecutionStateRe
|
|||
}
|
||||
return src;
|
||||
} else {
|
||||
char msg[1024];
|
||||
snprintf(msg, sizeof(msg), "GlobalObject.%s: cannot open file %s", builtinName, fileName);
|
||||
if (state) {
|
||||
state->throwException(URIErrorObjectRef::create(state.get(), StringRef::createFromUTF8(msg, strnlen(msg, sizeof msg))));
|
||||
const size_t maxNameLength = 990;
|
||||
if ((strnlen(builtinName, maxNameLength) + strnlen(fileName, maxNameLength)) < maxNameLength) {
|
||||
char msg[1024];
|
||||
snprintf(msg, sizeof(msg), "GlobalObject.%s: cannot open file %s", builtinName, fileName);
|
||||
state->throwException(URIErrorObjectRef::create(state.get(), StringRef::createFromUTF8(msg, strnlen(msg, sizeof msg))));
|
||||
} else {
|
||||
state->throwException(URIErrorObjectRef::create(state.get(), StringRef::createFromASCII("invalid file name")));
|
||||
}
|
||||
} else {
|
||||
puts(msg);
|
||||
puts(fileName);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue