common: validate and properly parse floats

Fixes: #1665.
This commit is contained in:
Andrew J. Hesford 2024-03-27 22:13:50 -04:00
parent d68376f2ac
commit a457542fb1
5 changed files with 138 additions and 3 deletions

View file

@ -4,6 +4,7 @@
#include <stdint.h>
#include <strings.h>
#include <wlr/util/log.h>
#include "common/parse-double.h"
#include "config/tablet.h"
#include "config/rcxml.h"
#include "input/tablet_pad.h"
@ -11,7 +12,8 @@
double
tablet_get_dbl_if_positive(const char *content, const char *name)
{
double value = atof(content);
double value = 0;
set_double(content, &value);
if (value < 0) {
wlr_log(WLR_ERROR, "Invalid value for tablet area %s", name);
return 0;