[geos-commits] [SCM] GEOS branch main updated. ab8e9c9a6059b407644e041dd739459631856514
git at osgeo.org
git at osgeo.org
Mon Jun 22 17:52:00 PDT 2026
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GEOS".
The branch, main has been updated
via ab8e9c9a6059b407644e041dd739459631856514 (commit)
from b7e11f5710ace681562228b791651bbc28835986 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit ab8e9c9a6059b407644e041dd739459631856514
Author: Arthur Chan <arthur.chan at adalogics.com>
Date: Tue Jun 23 01:51:39 2026 +0100
OSS-Fuzz: Move fuzzers upstream (#1447)
Signed-off-by: Arthur Chan <arthur.chan at adalogics.com>
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 3401775c8..70af383b4 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -10,3 +10,4 @@
################################################################################
add_subdirectory(unit)
add_subdirectory(xmltester)
+add_subdirectory(fuzz)
diff --git a/tests/CMakeLists.txt b/tests/fuzz/CMakeLists.txt
similarity index 50%
copy from tests/CMakeLists.txt
copy to tests/fuzz/CMakeLists.txt
index 3401775c8..d8868ed88 100644
--- a/tests/CMakeLists.txt
+++ b/tests/fuzz/CMakeLists.txt
@@ -8,5 +8,12 @@
# by the Free Software Foundation.
# See the COPYING file for more information.
################################################################################
-add_subdirectory(unit)
-add_subdirectory(xmltester)
+if(DEFINED ENV{LIB_FUZZING_ENGINE})
+ add_executable(fuzz_geo2 fuzz_geo2.c)
+ target_include_directories(fuzz_geo2 PUBLIC $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>)
+ target_link_libraries(fuzz_geo2 geos_c $ENV{LIB_FUZZING_ENGINE})
+
+ add_executable(fuzz_geojson fuzz_geojson.c)
+ target_include_directories(fuzz_geojson PUBLIC $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>)
+ target_link_libraries(fuzz_geojson geos_c $ENV{LIB_FUZZING_ENGINE})
+endif()
diff --git a/tests/fuzz/fuzz_geo2.c b/tests/fuzz/fuzz_geo2.c
new file mode 100644
index 000000000..ceee7ea6b
--- /dev/null
+++ b/tests/fuzz/fuzz_geo2.c
@@ -0,0 +1,69 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <stdarg.h>
+#include <string.h>
+
+#include "geos_c.h"
+
+static int initialized = 0;
+FILE * flogOut;
+
+void
+notice(const char *fmt, ...) {
+ va_list ap;
+ fprintf( flogOut, "NOTICE: ");
+ va_start (ap, fmt);
+ vfprintf( flogOut, fmt, ap);
+ va_end(ap);
+ fprintf( flogOut, "\n" );
+}
+
+void
+log_and_exit(const char *fmt, ...) {
+ va_list ap;
+ fprintf( flogOut, "ERROR: ");
+ va_start (ap, fmt);
+ vfprintf( flogOut, fmt, ap);
+ va_end(ap);
+ fprintf( flogOut, "\n" );
+}
+
+int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+ if (initialized == 0) {
+ flogOut = fopen("/dev/null", "wb");
+ initGEOS(notice, log_and_exit);
+ initialized = 1;
+ }
+ size_t sep;
+ for (sep = 0; sep < Size; sep ++) {
+ if (Data[sep] == 0) {
+ break;
+ }
+ }
+ if (sep == Size) {
+ return 0;
+ }
+ GEOSGeometry *g1 = GEOSGeomFromWKT(Data);
+
+ if (g1 != NULL) {
+ GEOSGeometry *g2 = GEOSGeomFromWKB_buf(Data+sep, Size-sep);
+ if (g2 != NULL) {
+ size_t usize;
+ GEOSGeometry *g3 = GEOSIntersection(g1, g2);
+ GEOSGeom_destroy(g3);
+ g3 = GEOSDifference(g1, g2);
+ GEOSGeom_destroy(g3);
+ g3 = GEOSUnion(g1, g2);
+ GEOSGeom_destroy(g3);
+ unsigned char* uptr = GEOSGeomToWKB_buf(g1, &usize);
+ free(uptr);
+ GEOSGeom_destroy(g2);
+ }
+ char * r = GEOSGeomToWKT(g1);
+ free(r);
+ GEOSGeom_destroy(g1);
+ }
+ return 0;
+}
+
diff --git a/tests/fuzz/fuzz_geojson.c b/tests/fuzz/fuzz_geojson.c
new file mode 100644
index 000000000..bbdcc6bfd
--- /dev/null
+++ b/tests/fuzz/fuzz_geojson.c
@@ -0,0 +1,57 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <stdarg.h>
+#include <string.h>
+
+#include "geos_c.h"
+
+static int initialized = 0;
+FILE * flogOut;
+
+void
+notice(const char *fmt, ...) {
+ va_list ap;
+ fprintf( flogOut, "NOTICE: ");
+ va_start (ap, fmt);
+ vfprintf( flogOut, fmt, ap);
+ va_end(ap);
+ fprintf( flogOut, "\n" );
+}
+
+void
+log_and_exit(const char *fmt, ...) {
+ va_list ap;
+ fprintf( flogOut, "ERROR: ");
+ va_start (ap, fmt);
+ vfprintf( flogOut, fmt, ap);
+ va_end(ap);
+ fprintf( flogOut, "\n" );
+}
+
+int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
+ if (initialized == 0) {
+ flogOut = fopen("/dev/null", "wb");
+ initGEOS(notice, log_and_exit);
+ initialized = 1;
+ }
+
+ char *json = (char *) malloc(Size + 1);
+ if (json == NULL) {
+ return 0;
+ }
+ memcpy(json, Data, Size);
+ json[Size] = '\0';
+
+ GEOSGeoJSONReader *reader = GEOSGeoJSONReader_create();
+ if (reader != NULL) {
+ GEOSGeometry *g = GEOSGeoJSONReader_readGeometry(reader, json);
+ if (g != NULL) {
+ GEOSGeom_destroy(g);
+ }
+ GEOSGeoJSONReader_destroy(reader);
+ }
+
+ free(json);
+ return 0;
+}
diff --git a/tests/fuzz/geojson.dict b/tests/fuzz/geojson.dict
new file mode 100644
index 000000000..14d2ee89b
--- /dev/null
+++ b/tests/fuzz/geojson.dict
@@ -0,0 +1,38 @@
+# GeoJSON tokens for fuzz_geojson (see geos::io::GeoJSONReader)
+# Object keys
+"type"
+"coordinates"
+"geometry"
+"geometries"
+"features"
+"properties"
+# Geometry / object type values
+"Point"
+"LineString"
+"Polygon"
+"MultiPoint"
+"MultiLineString"
+"MultiPolygon"
+"GeometryCollection"
+"Feature"
+"FeatureCollection"
+# Common key/value fragments
+"\"type\":"
+"\"coordinates\":"
+"\"geometry\":"
+"\"properties\":"
+"\"features\":"
+"\"geometries\":"
+# Structural / literal tokens
+"{"
+"}"
+"["
+"]"
+":"
+","
+"true"
+"false"
+"null"
+"0.0"
+"1.0"
+"1e10"
diff --git a/tests/fuzz/geojson_seed_corpus/feature.json b/tests/fuzz/geojson_seed_corpus/feature.json
new file mode 100644
index 000000000..0ead4f4eb
--- /dev/null
+++ b/tests/fuzz/geojson_seed_corpus/feature.json
@@ -0,0 +1 @@
+{"type":"Feature","geometry":{"type":"Point","coordinates":[100.0,0.0]},"properties":{"name":"x","n":1,"b":true,"nil":null}}
\ No newline at end of file
diff --git a/tests/fuzz/geojson_seed_corpus/featurecollection.json b/tests/fuzz/geojson_seed_corpus/featurecollection.json
new file mode 100644
index 000000000..9913dd38f
--- /dev/null
+++ b/tests/fuzz/geojson_seed_corpus/featurecollection.json
@@ -0,0 +1 @@
+{"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"Point","coordinates":[100.0,0.0]},"properties":{}},{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[100.0,0.0],[101.0,0.0],[101.0,1.0],[100.0,0.0]]]},"properties":{"k":"v"}}]}
\ No newline at end of file
diff --git a/tests/fuzz/geojson_seed_corpus/geometrycollection.json b/tests/fuzz/geojson_seed_corpus/geometrycollection.json
new file mode 100644
index 000000000..0c78938cd
--- /dev/null
+++ b/tests/fuzz/geojson_seed_corpus/geometrycollection.json
@@ -0,0 +1 @@
+{"type":"GeometryCollection","geometries":[{"type":"Point","coordinates":[100.0,0.0]},{"type":"LineString","coordinates":[[101.0,0.0],[102.0,1.0]]}]}
\ No newline at end of file
diff --git a/tests/fuzz/geojson_seed_corpus/linestring.json b/tests/fuzz/geojson_seed_corpus/linestring.json
new file mode 100644
index 000000000..4a40c6726
--- /dev/null
+++ b/tests/fuzz/geojson_seed_corpus/linestring.json
@@ -0,0 +1 @@
+{"type":"LineString","coordinates":[[100.0,0.0],[101.0,1.0]]}
\ No newline at end of file
diff --git a/tests/fuzz/geojson_seed_corpus/multilinestring.json b/tests/fuzz/geojson_seed_corpus/multilinestring.json
new file mode 100644
index 000000000..68aa13f58
--- /dev/null
+++ b/tests/fuzz/geojson_seed_corpus/multilinestring.json
@@ -0,0 +1 @@
+{"type":"MultiLineString","coordinates":[[[100.0,0.0],[101.0,1.0]],[[102.0,2.0],[103.0,3.0]]]}
\ No newline at end of file
diff --git a/tests/fuzz/geojson_seed_corpus/multipoint.json b/tests/fuzz/geojson_seed_corpus/multipoint.json
new file mode 100644
index 000000000..27c3d27de
--- /dev/null
+++ b/tests/fuzz/geojson_seed_corpus/multipoint.json
@@ -0,0 +1 @@
+{"type":"MultiPoint","coordinates":[[100.0,0.0],[101.0,1.0]]}
\ No newline at end of file
diff --git a/tests/fuzz/geojson_seed_corpus/multipolygon.json b/tests/fuzz/geojson_seed_corpus/multipolygon.json
new file mode 100644
index 000000000..afa67db9f
--- /dev/null
+++ b/tests/fuzz/geojson_seed_corpus/multipolygon.json
@@ -0,0 +1 @@
+{"type":"MultiPolygon","coordinates":[[[[102.0,2.0],[103.0,2.0],[103.0,3.0],[102.0,3.0],[102.0,2.0]]],[[[100.0,0.0],[101.0,0.0],[101.0,1.0],[100.0,1.0],[100.0,0.0]]]]}
\ No newline at end of file
diff --git a/tests/fuzz/geojson_seed_corpus/point.json b/tests/fuzz/geojson_seed_corpus/point.json
new file mode 100644
index 000000000..2756bae67
--- /dev/null
+++ b/tests/fuzz/geojson_seed_corpus/point.json
@@ -0,0 +1 @@
+{"type":"Point","coordinates":[100.0,0.0]}
\ No newline at end of file
diff --git a/tests/fuzz/geojson_seed_corpus/point_z.json b/tests/fuzz/geojson_seed_corpus/point_z.json
new file mode 100644
index 000000000..a13a91b66
--- /dev/null
+++ b/tests/fuzz/geojson_seed_corpus/point_z.json
@@ -0,0 +1 @@
+{"type":"Point","coordinates":[100.0,0.0,50.0]}
\ No newline at end of file
diff --git a/tests/fuzz/geojson_seed_corpus/polygon.json b/tests/fuzz/geojson_seed_corpus/polygon.json
new file mode 100644
index 000000000..9c573c1a3
--- /dev/null
+++ b/tests/fuzz/geojson_seed_corpus/polygon.json
@@ -0,0 +1 @@
+{"type":"Polygon","coordinates":[[[100.0,0.0],[101.0,0.0],[101.0,1.0],[100.0,1.0],[100.0,0.0]]]}
\ No newline at end of file
diff --git a/tests/fuzz/geojson_seed_corpus/polygon_hole.json b/tests/fuzz/geojson_seed_corpus/polygon_hole.json
new file mode 100644
index 000000000..11661ebf6
--- /dev/null
+++ b/tests/fuzz/geojson_seed_corpus/polygon_hole.json
@@ -0,0 +1 @@
+{"type":"Polygon","coordinates":[[[100.0,0.0],[101.0,0.0],[101.0,1.0],[100.0,1.0],[100.0,0.0]],[[100.2,0.2],[100.8,0.2],[100.8,0.8],[100.2,0.8],[100.2,0.2]]]}
\ No newline at end of file
-----------------------------------------------------------------------
Summary of changes:
tests/CMakeLists.txt | 1 +
{benchmarks/index => tests/fuzz}/CMakeLists.txt | 16 +++--
tests/fuzz/fuzz_geo2.c | 69 ++++++++++++++++++++++
tests/fuzz/fuzz_geojson.c | 57 ++++++++++++++++++
tests/fuzz/geojson.dict | 38 ++++++++++++
tests/fuzz/geojson_seed_corpus/feature.json | 1 +
.../geojson_seed_corpus/featurecollection.json | 1 +
.../geojson_seed_corpus/geometrycollection.json | 1 +
tests/fuzz/geojson_seed_corpus/linestring.json | 1 +
.../fuzz/geojson_seed_corpus/multilinestring.json | 1 +
tests/fuzz/geojson_seed_corpus/multipoint.json | 1 +
tests/fuzz/geojson_seed_corpus/multipolygon.json | 1 +
tests/fuzz/geojson_seed_corpus/point.json | 1 +
tests/fuzz/geojson_seed_corpus/point_z.json | 1 +
tests/fuzz/geojson_seed_corpus/polygon.json | 1 +
tests/fuzz/geojson_seed_corpus/polygon_hole.json | 1 +
16 files changed, 183 insertions(+), 9 deletions(-)
copy {benchmarks/index => tests/fuzz}/CMakeLists.txt (51%)
create mode 100644 tests/fuzz/fuzz_geo2.c
create mode 100644 tests/fuzz/fuzz_geojson.c
create mode 100644 tests/fuzz/geojson.dict
create mode 100644 tests/fuzz/geojson_seed_corpus/feature.json
create mode 100644 tests/fuzz/geojson_seed_corpus/featurecollection.json
create mode 100644 tests/fuzz/geojson_seed_corpus/geometrycollection.json
create mode 100644 tests/fuzz/geojson_seed_corpus/linestring.json
create mode 100644 tests/fuzz/geojson_seed_corpus/multilinestring.json
create mode 100644 tests/fuzz/geojson_seed_corpus/multipoint.json
create mode 100644 tests/fuzz/geojson_seed_corpus/multipolygon.json
create mode 100644 tests/fuzz/geojson_seed_corpus/point.json
create mode 100644 tests/fuzz/geojson_seed_corpus/point_z.json
create mode 100644 tests/fuzz/geojson_seed_corpus/polygon.json
create mode 100644 tests/fuzz/geojson_seed_corpus/polygon_hole.json
hooks/post-receive
--
GEOS
More information about the geos-commits
mailing list