mirror of https://github.com/ecmwf/eccodes.git
Guard against buffer overrun
This commit is contained in:
parent
7c38b300e2
commit
148604189e
|
@ -27,7 +27,7 @@
|
|||
const char* grib_tool_description = "Convert a GRIB file to netCDF format.";
|
||||
const char* grib_tool_name = "grib_to_netcdf";
|
||||
const char* grib_tool_usage = "[options] grib_file grib_file ... ";
|
||||
static char argvString[2048];
|
||||
static char argvString[2048] = {0,};
|
||||
|
||||
/*=====================================================================*/
|
||||
|
||||
|
@ -3978,7 +3978,11 @@ int main(int argc, char *argv[])
|
|||
int i, ret = 0;
|
||||
|
||||
/* GRIB-413: Collect all program arguments into a string */
|
||||
const size_t maxLen = sizeof(argvString);
|
||||
size_t currLen = 0;
|
||||
for (i=0; i<argc; ++i) {
|
||||
currLen += strlen(argv[i]);
|
||||
if ( currLen >= maxLen-1 ) break;
|
||||
strcat(argvString, argv[i]);
|
||||
if (i != argc-1) strcat(argvString, " ");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue