[SCM] PostGIS branch stable-3.6 updated. 3.6.4-156-gb3cd6ff2c

git at osgeo.org git at osgeo.org
Sun Nov 15 01:54:57 PST 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 "PostGIS".

The branch, stable-3.6 has been updated
       via  b3cd6ff2cedb2b17b11407c64b532946bf472619 (commit)
       via  5d9f0f30edb001c8c3d94af148113fa39342aa05 (commit)
       via  536718423a3ee58564455f53e99b3c048c13525f (commit)
      from  82b51ba31c5303c600d9bb6272ed4e94c6843115 (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 b3cd6ff2cedb2b17b11407c64b532946bf472619
Author: Darafei Praliaskouski <me at komzpa.net>
Date:   Sun Nov 15 13:07:24 2026 +0400

    Correct column-list comment spelling

diff --git a/loader/shp2pgsql-core.h b/loader/shp2pgsql-core.h
index 905f92253..748d4773a 100644
--- a/loader/shp2pgsql-core.h
+++ b/loader/shp2pgsql-core.h
@@ -192,7 +192,7 @@ typedef struct shp_loader_state
 	/* Pointer to an array of PostgreSQL field types */
 	char **pgfieldtypes;
 
-	/* String containing colume name list in the form "col1, col2, col3 ... , colN" */
+	/* String containing column name list in the form "col1, col2, col3 ... , colN" */
 	char *col_names;
 
 	/* String containing the PostGIS geometry type, e.g. POINT, POLYGON etc. */

commit 5d9f0f30edb001c8c3d94af148113fa39342aa05
Author: Darafei Praliaskouski <me at komzpa.net>
Date:   Sun Nov 8 10:31:53 2026 +0400

    News entry for GH-1178

diff --git a/NEWS b/NEWS
index 6f085e24b..1923c6d5c 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,8 @@ PostGIS 3.6.5dev
 
 * Fixes *
 
+- GH-1178, Avoid NULL dereferences when column-map allocation fails and make
+  partial column-map cleanup safe (Maksim Korotkov)
 - GT-779, [raster] Make postgis.enable_outdb_rasters=off enforce offline-band
   metadata and pixel-read restrictions after upgrade
   (reported by Sarath Kumar, IITM Pravartak Security Team;

commit 536718423a3ee58564455f53e99b3c048c13525f
Author: Maksim Korotkov <m.korotkov at postgrespro.ru>
Date:   Mon Sep 7 18:06:41 2026 +0300

    loader: check column map allocations and fix cleanup
    
    Check the return of malloc/calloc in colmap_read and bail out with an
    error instead of dereferencing NULL on the pgfieldnames/dbffieldnames
    array and per-field string allocations. The column map arrays are now
    calloc'd so unused slots are NULL-initialized.
    
    Rework colmap_clean to be safe on partial state: early-return on NULL,
    free the field-name arrays unconditionally (free(NULL) is valid), and
    reset the map via colmap_init so the map is reusable and a subsequent
    ShpLoaderDestroy colmap_clean call stays safe. The calloc-failure path
    resets map->size first so the cleanup loop doesn't index a half-allocated
    array.
    
    Signed-off-by: Maksim Korotkov <m.korotkov at postgrespro.ru>
    Closes https://github.com/postgis/postgis/pull/1178 for PostGIS 3.6
    (cherry picked from commit 6a9387914570bcdcf6a4a4b4557a17a9c6abeb28)

diff --git a/loader/shpcommon.c b/loader/shpcommon.c
index a27d45dc4..0c82089f3 100644
--- a/loader/shpcommon.c
+++ b/loader/shpcommon.c
@@ -171,18 +171,21 @@ void
 colmap_clean(colmap *map)
 {
 	int i;
-	if (map != NULL){
-		if (map->size)
+	if (map == NULL)
+	{
+		return;
+	}
+	if (map->size)
+	{
+		for (i = 0; i < map->size; i++)
 		{
-			for (i = 0; i < map->size; i++)
-			{
-				if (map->pgfieldnames[i]) free(map->pgfieldnames[i]);
-				if (map->dbffieldnames[i]) free(map->dbffieldnames[i]);
-			}
-			free(map->pgfieldnames);
-			free(map->dbffieldnames);
+			free(map->pgfieldnames[i]);
+			free(map->dbffieldnames[i]);
 		}
 	}
+	free(map->pgfieldnames);
+	free(map->dbffieldnames);
+	colmap_init(map);
 }
 
 const char *
@@ -232,13 +235,30 @@ colmap_read(const char *filename, colmap *map, char *errbuf, size_t errbuflen)
     return 0;
   }
 
+  /* Release any prior contents and reset the map so this call is safe to
+   * reuse on the same struct (and so ++map->size below starts from zero) */
+  colmap_clean(map);
+
   /* First count how many columns we have... */
   while (fgets(linebuffer, 1024, fptr) != NULL) ++map->size;
 
+  if (!map->size)
+  {
+    fclose(fptr);
+    return 1;
+  }
   /* Now we know the final size, allocate the arrays and load the data */
   fseek(fptr, 0, SEEK_SET);
-  map->pgfieldnames = (char **)malloc(sizeof(char *) * map->size);
-  map->dbffieldnames = (char **)malloc(sizeof(char *) * map->size);
+  map->pgfieldnames = (char **)calloc(map->size, sizeof(char *));
+  map->dbffieldnames = (char **)calloc(map->size, sizeof(char *));
+  if (!map->pgfieldnames || !map->dbffieldnames)
+  {
+    map->size = 0;
+    colmap_clean(map);
+    fclose(fptr);
+    snprintf(errbuf, errbuflen, _("ERROR: Unable to allocate memory for column map file %s"), filename);
+    return 0;
+  }
 
   /* Read in a line at a time... */
   curmapsize = 0;
@@ -251,6 +271,13 @@ colmap_read(const char *filename, colmap *map, char *errbuf, size_t errbuflen)
 
     /* Allocate memory and copy the string ensuring it is terminated */
     map->pgfieldnames[curmapsize] = malloc(fieldnamesize + 1);
+    if (!map->pgfieldnames[curmapsize])
+    {
+      colmap_clean(map);
+      fclose(fptr);
+      snprintf(errbuf, errbuflen, _("ERROR: Unable to allocate memory for column map file %s"), filename);
+      return 0;
+    }
     strncpy(map->pgfieldnames[curmapsize], tmpstr, fieldnamesize);
     map->pgfieldnames[curmapsize][fieldnamesize] = '\0';
 
@@ -263,6 +290,13 @@ colmap_read(const char *filename, colmap *map, char *errbuf, size_t errbuflen)
 
     /* Allocate memory and copy the string ensuring it is terminated */
     map->dbffieldnames[curmapsize] = malloc(fieldnamesize + 1);
+    if (!map->dbffieldnames[curmapsize])
+    {
+      colmap_clean(map);
+      fclose(fptr);
+      snprintf(errbuf, errbuflen, _("ERROR: Unable to allocate memory for column map file %s"), filename);
+      return 0;
+    }
     strncpy(map->dbffieldnames[curmapsize], tmpstr, fieldnamesize);
     map->dbffieldnames[curmapsize][fieldnamesize] = '\0';
 

-----------------------------------------------------------------------

Summary of changes:
 NEWS                    |  2 ++
 loader/shp2pgsql-core.h |  2 +-
 loader/shpcommon.c      | 56 +++++++++++++++++++++++++++++++++++++++----------
 3 files changed, 48 insertions(+), 12 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list