From 8e6d3301b8ba928f5e8732ccd0ca48d55ea01436 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 25 Nov 2016 16:27:17 +1000 Subject: [PATCH] evdev: use safe_atod to convert the matrix values Avoids parsing issues when we're in different locales https://bugs.freedesktop.org/show_bug.cgi?id=98828 Signed-off-by: Peter Hutterer Reviewed-by: Hans de Goede (cherry picked from commit 98793f6b435abf8c17b84102de1d7c59ba8e3f54) --- src/evdev.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/evdev.c b/src/evdev.c index 620588d4..1e3cc905 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -2980,7 +2980,8 @@ evdev_read_calibration_prop(struct evdev_device *device) { const char *calibration_values; float calibration[6]; - int nread; + int idx; + char **strv; calibration_values = udev_device_get_property_value(device->udev_device, @@ -2992,17 +2993,22 @@ evdev_read_calibration_prop(struct evdev_device *device) if (!device->abs.absinfo_x || !device->abs.absinfo_y) return; - nread = sscanf(calibration_values, - "%f %f %f %f %f %f", - &calibration[0], - &calibration[1], - &calibration[2], - &calibration[3], - &calibration[4], - &calibration[5]); - if (nread != 6) + strv = strv_from_string(calibration_values, " "); + if (!strv) return; + for (idx = 0; idx < 6; idx++) { + double v; + if (strv[idx] == NULL || !safe_atod(strv[idx], &v)) { + strv_free(strv); + return; + } + + calibration[idx] = v; + } + + strv_free(strv); + evdev_device_set_default_calibration(device, calibration); log_info(evdev_libinput_context(device), "Applying calibration: %f %f %f %f %f %f\n",