From: Marek Schimara Date: Thu, 16 Jun 2016 13:35:22 +0000 (+0200) Subject: src/rrd_graph_helper.c: fix Coverity CID#26523 Buffer not null terminated X-Git-Tag: v1.7.0~42^2~29 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=17c1a3e75eaf0bf05c95f134d5c4d7dfe6c6d0b1;p=thirdparty%2Frrdtool-1.x.git src/rrd_graph_helper.c: fix Coverity CID#26523 Buffer not null terminated CWE-170 / https://cwe.mitre.org/data/definitions/170.html --- diff --git a/src/rrd_graph_helper.c b/src/rrd_graph_helper.c index 422839f3..0f518eec 100644 --- a/src/rrd_graph_helper.c +++ b/src/rrd_graph_helper.c @@ -783,9 +783,18 @@ static graph_desc_t* newGraphDescription(image_desc_t *const im,enum gf_en gf,pa } /* and assign it */ - if (vname) { strncpy(gdp->vname,vname,MAX_VNAME_LEN + 1);} - if (rrd) { strncpy(gdp->rrd,rrd,1024); } - if (ds) { strncpy(gdp->ds_nam,ds,DS_NAM_SIZE); } + if (vname) { + strncpy(gdp->vname,vname,MAX_VNAME_LEN); + gdp->vname[MAX_VNAME_LEN] = '\0'; + } + if (rrd) { + strncpy(gdp->rrd,rrd, 1023); + gdp->rrd[1023] = '\0'; + } + if (ds) { + strncpy(gdp->ds_nam,ds,DS_NAM_SIZE - 1); + gdp->ds_nam[DS_NAM_SIZE - 1] = '\0'; + } if (cf) { gdp->cf=cf_conv(cf); if (((int)gdp->cf)==-1) {