All Projects → jasenhuang → Nsobjectsafe

jasenhuang / Nsobjectsafe

Swizzle commonly used function of Foundation container to prevent nil crash

Labels

Projects that are alternatives of or similar to Nsobjectsafe

SafeGuard
WTSafeGuard can effectively prevent the IOS system application crash
Stars: ✭ 54 (-89.98%)
Mutual labels:  crash
CVE-2022-21907-http.sys
Proof of concept of CVE-2022-21907 Double Free in http.sys driver, triggering a kernel crash on IIS servers
Stars: ✭ 67 (-87.57%)
Mutual labels:  crash
Pyjfuzz
PyJFuzz - Python JSON Fuzzer
Stars: ✭ 342 (-36.55%)
Mutual labels:  crash
Safari-Crash
Small HTML DoS exploit kit aimed at mobile browsers that allows rapid deployment and testing
Stars: ✭ 32 (-94.06%)
Mutual labels:  crash
Crasher
解析iOS crash 工具
Stars: ✭ 61 (-88.68%)
Mutual labels:  crash
CrashLogger
A dll injected into process to dump stack when crashing.
Stars: ✭ 19 (-96.47%)
Mutual labels:  crash
XLog
一个简易的日志打印框架(支持打印策略自定义,默认提供2种策略:logcat打印和磁盘打印)
Stars: ✭ 33 (-93.88%)
Mutual labels:  crash
Impact
Crash capturing library for Apple platforms
Stars: ✭ 395 (-26.72%)
Mutual labels:  crash
FWDebug
iOS调试库,支持iOS11+,无需添加任何代码,方便iOS开发和测试。 iOS debugging library, support for iOS11 +, without adding any code to facilitate iOS development and testing.
Stars: ✭ 49 (-90.91%)
Mutual labels:  crash
Cockroach
降低Android非必要crash
Stars: ✭ 3,002 (+456.96%)
Mutual labels:  crash
kotlin-multiplatform-example
A Kotlin multiplatform example app that targets Android, ReactJS, iOS, JavaFx, and Spring Boot
Stars: ✭ 115 (-78.66%)
Mutual labels:  crash
my-qt-crasher
😽🖥💥 Example MacOS, Windows, and Linux Qt application integrated with Crashpad.
Stars: ✭ 29 (-94.62%)
Mutual labels:  crash
KJExceptionDemo
Automatic crash protection.自动防护异常崩溃 🌇
Stars: ✭ 27 (-94.99%)
Mutual labels:  crash
Crashalert
Set of React Native components that allow reporting of the crashes in RN applications.
Stars: ✭ 68 (-87.38%)
Mutual labels:  crash
Flightairmap
Open source project displaying live aircrafts, ships or trackers on 2D/3D map. Browse through the data based on a particular aircraft, airline, airport, tracker or vessel to search through the database or see extensive statistics. Can use ADS-B in SBS1 format (dump1090, Radarcape,...), VRS, VA (VATSIM, IVAO whazzup.txt, phpvms,...), ACARS (acarsdec, acarsdeco2), APRS, AIS as datasource.
Stars: ✭ 366 (-32.1%)
Mutual labels:  crash
LogServiceCrash
POC code to crash Windows Event Logger Service
Stars: ✭ 23 (-95.73%)
Mutual labels:  crash
SCP3Picture
A python script to get P3 picture names
Stars: ✭ 22 (-95.92%)
Mutual labels:  crash
Bugsnag Php
Bugsnag error monitoring and crash reporting tool for PHP apps
Stars: ✭ 475 (-11.87%)
Mutual labels:  crash
Bugsnag React Native
Error monitoring and reporting tool for native exceptions and JS errors in React Native apps
Stars: ✭ 374 (-30.61%)
Mutual labels:  crash
wifi-deauther
A fully automatic wifi deauther coded in Python
Stars: ✭ 25 (-95.36%)
Mutual labels:  crash

NSObject-Safe

Update 2019.07.04

  • add overflow/negative support for NSRange
1: negative value
    - NSUInteger  > NSIntegerMax
2: overflow
    - (a+ b) > a

Update 2018.11.20

  • add thread-safe support

Update 2018.6.26

  • remove unused swizze for NSDictionary objectForKey:
  • more class cluster support
NSArray
    __NSArrayI_Transfer, __NSArrayReversed, __NSFrozenArrayM, __NSCFArray
NSString
    NSTaggedPointerString, __NSCFString, _NSCFConstantString
