mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
checkwps: Validate %?St() tags
This will bail if referenced setting name does not exist. Change-Id: I7abd54ec1260d3da6024ebec809f8e270b0a84e5
This commit is contained in:
parent
d57e1a21d1
commit
d7d7627baf
6 changed files with 91 additions and 22 deletions
|
@ -829,19 +829,12 @@ static int parse_setting_and_lang(struct skin_element *element,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* NOTE: The string validations that happen here will
|
|
||||||
* automatically PASS on checkwps because its too hard to get
|
|
||||||
* settings_list.c built for a specific target.
|
|
||||||
* If that ever changes remove the #ifndef __PCTOOL__ here
|
|
||||||
*/
|
|
||||||
#ifndef __PCTOOL__
|
|
||||||
const struct settings_list *setting = find_setting_by_cfgname(temp);
|
const struct settings_list *setting = find_setting_by_cfgname(temp);
|
||||||
if (!setting) {
|
if (!setting) {
|
||||||
DEBUGF("Invalid setting [%s]\n", temp);
|
DEBUGF("Invalid setting [%s]\n", temp);
|
||||||
return WPS_ERROR_INVALID_PARAM;
|
return WPS_ERROR_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
token->value.xdata = (void *)setting;
|
token->value.xdata = (void *)setting;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,18 +21,17 @@
|
||||||
#ifndef _ICONS_H_
|
#ifndef _ICONS_H_
|
||||||
#define _ICONS_H_
|
#define _ICONS_H_
|
||||||
|
|
||||||
#ifndef PLUGIN
|
#if !defined(PLUGIN) && !defined(__PCTOOL__)
|
||||||
|
|
||||||
#include <lcd.h>
|
#include <lcd.h>
|
||||||
#include "metadata.h"
|
#include "metadata.h"
|
||||||
|
|
||||||
/* External bitmaps */
|
/* External bitmaps */
|
||||||
|
|
||||||
#include "bitmaps/rockboxlogo.h"
|
#include "bitmaps/rockboxlogo.h"
|
||||||
#ifdef HAVE_REMOTE_LCD
|
#ifdef HAVE_REMOTE_LCD
|
||||||
#include "bitmaps/remote_rockboxlogo.h"
|
#include "bitmaps/remote_rockboxlogo.h"
|
||||||
#endif
|
#endif
|
||||||
#endif /* PLUGIN */
|
#endif /* !(PLUGIN || __PCTOOL__) */
|
||||||
|
|
||||||
struct cbmp_bitmap_info_entry /* */
|
struct cbmp_bitmap_info_entry /* */
|
||||||
{
|
{
|
||||||
|
|
|
@ -76,11 +76,13 @@
|
||||||
#include "bootchart.h"
|
#include "bootchart.h"
|
||||||
#include "scroll_engine.h"
|
#include "scroll_engine.h"
|
||||||
|
|
||||||
|
#ifndef __PCTOOL__
|
||||||
struct user_settings global_settings;
|
struct user_settings global_settings;
|
||||||
struct system_status global_status;
|
struct system_status global_status;
|
||||||
static uint32_t user_settings_crc;
|
static uint32_t user_settings_crc;
|
||||||
static long next_status_update_tick;
|
static long next_status_update_tick;
|
||||||
static long lasttime = 0;
|
static long lasttime = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* flush system_status more often for spinning harddisks as we may not be able
|
/* flush system_status more often for spinning harddisks as we may not be able
|
||||||
* to spin up at shutdown in order to save so keep the gap minimal */
|
* to spin up at shutdown in order to save so keep the gap minimal */
|
||||||
|
@ -106,6 +108,14 @@ static long lasttime = 0;
|
||||||
#include "usb-ibasso.h"
|
#include "usb-ibasso.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef LOGF_ENABLE
|
||||||
|
static char *debug_get_flags(uint32_t flags);
|
||||||
|
#undef DEBUGF /* allow DEBUGF or logf not both */
|
||||||
|
#define DEBUGF(...) do { } while(0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __PCTOOL__
|
||||||
|
|
||||||
#ifdef ROCKBOX_NO_TEMP_SETTINGS_FILE /* Overwrites same file each time */
|
#ifdef ROCKBOX_NO_TEMP_SETTINGS_FILE /* Overwrites same file each time */
|
||||||
#define CONFIGFILE_TEMP CONFIGFILE
|
#define CONFIGFILE_TEMP CONFIGFILE
|
||||||
#define RESUMEFILE_TEMP RESUMEFILE
|
#define RESUMEFILE_TEMP RESUMEFILE
|
||||||
|
@ -114,11 +124,6 @@ static long lasttime = 0;
|
||||||
#define CONFIGFILE_TEMP CONFIGFILE".new"
|
#define CONFIGFILE_TEMP CONFIGFILE".new"
|
||||||
#define RESUMEFILE_TEMP RESUMEFILE".new"
|
#define RESUMEFILE_TEMP RESUMEFILE".new"
|
||||||
|
|
||||||
#ifdef LOGF_ENABLE
|
|
||||||
static char *debug_get_flags(uint32_t flags);
|
|
||||||
#undef DEBUGF /* allow DEBUGF or logf not both */
|
|
||||||
#define DEBUGF(...) do { } while(0)
|
|
||||||
#endif
|
|
||||||
static void debug_available_settings(void);
|
static void debug_available_settings(void);
|
||||||
|
|
||||||
static void rename_temp_file(const char *tempfile,
|
static void rename_temp_file(const char *tempfile,
|
||||||
|
@ -1166,6 +1171,7 @@ const struct settings_list* find_setting(const void* variable)
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
#endif /* __PCTOOL__ */
|
||||||
|
|
||||||
const struct settings_list* find_setting_by_cfgname(const char* name)
|
const struct settings_list* find_setting_by_cfgname(const char* name)
|
||||||
{
|
{
|
||||||
|
@ -1187,6 +1193,7 @@ const struct settings_list* find_setting_by_cfgname(const char* name)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef __PCTOOL__
|
||||||
bool set_bool(const char* string, const bool* variable )
|
bool set_bool(const char* string, const bool* variable )
|
||||||
{
|
{
|
||||||
return set_bool_options(string, variable,
|
return set_bool_options(string, variable,
|
||||||
|
@ -1457,3 +1464,4 @@ static void debug_available_settings(void)
|
||||||
logf("End Available Settings\r\n");
|
logf("End Available Settings\r\n");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif /* __PCTOOL__ */
|
||||||
|
|
|
@ -80,7 +80,13 @@
|
||||||
#define BOOL(a) {.bool_ = a}
|
#define BOOL(a) {.bool_ = a}
|
||||||
#define CHARPTR(a) {.charptr = a}
|
#define CHARPTR(a) {.charptr = a}
|
||||||
#define UCHARPTR(a) {.ucharptr = a}
|
#define UCHARPTR(a) {.ucharptr = a}
|
||||||
|
#ifdef __PCTOOL__
|
||||||
|
#define FUNCTYPE(a) { }
|
||||||
|
#define lcd_set_contrast NULL
|
||||||
|
#define set_battery_capacity NULL
|
||||||
|
#else
|
||||||
#define FUNCTYPE(a) {.func = a}
|
#define FUNCTYPE(a) {.func = a}
|
||||||
|
#endif
|
||||||
#define NODEFAULT INT(0)
|
#define NODEFAULT INT(0)
|
||||||
|
|
||||||
/* in all the following macros the args are:
|
/* in all the following macros the args are:
|
||||||
|
@ -109,10 +115,17 @@
|
||||||
yes_id is the lang_id for the 'yes' (or 'on') option in the menu
|
yes_id is the lang_id for the 'yes' (or 'on') option in the menu
|
||||||
no_id is the lang_id for the 'no' (or 'off') option in the menu
|
no_id is the lang_id for the 'no' (or 'off') option in the menu
|
||||||
*/
|
*/
|
||||||
|
#ifdef __PCTOOL_
|
||||||
#define BOOL_SETTING(flags,var,lang_id,default,name,cfgvals,yes_id,no_id,cb)\
|
#define BOOL_SETTING(flags,var,lang_id,default,name,cfgvals,yes_id,no_id,cb)\
|
||||||
{flags|F_BOOL_SETTING, &global_settings.var, \
|
{flags|F_BOOL_SETTING, &global_settings.var, \
|
||||||
lang_id, BOOL(default),name, \
|
lang_id, BOOL(default),name, \
|
||||||
{.bool_setting=(struct bool_setting[]){{cb,yes_id,no_id,cfgvals}}} }
|
{.bool_setting=(struct bool_setting[]){{cb,yes_id,no_id,cfgvals}}} }
|
||||||
|
#else
|
||||||
|
#define BOOL_SETTING(flags,var,lang_id,default,name,cfgvals,yes_id,no_id,cb)\
|
||||||
|
{flags|F_BOOL_SETTING, &global_settings.var, \
|
||||||
|
lang_id, BOOL(default),name, \
|
||||||
|
{.bool_setting=(struct bool_setting[]){{NULL,yes_id,no_id,cfgvals}}} }
|
||||||
|
#endif
|
||||||
|
|
||||||
/* bool setting which does use LANG_YES and _NO and save as "off,on" */
|
/* bool setting which does use LANG_YES and _NO and save as "off,on" */
|
||||||
#define OFFON_SETTING(flags,var,lang_id,default,name,cb) \
|
#define OFFON_SETTING(flags,var,lang_id,default,name,cb) \
|
||||||
|
@ -155,12 +168,21 @@
|
||||||
/* Used for settings which use the set_option() setting screen.
|
/* Used for settings which use the set_option() setting screen.
|
||||||
The ... arg is a list of pointers to strings to display in the setting
|
The ... arg is a list of pointers to strings to display in the setting
|
||||||
screen. These can either be literal strings, or ID2P(LANG_*) */
|
screen. These can either be literal strings, or ID2P(LANG_*) */
|
||||||
|
#ifdef __PCTOOL__
|
||||||
#define CHOICE_SETTING(flags,var,lang_id,default,name,cfg_vals,cb,count,...) \
|
#define CHOICE_SETTING(flags,var,lang_id,default,name,cfg_vals,cb,count,...) \
|
||||||
{flags|F_CHOICE_SETTING|F_T_INT, &global_settings.var, lang_id, \
|
{flags|F_CHOICE_SETTING|F_T_INT, &global_settings.var, lang_id, \
|
||||||
INT(default), name, \
|
INT(default), name, \
|
||||||
{.choice_setting = (struct choice_setting[]){ \
|
{.choice_setting = (struct choice_setting[]){ \
|
||||||
{cb, count, cfg_vals, {.desc = (const unsigned char*[]) \
|
{NULL, count, cfg_vals, {.desc = (const unsigned char*[]) \
|
||||||
{__VA_ARGS__}}}}}}
|
{__VA_ARGS__}}}}}}
|
||||||
|
#else
|
||||||
|
#define CHOICE_SETTING(flags,var,lang_id,default,name,cfg_vals,cb,count,...) \
|
||||||
|
{flags|F_CHOICE_SETTING|F_T_INT, &global_settings.var, lang_id, \
|
||||||
|
INT(default), name, \
|
||||||
|
{.choice_setting = (struct choice_setting[]){ \
|
||||||
|
{cb, count, cfg_vals, {.desc = (const unsigned char*[]) \
|
||||||
|
{__VA_ARGS__}}}}}}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Similar to above, except the strings to display are taken from cfg_vals,
|
/* Similar to above, except the strings to display are taken from cfg_vals,
|
||||||
the ... arg is a list of ID's to talk for the strings, can use TALK_ID()'s */
|
the ... arg is a list of ID's to talk for the strings, can use TALK_ID()'s */
|
||||||
|
@ -176,6 +198,20 @@
|
||||||
unit is the UNIT_ define to display/talk.
|
unit is the UNIT_ define to display/talk.
|
||||||
the first one saves a string to the config file,
|
the first one saves a string to the config file,
|
||||||
the second one saves the variable value to the config file */
|
the second one saves the variable value to the config file */
|
||||||
|
#ifdef __PCTOOL__
|
||||||
|
#define INT_SETTING(flags, var, lang_id, default, name, \
|
||||||
|
unit, min, max, step, formatter, get_talk_id, cb) \
|
||||||
|
{flags|F_INT_SETTING|F_T_INT, &global_settings.var, \
|
||||||
|
lang_id, INT(default), name, \
|
||||||
|
{.int_setting = (struct int_setting[]){ \
|
||||||
|
{NULL, 0, step, min, max, NULL, NULL}}}}
|
||||||
|
#define INT_SETTING_NOWRAP(flags, var, lang_id, default, name, \
|
||||||
|
unit, min, max, step, formatter, get_talk_id, cb) \
|
||||||
|
{flags|F_INT_SETTING|F_T_INT|F_NO_WRAP, &global_settings.var, \
|
||||||
|
lang_id, INT(default), name, \
|
||||||
|
{.int_setting = (struct int_setting[]){ \
|
||||||
|
{NULL, 0, step, min, max, NULL, NULL}}}}
|
||||||
|
#else
|
||||||
#define INT_SETTING(flags, var, lang_id, default, name, \
|
#define INT_SETTING(flags, var, lang_id, default, name, \
|
||||||
unit, min, max, step, formatter, get_talk_id, cb) \
|
unit, min, max, step, formatter, get_talk_id, cb) \
|
||||||
{flags|F_INT_SETTING|F_T_INT, &global_settings.var, \
|
{flags|F_INT_SETTING|F_T_INT, &global_settings.var, \
|
||||||
|
@ -188,7 +224,16 @@
|
||||||
lang_id, INT(default), name, \
|
lang_id, INT(default), name, \
|
||||||
{.int_setting = (struct int_setting[]){ \
|
{.int_setting = (struct int_setting[]){ \
|
||||||
{cb, unit, step, min, max, formatter, get_talk_id}}}}
|
{cb, unit, step, min, max, formatter, get_talk_id}}}}
|
||||||
|
#endif
|
||||||
|
#ifdef __PCTOOL__
|
||||||
|
#define TABLE_SETTING(flags, var, lang_id, default, name, cfg_vals, \
|
||||||
|
unit, formatter, get_talk_id, cb, count, ...) \
|
||||||
|
{flags|F_TABLE_SETTING|F_T_INT, &global_settings.var, \
|
||||||
|
lang_id, INT(default), name, \
|
||||||
|
{.table_setting = (struct table_setting[]) { \
|
||||||
|
{NULL, NULL, NULL, 0, count, \
|
||||||
|
cfg_vals, (const int[]){__VA_ARGS__}}}}}
|
||||||
|
#else
|
||||||
#define TABLE_SETTING(flags, var, lang_id, default, name, cfg_vals, \
|
#define TABLE_SETTING(flags, var, lang_id, default, name, cfg_vals, \
|
||||||
unit, formatter, get_talk_id, cb, count, ...) \
|
unit, formatter, get_talk_id, cb, count, ...) \
|
||||||
{flags|F_TABLE_SETTING|F_T_INT, &global_settings.var, \
|
{flags|F_TABLE_SETTING|F_T_INT, &global_settings.var, \
|
||||||
|
@ -196,14 +241,32 @@
|
||||||
{.table_setting = (struct table_setting[]) { \
|
{.table_setting = (struct table_setting[]) { \
|
||||||
{cb, formatter, get_talk_id, unit, count, \
|
{cb, formatter, get_talk_id, unit, count, \
|
||||||
cfg_vals, (const int[]){__VA_ARGS__}}}}}
|
cfg_vals, (const int[]){__VA_ARGS__}}}}}
|
||||||
|
#endif /* __PCTOOL__ */
|
||||||
|
#ifdef __PCTOOL__
|
||||||
|
#define TABLE_SETTING_LIST(flags, var, lang_id, default, name, cfg_vals, \
|
||||||
|
unit, formatter, get_talk_id, cb, count, list) \
|
||||||
|
{flags|F_TABLE_SETTING|F_T_INT, &global_settings.var, \
|
||||||
|
lang_id, INT(default), name, \
|
||||||
|
{.table_setting = (struct table_setting[]) { \
|
||||||
|
{NULL, NULL, NULL, 0, count, cfg_vals, list}}}}
|
||||||
|
#else
|
||||||
#define TABLE_SETTING_LIST(flags, var, lang_id, default, name, cfg_vals, \
|
#define TABLE_SETTING_LIST(flags, var, lang_id, default, name, cfg_vals, \
|
||||||
unit, formatter, get_talk_id, cb, count, list) \
|
unit, formatter, get_talk_id, cb, count, list) \
|
||||||
{flags|F_TABLE_SETTING|F_T_INT, &global_settings.var, \
|
{flags|F_TABLE_SETTING|F_T_INT, &global_settings.var, \
|
||||||
lang_id, INT(default), name, \
|
lang_id, INT(default), name, \
|
||||||
{.table_setting = (struct table_setting[]) { \
|
{.table_setting = (struct table_setting[]) { \
|
||||||
{cb, formatter, get_talk_id, unit, count, cfg_vals, list}}}}
|
{cb, formatter, get_talk_id, unit, count, cfg_vals, list}}}}
|
||||||
|
#endif
|
||||||
|
#ifdef __PCTOOL__
|
||||||
|
#define CUSTOM_SETTING(flags, var, lang_id, default, name, \
|
||||||
|
load_from_cfg, write_to_cfg, \
|
||||||
|
is_change, set_default) \
|
||||||
|
{flags|F_CUSTOM_SETTING|F_T_CUSTOM|F_BANFROMQS, \
|
||||||
|
&global_settings.var, lang_id, \
|
||||||
|
{.custom = (void*)default}, name, \
|
||||||
|
{.custom_setting = (struct custom_setting[]){ \
|
||||||
|
{NULL, NULL, NULL, NULL}}}}
|
||||||
|
#else
|
||||||
#define CUSTOM_SETTING(flags, var, lang_id, default, name, \
|
#define CUSTOM_SETTING(flags, var, lang_id, default, name, \
|
||||||
load_from_cfg, write_to_cfg, \
|
load_from_cfg, write_to_cfg, \
|
||||||
is_change, set_default) \
|
is_change, set_default) \
|
||||||
|
@ -212,6 +275,7 @@
|
||||||
{.custom = (void*)default}, name, \
|
{.custom = (void*)default}, name, \
|
||||||
{.custom_setting = (struct custom_setting[]){ \
|
{.custom_setting = (struct custom_setting[]){ \
|
||||||
{load_from_cfg, write_to_cfg, is_change, set_default}}}}
|
{load_from_cfg, write_to_cfg, is_change, set_default}}}}
|
||||||
|
#endif
|
||||||
|
|
||||||
#define VIEWPORT_SETTING(var,name) \
|
#define VIEWPORT_SETTING(var,name) \
|
||||||
TEXT_SETTING(F_THEMESETTING|F_NEEDAPPLY,var,name,"-", NULL, NULL)
|
TEXT_SETTING(F_THEMESETTING|F_NEEDAPPLY,var,name,"-", NULL, NULL)
|
||||||
|
@ -394,6 +458,8 @@ static const char graphic_numeric[] = "graphic,numeric";
|
||||||
# define MAX_FILES_IN_DIR_STEP 50
|
# define MAX_FILES_IN_DIR_STEP 50
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef __PCTOOL__
|
||||||
|
|
||||||
#if LCD_DEPTH > 1
|
#if LCD_DEPTH > 1
|
||||||
static const char* list_pad_formatter(char *buffer, size_t buffer_size,
|
static const char* list_pad_formatter(char *buffer, size_t buffer_size,
|
||||||
int val, const char *unit)
|
int val, const char *unit)
|
||||||
|
@ -571,6 +637,7 @@ static int32_t get_precut_talkid(int value, int unit)
|
||||||
{
|
{
|
||||||
return TALK_ID_DECIMAL(-value, 1, unit);
|
return TALK_ID_DECIMAL(-value, 1, unit);
|
||||||
}
|
}
|
||||||
|
#endif /* __PCTOOL__ */
|
||||||
|
|
||||||
struct eq_band_setting eq_defaults[EQ_NUM_BANDS] = {
|
struct eq_band_setting eq_defaults[EQ_NUM_BANDS] = {
|
||||||
{ 32, 7, 0 },
|
{ 32, 7, 0 },
|
||||||
|
@ -585,6 +652,7 @@ struct eq_band_setting eq_defaults[EQ_NUM_BANDS] = {
|
||||||
{ 16000, 7, 0 },
|
{ 16000, 7, 0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifndef __PCTOOL__
|
||||||
static void eq_load_from_cfg(void *setting, char *value)
|
static void eq_load_from_cfg(void *setting, char *value)
|
||||||
{
|
{
|
||||||
struct eq_band_setting *eq = setting;
|
struct eq_band_setting *eq = setting;
|
||||||
|
@ -846,6 +914,8 @@ static void hp_lo_select_apply(int arg)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif /* __PCTOOL__ */
|
||||||
|
|
||||||
const struct settings_list settings[] = {
|
const struct settings_list settings[] = {
|
||||||
/* system_status settings .resume.cfg */
|
/* system_status settings .resume.cfg */
|
||||||
SYSTEM_STATUS_SOUND(F_NO_WRAP, volume, LANG_VOLUME, "volume", SOUND_VOLUME),
|
SYSTEM_STATUS_SOUND(F_NO_WRAP, volume, LANG_VOLUME, "volume", SOUND_VOLUME),
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
../../apps/gui/viewport.c
|
../../apps/gui/viewport.c
|
||||||
../../apps/language.c
|
../../apps/language.c
|
||||||
../../apps/misc.c
|
../../apps/misc.c
|
||||||
|
../../apps/settings.c
|
||||||
|
../../apps/settings_list.c
|
||||||
../../firmware/common/strmemccpy.c
|
../../firmware/common/strmemccpy.c
|
||||||
../../firmware/common/strlcpy.c
|
../../firmware/common/strlcpy.c
|
||||||
../../firmware/common/pathfuncs.c
|
../../firmware/common/pathfuncs.c
|
||||||
|
|
|
@ -39,9 +39,6 @@ bool debug_wps = false;
|
||||||
int wps_verbose_level = 0;
|
int wps_verbose_level = 0;
|
||||||
char *skin_buffer;
|
char *skin_buffer;
|
||||||
|
|
||||||
const struct settings_list *settings;
|
|
||||||
const int nb_settings = 0;
|
|
||||||
|
|
||||||
#ifdef SIMULATOR
|
#ifdef SIMULATOR
|
||||||
#error beep beep
|
#error beep beep
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue