]> granicus.if.org Git - postgis/commitdiff
Check return from an sprintf
authorSandro Santilli <strk@kbt.io>
Mon, 10 Jul 2017 17:51:13 +0000 (17:51 +0000)
committerSandro Santilli <strk@kbt.io>
Mon, 10 Jul 2017 17:51:13 +0000 (17:51 +0000)
Would be dangerous with field names > 256 characters..

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

loader/pgsql2shp-core.c

index 3e904ea3049bfc2f1a2a61e47424d4846721c090..b0774de7e0494db097560e74f49ce4e49668e703 100644 (file)
@@ -1558,7 +1558,11 @@ ShpDumperOpenTable(SHPDUMPERSTATE *state)
                /* Issue warning if column has been renamed */
                if (strcasecmp(dbffieldname, pgfieldname))
                {
-                       snprintf(buf, 256, _("Warning, field %s renamed to %s\n"), pgfieldname, dbffieldname);
+                       if ( snprintf(buf, 256, _("Warning, field %s renamed to %s\n"),
+                                                        pgfieldname, dbffieldname) >= 256 )
+                       {
+                               buf[255] = '\0';
+                       }
                        /* Note: we concatenate all warnings from the main loop as this is useful information */
                        strncat(state->message, buf, SHPDUMPERMSGLEN - strlen(state->message) - 1);