mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-29 01:00:09 +01:00
ifcfg-rh: assert that keys are valid shell names
This commit is contained in:
parent
806ffbbe14
commit
afc394b969
1 changed files with 17 additions and 0 deletions
|
|
@ -85,6 +85,21 @@ svParseBoolean (const char *value, gint fallback)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static gboolean
|
||||
_shell_is_name (const char *key)
|
||||
{
|
||||
/* whether @key is a valid identifier (name). */
|
||||
if (!key)
|
||||
return FALSE;
|
||||
if ( !g_ascii_isalpha (key[0])
|
||||
&& key[0] != '_')
|
||||
return FALSE;
|
||||
return NM_STRCHAR_ALL (&key[1], ch,
|
||||
g_ascii_isalnum (ch) || ch == '_');
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define ESC_ESCAPEES "\"'\\$~`" /* must be escaped */
|
||||
#define ESC_SPACES " \t|&;()<>" /* only require "" */
|
||||
#define ESC_NEWLINES "\n\r" /* will be removed */
|
||||
|
|
@ -312,6 +327,8 @@ find_line (shvarFile *s, const char *key)
|
|||
const char *line;
|
||||
gsize len;
|
||||
|
||||
nm_assert (_shell_is_name (key));
|
||||
|
||||
len = strlen (key);
|
||||
|
||||
for (s->current = s->lineList; s->current; s->current = s->current->next) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue