Django

Code

Ticket #11245 (closed: fixed)

Opened 10 months ago

Last modified 9 months ago

contrib.gis.utils.GeoIP._check_query does not check for NULL pointer to _city or _country GeoIP libraries

Reported by: andrewfox Assigned to: jbronn
Milestone: Component: GIS
Version: 1.0 Keywords: geodjango, gis, geoip, ctype
Cc: andrewfox Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description (Last modified by jbronn)

In the _check_query method of geoip.py lines 344, 346, and 348 should not check self._city and/or self._country for 'is None' but instead for 'not self._city' or 'not self._country'. self._city and self._country are ctype wrapped pointers; so even if they returned NULL from the C library (e.g. fopen failure), self._city and self._country would still be not None but instead their pointer values would be None. Ctype checking for null pointers could be instead achieved by checking for 'not self._city'.

Referenced code (django/contrib/gis/utils/geoip.py (~line 344):

        # Extra checks for the existence of country and city databases.
        if city_or_country and self._country is None and self._city is None:
            raise GeoIPException('Invalid GeoIP country and city data files.')
        elif country and self._country is None:
            raise GeoIPException('Invalid GeoIP country data file: %s' % self._country_file)
        elif city and self._city is None:
            raise GeoIPException('Invalid GeoIP city data file: %s' % self._city_file)

Attachments

Change History

06/01/09 11:37:50 changed by andrewfox

  • cc set to andrewfox.
  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

06/01/09 11:45:58 changed by andrewfox

Lines actually 222, 224, and 226.

06/02/09 23:09:12 changed by jbronn

  • owner changed from nobody to jbronn.
  • component changed from Contrib apps to GIS.
  • description changed.

06/10/09 21:45:48 changed by jbronn

  • status changed from new to closed.
  • resolution set to fixed.

(In [10979]) Fixed #11245, #11246 -- Fixed validity check of GeoIP pointers and leaking of their references; also clarified initialization, fixed a stale test, added comments about version compatibility, and did some whitespace cleanup.

06/10/09 21:53:33 changed by jbronn

(In [10980]) [1.0.X] Fixed #11245, #11246 -- Fixed validity check of GeoIP pointers and leaking of their references; also clarified initialization, fixed a stale test, added comments about version compatibility, and did some whitespace cleanup.

Backport of r10979 from trunk.


Add/Change #11245 (contrib.gis.utils.GeoIP._check_query does not check for NULL pointer to _city or _country GeoIP libraries)




Change Properties
Action