google / earthenterprise

Google Earth Enterprise - Open Source
Apache License 2.0
2.66k stars 882 forks source link

Fusion Code does not check c++ vector size before accessing indexes #1943

Closed tst-mreinert closed 3 years ago

tst-mreinert commented 3 years ago

Description Fusion includes a function called "TokenizeString" that splits a string into a vector of tokens. There are two places in the code where this function is called and the resulting vector's size is not checked before it is accessed.

The two places where the bounds are not checked are:

JsonUtils.cpp, in the function "LookAtJson". It is assumed that "tokens" will have at least 3 elements, but this is not checked.

geaddtomapproject.cpp, when processing command line arguments in the main function. It is assumed that "tokens" will have at least 1 element, but this is not checked.

Steps To Reproduce

These bugs were found through code inspection.

geaddtomapproject.cpp

  1. genewmapproject -o testproject
  2. geaddtomapproject -o testproject "" -> segfault

JsonUtils.cpp

  1. Drop a pin in google earth and save the point to create a kml/kmz with a single point in it
  2. Create a vector resources. CAHighways from the tutorial set is fine
  3. Create a vector project
  4. Add the resource to the project. Modify the layer properties and set the look at field using the point you created in step 1
  5. Build the vector project
  6. Edit the dbroot.kva/ver001/dbrootconfig.xml file for the vector project you just built. Find the xml element look_at. Change the value from the pipe delimited value to a single integer, something like 123
  7. Restart gefusion(this step may not be necessary)
  8. Build a globe using the now corrupted vector project
  9. Run geserveradmin --adddb and --pushdb for the globe you just built
  10. Run geserveradmin --publishdb for the globe you just built. This step will fail with a no status returned message
  11. Inspect the log file at /opt/google/gehttpd/logs/error_log to see the seg fault message