fix buffer overflow for LONG lines in journal handling code for update requests.
[rrdtool.git] / src / rrd_tool.c
index 5c717f9..bb1bc3e 100644 (file)
@@ -534,7 +534,7 @@ int HandleInputLine(
      */
     if (RemoteMode) {
         if (argc > 1 && strcmp("quit", argv[1]) == 0) {
-            if (argc > 2) {
+            if (argc != 2) {
                 printf("ERROR: invalid parameter count for quit\n");
                 return (1);
             }
@@ -542,7 +542,7 @@ int HandleInputLine(
         }
 #if defined(HAVE_OPENDIR) && defined(HAVE_READDIR) && defined(HAVE_CHDIR)
         if (argc > 1 && strcmp("cd", argv[1]) == 0) {
-            if (argc > 3) {
+            if (argc != 3) {
                 printf("ERROR: invalid parameter count for cd\n");
                 return (1);
             }
@@ -562,7 +562,7 @@ int HandleInputLine(
         }
         if (argc > 1 && strcmp("pwd", argv[1]) == 0) {
             char     *cwd;      /* To hold current working dir on call to pwd */
-            if (argc > 2) {
+            if (argc != 2) {
                 printf("ERROR: invalid parameter count for pwd\n");
                 return (1);
             }
@@ -576,7 +576,7 @@ int HandleInputLine(
             return (0);
         }
         if (argc > 1 && strcmp("mkdir", argv[1]) == 0) {
-            if (argc > 3) {
+            if (argc != 3) {
                 printf("ERROR: invalid parameter count for mkdir\n");
                 return (1);
             }
@@ -595,7 +595,7 @@ int HandleInputLine(
             return (0);
         }
         if (argc > 1 && strcmp("ls", argv[1]) == 0) {
-            if (argc > 2) {
+            if (argc != 2) {
                 printf("ERROR: invalid parameter count for ls\n");
                 return (1);
             }
@@ -695,6 +695,7 @@ int HandleInputLine(
             free(data);
         }
     } else if (strcmp("xport", argv[1]) == 0) {
+#ifdef HAVE_RRD_GRAPH
         int       xxsize;
         unsigned long int j = 0;
         time_t    start, end, ti;
@@ -714,7 +715,8 @@ int HandleInputLine(
         if (rrd_xport
             (argc - 1, &argv[1], &xxsize, &start, &end, &step, &col_cnt,
              &legend_v, &data) != -1) {
-            char *old_locale = setlocale(LC_NUMERIC, "C");
+            char *old_locale = setlocale(LC_NUMERIC,NULL);
+            setlocale(LC_NUMERIC, "C");
             row_cnt = (end - start) / step;
             ptr = data;
             printf("<?xml version=\"1.0\" encoding=\"%s\"?>\n\n",
@@ -770,7 +772,11 @@ int HandleInputLine(
             setlocale(LC_NUMERIC, old_locale);
         }
         free(vtag);
+#else
+        rrd_set_error("the instance of rrdtool has been compiled without graphics");
+#endif
     } else if (strcmp("graph", argv[1]) == 0) {
+#ifdef HAVE_RRD_GRAPH
         char    **calcpr;
 
 #ifdef notused /*XXX*/
@@ -804,7 +810,11 @@ int HandleInputLine(
             }
         }
 
+#else
+       rrd_set_error("the instance of rrdtool has been compiled without graphics");
+#endif
     } else if (strcmp("graphv", argv[1]) == 0) {
+#ifdef HAVE_RRD_GRAPH
         rrd_info_t *grinfo = NULL;  /* 1 to distinguish it from the NULL that rrd_graph sends in */
 
         grinfo = rrd_graph_v(argc - 1, &argv[1]);
@@ -812,7 +822,9 @@ int HandleInputLine(
             rrd_info_print(grinfo);
             rrd_info_free(grinfo);
         }
-
+#else
+       rrd_set_error("the instance of rrdtool has been compiled without graphics");
+#endif
     } else if (strcmp("tune", argv[1]) == 0)
         rrd_tune(argc - 1, &argv[1]);
 #ifndef WIN32