Skip to content

Commit

Permalink
drivers/nutdrv_qx_blazer-common.c: blazer_process_command() for "test…
Browse files Browse the repository at this point in the history
….battery.start" might vary by applicable formatting strings [networkupstools#2450]

Signed-off-by: Jim Klimov <[email protected]>
  • Loading branch information
jimklimov committed Jun 2, 2024
1 parent 56b9a72 commit c4cfa87
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion drivers/nutdrv_qx_blazer-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,26 @@ int blazer_process_command(item_t *item, char *value, const size_t valuelen)

delay = delay / 60;

snprintf(value, valuelen, item->command, delay);
/* In various mapping tables, "%02d" is prevalent; actual
* value is range-checked above to fit into a typical int
*/
if (validate_formatting_string(item->command, "%d", -1) >= 0) {
/* The most likely case, should not cause debug-log
* noise for most end-users when missing the check */
snprintf_dynamic(value, valuelen, item->command, "%d", (int)delay);
} else {
if (validate_formatting_string(item->command, "", -1) >= 0) {
/* A few mappings seem to just request the test
* without parameters, so the second check is
* for that eventuality
*/
snprintf(value, valuelen, "%s", item->command);
} else {
/* Finally try the actual long int (complaining
* with default verbosity==1 if a bad fit) */
snprintf_dynamic(value, valuelen, item->command, "%ld", delay);
}
}

} else {

Expand Down

0 comments on commit c4cfa87

Please sign in to comment.