NSData
    NSConcreteData, NSConcreteMutableData, _NSZeroData, _NSInlineData, __NSCFData

Warn:

  • Compile NSObjectSafe.m with -fno-objc-arc, otherwise it will cause strange release error: [UIKeyboardLayoutStar release]: message sent to deallocated instance
  • Conflict with MultiDelegate

Desciption

  • Swizzle commonly used function of Foundation container to prevent nil crash
  • Hook forwardInvocation to catch unrecognized selector exception
  • Assert in Debug and log in Release

Usage:

  • involve NSObjectSafe.h/NSObjectSafe.m as build phases

unrecognized selector protection

  • NSSafeProxy: unrecognized selector [print:] sent to A
@interface A : NSObject
- (void)print:(NSString*)msg;
@end
@implementation A
@end

Object Literals

NSArray* item = nil;
NSArray * items = @[@"a",@"b", item ,@"c"];
NSLog(@"%@", items);

NSString* key = nil;
NSString* value = nil;
NSLog(@"%@", @{@"b":@"c",key:value, @"e":value});

Swizzle Functions:

  • NSObject(Swizzle):
+ (void)swizzleClassMethod:(SEL)origSelector withMethod:(SEL)newSelector;
- (void)swizzleInstanceMethod:(SEL)origSelector withMethod:(SEL)newSelector;
  • NSObject(Safe)
- (void) addObserver:(NSObject *)observer forKeyPath:(NSString *)keyPath 
						options:(NSKeyValueObservingOptions)options context:(void *)context;
- (void) removeObserver:(NSObject *)observer forKeyPath:(NSString *)keyPath;
  • NSString
+ (NSString*) stringWithUTF8String:(const char *)nullTerminatedCString;
+ (nullable instancetype) stringWithCString:(const char *)cString encoding:(NSStringEncoding)enc;
- (nullable instancetype) initWithCString:(const char *)nullTerminatedCString encoding:(NSStringEncoding)encoding;
- (NSString *)stringByAppendingString:(NSString *)aString;
  • NSMutableString
- (nullable instancetype) safeInitWithCString:(const char *)nullTerminatedCString encoding:(NSStringEncoding)encoding;
- (void) appendString:(NSString *)aString;
- (void) insertString:(NSString *)aString atIndex:(NSUInteger)loc;
- (void) deleteCharactersInRange:(NSRange)range;
- (NSString *)stringByAppendingString:(NSString *)aString;
  • NSArray
+ (instancetype) arrayWithObject:(id)anObject;
- (id) objectAtIndex:(NSUInteger)index;
  • NSMutableArray
- (void) addObject:(id)anObject;
- (id) objectAtIndex:(NSUInteger)index;
- (void) insertObject:(id)anObject atIndex:(NSUInteger)index;
- (void) removeObjectAtIndex:(NSUInteger)index;
- (void) replaceObjectAtIndex:(NSUInteger)index withObject:(id)anObject;
- (void) removeObjectsInRange:(NSRange)range;
  • NSDictionary
+ (instancetype) dictionaryWithObject:(id)object forKey:(id)key;
- (id) objectForKey:(id)aKey;
  • NSMutableDictionary
- (id) objectForKey:(id)aKey;
- (void) setObject:(id)anObject forKey:(id)aKey;
- (void) removeObjectForKey:(id)aKey;
  • NSSet
+ (instancetype)setWithObject:(id)object;
  • NSMutableSet
- (void) addObject:(id)object;
- (void) removeObject:(id)object;
  • NSOrderedSet
+ (instancetype)orderedSetWithObject:(id)object;
- (instancetype)initWithObject:(id)object;
- (id)objectAtIndex:(NSUInteger)idx;
  • NSMutableOrderedSet
- (id)objectAtIndex:(NSUInteger)idx;
- (void)addObject:(id)object;
- (void)insertObject:(id)object atIndex:(NSUInteger)idx;
- (void)removeObjectAtIndex:(NSUInteger)idx;
- (void)replaceObjectAtIndex:(NSUInteger)idx withObject:(id)object;
  • NSUserDefault
- (id) objectForKey:(NSString *)defaultName;
- (NSInteger) integerForKey:(NSString *)defaultName;
- (BOOL) boolForKey:(NSString *)defaultName;
- (void) setObject:(id)value forKey:(NSString*)aKey;
- (void) removeObjectForKey:(NSString*)aKey;
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].