aboutsummaryrefslogtreecommitdiffstats
path: root/epan/maxmind_db.c
AgeCommit message (Collapse)AuthorFilesLines
2019-01-05maxmind_db: Close our pipe FDs inside a lock.Gerald Combs1-4/+15
Lock our pipe mutex before closing its file descriptors. This should hopefully fix some infrequent crashes that I'm seeing on my Windows 7 VM. Add a note about GRWLock behavior on Windows which doesn't appear to be related to this issue, but which is nevertheless important. Ping-Bug: 14701 Change-Id: I32e66a24258264fa65a907f319755594f90c0177 Reviewed-on: https://code.wireshark.org/review/31375 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-12-26maxmind_db: force buffer contain an empty string (CID: 1441961).Dario Lombardo1-0/+2
Change-Id: Ia290f528befa0c071de9e62ea264fdda0740d6f8 Reviewed-on: https://code.wireshark.org/review/31206 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-12-03maxminddb: Expand a comment.Gerald Combs1-2/+8
Change-Id: Iac0d158ccc56c40c87ccc8399a8a5b16af768e12 Reviewed-on: https://code.wireshark.org/review/30901 Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-12-03Revert "maxmind: Simplify our read logic."Gerald Combs1-14/+28
This reverts commit 4154e35cde9c863ace57598cabc37034dab2ab1c. Apparently we do need to call PeekNamedPipe on Windows. Change-Id: I9c9bbcb56bf1e1c2e6ae240ac5056b8a80674f15 Reviewed-on: https://code.wireshark.org/review/30900 Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-12-02maxmind: Simplify our read logic.Gerald Combs1-28/+14
Don't bother checking to see if our pipe has data. Change-Id: I55f24850a16f66be9c679ad51e35df9f35c206db Reviewed-on: https://code.wireshark.org/review/30877 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-12-01maxmind: Process responses one character at a time.Gerald Combs1-22/+62
Process mmdbresolve output one character at a time and only after ws_pipe_data_available tells us that we can do so without blocking. Bug: 14701 Change-Id: Ib8f5eabed28e9385585a022d948b83f830c6358c Reviewed-on: https://code.wireshark.org/review/30850 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-30maxmind: Move response processing to a thread.Gerald Combs1-98/+150
Move response processing to a thread. Blind attempt at fixing bug 14701. Bug: 14701 Change-Id: I2b7e6a0669c4784c7c169e659fa37ea2e62c96a3 Reviewed-on: https://code.wireshark.org/review/30837 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-01wsutil: introduce ws_pipe_close() helper and use it to terminate mmdbresolvePascal Quantin1-2/+1
We were not calling TerminateProcess() to stop mmdbresolve.Exe process on Windows. Bug: 15248 Change-Id: Ic90cf438a8003a6fefb023b7056984681ce09b46 Reviewed-on: https://code.wireshark.org/review/30449 Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-01mmdb: do not lock the pipe mutex recursivelyPascal Quantin1-9/+11
According to GLib documentation, take twice the lock in the same thread leads to undefined behavior (and could lead to deadlocks). Change-Id: I40e02ba9d619eb1db2a04f2be54c461c817b15ff Reviewed-on: https://code.wireshark.org/review/30446 Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-05-26maxmind_db.c: fix a memory leakPascal Quantin1-3/+3
Change-Id: Iee898541ec723cec209a3561899530a8dbe6e680 Reviewed-on: https://code.wireshark.org/review/27809 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com> Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-05-24maxmind: Move request processing to a thread.Gerald Combs1-33/+86
It's possible to block while we're writing to our mmdbresolve pipe, particularly on Windows. Move the write to a separate thread. Add an #ifdef to mmdbresolve.c which helps test blocking. Bug: 14701 Change-Id: I6cb8a46a190a268da64f1e6f54d1052d03743c95 Reviewed-on: https://code.wireshark.org/review/27750 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-05-18maxmind: Process our requests more often.Gerald Combs1-2/+12
The answer to // XXX Should we call maxmind_db_lookup_process first? in maxmind_db.c is "yes", since it's possible to fill up our pipe between host name lookup intervals, at least on Windows. Note that we might want to move request processing to a thread. Bug: 14701 Change-Id: I8cfb77444d7f999e77571bc6bb61ea7f1f677778 Reviewed-on: https://code.wireshark.org/review/27644 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-03-13Properly initialize mmdb_lookup_t.Gerald Combs1-3/+8
Set our initial geographic coordinates to DBL_MAX, otherwise we might give people the wrong impression about the PIRATA weather buoy at 0°0'0" N 0°0'0" E. Change-Id: I34683883ef02c4fe40d5d93a7695d0cca277345c Reviewed-on: https://code.wireshark.org/review/26463 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-03-11maxmind: check val_start before using it.Dario Lombardo1-4/+4
Change-Id: Id3ee8e8d4c54c02d68048ec677fdda599b329713 Reviewed-on: https://code.wireshark.org/review/26417 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-03-11maxmind: use ws_strtou32 to convert AS numbers.Dario Lombardo1-3/+7
Change-Id: I0578f8a674feee6e4763d5481a2285b7b2a054dc Reviewed-on: https://code.wireshark.org/review/26416 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-03-10MaxMindDB: Add country ISO codes.Gerald Combs1-1/+4
Add and dissect country ISO codes. Prefer them when printing summary information. Change-Id: I3ce2bde88fa5ca2604c8bb745c42f239660252ff Reviewed-on: https://code.wireshark.org/review/26415 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-03-10MaxMind DB: Fixup IPv6 address interning.Gerald Combs1-2/+7
Intern IPv6 addresses into their own hash table. Change-Id: I1ad60bf56585fcd89964e949e8754af3c7512a75 Reviewed-on: https://code.wireshark.org/review/26414 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-03-10Process MaxMind DB data one line at a time.Gerald Combs1-77/+74
Use fgets instead of ws_read + g_strsplit. Change-Id: I9d13183cc129e0c749742779f9c48fdfba21a8fc Reviewed-on: https://code.wireshark.org/review/26374 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-03-09maxminf_db.c: ad an explicit cast to please gcc 7.3.1Pascal Quantin1-1/+1
Change-Id: Ie97008ece77e485948a3a8d418a49b77c1a52a33 Reviewed-on: https://code.wireshark.org/review/26395 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2018-03-09GeoIP: avoid closing random file descriptorsPeter Wu1-6/+19
Previously there were three different pipe validity checks: PID != WS_INVALID_PID, PID != 0 and stdin != 0. This resulted in using/closing file descriptors which might be owned by something else. When no GeoIP databases are defined, mmdb_resolve_stop would be called to close the pipe and set PID to WS_INVALID_PID. stdin is however not cleared and future invocations would try to close the previous fd. Change-Id: I1d15da29208efb41098ee6a4edeeabf61f84c2b3 Fixes: v2.5.1rc0-466-ga1da75c554 ("Transition from GeoIP Legacy to MaxMindDB.") Reviewed-on: https://code.wireshark.org/review/26391 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-03-09Add MaxMindDB 1.3.2 library to WindowsPascal Quantin1-2/+2
Change-Id: I328b6a05cc356be59ac63e80eae55a832bf76a47 Reviewed-on: https://code.wireshark.org/review/26347 Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2018-03-09Intern MaxMinDB IPv6 addresses.Gerald Combs1-3/+14
Make sure our IPv6 addresses are unique and allocated, similar to our strings. Bug: 14514 Change-Id: I602b3b0ec4674fb2bc8cbaa973a73a6f3188e0c3 Reviewed-on: https://code.wireshark.org/review/26371 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-03-08MaxMind DB fixups.Gerald Combs1-9/+12
Make sure the text we read is null terminated. Properly strip our lines and chunked strings. Copy over cast and strtod fixes from change 26347. Change-Id: I0695e35c446c1bd277c53b458b07e428cdd90fb8 Reviewed-on: https://code.wireshark.org/review/26370 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-03-06maxmind_db.c: fix a memory leakPascal Quantin1-0/+1
Change-Id: Ie3484e863363a8d2b9ccb435088886020678d15d Reviewed-on: https://code.wireshark.org/review/26284 Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Reviewed-by: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2018-03-06maxmind_db.c: add an explicit cast to please gcc 7.3.1Pascal Quantin1-1/+1
Change-Id: Idb2ae052804fb523d6769fe50b5bb4ba45e40f79 Reviewed-on: https://code.wireshark.org/review/26283 Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-03-06Transition from GeoIP Legacy to MaxMindDB.Gerald Combs1-0/+513
MaxMind is discontinuing its legacy databases in April in favor of GeoIP2, which use a newer database format (MaxMind DB). The reference C library (libmaxminddb) is available under the Apache 2.0 license which isn't quite compatible with ours. Add mmdbresolve, a utility that reads IPv4 and IPv6 addresses on stdin and prints resolved information on stdout. Place it under a liberal license (MIT) so that we can keep libmaxminddb at arm's length. Add epan/maxmind_db.[ch], which spawns mmdbresolve and communicates with it via stdio. Migrate the preferences and documentation to MaxMindDB. Change the IPv4 and IPv6 asnum fields to FT_UINT32s. Change the geographic coordinate fields to FT_DOUBLEs. Bug: 10658 Change-Id: I24aeed637bea1b41d173270bda413af230f4425f Reviewed-on: https://code.wireshark.org/review/26214 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>