Corrected a buffer overrun error in genlib.c
@@ -16,7 +16,7 @@ The output file name is chosen by using the following in priority order:
void
define_netcdf(void)
{
- char filename[2048+1];
+ char filename[2049];
/* Rule for specifying the dataset name:
1. use -o name
@@ -37,7 +37,7 @@ define_netcdf(void)
p = strrchr(filename,'.');
if(p != NULL) {*p= '\0';}
p = strrchr(filename,'/');
- if(p != NULL) {memmove(filename,(p+1),2048);}
+ if(p != NULL) {memmove(filename,(p+1),(2048-strlen(cdlname)));}
} else {/* construct name from dataset name */
strncpy(filename,datasetname,2048); /* Reserve space for extension, terminating '\0' */
