Merge pull request #729 from mingwandroid/master

Fix buffer overrun in tabs[MAX_NESTS] by adding space for \0 terminator
This commit is contained in:
Ward Fisher 2017-12-21 13:05:41 -07:00 committed by GitHub
commit 1cdafd2201
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1857,14 +1857,15 @@ rec_print_metadata(NC_GRP_INFO_T *grp, int tab_count)
NC_DIM_INFO_T *dim;
NC_TYPE_INFO_T *type;
NC_FIELD_INFO_T *field;
char tabs[MAX_NESTS] = "";
char tabs[MAX_NESTS+1] = "";
char *dims_string = NULL;
char temp_string[10];
int t, retval, d, i;
/* Come up with a number of tabs relative to the group. */
for (t = 0; t < tab_count && t < MAX_NESTS; t++)
strcat(tabs, "\t");
tabs[t] = '\t';
tabs[t] = '\0';
LOG((2, "%s GROUP - %s nc_grpid: %d nvars: %d natts: %d",
tabs, grp->name, grp->nc_grpid, grp->nvars, grp->natts));