From: Tobias Oetiker Date: Mon, 20 Apr 2015 21:49:49 +0000 (+0200) Subject: allow floats to be up 40 charaters long X-Git-Tag: v1.5.1~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=23499078b8ad3f064cf92daa3b179144b5a5ebc1;p=thirdparty%2Frrdtool-1.x.git allow floats to be up 40 charaters long --- diff --git a/src/rrd_graph.c b/src/rrd_graph.c index bfb98646..74258901 100644 --- a/src/rrd_graph.c +++ b/src/rrd_graph.c @@ -4792,7 +4792,7 @@ void rrd_graph_options( int stroff; char *parsetime_error = NULL; char scan_gtm[12], scan_mtm[12], scan_ltm[12], col_nam[12]; - char double_str[20], double_str2[20]; + char double_str[41] = {0}, double_str2[41] = {0}; time_t start_tmp = 0, end_tmp = 0; long long_tmp; rrd_time_value_t start_tv, end_tv; @@ -5026,7 +5026,7 @@ void rrd_graph_options( im->draw_y_grid = 0; break; }; - if (sscanf(optarg, "%[0-9.e+-]:%d", double_str , &im->ylabfact) == 2) { + if (sscanf(optarg, "%40[0-9.e+-]:%d", double_str , &im->ylabfact) == 2) { if (rrd_strtodbl( double_str, 0, &(im->ygridstep), "option -y") != 2){ return; } @@ -5047,7 +5047,7 @@ void rrd_graph_options( break; case 1008: /* grid-dash */ if(sscanf(optarg, - "%[0-9.e+-]:%[0-9.e+-]", + "%40[0-9.e+-]:%40[0-9.e+-]", double_str, double_str2 ) != 2) { if ( rrd_strtodbl( double_str, 0, &(im->grid_dash_on),NULL) !=2 @@ -5066,7 +5066,7 @@ void rrd_graph_options( break; case 1002: /* right y axis */ if(sscanf(optarg, - "%[0-9.e+-]:%[0-9.e+-]", + "%40[0-9.e+-]:%40[0-9.e+-]", double_str, double_str2 ) == 2 && rrd_strtodbl( double_str, 0, &(im->second_axis_scale),NULL) == 2 @@ -5252,7 +5252,7 @@ void rrd_graph_options( double size = 1; int end; - if (sscanf(optarg, "%10[A-Z]:%[0-9.e+-]%n", prop, double_str, &end) >= 2 + if (sscanf(optarg, "%10[A-Z]:%40[0-9.e+-]%n", prop, double_str, &end) >= 2 && rrd_strtodbl( double_str, 0, &size, NULL) == 2) { int sindex, propidx; @@ -5542,11 +5542,11 @@ int vdef_parse( * so the parsing is rather simple. Change if needed. */ double param; - char func[30] = {0}, double_str[21] = {0}; + char func[30] = {0}, double_str[41] = {0}; int n; n = 0; - sscanf(str, "%[0-9.e+-],%29[A-Z]%n", double_str, func, &n); + sscanf(str, "%40[0-9.e+-],%29[A-Z]%n", double_str, func, &n); if ( rrd_strtodbl( double_str, NULL, ¶m, NULL) != 2 ){ n = 0; sscanf(str, "%29[A-Z]%n", func, &n); diff --git a/src/rrd_rpncalc.c b/src/rrd_rpncalc.c index e3db18c3..243a7e65 100644 --- a/src/rrd_rpncalc.c +++ b/src/rrd_rpncalc.c @@ -309,7 +309,7 @@ rpnp_t *rpn_parse( long steps = -1; rpnp_t *rpnp; char vname[MAX_VNAME_LEN + 10]; - char double_str[20]; + char double_str[41] = {0}; rpnp = NULL; expr = (char *) expr_const; @@ -320,7 +320,7 @@ rpnp_t *rpn_parse( return NULL; } - else if ((sscanf(expr, "%[0-9.e+-]%n", double_str, &pos) == 1) + else if ((sscanf(expr, "%40[0-9.e+-]%n", double_str, &pos) == 1) && (expr[pos] == ',') && ( rrd_strtodbl( double_str, NULL, &(rpnp[steps].val), NULL ) == 2 )) { rpnp[steps].op = OP_NUMBER; diff --git a/src/rrd_tune.c b/src/rrd_tune.c index 086033a6..4838d4c7 100644 --- a/src/rrd_tune.c +++ b/src/rrd_tune.c @@ -87,7 +87,7 @@ int rrd_tune( int opt_newstep = -1; rrd_file_t *rrd_file = NULL; char *opt_daemon = NULL; - char double_str[ 12 ]; + char double_str[ 41 ] = {0}; const char *in_filename = NULL; struct option long_options[] = { {"heartbeat", required_argument, 0, 'h'}, @@ -208,7 +208,7 @@ int rrd_tune( break; case 'i': - matches = sscanf(optarg, DS_NAM_FMT ":%[0-9.e+-]", ds_nam, double_str); + matches = sscanf(optarg, DS_NAM_FMT ":%40[0-9.e+-]", ds_nam, double_str); if( matches >= 1 ) { strtod_ret_val = rrd_strtodbl( double_str, NULL, &min, NULL ); } @@ -228,7 +228,7 @@ int rrd_tune( break; case 'a': - matches = sscanf(optarg, DS_NAM_FMT ":%[0-9.e+-]", ds_nam, double_str); + matches = sscanf(optarg, DS_NAM_FMT ":%40[0-9.e+-]", ds_nam, double_str); if( matches >= 1 ) { strtod_ret_val = rrd_strtodbl( double_str, NULL, &max, NULL ); }