]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
allow floats to be up 40 charaters long
authorTobias Oetiker <tobi@oetiker.ch>
Mon, 20 Apr 2015 21:49:49 +0000 (23:49 +0200)
committerTobias Oetiker <tobi@oetiker.ch>
Mon, 20 Apr 2015 21:49:49 +0000 (23:49 +0200)
src/rrd_graph.c
src/rrd_rpncalc.c
src/rrd_tune.c

index bfb986469207bfc45aa4c4514f1212ae264e800a..7425890159add46628f524f3ed8d70406cec50ce 100644 (file)
@@ -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, &param, NULL) != 2 ){
         n = 0;
         sscanf(str, "%29[A-Z]%n", func, &n);
index e3db18c39790c801e0dc0b4b7aa55696d8f2a11a..243a7e65956ee6ec089c0502bebfd4009d3af104 100644 (file)
@@ -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;
index 086033a644e0825d28724dba8f1b8a5fc089e261..4838d4c70ee10f9ca07292ab6ab853cfcd2541df 100644 (file)
@@ -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 );
             }