Skip to content

Commit db78324

Browse files
committed
Enable -Wconditional-uninitialized in WebCore project
<https://webkit.org/b/206508> Reviewed by Darin Adler. * Configurations/Base.xcconfig: (WARNING_CFLAGS): Add -Wconditional-uninitialized switch. Source/WebCore: * Modules/webgpu/WHLSL/WHLSLIntrinsics.cpp: (WebCore::WHLSL::Intrinsics::addFullTexture): - Initialize `vectorLength` to zero and add release assert that it is in a valid range [1-4] to prevent buffer out-of-bounds reads. - Change ASSERT() to ASSERT_WITH_SECURITY_IMPLICATION() since they all have security implications. * Modules/webgpu/WHLSL/WHLSLParser.cpp: (WebCore::WHLSL::Parser::parseResourceSemantic): - Add default case to switch statement with release assert since `mode` is not set for all possible character values. * accessibility/AXObjectCache.cpp: (WebCore::characterForCharacterOffset): - Ignore -Wconditional-warning for U16_NEXT() macro. Fix must be in compiler or in ICU header. * bindings/js/SerializedScriptValue.cpp: (WebCore::CloneDeserializer::readRSAKey): - Initialize `hash` to CryptoAlgorithmIdentifier::SHA_1. SHA_1 was chosen since Optional<CryptoAlgorithmIdentifier> parameters use that as a default vaule in crypto/keys/CryptoKeyRSA.cpp. * contentextensions/DFABytecodeCompiler.cpp: (WebCore::ContentExtensions::DFABytecodeCompiler::transitions): - Initialize `rangeMin` to 0. * css/parser/CSSSupportsParser.cpp: (WebCore::CSSSupportsParser::consumeCondition): - Initialize `result` to false. * cssjit/SelectorCompiler.cpp: (WebCore::SelectorCompiler::SelectorCodeGenerator::modulo): - Initialize `inputDividendCopy` to JSC::InvalidGPRReg. * dom/Document.cpp: (WebCore::Document::processHttpEquiv): - Initialize `delay` to zero. * rendering/svg/RenderSVGResourceGradient.cpp: (WebCore::RenderSVGResourceGradient::applyResource): - Initialize `gradientData` to nullptr. This false positive is tracked by <rdar://problem/58615489>. Canonical link: https://commits.webkit.org/219710@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255036 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent ccf5798 commit db78324

13 files changed

Lines changed: 86 additions & 13 deletions

File tree

Source/WebCore/ChangeLog

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,59 @@
1+
2020-01-23 David Kilzer <ddkilzer@apple.com>
2+
3+
Enable -Wconditional-uninitialized in WebCore project
4+
<https://webkit.org/b/206508>
5+
6+
Reviewed by Darin Adler.
7+
8+
* Configurations/Base.xcconfig:
9+
(WARNING_CFLAGS): Add -Wconditional-uninitialized switch.
10+
11+
* Modules/webgpu/WHLSL/WHLSLIntrinsics.cpp:
12+
(WebCore::WHLSL::Intrinsics::addFullTexture):
13+
- Initialize `vectorLength` to zero and add release assert that
14+
it is in a valid range [1-4] to prevent buffer out-of-bounds
15+
reads.
16+
- Change ASSERT() to ASSERT_WITH_SECURITY_IMPLICATION() since
17+
they all have security implications.
18+
19+
* Modules/webgpu/WHLSL/WHLSLParser.cpp:
20+
(WebCore::WHLSL::Parser::parseResourceSemantic):
21+
- Add default case to switch statement with release assert since
22+
`mode` is not set for all possible character values.
23+
24+
* accessibility/AXObjectCache.cpp:
25+
(WebCore::characterForCharacterOffset):
26+
- Ignore -Wconditional-warning for U16_NEXT() macro. Fix must be
27+
in compiler or in ICU header.
28+
29+
* bindings/js/SerializedScriptValue.cpp:
30+
(WebCore::CloneDeserializer::readRSAKey):
31+
- Initialize `hash` to CryptoAlgorithmIdentifier::SHA_1. SHA_1
32+
was chosen since Optional<CryptoAlgorithmIdentifier>
33+
parameters use that as a default vaule in
34+
crypto/keys/CryptoKeyRSA.cpp.
35+
36+
* contentextensions/DFABytecodeCompiler.cpp:
37+
(WebCore::ContentExtensions::DFABytecodeCompiler::transitions):
38+
- Initialize `rangeMin` to 0.
39+
40+
* css/parser/CSSSupportsParser.cpp:
41+
(WebCore::CSSSupportsParser::consumeCondition):
42+
- Initialize `result` to false.
43+
44+
* cssjit/SelectorCompiler.cpp:
45+
(WebCore::SelectorCompiler::SelectorCodeGenerator::modulo):
46+
- Initialize `inputDividendCopy` to JSC::InvalidGPRReg.
47+
48+
* dom/Document.cpp:
49+
(WebCore::Document::processHttpEquiv):
50+
- Initialize `delay` to zero.
51+
52+
* rendering/svg/RenderSVGResourceGradient.cpp:
53+
(WebCore::RenderSVGResourceGradient::applyResource):
54+
- Initialize `gradientData` to nullptr. This false positive is
55+
tracked by <rdar://problem/58615489>.
56+
157
2020-01-23 Per Arne Vollan <pvollan@apple.com>
258

