diff -Nru mozjs102-102.10.0/config/milestone.txt mozjs102-102.11.0/config/milestone.txt --- mozjs102-102.10.0/config/milestone.txt 2023-04-10 19:40:44.000000000 -0400 +++ mozjs102-102.11.0/config/milestone.txt 2023-05-08 11:51:14.000000000 -0400 @@ -10,4 +10,4 @@ # hardcoded milestones in the tree from these two files. #-------------------------------------------------------- -102.10.0 +102.11.0 diff -Nru mozjs102-102.10.0/debian/changelog mozjs102-102.11.0/debian/changelog --- mozjs102-102.10.0/debian/changelog 2023-04-10 19:48:42.000000000 -0400 +++ mozjs102-102.11.0/debian/changelog 2023-05-08 11:59:12.000000000 -0400 @@ -1,3 +1,17 @@ +mozjs102 (102.11.0-1) unstable; urgency=high + + * New upstream release (LP: #2018905) + - CVE-2023-32205: Browser prompts could have been obscured by popups + - CVE-2023-32206: Crash in RLBox Expat driver + - CVE-2023-32207: Potential permissions request bypass via clickjacking + - CVE-2023-32211: Content process crash due to invalid wasm code + - CVE-2023-32212: Potential spoof due to obscured address bar + - CVE-2023-32213: Potential memory corruption in FileReader::DoReadData() + - CVE-2023-32214: Potential DoS via exposed protocol handlers + - CVE-2023-32215: Memory safety bugs + + -- Jeremy BĂ­cha Mon, 08 May 2023 11:59:12 -0400 + mozjs102 (102.10.0-1) unstable; urgency=high * New upstream release (LP: #2015880) diff -Nru mozjs102-102.10.0/js/public/friend/StackLimits.h mozjs102-102.11.0/js/public/friend/StackLimits.h --- mozjs102-102.10.0/js/public/friend/StackLimits.h 2023-04-10 19:40:44.000000000 -0400 +++ mozjs102-102.11.0/js/public/friend/StackLimits.h 2023-05-08 11:51:14.000000000 -0400 @@ -216,7 +216,7 @@ MOZ_ALWAYS_INLINE bool AutoCheckRecursionLimit::checkConservativeDontReport( JSContext* cx) const { uintptr_t limit = getStackLimitHelper(cx, JS::StackForUntrustedScript, - -1024 * int(sizeof(size_t))); + -4096 * int(sizeof(size_t))); int stackDummy; return checkLimitImpl(limit, &stackDummy); } diff -Nru mozjs102-102.10.0/js/src/frontend/Stencil.cpp mozjs102-102.11.0/js/src/frontend/Stencil.cpp --- mozjs102-102.10.0/js/src/frontend/Stencil.cpp 2023-04-10 19:40:44.000000000 -0400 +++ mozjs102-102.11.0/js/src/frontend/Stencil.cpp 2023-05-08 11:51:14.000000000 -0400 @@ -7,6 +7,7 @@ #include "frontend/Stencil.h" #include "mozilla/AlreadyAddRefed.h" // already_AddRefed +#include "mozilla/Assertions.h" // MOZ_RELEASE_ASSERT #include "mozilla/Maybe.h" // mozilla::Maybe #include "mozilla/OperatorNewExtensions.h" // mozilla::KnownNotNull #include "mozilla/PodOperations.h" // mozilla::PodCopy @@ -4063,6 +4064,7 @@ JSString* CompilationAtomCache::getExistingStringAt( ParserAtomIndex index) const { + MOZ_RELEASE_ASSERT(atoms_.length() >= index); return atoms_[index]; } diff -Nru mozjs102-102.10.0/js/src/jsdate.cpp mozjs102-102.11.0/js/src/jsdate.cpp --- mozjs102-102.10.0/js/src/jsdate.cpp 2023-04-10 19:40:44.000000000 -0400 +++ mozjs102-102.11.0/js/src/jsdate.cpp 2023-05-08 11:51:14.000000000 -0400 @@ -1026,6 +1026,126 @@ #undef NEED_NDIGITS_OR_LESS } +int FixupNonFullYear(int year) { + if (year < 50) { + year += 2000; + } else if (year >= 50 && year < 100) { + year += 1900; + } + return year; +} + +template +bool IsPrefixOfKeyword(const CharT* s, size_t len, const char* keyword) { + while (len > 0 && *keyword) { + MOZ_ASSERT(IsAsciiAlpha(*s)); + MOZ_ASSERT(IsAsciiLowercaseAlpha(*keyword)); + + if (unicode::ToLowerCase(static_cast(*s)) != *keyword) { + break; + } + + s++, keyword++; + len--; + } + + return len == 0; +} + +static constexpr const char* const months_names[] = { + "january", "february", "march", "april", "may", "june", + "july", "august", "september", "october", "november", "december", +}; + +// Try to parse the following date format: +// dd-MMM-yyyy +// dd-MMM-yy +// yyyy-MMM-dd +// yy-MMM-dd +// +// Returns true and fills all out parameters when successfully parsed +// dashed-date. Otherwise returns false and leaves out parameters untouched. +template +static bool TryParseDashedDatePrefix(const CharT* s, size_t length, + size_t* indexOut, int* yearOut, + int* monOut, int* mdayOut) { + size_t i = 0; + + size_t mday; + if (!ParseDigitsNOrLess(4, &mday, s, &i, length)) { + return false; + } + size_t mdayDigits = i; + + if (i >= length || s[i] != '-') { + return false; + } + ++i; + + size_t start = i; + for (; i < length; i++) { + if (!IsAsciiAlpha(s[i])) { + break; + } + } + + // The shortest month is "may". + static constexpr size_t ShortestMonthNameLength = 3; + if (i - start < ShortestMonthNameLength) { + return false; + } + + size_t mon = 0; + for (size_t m = 0; m < std::size(months_names); ++m) { + // If the field isn't a prefix of the month (an exact match is *not* + // required), try the next one. + if (IsPrefixOfKeyword(s + start, i - start, months_names[m])) { + // Use numeric value. + mon = m + 1; + break; + } + } + if (mon == 0) { + return false; + } + + if (i >= length || s[i] != '-') { + return false; + } + ++i; + + size_t pre = i; + size_t year; + if (!ParseDigitsNOrLess(4, &year, s, &i, length)) { + return false; + } + size_t yearDigits = i - pre; + + if (i < length && IsAsciiDigit(s[i])) { + return false; + } + + // Swap the mday and year iff the year wasn't specified in full. + if (mday > 31 && year <= 31 && yearDigits < 4) { + std::swap(mday, year); + std::swap(mdayDigits, yearDigits); + } + + if (mday > 31 || mdayDigits > 2) { + return false; + } + + if (yearDigits < 4) { + year = FixupNonFullYear(year); + } + + *indexOut = i; + *yearOut = year; + *monOut = mon; + *mdayOut = mday; + return true; +} + struct CharsAndAction { const char* chars; int action; @@ -1108,6 +1228,17 @@ bool negativeYear = false; size_t index = 0; + + // Try parsing the leading dashed-date. + // + // If successfully parsed, index is updated to the end of the date part, + // and year, mon, mday are set to the date. + // Continue parsing optional time + tzOffset parts. + // + // Otherwise, this is no-op. + bool isDashedDate = + TryParseDashedDatePrefix(s, length, &index, &year, &mon, &mday); + while (index < length) { int c = s[index]; index++; @@ -1281,23 +1412,6 @@ return false; } - auto IsPrefixOfKeyword = [](const CharT* s, size_t len, - const char* keyword) { - while (len > 0 && *keyword) { - MOZ_ASSERT(IsAsciiAlpha(*s)); - MOZ_ASSERT(IsAsciiLowercaseAlpha(*keyword)); - - if (unicode::ToLowerCase(static_cast(*s)) != *keyword) { - break; - } - - s++, keyword++; - len--; - } - - return len == 0; - }; - size_t k = std::size(keywords); while (k-- > 0) { const CharsAndAction& keyword = keywords[k]; @@ -1392,68 +1506,68 @@ return false; } - /* - * Case 1. The input string contains an English month name. - * The form of the string can be month f l, or f month l, or - * f l month which each evaluate to the same date. - * If f and l are both greater than or equal to 100 the date - * is invalid. - * - * The year is taken to be either l, f if f > 31, or whichever - * is set to zero. - * - * Case 2. The input string is of the form "f/m/l" where f, m and l are - * integers, e.g. 7/16/45. mon, mday and year values are adjusted - * to achieve Chrome compatibility. - * - * a. If 0 < f <= 12 and 0 < l <= 31, f/m/l is interpreted as - * month/day/year. - * b. If 31 < f and 0 < m <= 12 and 0 < l <= 31 f/m/l is - * interpreted as year/month/day - */ - if (seenMonthName) { - if (mday >= 100 && mon >= 100) { - return false; - } - - if (year > 0 && (mday == 0 || mday > 31) && !seenFullYear) { - int temp = year; - year = mday; - mday = temp; - } - - if (mday <= 0 || mday > 31) { - return false; - } - - } else if (0 < mon && mon <= 12 && 0 < mday && mday <= 31) { - /* (a) month/day/year */ - } else { - /* (b) year/month/day */ - if (mon > 31 && mday <= 12 && year <= 31 && !seenFullYear) { - int temp = year; - year = mon; - mon = mday; - mday = temp; + if (!isDashedDate) { + // NOTE: TryParseDashedDatePrefix already handles the following fixup. + + /* + * Case 1. The input string contains an English month name. + * The form of the string can be month f l, or f month l, or + * f l month which each evaluate to the same date. + * If f and l are both greater than or equal to 100 the date + * is invalid. + * + * The year is taken to be either l, f if f > 31, or whichever + * is set to zero. + * + * Case 2. The input string is of the form "f/m/l" where f, m and l are + * integers, e.g. 7/16/45. mon, mday and year values are adjusted + * to achieve Chrome compatibility. + * + * a. If 0 < f <= 12 and 0 < l <= 31, f/m/l is interpreted as + * month/day/year. + * b. If 31 < f and 0 < m <= 12 and 0 < l <= 31 f/m/l is + * interpreted as year/month/day + */ + if (seenMonthName) { + if (mday >= 100 && mon >= 100) { + return false; + } + + if (year > 0 && (mday == 0 || mday > 31) && !seenFullYear) { + int temp = year; + year = mday; + mday = temp; + } + + if (mday <= 0 || mday > 31) { + return false; + } + + } else if (0 < mon && mon <= 12 && 0 < mday && mday <= 31) { + /* (a) month/day/year */ } else { - return false; + /* (b) year/month/day */ + if (mon > 31 && mday <= 12 && year <= 31 && !seenFullYear) { + int temp = year; + year = mon; + mon = mday; + mday = temp; + } else { + return false; + } } - } - // If the year is greater than or equal to 50 and less than 100, it is - // considered to be the number of years after 1900. If the year is less - // than 50 it is considered to be the number of years after 2000, - // otherwise it is considered to be the number of years after 0. - if (!seenFullYear) { - if (year < 50) { - year += 2000; - } else if (year >= 50 && year < 100) { - year += 1900; + // If the year is greater than or equal to 50 and less than 100, it is + // considered to be the number of years after 1900. If the year is less + // than 50 it is considered to be the number of years after 2000, + // otherwise it is considered to be the number of years after 0. + if (!seenFullYear) { + year = FixupNonFullYear(year); } - } - if (negativeYear) { - year = -year; + if (negativeYear) { + year = -year; + } } mon -= 1; /* convert month to 0-based */ diff -Nru mozjs102-102.10.0/js/src/tests/non262/Date/dashed-date.js mozjs102-102.11.0/js/src/tests/non262/Date/dashed-date.js --- mozjs102-102.10.0/js/src/tests/non262/Date/dashed-date.js 1969-12-31 19:00:00.000000000 -0500 +++ mozjs102-102.11.0/js/src/tests/non262/Date/dashed-date.js 2023-05-08 11:51:14.000000000 -0400 @@ -0,0 +1,118 @@ +const tests = [ + // ==== Date only ==== + + // dd-MMM-yyyy + ["24-Apr-2023", "2023-04-24T00:00:00"], + ["24-apr-2023", "2023-04-24T00:00:00"], + ["24-April-2023", "2023-04-24T00:00:00"], + ["24-APRIL-2023", "2023-04-24T00:00:00"], + ["24-Apr-2033", "2033-04-24T00:00:00"], + + ["24-Apr-0023", "0023-04-24T00:00:00"], + + // dd-MMM-yy + ["24-Apr-23", "2023-04-24T00:00:00"], + ["24-Apr-33", "2033-04-24T00:00:00"], + + // dd-MMM-yyy + ["24-Apr-023", "2023-04-24T00:00:00"], + + // yyyy-MM-dd + ["2023-Apr-24", "2023-04-24T00:00:00"], + ["2033-Apr-24", "2033-04-24T00:00:00"], + + // yy-MM-dd + ["33-Apr-24", "2033-04-24T00:00:00"], + + // yyy-MM-dd + ["033-Apr-24", "2033-04-24T00:00:00"], + + // ==== Date followed by hour and TZ ==== + + ["24-Apr-2023 12:34:56", "2023-04-24T12:34:56"], + ["24-Apr-2023 Mon 12:34:56", "2023-04-24T12:34:56"], + ["24-Apr-2023 (Mon) 12:34:56", "2023-04-24T12:34:56"], + ["24-Apr-2023(Mon)12:34:56", "2023-04-24T12:34:56"], + + ["24-Apr-2023,12:34:56", "2023-04-24T12:34:56"], + ["24-Apr-2023,Mon 12:34:56", "2023-04-24T12:34:56"], + + ["24-Apr-2023 12:34:56 GMT", "2023-04-24T12:34:56Z"], + ["24-Apr-2023 12:34:56 +04", "2023-04-24T12:34:56+04:00"], + ["24-Apr-2023 12:34:56 +04:30", "2023-04-24T12:34:56+04:30"], + ["24-Apr-2023 12:34:56 -04", "2023-04-24T12:34:56-04:00"], + ["24-Apr-2023 12:34:56 -04:30", "2023-04-24T12:34:56-04:30"], + + ["24-Apr-2023 GMT", "2023-04-24T00:00:00Z"], + ["24-Apr-2023 +04", "2023-04-24T00:00:00+04:00"], + ["24-Apr-2023 +04:30", "2023-04-24T00:00:00+04:30"], + ["24-Apr-2023 -04", "2023-04-24T00:00:00-04:00"], + ["24-Apr-2023 -04:30", "2023-04-24T00:00:00-04:30"], + + ["24-Apr-2023GMT", "2023-04-24T00:00:00Z"], + ["24-Apr-2023+04", "2023-04-24T00:00:00+04:00"], + ["24-Apr-2023+04:30", "2023-04-24T00:00:00+04:30"], + ["24-Apr-2023-04", "2023-04-24T00:00:00-04:00"], + ["24-Apr-2023-04:30", "2023-04-24T00:00:00-04:30"], + + ["24-Apr-2023,GMT", "2023-04-24T00:00:00Z"], + ["24-Apr-2023,+04", "2023-04-24T00:00:00+04:00"], + ["24-Apr-2023,+04:30", "2023-04-24T00:00:00+04:30"], + ["24-Apr-2023,-04", "2023-04-24T00:00:00-04:00"], + ["24-Apr-2023,-04:30", "2023-04-24T00:00:00-04:30"], + + ["24-Apr-2023/12:34:56", "2023-04-24T12:34:56"], + ["24-Apr-2023/GMT", "2023-04-24T00:00:00Z"], + + // ==== non dd-MMM-yyyy. Uses fallback path ==== + + // Missing space. + ["24-Apr-202312:13:14", "-202312-04-24T13:14:00"], + + // Extra delimiter. + ["24-Apr- 2023", "2023-04-24T00:00:00"], + ["24-Apr -2023", "-002023-04-24T00:00:00"], + ["24- Apr-2023", "-002023-04-24T00:00:00"], + ["24 -Apr-2023", "-002023-04-24T00:00:00"], + + ["24-Apr-/2023", "2023-04-24T00:00:00"], + ["24-Apr/-2023", "-002023-04-24T00:00:00"], + ["24-/Apr-2023", "-002023-04-24T00:00:00"], + ["24/-Apr-2023", "-002023-04-24T00:00:00"], + + ["24-Apr-()2023", "2023-04-24T00:00:00"], + ["24-Apr()-2023", "-002023-04-24T00:00:00"], + ["24-()Apr-2023", "-002023-04-24T00:00:00"], + ["24()-Apr-2023", "-002023-04-24T00:00:00"], + + // mday being 3+ digits + ["024-Apr-2023", "-002023-04-24T00:00:00"], + ["0024-Apr-2023", "-002023-04-24T00:00:00"], +]; + +for (const [testString, isoString] of tests) { + const testDate = new Date(testString); + const isoDate = new Date(isoString); + + assertEq(testDate.getTime(), isoDate.getTime(), + testString); +} + +const invalidTests = [ + // mday being out of range. + "32-01-32", + + // mday being 3+ digits, while year being 2-3 digits. + "024-Apr-22", + "024-Apr-023", + + // Duplicate date. + "2012-Apr-08 12/12/12", +]; + +for (const testString of invalidTests) { + assertEq(Number.isNaN(new Date(testString).getTime()), true, testString); +} + +if (typeof reportCompare === "function") + reportCompare(true, true); diff -Nru mozjs102-102.10.0/js/src/wasm/WasmOpIter.h mozjs102-102.11.0/js/src/wasm/WasmOpIter.h --- mozjs102-102.10.0/js/src/wasm/WasmOpIter.h 2023-04-10 19:40:46.000000000 -0400 +++ mozjs102-102.11.0/js/src/wasm/WasmOpIter.h 2023-05-08 11:51:16.000000000 -0400 @@ -265,7 +265,7 @@ } void switchToCatch() { - MOZ_ASSERT(kind() == LabelKind::Try); + MOZ_ASSERT(kind() == LabelKind::Try || kind() == LabelKind::Catch); kind_ = LabelKind::Catch; polymorphicBase_ = false; } @@ -1587,9 +1587,7 @@ } valueStack_.shrinkTo(block.valueStackBase()); - if (block.kind() == LabelKind::Try) { - block.switchToCatch(); - } + block.switchToCatch(); return push(env_.tags[*tagIndex].type->resultType()); }