From 9e348f2a2703cc4c743c62f9a22719970fec3bfe Mon Sep 17 00:00:00 2001 From: Michael Kirk <michael@signal.org> Date: Wed, 18 Jul 2018 16:48:02 -0600 Subject: [PATCH] update ubsan --- Signal.xcodeproj/project.pbxproj | 4 +++ .../xcshareddata/xcschemes/Signal.xcscheme | 8 ++++- Signal/SignalUBSan.supp | 32 +++++++++++++++++++ .../OWSLinkedDevicesTableViewController.m | 10 ++++-- .../Cells/OWSMessageHeaderView.m | 1 + .../Cells/OWSSystemMessageCell.m | 1 + .../OWSConversationSettingsViewController.m | 9 ++++-- 7 files changed, 58 insertions(+), 7 deletions(-) create mode 100644 Signal/SignalUBSan.supp diff --git a/Signal.xcodeproj/project.pbxproj b/Signal.xcodeproj/project.pbxproj index 6cd95074f..ee6f104b1 100644 --- a/Signal.xcodeproj/project.pbxproj +++ b/Signal.xcodeproj/project.pbxproj @@ -419,6 +419,7 @@ 4C20B2B720CA0034001BAC90 /* ThreadViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4542DF51208B82E9007B4E76 /* ThreadViewModel.swift */; }; 4C20B2B920CA10DE001BAC90 /* ConversationSearchViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C20B2B820CA10DE001BAC90 /* ConversationSearchViewController.swift */; }; 4C4AEC4520EC343B0020E72B /* DismissableTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C4AEC4420EC343B0020E72B /* DismissableTextField.swift */; }; + 4C6F527C20FFE8400097DEEE /* SignalUBSan.supp in Resources */ = {isa = PBXBuildFile; fileRef = 4C6F527B20FFE8400097DEEE /* SignalUBSan.supp */; }; 4CB5F26720F6E1E2004D1B42 /* MenuActionsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CFF4C0920F55BBA005DA313 /* MenuActionsViewController.swift */; }; 4CB5F26920F7D060004D1B42 /* MessageActions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CB5F26820F7D060004D1B42 /* MessageActions.swift */; }; 4CC0B59C20EC5F2E00CF6EE0 /* ConversationConfigurationSyncOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CC0B59B20EC5F2E00CF6EE0 /* ConversationConfigurationSyncOperation.swift */; }; @@ -1084,6 +1085,7 @@ 4C13C9F520E57BA30089A98B /* ColorPickerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorPickerViewController.swift; sourceTree = "<group>"; }; 4C20B2B820CA10DE001BAC90 /* ConversationSearchViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConversationSearchViewController.swift; sourceTree = "<group>"; }; 4C4AEC4420EC343B0020E72B /* DismissableTextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DismissableTextField.swift; sourceTree = "<group>"; }; + 4C6F527B20FFE8400097DEEE /* SignalUBSan.supp */ = {isa = PBXFileReference; lastKnownFileType = text; path = SignalUBSan.supp; sourceTree = "<group>"; }; 4CB5F26820F7D060004D1B42 /* MessageActions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageActions.swift; sourceTree = "<group>"; }; 4CC0B59B20EC5F2E00CF6EE0 /* ConversationConfigurationSyncOperation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConversationConfigurationSyncOperation.swift; sourceTree = "<group>"; }; 4CFF4C0920F55BBA005DA313 /* MenuActionsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuActionsViewController.swift; sourceTree = "<group>"; }; @@ -2402,6 +2404,7 @@ D221A094169C9E5E00537ABF /* Supporting Files */ = { isa = PBXGroup; children = ( + 4C6F527B20FFE8400097DEEE /* SignalUBSan.supp */, B6B6C3C419193F5B00C0B76B /* Translations */, D221A099169C9E5E00537ABF /* main.m */, D221A095169C9E5E00537ABF /* Signal-Info.plist */, @@ -2754,6 +2757,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 4C6F527C20FFE8400097DEEE /* SignalUBSan.supp in Resources */, 34CF078A203E6B78005C4D61 /* end_call_tone_cept.caf in Resources */, AD83FF3F1A73426500B5C81A /* audio_pause_button_blue.png in Resources */, 34330A5A1E7875FB00DF2FB9 /* fontawesome-webfont.ttf in Resources */, diff --git a/Signal.xcodeproj/xcshareddata/xcschemes/Signal.xcscheme b/Signal.xcodeproj/xcshareddata/xcschemes/Signal.xcscheme index 7dd0b1819..78b9c56c1 100644 --- a/Signal.xcodeproj/xcshareddata/xcschemes/Signal.xcscheme +++ b/Signal.xcodeproj/xcshareddata/xcschemes/Signal.xcscheme @@ -28,7 +28,7 @@ buildForAnalyzing = "YES"> <BuildableReference BuildableIdentifier = "primary" - BlueprintIdentifier = "B57ACF2237BE640621E2E2CF12637CFE" + BlueprintIdentifier = "13CED0CFD8586E9C6BAC02E581D06068" BuildableName = "SignalServiceKit.framework" BlueprintName = "SignalServiceKit" ReferencedContainer = "container:Pods/Pods.xcodeproj"> @@ -83,6 +83,7 @@ useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" debugDocumentVersioning = "YES" + stopOnEveryUBSanitizerIssue = "YES" debugServiceExtension = "internal" allowLocationSimulation = "YES" showNonLocalizedStrings = "YES"> @@ -102,6 +103,11 @@ value = "disable" isEnabled = "YES"> </EnvironmentVariable> + <EnvironmentVariable + key = "UBSAN_OPTIONS" + value = "suppressions=SignalUBSan.supp" + isEnabled = "YES"> + </EnvironmentVariable> <EnvironmentVariable key = "DYLD_PRINT_STATISTICS" value = "1" diff --git a/Signal/SignalUBSan.supp b/Signal/SignalUBSan.supp new file mode 100644 index 000000000..043c00979 --- /dev/null +++ b/Signal/SignalUBSan.supp @@ -0,0 +1,32 @@ +# See https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#runtime-suppressions +# for details. + +# protobuf lib +shift-base:CodedInputStream.m +# generated protos +bool:WebSocketResources.pb.m +bool:OWSSignalServiceProtos.pb.m +bool:WhisperTextProtocol.pb.m +bool:OWSWebRTCDataProtos.pb.m +bool:OWSSignaliOSProtos.pb.m +bool:OWSProvisioningProtos.pb.m +bool:OWSFingerprintProtos.pb.m + +# YapDatabase +bool:YapDatabaseAutoViewTransaction.m + +# SocketRocket +bool:SRWebSocket.m + +# Curve25519 expected +shift-base:curve25519-donna.c +shift-base:ge_scalarmult_base.c +shift-base:fe_mul.c +shift-exponent:fe_sq.c +shift-base:fe_sq.c +shift-base:fe_sq2.c +shift-exponent:fe_sq2.c +shift-base:fe_tobytes.c +shift-exponent:fe_tobytes.c +shift-base:sc_reduce.c +shift-exponent:sc_reduce.c diff --git a/Signal/src/ViewControllers/AppSettings/OWSLinkedDevicesTableViewController.m b/Signal/src/ViewControllers/AppSettings/OWSLinkedDevicesTableViewController.m index 9a4878119..f28f57bbf 100644 --- a/Signal/src/ViewControllers/AppSettings/OWSLinkedDevicesTableViewController.m +++ b/Signal/src/ViewControllers/AppSettings/OWSLinkedDevicesTableViewController.m @@ -75,9 +75,13 @@ int const OWSLinkedDevicesTableViewControllerSectionAddDevice = 1; { [super viewWillAppear:animated]; [self refreshDevices]; - // HACK to unselect rows when swiping back - // http://stackoverflow.com/questions/19379510/uitableviewcell-doesnt-get-deselected-when-swiping-back-quickly - [self.tableView deselectRowAtIndexPath:[self.tableView indexPathForSelectedRow] animated:animated]; + + NSIndexPath *_Nullable selectedPath = [self.tableView indexPathForSelectedRow]; + if (selectedPath) { + // HACK to unselect rows when swiping back + // http://stackoverflow.com/questions/19379510/uitableviewcell-doesnt-get-deselected-when-swiping-back-quickly + [self.tableView deselectRowAtIndexPath:selectedPath animated:animated]; + } } - (void)viewWillDisappear:(BOOL)animated diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageHeaderView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageHeaderView.m index b687f8842..392ce64fe 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageHeaderView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageHeaderView.m @@ -43,6 +43,7 @@ const CGFloat OWSMessageHeaderViewDateHeaderVMargin = 23; OWSAssert(!self.titleLabel); self.layoutMargins = UIEdgeInsetsZero; + self.layoutConstraints = @[]; // Intercept touches. // Date breaks and unread indicators are not interactive. diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSSystemMessageCell.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSSystemMessageCell.m index 2851ee105..7df6ba637 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSSystemMessageCell.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSSystemMessageCell.m @@ -77,6 +77,7 @@ typedef void (^SystemMessageActionBlock)(void); self.layoutMargins = UIEdgeInsetsZero; self.contentView.layoutMargins = UIEdgeInsetsZero; self.contentView.backgroundColor = UIColor.whiteColor; + self.layoutConstraints = @[]; self.headerView = [OWSMessageHeaderView new]; self.headerViewHeightConstraint = [self.headerView autoSetDimension:ALDimensionHeight toSize:0]; diff --git a/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m b/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m index 33983ab71..e90439722 100644 --- a/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m +++ b/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m @@ -847,9 +847,12 @@ const CGFloat kIconViewLength = 24; { [super viewWillAppear:animated]; - // HACK to unselect rows when swiping back - // http://stackoverflow.com/questions/19379510/uitableviewcell-doesnt-get-deselected-when-swiping-back-quickly - [self.tableView deselectRowAtIndexPath:[self.tableView indexPathForSelectedRow] animated:animated]; + NSIndexPath *_Nullable selectedPath = [self.tableView indexPathForSelectedRow]; + if (selectedPath) { + // HACK to unselect rows when swiping back + // http://stackoverflow.com/questions/19379510/uitableviewcell-doesnt-get-deselected-when-swiping-back-quickly + [self.tableView deselectRowAtIndexPath:selectedPath animated:animated]; + } [self updateTableContents]; }