359
[Cocoa] Broker access to the PowerManagement API

Source/WebCore/Configurations/Base.xcconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ GCC_WARN_SIGN_COMPARE = YES;
8888
GCC_WARN_UNINITIALIZED_AUTOS = YES;
8989
GCC_WARN_UNUSED_FUNCTION = YES;
9090
GCC_WARN_UNUSED_VARIABLE = YES;
91-
WARNING_CFLAGS = -Wall -Wextra -Wcast-qual -Wchar-subscripts -Wextra-tokens -Wformat=2 -Winit-self -Wmissing-format-attribute -Wmissing-noreturn -Wpacked -Wpointer-arith -Wredundant-decls -Wundef -Wwrite-strings -Wexit-time-destructors -Wglobal-constructors -Wtautological-compare -Wimplicit-fallthrough -Wno-unknown-warning-option;
91+
WARNING_CFLAGS = -Wall -Wextra -Wcast-qual -Wchar-subscripts -Wconditional-uninitialized -Wextra-tokens -Wformat=2 -Winit-self -Wmissing-format-attribute -Wmissing-noreturn -Wpacked -Wpointer-arith -Wredundant-decls -Wundef -Wwrite-strings -Wexit-time-destructors -Wglobal-constructors -Wtautological-compare -Wimplicit-fallthrough -Wno-unknown-warning-option;
9292

9393
TARGET_MAC_OS_X_VERSION_MAJOR = $(TARGET_MAC_OS_X_VERSION_MAJOR$(MACOSX_DEPLOYMENT_TARGET:suffix:identifier));
9494
TARGET_MAC_OS_X_VERSION_MAJOR_13 = 101300;

