1
0
Fork 0

fix integer handling

This commit is contained in:
jsteemann 2017-02-02 10:15:39 +01:00
parent b1c1a14fd4
commit 454c69a148
1 changed files with 4 additions and 3 deletions

View File

@ -1140,15 +1140,16 @@ static void JS_ChMod(v8::FunctionCallbackInfo<v8::Value> const& args) {
}
std::string const modeStr = TRI_ObjectToString(isolate, args[1]);
size_t const length = modeStr.length();
if ((modeStr.length() > 5) || (modeStr.length() == 0)) {
if (length == 0 || length > 5) {
TRI_V8_THROW_TYPE_ERROR(
"<mode> must be a string with up to 4 octal digits in it plus a "
"leading zero.");
}
long mode = 0;
for (uint32_t i = 0; i < modeStr.length(); i++) {
for (uint32_t i = 0; i < length; ++i) {
if (!isdigit(modeStr[i])) {
TRI_V8_THROW_TYPE_ERROR(
"<mode> must be a string with up to 4 octal digits in it plus a "
@ -1163,7 +1164,7 @@ static void JS_ChMod(v8::FunctionCallbackInfo<v8::Value> const& args) {
"<mode> must be a string with up to 4 octal digits in it plus a "
"leading zero.");
}
mode = mode | digit << ((modeStr.length() - i - 1) * 3);
mode = mode | digit << ((length - i - 1) * 3);
}
std::string err;
int rc = TRI_ChMod(*name, mode, err);