summaryrefslogtreecommitdiff
path: root/libdm/libdm-report.c
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2017-07-16 10:28:02 +0200
committerZdenek Kabelac <zkabelac@redhat.com>2017-07-17 12:32:18 +0200
commitba9820b14223b731125c83dbc9709aa44fdcdbf1 (patch)
treef511155e41da0df7f0aea77bccdec07048476a8a /libdm/libdm-report.c
parent94838b4df06c4f5a47c4cb51d5949d8e7b4684e7 (diff)
downloadlvm2-ba9820b14223b731125c83dbc9709aa44fdcdbf1.tar.gz
numbers: strtod or strtoul need reset of errno
API for strtod() or strtoul() needs reset of errno, before it's being called. So add missing resets in missing places and some also some errno validation for out-of-range numbers.
Diffstat (limited to 'libdm/libdm-report.c')
-rw-r--r--libdm/libdm-report.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/libdm/libdm-report.c b/libdm/libdm-report.c
index 0017ac3ef..20a0827a9 100644
--- a/libdm/libdm-report.c
+++ b/libdm/libdm-report.c
@@ -3185,6 +3185,7 @@ static const char *_tok_value_time(const struct dm_report_field_type *ft,
goto out;
}
+ errno = 0;
if (((t = strtoull(time_str, NULL, 10)) == ULLONG_MAX) && errno == ERANGE) {
log_error(_out_of_range_msg, time_str, ft->id);
goto out;
@@ -3555,6 +3556,7 @@ static struct field_selection *_create_field_selection(struct dm_report *rh,
if (rvw->reserved->type & DM_REPORT_FIELD_RESERVED_VALUE_RANGE)
fs->value->next->v.i = (((const uint64_t *) rvw->value)[1]);
} else {
+ errno = 0;
if (((fs->value->v.i = strtoull(s, NULL, 10)) == ULLONG_MAX) &&
(errno == ERANGE)) {
log_error(_out_of_range_msg, s, field_id);
@@ -3573,6 +3575,7 @@ static struct field_selection *_create_field_selection(struct dm_report *rh,
if (rvw->reserved->type & DM_REPORT_FIELD_RESERVED_VALUE_RANGE)
fs->value->next->v.d = (((const double *) rvw->value)[1]);
} else {
+ errno = 0;
fs->value->v.d = strtod(s, NULL);
if (errno == ERANGE) {
log_error(_out_of_range_msg, s, field_id);
@@ -3594,6 +3597,7 @@ static struct field_selection *_create_field_selection(struct dm_report *rh,
if (rvw->reserved->type & DM_REPORT_FIELD_RESERVED_VALUE_RANGE)
fs->value->next->v.i = (((const uint64_t *) rvw->value)[1]);
} else {
+ errno = 0;
fs->value->v.d = strtod(s, NULL);
if ((errno == ERANGE) || (fs->value->v.d < 0) || (fs->value->v.d > 100)) {
log_error(_out_of_range_msg, s, field_id);