mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-07 04:58:01 +02:00
ifcfg-rh: use NM_STRCHAR_ANY() macro in add_one_wep_key()
(cherry picked from commit da6394d572)
This commit is contained in:
parent
020dcf5bc1
commit
74c2538bb3
1 changed files with 8 additions and 18 deletions
|
|
@ -2355,29 +2355,19 @@ add_one_wep_key (shvarFile *ifcfg,
|
||||||
} else {
|
} else {
|
||||||
if (strlen (value) == 10 || strlen (value) == 26) {
|
if (strlen (value) == 10 || strlen (value) == 26) {
|
||||||
/* Hexadecimal WEP key */
|
/* Hexadecimal WEP key */
|
||||||
char *p = value;
|
if (NM_STRCHAR_ANY (value, ch, !g_ascii_isxdigit (ch))) {
|
||||||
|
g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
|
||||||
while (*p) {
|
"Invalid hexadecimal WEP key.");
|
||||||
if (!g_ascii_isxdigit (*p)) {
|
return FALSE;
|
||||||
g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
|
|
||||||
"Invalid hexadecimal WEP key.");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
p++;
|
|
||||||
}
|
}
|
||||||
key = g_strdup (value);
|
key = g_strdup (value);
|
||||||
} else if ( !strncmp (value, "s:", 2)
|
} else if ( !strncmp (value, "s:", 2)
|
||||||
&& (strlen (value) == 7 || strlen (value) == 15)) {
|
&& (strlen (value) == 7 || strlen (value) == 15)) {
|
||||||
/* ASCII key */
|
/* ASCII key */
|
||||||
char *p = value + 2;
|
if (NM_STRCHAR_ANY (value + 2, ch, !g_ascii_isprint (ch))) {
|
||||||
|
g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
|
||||||
while (*p) {
|
"Invalid ASCII WEP key.");
|
||||||
if (!g_ascii_isprint ((int) (*p))) {
|
return FALSE;
|
||||||
g_set_error (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_INVALID_CONNECTION,
|
|
||||||
"Invalid ASCII WEP key.");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
p++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remove 's:' prefix.
|
/* Remove 's:' prefix.
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue