Addressed Coverity issues 711911, 1102823

This commit is contained in:
Ward Fisher 2013-10-07 16:25:30 -06:00
parent 8b368d0c3b
commit 23cf133b39
2 changed files with 7 additions and 4 deletions

View File

@ -2626,9 +2626,12 @@ nc4_rec_write_metadata(NC_GRP_INFO_T *grp, int bad_coord_order)
done:
if(oldfullname) free(oldfullname);
if(newfullname) free(newfullname);
if(retval) return retval;
if(retval) {
if(tmp)
grp->name = tmp;
return retval;
}
}
/* If there are any child groups, write their metadata. */
for (child_grp = grp->children; child_grp; child_grp = child_grp->next)
if ((retval = nc4_rec_write_metadata(child_grp, bad_coord_order)))

View File

@ -27,7 +27,7 @@ define_netcdf(void)
file name, but oh well.
*/
if(netcdf_name) { /* -o flag name */
strcpy(filename,netcdf_name);
strncpy(filename,netcdf_name,2048);
} else { /* construct a usable output file name */
if (cdlname != NULL && strcmp(cdlname,"-") != 0) {/* cmd line name */
char* p;
@ -41,7 +41,7 @@ define_netcdf(void)
strncpy(filename,datasetname,2048); /* Reserve space for extension, terminating '\0' */
}
/* Append the proper extension */
strcat(filename,binary_ext);
strncat(filename,binary_ext,2048-(strlen(filename) + strlen(binary_ext)));
}
/* Execute exactly one of these */