Update int_parser to reject invalid input

update-lkm
nirenjan 2022-09-01 20:50:36 -07:00
parent 1d1e5781c2
commit c3a4fea139
4 changed files with 24 additions and 20 deletions

View File

@ -6,11 +6,11 @@ Verify mouse speed is set to 32
config get mouse speed
DATA mouse speed 32
Set mouse speed to invalid value # TODO: May fail
Set mouse speed to invalid value
config set mouse speed off
ERR "Error 22 setting 'mouse.speed'='off': Invalid argument"
Verify mouse speed is unchanged # TODO: May fail if previous test failed
Verify mouse speed is unchanged
config get mouse speed
DATA mouse speed 32

View File

@ -71,6 +71,10 @@ static int int_parser(struct x52d_config *cfg, size_t offset, const char *value)
if (errno != 0) {
return errno;
}
if (*endptr != '\0') {
// Invalid characters in string
return EINVAL;
}
*config = retval;
return 0;

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: libx52 0.2.3\n"
"Report-Msgid-Bugs-To: https://github.com/nirenjan/libx52/issues\n"
"POT-Creation-Date: 2022-07-27 12:45-0700\n"
"POT-Creation-Date: 2022-08-31 20:39-0700\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -733,40 +733,40 @@ msgstr ""
msgid "Failed to dump %s.%s to config file %s"
msgstr ""
#: daemon/x52d_config_parser.c:168
#: daemon/x52d_config_parser.c:172
#, c-format
msgid "Ignoring unknown key '%s.%s'"
msgstr ""
#: daemon/x52d_config_parser.c:209
#: daemon/x52d_config_parser.c:213
#, c-format
msgid "Failed processing configuration file %s - code %d"
msgstr ""
#: daemon/x52d_config_parser.c:239
#: daemon/x52d_config_parser.c:243
msgid "Failed to allocate memory for override structure"
msgstr ""
#: daemon/x52d_config_parser.c:248
#: daemon/x52d_config_parser.c:252
msgid "Failed to allocate memory for override string"
msgstr ""
#: daemon/x52d_config_parser.c:259
#: daemon/x52d_config_parser.c:263
#, c-format
msgid "No section found in override string '%s'"
msgstr ""
#: daemon/x52d_config_parser.c:273
#: daemon/x52d_config_parser.c:277
#, c-format
msgid "No key found in override string '%s'"
msgstr ""
#: daemon/x52d_config_parser.c:284
#: daemon/x52d_config_parser.c:288
#, c-format
msgid "No value found in override string '%s'"
msgstr ""
#: daemon/x52d_config_parser.c:335
#: daemon/x52d_config_parser.c:339
#, c-format
msgid "Error processing override '%s.%s=%s'"
msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: libx52 0.2.3\n"
"Report-Msgid-Bugs-To: https://github.com/nirenjan/libx52/issues\n"
"POT-Creation-Date: 2022-07-27 12:45-0700\n"
"POT-Creation-Date: 2022-08-31 20:39-0700\n"
"PO-Revision-Date: 2022-07-27 12:45-0700\n"
"Last-Translator: Nirenjan Krishnan <nirenjan@gmail.com>\n"
"Language-Team: Dummy Language for testing i18n\n"
@ -785,40 +785,40 @@ msgstr "Unableay otay avesay onfigcay ilefay %s - odecay %d: %s"
msgid "Failed to dump %s.%s to config file %s"
msgstr "Ailedfay otay umpday %s.%s otay onfigcay ilefay %s"
#: daemon/x52d_config_parser.c:168
#: daemon/x52d_config_parser.c:172
#, c-format
msgid "Ignoring unknown key '%s.%s'"
msgstr "Ignoringay unknownay eykay '%s.%s'"
#: daemon/x52d_config_parser.c:209
#: daemon/x52d_config_parser.c:213
#, c-format
msgid "Failed processing configuration file %s - code %d"
msgstr "Ailedfay ocessingpray onfigurationcay ilefay %s - odecay %d"
#: daemon/x52d_config_parser.c:239
#: daemon/x52d_config_parser.c:243
msgid "Failed to allocate memory for override structure"
msgstr "Ailedfay otay allocateay emorymay orfay overrideay ucturestray"
#: daemon/x52d_config_parser.c:248
#: daemon/x52d_config_parser.c:252
msgid "Failed to allocate memory for override string"
msgstr "Ailedfay otay allocateay emorymay orfay overrideay ingstray"
#: daemon/x52d_config_parser.c:259
#: daemon/x52d_config_parser.c:263
#, c-format
msgid "No section found in override string '%s'"
msgstr "Onay ectionsay oundfay inay overrideay ingstray '%s'"
#: daemon/x52d_config_parser.c:273
#: daemon/x52d_config_parser.c:277
#, c-format
msgid "No key found in override string '%s'"
msgstr "Onay eykay oundfay inay overrideay ingstray '%s'"
#: daemon/x52d_config_parser.c:284
#: daemon/x52d_config_parser.c:288
#, c-format
msgid "No value found in override string '%s'"
msgstr "Onay aluevay oundfay inay overrideay ingstray '%s'"
#: daemon/x52d_config_parser.c:335
#: daemon/x52d_config_parser.c:339
#, c-format
msgid "Error processing override '%s.%s=%s'"
msgstr "Erroray ocessingpray overriday '%s.%s=%s'"