The following issues were found
src/third_party/mozjs-60/extract/js/src/wasm/WasmTextToBinary.cpp
3 issues
Line: 616
CWE codes:
476
{}
void generateError(WasmToken token, UniqueChars* error) {
unsigned column = token.begin() - lineStart_ + 1;
*error = JS_smprintf("parsing wasm text at %u:%u", line_, column);
}
void generateError(WasmToken token, const char* msg, UniqueChars* error) {
unsigned column = token.begin() - lineStart_ + 1;
*error = JS_smprintf("parsing wasm text at %u:%u: %s", line_, column, msg);
}
Reported by Cppcheck.
Line: 616
CWE codes:
476
{}
void generateError(WasmToken token, UniqueChars* error) {
unsigned column = token.begin() - lineStart_ + 1;
*error = JS_smprintf("parsing wasm text at %u:%u", line_, column);
}
void generateError(WasmToken token, const char* msg, UniqueChars* error) {
unsigned column = token.begin() - lineStart_ + 1;
*error = JS_smprintf("parsing wasm text at %u:%u: %s", line_, column, msg);
}
Reported by Cppcheck.
Line: 5078
Column: 45
CWE codes:
126
{
TwoByteChars range(wasmName.begin(), wasmName.length());
UniqueChars utf8(JS::CharsToNewUTF8CharsZ(nullptr, range).c_str());
return utf8 && e.writeBytes(utf8.get(), strlen(utf8.get()));
}
static bool
EncodeLimits(Encoder& e, const Limits& limits)
{
Reported by FlawFinder.
src/third_party/mozjs-60/extract/js/src/vm/StringType.cpp
3 issues
Line: 1968
template JSString*
js::ToStringSlow<NoGC>(JSContext* cx, const Value& arg);
JS_PUBLIC_API(JSString*)
js::ToStringSlow(JSContext* cx, HandleValue v)
{
return ToStringSlow<CanGC>(cx, v);
}
Reported by Cppcheck.
Line: 906
Column: 21
CWE codes:
126
bool
js::StringEqualsAscii(JSLinearString* str, const char* asciiBytes)
{
size_t length = strlen(asciiBytes);
#ifdef DEBUG
for (size_t i = 0; i != length; ++i)
MOZ_ASSERT(unsigned(asciiBytes[i]) <= 127);
#endif
if (length != str->length())
Reported by FlawFinder.
Line: 1562
Column: 72
CWE codes:
126
JSFlatString*
NewLatin1StringZ(JSContext* cx, UniqueChars chars)
{
JSFlatString* str = NewString<CanGC>(cx, (Latin1Char*)chars.get(), strlen(chars.get()));
if (!str)
return nullptr;
mozilla::Unused << chars.release();
return str;
Reported by FlawFinder.
src/third_party/mozjs-60/extract/js/src/vm/Printer.h
3 issues
Line: 49
Column: 10
CWE codes:
134
Suggestion:
Use a constant for the format specification
}
// Prints a formatted string into the buffer.
bool printf(const char* fmt, ...) MOZ_FORMAT_PRINTF(2, 3);
bool vprintf(const char* fmt, va_list ap) MOZ_FORMAT_PRINTF(2, 0);
// Report that a string operation failed to get the memory it requested.
virtual void reportOutOfMemory();
Reported by FlawFinder.
Line: 50
Column: 10
CWE codes:
134
Suggestion:
Use a constant for the format specification
// Prints a formatted string into the buffer.
bool printf(const char* fmt, ...) MOZ_FORMAT_PRINTF(2, 3);
bool vprintf(const char* fmt, va_list ap) MOZ_FORMAT_PRINTF(2, 0);
// Report that a string operation failed to get the memory it requested.
virtual void reportOutOfMemory();
// Return true if this Sprinter ran out of memory.
Reported by FlawFinder.
Line: 42
Column: 23
CWE codes:
126
virtual void flush() { /* Do nothing */ }
inline bool put(const char* s) {
return put(s, strlen(s));
}
inline bool putChar(const char c) {
return put(&c, 1);
}
Reported by FlawFinder.
src/third_party/mozjs-60/extract/js/src/vm/MemoryMetrics.cpp
3 issues
Line: 41
namespace js {
JS_FRIEND_API(size_t)
MemoryReportingSundriesThreshold()
{
return 8 * 1024;
}
Reported by Cppcheck.
Line: 206
Column: 20
CWE codes:
126
NotableClassInfo::NotableClassInfo(const char* className, const ClassInfo& info)
: ClassInfo(info)
{
size_t bytes = strlen(className) + 1;
className_ = js_pod_malloc<char>(bytes);
if (!className_)
MOZ_CRASH("oom");
PodCopy(className_, className, bytes);
}
Reported by FlawFinder.
Line: 237
Column: 20
CWE codes:
126
NotableScriptSourceInfo::NotableScriptSourceInfo(const char* filename, const ScriptSourceInfo& info)
: ScriptSourceInfo(info)
{
size_t bytes = strlen(filename) + 1;
filename_ = js_pod_malloc<char>(bytes);
if (!filename_)
MOZ_CRASH("oom");
PodCopy(filename_, filename, bytes);
}
Reported by FlawFinder.
src/third_party/mozjs-60/extract/js/src/vm/JSAtom.h
3 issues
Line: 44
/* Well-known predefined C strings. */
#define DECLARE_PROTO_STR(name,init,clasp) extern const char js_##name##_str[];
JS_FOR_EACH_PROTOTYPE(DECLARE_PROTO_STR)
#undef DECLARE_PROTO_STR
#define DECLARE_CONST_CHAR_STR(idpart, id, text) extern const char js_##idpart##_str[];
FOR_EACH_COMMON_PROPERTYNAME(DECLARE_CONST_CHAR_STR)
#undef DECLARE_CONST_CHAR_STR
Reported by Cppcheck.
Line: 44
/* Well-known predefined C strings. */
#define DECLARE_PROTO_STR(name,init,clasp) extern const char js_##name##_str[];
JS_FOR_EACH_PROTOTYPE(DECLARE_PROTO_STR)
#undef DECLARE_PROTO_STR
#define DECLARE_CONST_CHAR_STR(idpart, id, text) extern const char js_##idpart##_str[];
FOR_EACH_COMMON_PROPERTYNAME(DECLARE_CONST_CHAR_STR)
#undef DECLARE_CONST_CHAR_STR
Reported by Cppcheck.
Line: 44
/* Well-known predefined C strings. */
#define DECLARE_PROTO_STR(name,init,clasp) extern const char js_##name##_str[];
JS_FOR_EACH_PROTOTYPE(DECLARE_PROTO_STR)
#undef DECLARE_PROTO_STR
#define DECLARE_CONST_CHAR_STR(idpart, id, text) extern const char js_##idpart##_str[];
FOR_EACH_COMMON_PROPERTYNAME(DECLARE_CONST_CHAR_STR)
#undef DECLARE_CONST_CHAR_STR
Reported by Cppcheck.
src/third_party/mozjs-60/extract/js/src/vm/GeckoProfiler.cpp
3 issues
Line: 423
entry.setKind(ProfileEntry::Kind::JS_NORMAL);
}
JS_PUBLIC_API(JSScript*)
ProfileEntry::script() const
{
MOZ_ASSERT(isJs());
auto script = reinterpret_cast<JSScript*>(spOrScript.operator void*());
if (!script)
Reported by Cppcheck.
Line: 322
Column: 15
CWE codes:
134
Suggestion:
Use a constant for the format specification
ret = snprintf(cstr.get(), len + 1, "%s (%s:%" PRIu64 ")", atomStr.get(), filename, lineno);
} else {
ret = snprintf(cstr.get(), len + 1, "%s:%" PRIu64, filename, lineno);
}
MOZ_ASSERT(ret == len, "Computed length should match actual length!");
return cstr;
Reported by FlawFinder.
Line: 295
Column: 26
CWE codes:
126
const char* filename = script->filename();
if (filename == nullptr)
filename = "<unknown>";
size_t lenFilename = strlen(filename);
// Get the line number and its length as a string.
uint64_t lineno = script->lineno();
size_t lenLineno = 1;
for (uint64_t i = lineno; i /= 10; lenLineno++);
Reported by FlawFinder.
buildscripts/linter/filediff.py
3 issues
Line: 7
Column: 1
from typing import Tuple, List, Dict, Callable
from git import Repo
import structlog
# Get relative imports to work when the package is not installed on the PYTHONPATH.
if __name__ == "__main__" and __package__ is None:
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(os.path.realpath(__file__)))))
Reported by Pylint.
Line: 14
Column: 1
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(os.path.realpath(__file__)))))
# pylint: disable=wrong-import-position
from buildscripts.linter import git
from buildscripts.patch_builds.change_data import generate_revision_map, \
RevisionMap, find_changed_files_in_repos
# pylint: enable=wrong-import-position
Reported by Pylint.
Line: 15
Column: 1
# pylint: disable=wrong-import-position
from buildscripts.linter import git
from buildscripts.patch_builds.change_data import generate_revision_map, \
RevisionMap, find_changed_files_in_repos
# pylint: enable=wrong-import-position
LOGGER = structlog.get_logger(__name__)
Reported by Pylint.
src/third_party/mozjs-60/extract/js/src/vm/JSONParser.cpp
3 issues
Line: 92
Column: 9
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
getTextPosition(&column, &line);
const size_t MaxWidth = sizeof("4294967295");
char columnNumber[MaxWidth];
SprintfLiteral(columnNumber, "%" PRIu32, column);
char lineNumber[MaxWidth];
SprintfLiteral(lineNumber, "%" PRIu32, line);
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_JSON_BAD_PARSE,
Reported by FlawFinder.
Line: 94
Column: 9
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
const size_t MaxWidth = sizeof("4294967295");
char columnNumber[MaxWidth];
SprintfLiteral(columnNumber, "%" PRIu32, column);
char lineNumber[MaxWidth];
SprintfLiteral(lineNumber, "%" PRIu32, line);
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_JSON_BAD_PARSE,
msg, lineNumber, columnNumber);
}
Reported by FlawFinder.
Line: 280
Column: 30
CWE codes:
126
/* Fast path: no fractional or exponent part. */
if (current == end || (*current != '.' && *current != 'e' && *current != 'E')) {
mozilla::Range<const CharT> chars(digitStart.get(), current - digitStart);
if (chars.length() < strlen("9007199254740992")) {
// If the decimal number is shorter than the length of 2**53, (the
// largest number a double can represent with integral precision),
// parse it using a decimal-only parser. This comparison is
// conservative but faster than a fully-precise check.
double d = ParseDecimalNumber(chars);
Reported by FlawFinder.
src/third_party/mozjs-60/extract/js/src/util/Text.cpp
3 issues
Line: 39
template const char16_t*
js_strchr_limit(const char16_t* s, char16_t c, const char16_t* limit);
JS_PUBLIC_API(char*)
js_strdup(const char* s)
{
return DuplicateString(s).release();
}
Reported by Cppcheck.
Line: 59
Column: 16
CWE codes:
126
UniqueChars
js::DuplicateString(JSContext* cx, const char* s)
{
size_t n = strlen(s) + 1;
auto ret = cx->make_pod_array<char>(n);
if (!ret)
return ret;
PodCopy(ret.get(), s, n);
return ret;
Reported by FlawFinder.
Line: 81
Column: 16
CWE codes:
126
UniqueChars
js::DuplicateString(const char* s)
{
size_t n = strlen(s) + 1;
UniqueChars ret(js_pod_malloc<char>(n));
if (!ret)
return ret;
PodCopy(ret.get(), s, n);
return ret;
Reported by FlawFinder.
src/third_party/mozjs-60/extract/js/src/perf/pm_linux.cpp
3 issues
Line: 201
Column: 14
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
{
// This scratch buffer is to ensure that we have read all the
// available data, even if that's more than we expect.
unsigned char buf[1024];
if (!running || group_leader == -1)
return;
ioctl(group_leader, PERF_EVENT_IOC_DISABLE, 0);
Reported by FlawFinder.
Line: 217
Column: 13
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
if (read(fd, buf, sizeof(buf)) == sizeof(uint64_t)) {
uint64_t cur;
memcpy(&cur, buf, sizeof(uint64_t));
counters->*(slot.counter) += cur;
}
// Reset the counter regardless of whether the read did what
// we expected.
Reported by FlawFinder.
Line: 215
Column: 13
CWE codes:
120
20
if (fd == -1)
continue;
if (read(fd, buf, sizeof(buf)) == sizeof(uint64_t)) {
uint64_t cur;
memcpy(&cur, buf, sizeof(uint64_t));
counters->*(slot.counter) += cur;
}
Reported by FlawFinder.