Permalink
Browse files

Fix IndexOutOfRangeException error when a lookup end in the last vali…

…d netblock using GEOIP_MEMORY_CACHE mode ( Boris Zentner )
  • Loading branch information...
borisz committed May 16, 2009
1 parent 5ece40f commit 116cacb2638a4f3df36ee85352795e63005255dc
Showing with 5 additions and 6 deletions.
  1. +3 −0 ChangeLog
  2. +2 −6 LookupService.cs
View
@@ -1,3 +1,6 @@
+1.11 May 16th, 2009
+ - Fix IndexOutOfRangeException error when a lookup end in the last valid
+ netblock using GEOIP_MEMORY_CACHE mode ( Boris Zentner )
- Fixed spelling of Kazakhstan, was Kazakstan ( Boris Zentner )
- Sync RegionName.cs with more recent FIPS codes. ( Boris Zentner )
1.10 Oct 23th, 2008
View
@@ -429,9 +429,7 @@ public class LookupService{
}
record_pointer = Seek_country + ((2 * recordLength - 1) * databaseSegments[0]);
if ((dboptions & GEOIP_MEMORY_CACHE) == 1){
- for (int i = 0;i < FULL_RECORD_LENGTH;i++){
- record_buf[i] = dbbuffer[i+record_pointer];
- }
+ Array.Copy(dbbuffer, record_pointer, record_buf, 0, Math.Min(dbbuffer.Length - record_pointer, FULL_RECORD_LENGTH));
} else {
file.Seek(record_pointer,SeekOrigin.Begin);
file.Read(record_buf,0,FULL_RECORD_LENGTH);
@@ -534,9 +532,7 @@ public class LookupService{
record_pointer = Seek_org + (2 * recordLength - 1) * databaseSegments[0];
if ((dboptions & GEOIP_MEMORY_CACHE) == 1) {
- for (int i = 0;i < MAX_ORG_RECORD_LENGTH;i++) {
- buf[i] = dbbuffer[i+record_pointer];
- }
+ Array.Copy(dbbuffer, record_pointer, buf, 0, Math.Min(dbbuffer.Length - record_pointer, MAX_ORG_RECORD_LENGTH));
} else {
file.Seek(record_pointer,SeekOrigin.Begin);
file.Read(buf,0,MAX_ORG_RECORD_LENGTH);

0 comments on commit 116cacb

Please sign in to comment.