From: oetiker Date: Fri, 1 Feb 2008 06:52:56 +0000 (+0000) Subject: fixed parsing of fontnames with embeded spaces X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=20d9187a98df0ba6e498c4e32e7b875da26236c6;p=rrdtool.git fixed parsing of fontnames with embeded spaces git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@1274 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/src/rrd_graph.c b/src/rrd_graph.c index 2f20623..8c11868 100644 --- a/src/rrd_graph.c +++ b/src/rrd_graph.c @@ -4066,10 +4066,10 @@ void rrd_graph_options( case 'n':{ char prop[15]; double size = 1; - char font[1024] = ""; + int end; old_locale = setlocale(LC_NUMERIC, "C"); - if (sscanf(optarg, "%10[A-Z]:%lf:%1000s", prop, &size, font) >= 2) { + if (sscanf(optarg, "%10[A-Z]:%lf%n", prop, &size, &end) >= 2) { int sindex, propidx; setlocale(LC_NUMERIC, old_locale); @@ -4079,8 +4079,17 @@ void rrd_graph_options( if (size > 0) { im->text_prop[propidx].size = size; } - if (strlen(font) > 0) { - strcpy(im->text_prop[propidx].font, font); + if (strlen(prop) > end) { + if (prop[end] == ':') { + strncpy(im->text_prop[propidx].font, + prop + end + 1, 255); + im->text_prop[propidx].font[255] = '\0'; + } else { + rrd_set_error + ("expected after font size in '%s'", + prop); + return; + } } if (propidx == sindex && sindex != 0) break;