From: Sandro Santilli Date: Mon, 10 Jul 2017 17:51:13 +0000 (+0000) Subject: Check return from an sprintf X-Git-Tag: 2.4.0alpha~42 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fa676369718036e71f059ff0bc74231231515430;p=postgis Check return from an sprintf Would be dangerous with field names > 256 characters.. git-svn-id: http://svn.osgeo.org/postgis/trunk@15481 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/loader/pgsql2shp-core.c b/loader/pgsql2shp-core.c index 3e904ea30..b0774de7e 100644 --- a/loader/pgsql2shp-core.c +++ b/loader/pgsql2shp-core.c @@ -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);