]> granicus.if.org Git - postgis/commitdiff
Fix buffer overflow and use of uninitialized value
authorSandro Santilli <strk@kbt.io>
Mon, 10 Jul 2017 17:29:03 +0000 (17:29 +0000)
committerSandro Santilli <strk@kbt.io>
Mon, 10 Jul 2017 17:29:03 +0000 (17:29 +0000)
See #3101 (for trunk)

git-svn-id: http://svn.osgeo.org/postgis/trunk@15480 b70326c6-7e19-0410-871a-916f4a2858ee

loader/pgsql2shp-core.c

index 8952c10e15e6923cc09c620aa5fdf7a1daa1b691..3e904ea3049bfc2f1a2a61e47424d4846721c090 100644 (file)
@@ -1167,6 +1167,7 @@ ShpDumperCreate(SHPDUMPERCONFIG *config)
        state->dbffieldtypes = NULL;
        state->pgfieldnames = NULL;
        state->big_endian = is_bigendian();
+       state->message[0] = '\0';
        colmap_init(&state->column_map);
 
        return state;
@@ -1557,9 +1558,9 @@ ShpDumperOpenTable(SHPDUMPERSTATE *state)
                /* Issue warning if column has been renamed */
                if (strcasecmp(dbffieldname, pgfieldname))
                {
-                       /* Note: we concatenate all warnings from the main loop as this is useful information */
                        snprintf(buf, 256, _("Warning, field %s renamed to %s\n"), pgfieldname, dbffieldname);
-                       strncat(state->message, buf, SHPDUMPERMSGLEN - strlen(state->message));
+                       /* Note: we concatenate all warnings from the main loop as this is useful information */
+                       strncat(state->message, buf, SHPDUMPERMSGLEN - strlen(state->message) - 1);
 
                        ret = SHPDUMPERWARN;
                }