@@ -32,10 +32,11 @@ #endif #import "OFInvalidFormatException.h" #import "OFOpenItemFailedException.h" #import "OFOutOfMemoryException.h" +#import "OFOutOfRangeException.h" #ifdef OF_WINDOWS # define interface struct # include # undef interface @@ -236,30 +237,41 @@ # if !defined(OF_WINDOWS) && !defined(OF_AMIGAOS4) - (void)parseResolvConfOption: (OFString *)option { @try { if ([option hasPrefix: @"ndots:"]) { + unsigned long long number; + option = [option substringWithRange: of_range(6, option.length - 6)]; + number = option.unsignedLongLongValue; + + if (number > UINT_MAX) + @throw [OFOutOfRangeException exception]; - _minNumberOfDotsInAbsoluteName = - (unsigned int)option.decimalValue; + _minNumberOfDotsInAbsoluteName = (unsigned int)number; } else if ([option hasPrefix: @"timeout:"]) { option = [option substringWithRange: of_range(8, option.length - 8)]; - _timeout = option.decimalValue; + _timeout = option.unsignedLongLongValue; } else if ([option hasPrefix: @"attempts:"]) { + unsigned long long number; + option = [option substringWithRange: of_range(9, option.length - 9)]; + number = option.unsignedLongLongValue; + + if (number > UINT_MAX) + @throw [OFOutOfRangeException exception]; - _maxAttempts = (unsigned int)option.decimalValue; + _maxAttempts = (unsigned int)number; } else if ([option hasPrefix: @"reload-period:"]) { option = [option substringWithRange: of_range(14, option.length - 14)]; - _configReloadInterval = option.decimalValue; + _configReloadInterval = option.unsignedLongLongValue; } else if ([option isEqual: @"tcp"]) _usesTCP = true; } @catch (OFInvalidFormatException *e) { } }