From trac_fdo at osgeo.org Mon Nov 2 03:47:21 2026 From: trac_fdo at osgeo.org (FDO) Date: Mon, 02 Nov 2026 11:47:21 -0000 Subject: [Fdo-trac] [fdo-trac] #1024: Queries with coalesced geometries fails Message-ID: <036.d41f5c5bffb652fba20f9c8bc0957f56@osgeo.org> #1024: Queries with coalesced geometries fails -----------------------------------+---------------------- Reporter: jng | Owner: jng Type: defect | Status: assigned Priority: major | Milestone: 4.2.0 Component: PostgreSQL Provider | Version: Severity: 3 | Keywords: External ID: | -----------------------------------+---------------------- Copy from https://trac.osgeo.org/mapguide/ticket/2841 The cause is at the PostgreSQL provider level. Root cause A PostGIS view that merges two geometry types (COALESCE(pt, ln) AS geom) loses its geometry typmod, so geometry_columns reports the column as srid 0 / GEOMETRY even though every row still carries a real SRID: {{{ f_table_name f_geometry_column srid type v_ticket2841 geom 0 GEOMETRY <- COALESCE view v_ticket2841_lines geom 25832 LINESTRING <- "l.line AS geom" view rows in v_ticket2841: ST_SRID(geom) = 25832 (POINT and LINESTRING) }}} The provider takes the spatial filter's SRID from that metadata and binds the filter geometry with it: FdoRdbmsPostGisFilterProcessor.cpp:199 starts at srid = -1 and fills it from geomCol->GetSRID() (:207), which is -1 when geometry_columns.srid is 0 (ColumnGeom.cpp:84, fed by the geometry_columns query at SpatialContextReader.cpp:255). That SRID travels with the bind value (:271); Geometry.c:317 only sets the EWKB SRID flag when srid > 0, so the filter geometry arrives at the server as SRID 0. The generated SQL is ("geom" && $1::geometry AND _ST_Intersects("geom",$1::geometry)), and PostGIS rejects the exact predicate: {{{ ERROR: ST_Intersects: Operation on mixed SRID geometries (Point, 25832) != (Polygon, 0) }}} -- Ticket URL: FDO Feature Data Objects From trac_fdo at osgeo.org Mon Nov 2 03:52:08 2026 From: trac_fdo at osgeo.org (FDO) Date: Mon, 02 Nov 2026 11:52:08 -0000 Subject: [Fdo-trac] [fdo-trac] #1024: Queries with coalesced geometries fails In-Reply-To: <036.d41f5c5bffb652fba20f9c8bc0957f56@osgeo.org> References: <036.d41f5c5bffb652fba20f9c8bc0957f56@osgeo.org> Message-ID: <051.2dee1e54cf6d2ff14f4b1d7f87f4ac13@osgeo.org> #1024: Queries with coalesced geometries fails ---------------------------------+---------------------- Reporter: jng | Owner: jng Type: defect | Status: closed Priority: major | Milestone: 4.2.0 Component: PostgreSQL Provider | Version: Severity: 3 | Resolution: fixed Keywords: | External ID: ---------------------------------+---------------------- Changes (by jng): * resolution: => fixed * status: assigned => closed Comment: In [changeset:"8431" 8431]: {{{#!CommitTicketReference repository="" revision="8431" PostgreSQL provider: spatial filters on a geometry column whose SRID is unknown geometry_columns does not describe a geometry column that carries no typmod: a column declared as bare "geometry", and every view over an expression - COALESCE(point, line) being the natural way to merge two geometry types into one column - is reported there as SRID 0, while the rows it returns keep the SRID they were written with. FdoRdbmsPostGisFilterProcessor::ProcessSpatialDistanceCondition took the spatial filter's SRID from that metadata (FdoSmPhPostGisColumnGeom::GetSRID() reports it as -1), so the exact predicate compared an SRID-0 literal with a row carrying a real SRID: "geom" && $1::geometry AND _ST_Intersects("geom", $1::geometry) PostGIS rejects that comparison - "ST_Intersects: Operation on mixed SRID geometries (Point, 4326) != (Polygon, 0)" - as soon as the bounding boxes overlap, so the whole select fails. The rejection comes from the first FETCH rather than from Execute, so a caller that is already streaming the result set sees an empty result instead of an error; MapGuide's SELECTFEATURES over such a view returned no features for either geometry type, which is what MapGuide ticket 2841 reports (https://trac.osgeo.org/mapguide/ticket/2841). A view that selects one geometry column directly is unaffected, because a plain column reference keeps the typmod - which is why the report looked like a schema-cache problem. When the column's SRID is unknown, the exact spatial predicate - and ST_Distance() in the distance filter, which takes the same bind and applies the same check - now compare by coordinate: the column operand is wrapped in ST_SetSRID(...,0) so both operands carry the same unknown SRID. The && pre-filter deliberately stays on the raw column, because it ignores SRIDs and needs the cached envelope, so the spatial index still prunes; columns with a known SRID keep the SQL they had. Tests: * PostGisFdoSelectTest::TestSpatialFilterWithoutColumnSrid covers a COALESCE view over point and line columns, a bare geometry column holding SRID-4326 rows, and a typmod-preserving view as the control case. The filtered view must return both geometry types, and every advertised spatial predicate plus ST_Distance must keep working. Without the change it fails with the mixed-SRID error above. Verified on ubuntu22 amd64 against the dbs/docker-compose.yml postgis_pg16 fixture (PostGIS 3.4), Debug (ASan/LSan) and Release, through UnitTestPostGis initfiletest=...: * FdoSelectTest with the provider unfixed: Run: 25, Failure total: 1, that failure being TestSpatialFilterWithoutColumnSrid; OK (25) with the change. * UnitTestPostGis whole suite: OK (141) in both configurations, 140 tests before this change, and no LeakSanitizer report in the Debug run. Fixes #1024 }}} -- Ticket URL: FDO Feature Data Objects From trac_fdo at osgeo.org Wed Nov 4 02:46:34 2026 From: trac_fdo at osgeo.org (FDO) Date: Wed, 04 Nov 2026 10:46:34 -0000 Subject: [Fdo-trac] [fdo-trac] #1025: Make FDO install relocatable Message-ID: <036.7ea4ecb016075d8403edeec0fa32cf74@osgeo.org> #1025: Make FDO install relocatable ----------------------------+---------------------- Reporter: jng | Owner: jng Type: enhancement | Status: assigned Priority: major | Milestone: 4.2.0 Component: Build System | Version: Severity: 3 | Keywords: External ID: | ----------------------------+---------------------- FDO currently "installs" to /usr/local/fdo-4.2.0 However, under some scenarios we would like to relocate the libs from this location and have the relocated libs still work. -- Ticket URL: FDO Feature Data Objects From trac_fdo at osgeo.org Wed Nov 4 04:46:19 2026 From: trac_fdo at osgeo.org (FDO) Date: Wed, 04 Nov 2026 12:46:19 -0000 Subject: [Fdo-trac] [fdo-trac] #1025: Make FDO install relocatable In-Reply-To: <036.7ea4ecb016075d8403edeec0fa32cf74@osgeo.org> References: <036.7ea4ecb016075d8403edeec0fa32cf74@osgeo.org> Message-ID: <051.d4d81efb98f493ff1e62c2db91cc5258@osgeo.org> #1025: Make FDO install relocatable --------------------------+---------------------- Reporter: jng | Owner: jng Type: enhancement | Status: closed Priority: major | Milestone: 4.2.0 Component: Build System | Version: Severity: 3 | Resolution: fixed Keywords: | External ID: --------------------------+---------------------- Changes (by jng): * resolution: => fixed * status: assigned => closed Comment: In [changeset:"8434" 8434]: {{{#!CommitTicketReference repository="" revision="8434" Improve relocatability of FDO libs on Linux by improving providers.xml detection without needing FDOHOME. Fixes #1025 }}} -- Ticket URL: FDO Feature Data Objects From trac_fdo at osgeo.org Fri Nov 13 06:22:21 2026 From: trac_fdo at osgeo.org (FDO) Date: Fri, 13 Nov 2026 14:22:21 -0000 Subject: [Fdo-trac] [fdo-trac] #1026: Securty hardening sweep Message-ID: <036.5a9c78c2c3a4af472909d084e118417d@osgeo.org> #1026: Securty hardening sweep -----------------------+---------------------- Reporter: jng | Owner: jng Type: task | Status: assigned Priority: major | Milestone: 4.2.0 Component: FDO API | Version: Severity: 3 | Keywords: External ID: | -----------------------+---------------------- Let DeepSeek do a security vulnerability analysis and see what it finds -- Ticket URL: FDO Feature Data Objects From trac_fdo at osgeo.org Fri Nov 13 06:22:36 2026 From: trac_fdo at osgeo.org (FDO) Date: Fri, 13 Nov 2026 14:22:36 -0000 Subject: [Fdo-trac] [fdo-trac] #1026: Security hardening sweep (was: Securty hardening sweep) In-Reply-To: <036.5a9c78c2c3a4af472909d084e118417d@osgeo.org> References: <036.5a9c78c2c3a4af472909d084e118417d@osgeo.org> Message-ID: <051.bb779222c0e4a0f3993ddec0fcc9213c@osgeo.org> #1026: Security hardening sweep ---------------------+------------------------ Reporter: jng | Owner: jng Type: task | Status: assigned Priority: major | Milestone: 4.2.0 Component: FDO API | Version: Severity: 3 | Resolution: Keywords: | External ID: ---------------------+------------------------ Changes (by jng): * summary: Securty hardening sweep => Security hardening sweep -- Ticket URL: FDO Feature Data Objects From trac_fdo at osgeo.org Fri Nov 13 06:51:51 2026 From: trac_fdo at osgeo.org (FDO) Date: Fri, 13 Nov 2026 14:51:51 -0000 Subject: [Fdo-trac] [fdo-trac] #1026: Security hardening sweep In-Reply-To: <036.5a9c78c2c3a4af472909d084e118417d@osgeo.org> References: <036.5a9c78c2c3a4af472909d084e118417d@osgeo.org> Message-ID: <051.03afba693e428646f1b9bc8f51dd45ad@osgeo.org> #1026: Security hardening sweep ---------------------+---------------------- Reporter: jng | Owner: jng Type: task | Status: closed Priority: major | Milestone: 4.2.0 Component: FDO API | Version: Severity: 3 | Resolution: fixed Keywords: | External ID: ---------------------+---------------------- Changes (by jng): * resolution: => fixed * status: assigned => closed Comment: In [changeset:"8437" 8437]: {{{#!CommitTicketReference repository="" revision="8437" #1026: Fix the buffer overflows and input-validation gaps a security sweep found A code-reading sweep of FDO - core, utilities and every provider that builds on Linux, the vendored SQLite 3.3.13 included, and nothing else from Thirdparty - turned up 48 places where a value from an untrusted boundary reaches a sink unchecked. This is the fix for all of them. None of the changes moves the provider-facing ABI: no shipped class gains, loses or reorders a member, so the surface the SDK installs keeps its shape. Parsers (filter/expression lexer, WKT lexer, constraint lexer) FdoLex::getword() documented its maxCharacters parameter and then ignored it, copying the token into the caller's 4000-wchar stack buffer with no bound. A filter is client text - MapGuide's SELECTFEATURES passes the FILTER parameter straight to FdoFilter::Parse() - so a long enough identifier wrote past that buffer. getword() now refuses a token that does not fit (PARSE_5_STRINGTOOLONG), getdigits() takes an end pointer so a caller that has already written a sign or a radix character is bounded correctly, and the dotted-name and quoted-identifier paths append through AppendIdentifierPart(), which checks the capacity before concatenating: a name like a.a.a..., assembled from several tokens into the same buffer, could otherwise grow past it however each individual part was bounded. The heap buffer those paths take from get_string() is owned by a scope guard now, so a rejected token cannot leak it, and get_string() clears the caller's pointer when it frees the buffer itself - the callers' own error branch was a double free as soon as it became reachable. The same treatment is applied to the WKT lexer in Geometry/Parse/LexFgft.cpp, which had the unbounded copy against a 256-wchar buffer (FDO_27_BUFFERLENGTHERROR there), and to the constraint lexer in Utilities/Common/Src/Parse/Lex.cpp. Its bit and hex string literals are sized from the declared length and the length is tested before the store; the test came after it, so an over-long literal was written first and rejected second. XML reader FdoXmlReader is FDO's only Xerces construction site, and it resolved external general entities. The external-DTD switches it did set (fgXercesLoadExternalDTD, and the schema and doctype flags) only cover the external subset: a document that declares in its own internal subset is well formed, and everything FDO parses - a capabilities document, a schema, a spatial context file - can be remote. The reader sets fgXercesDisableDefaultEntityResolution now, which rejects such a document. The flag was chosen after reproducing the entity resolution against a real Xerces build: with the flags the code already had, an entity pointing at /etc/hostname came back as that file's contents. Geometry The FGF and WKB parsers read counts out of the stream and used them to size arrays and bound copies. Fgf/Util.cpp rejects a negative curve-segment position count and validates the accumulated ordinate count in 64 bits against the bytes that are left; Fgf/MultiPoint.cpp does the same for numDims*numPositions instead of letting the product wrap; Fgf/LineString.cpp checks the declared position count against the remaining stream before handing the array to callers; Fgf/GeometryFactory.cpp gained CheckWkbLength() and ReadWkbCount(), so no WKB branch reads a count or copies ordinates past the end. CoordinateGroup::invertAxis() swaps whole coordinates only, and SpatialGeometryConverter's 4-entry ordinate table is bounds checked (FDO_17_UNSUPPORTEDDIMENSIONALITY) because the index comes from an FGF header. Common and the expression engine FdoStringP::IsNumber() copied the string into a 1000-byte buffer with strcpy, with the length test that guarded it commented out; it scans the string in place now. FileStream's wide-to-narrow mode buffer was sized from the file name rather than from the mode, and both conversions are snprintf. TOSTRING and TODATE wrote past their fixed 500-entry format arrays, the latter's token counter also being reused across calls without being reset; both refuse a format specification that needs more than 500 tokens. RDBMS providers: SQL injection through a filter A function's name reached the generated SQL verbatim - ProcessFunctionName() appended expr.GetName() - and the filter grammar takes that name from an identifier, which may be delimited, so "x) OR 1=1 #"(1) = 1 was emitted as SQL. FdoRdbmsFilterProcessor validates the name first (ValidateSqlFunctionName()), which the SQL Server Spatial and PostGIS processors call as well, and an aggregate's first string argument is emitted as a bare keyword only when it is ALL or DISTINCT - anything else goes through ProcessStringValue() as a quoted literal. MySQL and MariaDB also treat a backslash as escaping the closing quote, so the MySQL processor escapes backslashes before the quote is doubled. A datastore name reached CREATE DATABASE and DROP DATABASE unescaped. It is delimited as a MySQL identifier with any embedded backtick doubled, from the raw owner name: GetDbName() is already ANSI-quoted by GetSQLObjectName(), so nesting it inside backticks would make the quotes part of the database name instead of delimiters. The metadata reader that looks a schema up by datastore name escapes it with the provider's own FormatSQLVal() rather than quoting it inline, and FdoRdbmsPropBindHelper's memset() had its arguments in the wrong order, which only worked because the struct happened to be value- initialised. The legacy King providers had no validation at all: filter identifiers, function names, ORDER BY identifiers and ApplySchema's table and column names are concatenated into SQL text. They go through KgOraIsSqlIdentifier() now, which accepts a plain identifier, a dotted one, or the same with each part double-quoted and holding no quote of its own. File providers SDF: a string's own length field was used as an allocation size and a read length with no bound against the record (SDFPROVIDER_110), and a property's offset and end offset from the record header became a read position and a length with no check either - positioning is PositionAtValue() now, SDFPROVIDER_111. The fixed-width readers compared m_pos against m_len - sizeof(T) in unsigned arithmetic, which underflows for a record shorter than the field, so a short record passed the test. The R-tree checked its record size with an assert that release builds compile out (CheckBlobSize() throws now), and the compare handler read one offset past its array and used the result as a length - the array has a slot for the record size now. SHP: the shape objects overlay the record buffer and trust the part and point counts read out of it, and a MultiPatch record additionally needs room for the part-type array the overlay injects, which the buffer did not have. ValidateShapeRecord() checks each shape type's declared counts and its part indices against the record before the shape object is built, and the read buffer takes the extra part-type room. The DBF side rejects a column layout that does not fit the record, copies a field out of the record before zero-terminating it, bounds the width-driven sprintf in SetData(), and checks the whitespace trim's bound before dereferencing it. SQLite: AppendSQuoted() and AppendDQuoted() wrapped a value in quotes without escaping it, and their output goes to sqlite3_exec(), so an embedded quote ended the literal; AppendQuoted() doubles it. Wkb2Fgf() and Fgf2Wkb() took neither the input length nor the output capacity; both do now and return 0 for a geometry that is malformed or does not fit. GetFgfExtents() ignored the length it was given and now stops at the end of the stream instead of walking the buffer. SQLiteTable::Drop() formatted the table name into char[128]. The vendored SQLite 3.3.13 had its page-size validation removed so that it could use a 51200-byte page, which is not a power of two: the page size taken from the file then sized the page structure and every cell offset read from it, while the pager allocated each page with its own size. lockBtree() requires the file's page size to match the pager's (the new sqlite3pager_pagesize()) and to be a multiple of 8, and findCell() range checks the stored cell offset instead of masking it, which cannot work for a page size that is not a power of two. Transport (WMS and WFS) TLS peer verification was disabled for every request, credentials followed redirects to any host, and the endpoint a remote capabilities document advertises was fetched as given - as was an absolute schemaLocation in a DescribeFeatureType response. Verification is on now (FDO_OWS_INSECURE_TLS=1 is the opt-out for a self-signed endpoint), CURLOPT_UNRESTRICTED_AUTH is off, and FdoOwsDelegate::IsSameOrigin() confines both the advertised endpoint and the schema imports to the origin the connection was configured for. Other providers OGR built two statements with sprintf() into char[512] from caller- supplied names, and the GDAL provider's string-conversion macros allocate their buffer on the stack from the input length; the first two are std::string now and the macros refuse an input longer than FDORFP_MAX_CONVERSION_LENGTH (GRFP_115). The ArcSDE connection copied its connection properties into fixed members with sde_strcpy() and no bound; they go through CacheConnectionProperty() (ARCSDE_CONNECTION_PROPERTY_TOO_LONG). Tests Three cases cover the safeguards, and each of them fails without its change: * XmlTest::testExternalEntityNotResolved - a document whose internal subset declares an external general entity is rejected by FdoXmlReader. Without the reader change the entity is resolved and the referenced file's contents appear in the parsed content. * FilterParseTest::testLongTokens - a quoted identifier one character short of the lexer's 4000-character buffer still parses; an identifier, quoted identifier, dotted name or string literal past it is refused rather than overflowing. * CommonTest::testStringBoundaries - IsNumber() on a 3000-character number and on the same with a trailing non-digit, plus the length-related conversions on a 2000-character string. Adding them turned up three defects in the harness, fixed here: ParseFilter()'s message buffer was a fixed 512 bytes holding two copies of the filter; the lexer's string reader freed its buffer without clearing the caller's pointer, a double free once a rejected token made the caller's cleanup reachable; and the SQLite provider escaped a string DEFAULT value itself as well as through the quoting helper, so it was stored double- escaped. Verified on ubuntu22 amd64 against the dbs/docker-compose.yml fixtures, Debug (ASan/LSan) and Release, each suite run from its build directory with LC_CTYPE and NLSPATH set as run_fdo_tests.sh does, and the SHP TestData reset from the sources: * FDO Core OK (133), SDF OK (122), SQLite OK (96), OGR OK (58), SHP OK (138) and MySQL OK (249) in both configurations, with no LeakSanitizer record of either kind in the Debug run. * The run_fdo_tests.sh run in Debug is green for the rest as well: GDAL OK (68), Oracle OK (42), PostGIS OK (141), SQL Server Spatial OK (290), ODBC SQL Server OK (87) and ODBC Access OK (35), none of them with a leak record either. Fixes #1026 }}} -- Ticket URL: FDO Feature Data Objects