From 3517f3965edce49440cc12d7b0d28c50e3df8572 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 26 Sep 2008 19:04:25 +0000 Subject: [PATCH] Change the test for the failure of strtol in the OS scan point-matching code. Previously the code checked for a zero (or negative) return value, but I want to assign some tests a value of 0 during OS scan refinement. Now it checks errno, makes sure the entire value was consumed, and errors on negative numbers. In addition to allowing values of 0, this change catches bogus values where garbage follows the number. --- osscan.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osscan.cc b/osscan.cc index fa1f31e73..fe72678c7 100644 --- a/osscan.cc +++ b/osscan.cc @@ -264,8 +264,9 @@ static int AVal_match(struct AVal *reference, struct AVal *fprint, struct AVal * if (points) { current_points = getattrbyname(points, current_ref->attribute); if (!current_points) fatal("%s: Failed to find point amount for test %s.%s", __func__, testGroupName? testGroupName : "", current_ref->attribute); + errno = 0; pointsThisTest = strtol(current_points->value, &endptr, 10); - if (pointsThisTest < 1) + if (errno != 0 || *endptr != '\0' || pointsThisTest < 0) fatal("%s: Got bogus point amount (%s) for test %s.%s", __func__, current_points->value, testGroupName? testGroupName : "", current_ref->attribute); } subtests += pointsThisTest;