Commit Graph

10 Commits

Author SHA1 Message Date
XuNiu 94d0e081c6 mmdbresolve: check the return value of malloc
The return value of malloc() is used without validation

Bug: 15851
Change-Id: I2635937d3107a75076e9bbee536797d97792683d
Reviewed-on: https://code.wireshark.org/review/33705
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-06-26 06:44:07 +00:00
Gerald Combs 276d62b639 mmdbresolve: Improve our main loop check.
Check the return value of fscanf() instead of relying on feof(). This
should help ensure that we exit correctly.

Bug: 15777
Change-Id: I8b5985f6015cb6a85378db5135b29bb2c3de1e90
Reviewed-on: https://code.wireshark.org/review/33196
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>
2019-05-15 05:28:40 +00:00
Peter Wu ba1ef0ec3d Re-implement "Map" feature for Endpoints
This feature was removed in v2.5.1rc0-427-gf529ab5d0a, anticipating that
MaxMind would remove support for it in 2019. They have however changed
their mind and maintained latitude and longitude information.

They recommend displaying an accuracy radius, but the reported values
are 50, 100, 200 and 1000km. When implemented literally, a marker in
Ireland would cover the whole island plus mainland, so I have instead
opted to use a fixed radius of 1km at deeper zoom levels.

The old ipmap.html file was outdated and had broken tiles, I rewrote a
new one from scratch using the light-weight Leaflet library combined
with tiles from OpenStreetMap. This is more mobile-friendly and secure
(https, SRI). To improve handling of nearby or overlapping nodes,
clustering is used (individual nodes can still be inspected).

Browser compatibility results: IE8 is unusable, IE9 partially works
(tooltips sometimes disappear and the cluster radius control is gone),
IE11 works. Of course Firefox 65 and Chromium 72 have no issues.

The map popup description in the generated GeoJSON structure is now
split in several properties, allowing presentation to be handled by the
HTML page instead of the C code.

Bug: 14693
Change-Id: If2ec9c518f7723ac0ab27b6272463356875a0ff2
Reviewed-on: https://code.wireshark.org/review/31952
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-02-16 21:11:12 +00:00
Gerald Combs c159d48420 maxmind: Move request processing to a thread.
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-24 04:07:44 +00:00
Guy Harris b8375119e3 Avoid the realloc() warning from VS Code Analyzer.
It's not just worrying about the lack of a check for a null return, it's
worried about the leak.  Assign the result to a different variable and,
if the result is null, free the old data before exiting, and if it's not
null, assign the new variable to the one we're using as a pointer to the
array.

Change-Id: Ia1d5d271293e13708c35a7562a1f40671304c417
Reviewed-on: https://code.wireshark.org/review/26410
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-03-10 01:52:51 +00:00
Guy Harris 190b2e89c3 entry_data.type is unsigned, so print it with %u.
This should squelch a warning from VS Code Analyzer.

Change-Id: I69e528c3dfd851d287b1faebc1469cd700fa9ef5
Reviewed-on: https://code.wireshark.org/review/26402
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-03-09 19:28:45 +00:00
Guy Harris 5a4468ccaf Check for realloc() failing.
Unlikely, but not impossible, and should squelch a VS Code Analyzer
warning.

Change-Id: I399c08896a3f08962ca46483d47ba5f6cbe4f28e
Reviewed-on: https://code.wireshark.org/review/26400
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-03-09 19:10:53 +00:00
Dario Lombardo 6c077a0818 mmdbresolve: remove leak (found by clang).
Change-Id: I7de7707d75c80bc12ec2c4a30a19f6988932b0b7
Reviewed-on: https://code.wireshark.org/review/26392
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-03-09 16:13:12 +00:00
Gerald Combs f0fb6ee50c mmdbresolve: Process our command line arguments by hand.
Visual Studio doesn't ship with a getopt implementation, so process our
arguments ourselves. Note that if we add support for more flags we'll
probably want to use GOption.

Change-Id: Ie78204aa64321ca68f3e66195b8c39e47ca410d9
Reviewed-on: https://code.wireshark.org/review/26288
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-03-06 23:31:40 +00:00
Gerald Combs a1da75c554 Transition from GeoIP Legacy to MaxMindDB.
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>
2018-03-06 18:02:21 +00:00