Skip to content

GeoIP: switch to GEOIP_MEMORY_CACHE from GEOIP_INDEX_CACHE #2378

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 30, 2020

Conversation

defanator
Copy link
Contributor

Using GEOIP_INDEX_CACHE on some older versions of libGeoIP (e.g. 1.5.0 which is the default version on CentOS 7) leads to "Error reading file" error while opening completely valid GeoIP.dat:

# cat test.c
#include <stdio.h>
#include "GeoIP.h"

int main(void) {
  GeoIP *g;

  g = GeoIP_open("/tmp/GeoIP.dat", GEOIP_INDEX_CACHE);

  if (g == NULL) {
    printf("error!\n");
  }

  GeoIP_delete(g);

  exit(0);
}
# cc -lGeoIP -o test test.c
# ./test
Error reading file /tmp/GeoIP.dat
error!
# sed -i -e 's,GEOIP_INDEX_CACHE,GEOIP_MEMORY_CACHE,' test.c
# cc -lGeoIP -o test test.c
# ./test
# geoiplookup -f /tmp/GeoIP.dat -v 8.8.8.8
GeoIP Country Edition: GEO-106FREE 20180327 Build 1 Copyright (c) 2018 MaxMind Inc All Rights Reserved

Also tested with recent GeoLite databases converted from new format into legacy format, distributed here:
https://mailfud.org/geoip-legacy/

Closes #2186.

Using GEOIP_INDEX_CACHE on some older versions of libGeoIP (e.g. 1.5.0
which is the default version on CentOS 7) leads to "Error reading file"
error while opening completely valid GeoIP.dat:

    # cat test.c
    #include <stdio.h>
    #include "GeoIP.h"

    int main(void) {
      GeoIP *g;

      g = GeoIP_open("/tmp/GeoIP.dat", GEOIP_INDEX_CACHE);

      if (g == NULL) {
        printf("error!\n");
      }

      GeoIP_delete(g);

      exit(0);
    }
    # cc -lGeoIP -o test test.c
    # ./test
    Error reading file /tmp/GeoIP.dat
    error!
    # sed -i -e 's,GEOIP_INDEX_CACHE,GEOIP_MEMORY_CACHE,' test.c
    # cc -lGeoIP -o test test.c
    # ./test
    # geoiplookup -f /tmp/GeoIP.dat -v 8.8.8.8
    GeoIP Country Edition: GEO-106FREE 20180327 Build 1 Copyright (c) 2018 MaxMind Inc All Rights Reserved

Also tested with recent GeoLite databases converted from new format
into legacy format, distributed here:

    https://mailfud.org/geoip-legacy/
@defanator
Copy link
Contributor Author

Also, I've been playing with libmodsecurity built with --without-maxmind configure option here to avoid any possible interferences between two supported "geoip backends".

@zimmerle zimmerle self-requested a review July 30, 2020 16:47
@zimmerle zimmerle self-assigned this Jul 30, 2020
@zimmerle zimmerle added the 3.x Related to ModSecurity version 3.x label Jul 30, 2020
@zimmerle zimmerle merged commit fe12385 into owasp-modsecurity:v3/master Jul 30, 2020
@zimmerle
Copy link
Contributor

Thank you @defanator

zimmerle added a commit that referenced this pull request Jul 30, 2020
vladbukin pushed a commit to vladbukin/ModSecurity that referenced this pull request Apr 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.x Related to ModSecurity version 3.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot load local GeoIPDB
2 participants