mirror of
https://github.com/transmission/transmission
synced 2025-03-06 11:38:21 +00:00
again verify that ip addresses are valid for the acl (removed in [6803])
This commit is contained in:
parent
86b6e00321
commit
6b637753c7
1 changed files with 30 additions and 10 deletions
|
@ -955,8 +955,10 @@ tr_handle * fHandle;
|
|||
NSMutableArray * newComponents = [NSMutableArray arrayWithCapacity: 4];
|
||||
|
||||
//create better-formatted ip string
|
||||
BOOL valid = false;
|
||||
if ([components count] == 4)
|
||||
{
|
||||
valid = true;
|
||||
NSEnumerator * enumerator = [components objectEnumerator];
|
||||
NSString * component;
|
||||
while ((component = [enumerator nextObject]))
|
||||
|
@ -964,19 +966,37 @@ tr_handle * fHandle;
|
|||
if ([component isEqualToString: @"*"])
|
||||
[newComponents addObject: component];
|
||||
else
|
||||
[newComponents addObject: [[NSNumber numberWithInt: [component intValue]] stringValue]];
|
||||
{
|
||||
int num = [component intValue];
|
||||
if (num >= 0 && num < 256)
|
||||
[newComponents addObject: [[NSNumber numberWithInt: num] stringValue]];
|
||||
else
|
||||
{
|
||||
valid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NSString * newIP = [newComponents componentsJoinedByString: @"."];
|
||||
|
||||
NSDictionary * newDict = [NSDictionary dictionaryWithObjectsAndKeys: newIP, @"IP",
|
||||
[oldDict objectForKey: @"Allow"], @"Allow", nil];
|
||||
[fRPCAccessArray replaceObjectAtIndex: row withObject: newDict];
|
||||
|
||||
NSSortDescriptor * descriptor = [[[NSSortDescriptor alloc] initWithKey: @"IP" ascending: YES
|
||||
selector: @selector(compareNumeric:)] autorelease];
|
||||
[fRPCAccessArray sortUsingDescriptors: [NSArray arrayWithObject: descriptor]];
|
||||
if (valid)
|
||||
{
|
||||
NSString * newIP = [newComponents componentsJoinedByString: @"."];
|
||||
|
||||
NSDictionary * newDict = [NSDictionary dictionaryWithObjectsAndKeys: newIP, @"IP",
|
||||
[oldDict objectForKey: @"Allow"], @"Allow", nil];
|
||||
[fRPCAccessArray replaceObjectAtIndex: row withObject: newDict];
|
||||
|
||||
NSSortDescriptor * descriptor = [[[NSSortDescriptor alloc] initWithKey: @"IP" ascending: YES
|
||||
selector: @selector(compareNumeric:)] autorelease];
|
||||
[fRPCAccessArray sortUsingDescriptors: [NSArray arrayWithObject: descriptor]];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSBeep();
|
||||
if ([[oldDict objectForKey: @"IP"] isEqualToString: @""])
|
||||
[fRPCAccessArray removeObjectAtIndex: row];
|
||||
}
|
||||
|
||||
[fRPCAccessTable deselectAll: self];
|
||||
[fRPCAccessTable reloadData];
|
||||
|
|
Loading…
Add table
Reference in a new issue