Fix pgbench's parsing of double values to notice trailing garbage.
authorTom Lane
Fri, 6 May 2016 15:08:48 +0000 (11:08 -0400)
committerTom Lane
Fri, 6 May 2016 15:08:48 +0000 (11:08 -0400)
Noted by Fabien Coelho, though this isn't exactly his proposed patch.
(The technique used here is borrowed from the zic sources.)

src/bin/pgbench/pgbench.c

index a4841656fa568c9731e28201e1b1df25644ab25f..f3c1a0e41598e74d2171150d05a7bf7c63df6e09 100644 (file)
@@ -928,8 +928,9 @@ makeVariableNumeric(Variable *var)
    else /* type should be double */
    {
        double dv;
+       char xs;
 
-       if (sscanf(var->value, "%lf", &dv) != 1)
+       if (sscanf(var->value, "%lf%c", &dv, &xs) != 1)
        {
            fprintf(stderr,
                    "malformed variable \"%s\" value: \"%s\"\n",