X-Git-Url: https://git.octo.it/?p=rrdtool.git;a=blobdiff_plain;f=src%2Frrd_xport.c;h=ebe72aad40b28e6627d63851245cf4c84fa0daff;hp=4457b60f9478dbe13159137b3ec7b50ddd3baf0d;hb=4e8787fdbff3ddd4044e19cf37b9e3a54b5ef0cb;hpb=d85e6bdfe82fdc4d16898df43f8a5371503816ae diff --git a/src/rrd_xport.c b/src/rrd_xport.c index 4457b60..ebe72aa 100644 --- a/src/rrd_xport.c +++ b/src/rrd_xport.c @@ -308,10 +308,9 @@ int rrd_xport_fn( *step_list_ptr = im->gdes[im->gdes[i].vidx].step; /* printf("%s:%lu\n",im->gdes[i].legend,*step_list_ptr); */ step_list_ptr++; + /* reserve room for one legend entry */ - /* is FMT_LEG_LEN + 5 the correct size? */ - if ((legend_list[j] = - (char*)malloc(sizeof(char) * (FMT_LEG_LEN + 5))) == NULL) { + if ((legend_list[j] = strdup(im->gdes[i].legend)) == NULL) { free(ref_list); *data = NULL; while (--j > -1) @@ -322,11 +321,9 @@ int rrd_xport_fn( return (-1); } - if (im->gdes[i].legend) - /* omit bounds check, should have the same size */ - strcpy(legend_list[j++], im->gdes[i].legend); - else - legend_list[j++][0] = '\0'; + if (im->gdes[i].legend == 0) + legend_list[j][0] = '\0'; + ++j; } } *step_list_ptr=0; @@ -382,6 +379,18 @@ int rrd_graph_xport(image_desc_t *im) { rrd_value_t *data=NULL; /* initialize buffer */ stringbuffer_t buffer={0,0,NULL,NULL}; + + /* check if we have a supported ggraph format */ + switch (im->graph_type) { + /* allow the following to pass */ + case GTYPE_TIME: + case GTYPE_XY: + break; + default: + rrd_set_error("Not supported graph type"); + return -1; + } + /* if we write a file, then open it */ if (strlen(im->graphfile)) { buffer.file=fopen(im->graphfile,"w");