From 8d4e020746565d19e3226f6a3f8233da2dead83c Mon Sep 17 00:00:00 2001 From: "mkaply%us.ibm.com" Date: Thu, 13 Jun 2002 20:51:03 +0000 Subject: [PATCH] #150012 r=dougt, sr=darin Support ranges (x-y) in the list of banned.override ports --- netwerk/base/src/nsIOService.cpp | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/netwerk/base/src/nsIOService.cpp b/netwerk/base/src/nsIOService.cpp index a70fc0f880cd..dc8d16b96c18 100644 --- a/netwerk/base/src/nsIOService.cpp +++ b/netwerk/base/src/nsIOService.cpp @@ -980,13 +980,29 @@ nsIOService::ParsePortList(nsIPrefBranch *prefBranch, const char *pref, PRBool r PRInt32 index; for (index=0; index < portListArray.Count(); index++) { portListArray[index]->StripWhitespace(); + PRInt32 aErrorCode, portBegin, portEnd; + + if (PR_sscanf(portListArray[index]->get(), "%d-%d", &portBegin, &portEnd) == 2) { + if ((portBegin < 65536) && (portEnd < 65536)) { + PRInt32 curPort; + if (remove) { + for (curPort=portBegin; curPort <= portEnd; curPort++) + mRestrictedPortList.RemoveElement((void*)curPort); + } else { + for (curPort=portBegin; curPort <= portEnd; curPort++) + mRestrictedPortList.AppendElement((void*)curPort); + } + } + } else { + PRInt32 port = portListArray[index]->ToInteger(&aErrorCode); + if (NS_SUCCEEDED(aErrorCode) && port < 65536) { + if (remove) + mRestrictedPortList.RemoveElement((void*)port); + else + mRestrictedPortList.AppendElement((void*)port); + } + } - PRInt32 aErrorCode; - PRInt32 value = portListArray[index]->ToInteger(&aErrorCode); - if (remove) - mRestrictedPortList.RemoveElement((void*)value); - else - mRestrictedPortList.AppendElement((void*)value); } } }