Source/WebCore/Modules/webgpu/WHLSL/WHLSLIntrinsics.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,22 +203,23 @@ bool Intrinsics::addFullTexture(AST::NativeTypeDeclaration& nativeTypeDeclaratio
203203
return false;
204204

205205
unsigned innerTypeIndex = WTF_ARRAY_LENGTH(m_textureInnerTypeNames);
206-
unsigned vectorLength;
206+
unsigned vectorLength = 0;
207207
for (unsigned i = 0; i < WTF_ARRAY_LENGTH(m_textureInnerTypeNames); ++i) {
208208
if (innerType.name().startsWith(m_textureInnerTypeNames[i])) {
209209
innerTypeIndex = i;
210210
if (innerType.name() == m_textureInnerTypeNames[i])
211211
vectorLength = 1;
212212
else {
213-
ASSERT(innerType.name().length() == strlen(m_textureInnerTypeNames[i]) + 1);
214-
ASSERT(innerType.name()[innerType.name().length() - 1] == '2'
213+
ASSERT_WITH_SECURITY_IMPLICATION(innerType.name().length() == strlen(m_textureInnerTypeNames[i]) + 1);
214+
ASSERT_WITH_SECURITY_IMPLICATION(innerType.name()[innerType.name().length() - 1] == '2'
215215
|| innerType.name()[innerType.name().length() - 1] == '3'
216216
|| innerType.name()[innerType.name().length() - 1] == '4');
217217
vectorLength = innerType.name()[innerType.name().length() - 1] - '0';
218218
}
219219
}
220220
}
221-
ASSERT(innerTypeIndex != WTF_ARRAY_LENGTH(m_textureInnerTypeNames));
221+
RELEASE_ASSERT(vectorLength && vectorLength < 5);
222+
ASSERT_WITH_SECURITY_IMPLICATION(innerTypeIndex != WTF_ARRAY_LENGTH(m_textureInnerTypeNames));
222223
nativeTypeDeclaration.setIsTexture();
223224
nativeTypeDeclaration.setIsOpaqueType();
224225
if (nativeTypeDeclaration.name() == "Texture1DArray" || nativeTypeDeclaration.name() == "RWTexture1DArray" || nativeTypeDeclaration.name() == "Texture2DArray" || nativeTypeDeclaration.name() == "RWTexture2DArray")

Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,8 @@ auto Parser::parseResourceSemantic() -> Expected<AST::ResourceSemantic, Error>
696696
case 's':
697697
mode = AST::ResourceSemantic::Mode::Sampler;
698698
break;
699+
default:
700+
RELEASE_ASSERT_NOT_REACHED();
699701
}
700702

701703
auto index = recognizeSimpleUnsignedInteger(infoStringView.substring(1));

Source/WebCore/PAL/ChangeLog

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
2020-01-23 David Kilzer <ddkilzer@apple.com>
2+
3+
Enable -Wconditional-uninitialized in WebCore project
4+
<https://webkit.org/b/206508>
5+
6+
Reviewed by Darin Adler.
7+
8+
* Configurations/Base.xcconfig:
9+
(WARNING_CFLAGS): Add -Wconditional-uninitialized switch.
10+
111
2020-01-21 Alex Christensen <achristensen@webkit.org>
212

313
Add missing NS_NOESCAPE to CFNetwork SPI

Source/WebCore/PAL/Configurations/Base.xcconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ GCC_WARN_SIGN_COMPARE = YES;
8888
GCC_WARN_UNINITIALIZED_AUTOS = YES;
8989
GCC_WARN_UNUSED_FUNCTION = YES;
9090
GCC_WARN_UNUSED_VARIABLE = YES;
91-
WARNING_CFLAGS = -Wall -Wextra -Wcast-qual -Wchar-subscripts -Wextra-tokens -Wformat=2 -Winit-self -Wmissing-format-attribute -Wmissing-noreturn -Wpacked -Wpointer-arith -Wredundant-decls -Wundef -Wwrite-strings -Wexit-time-destructors -Wglobal-constructors -Wtautological-compare -Wimplicit-fallthrough -Wno-unknown-warning-option;
91+
WARNING_CFLAGS = -Wall -Wextra -Wcast-qual -Wchar-subscripts -Wconditional-uninitialized -Wextra-tokens -Wformat=2 -Winit-self -Wmissing-format-attribute -Wmissing-noreturn -Wpacked -Wpointer-arith -Wredundant-decls -Wundef -Wwrite-strings -Wexit-time-destructors -Wglobal-constructors -Wtautological-compare -Wimplicit-fallthrough -Wno-unknown-warning-option;
9292

9393
TARGET_MAC_OS_X_VERSION_MAJOR = $(TARGET_MAC_OS_X_VERSION_MAJOR$(MACOSX_DEPLOYMENT_TARGET:suffix:identifier));
9494
TARGET_MAC_OS_X_VERSION_MAJOR_13 = 101300;

Source/WebCore/accessibility/AXObjectCache.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2523,8 +2523,12 @@ static UChar32 characterForCharacterOffset(const CharacterOffset& characterOffse
25232523

25242524
UChar32 ch = 0;
25252525
unsigned offset = characterOffset.startIndex + characterOffset.offset;
2526-
if (offset < characterOffset.node->textContent().length())
2526+
if (offset < characterOffset.node->textContent().length()) {
2527+
// FIXME: Remove IGNORE_WARNINGS macros once one of <rdar://problem/58615489&58615391> is fixed.
2528+
IGNORE_WARNINGS_BEGIN("conditional-uninitialized")
25272529
U16_NEXT(characterOffset.node->textContent(), offset, characterOffset.node->textContent().length(), ch);
2530+
IGNORE_WARNINGS_END
2531+
}
25282532
return ch;
25292533
}
25302534

Source/WebCore/bindings/js/SerializedScriptValue.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2346,7 +2346,7 @@ class CloneDeserializer : CloneBase {
23462346
return false;
23472347

23482348
int32_t isRestrictedToHash;
2349-
CryptoAlgorithmIdentifier hash;
2349+
CryptoAlgorithmIdentifier hash = CryptoAlgorithmIdentifier::SHA_1;
23502350
if (!read(isRestrictedToHash))
23512351
return false;
23522352
if (isRestrictedToHash && !read(hash))

Source/WebCore/contentextensions/DFABytecodeCompiler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ DFABytecodeCompiler::Transitions DFABytecodeCompiler::transitions(const DFANode&
248248
}
249249

250250
Vector<Range>& ranges = transitions.ranges;
251-
uint8_t rangeMin;
251+
uint8_t rangeMin = 0;
252252
bool hasRangeMin = false;
253253
for (uint8_t i = 0; i < 128; i++) {
254254
if (hasRangeMin) {

Source/WebCore/css/parser/CSSSupportsParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ CSSSupportsParser::SupportsResult CSSSupportsParser::consumeCondition(CSSParserT
5656
if (range.peek().type() == IdentToken || range.peek().type() == FunctionToken)
5757
return consumeNegation(range);
5858

59-
bool result;
59+
bool result = false;
6060
ClauseType clauseType = Unresolved;
6161

6262
auto previousTokenType = IdentToken;

0 commit comments

Comments
 (0)