mirror of https://gitee.com/openkylin/linux.git
return same error value from spk_set_key_info
This patch makes spk_set_key_info return -EINVAL in case of failure instead of returning 4 different values for the type of error that occurred. Print the offending values instead as debug message. Signed-off-by: Pranay Kr. Srivastava <pranjas@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
2c14d2e426
commit
4e9cc9a0a5
|
@ -1226,13 +1226,19 @@ int spk_set_key_info(const u_char *key_info, u_char *k_buffer)
|
||||||
u_char ch, version, num_keys;
|
u_char ch, version, num_keys;
|
||||||
|
|
||||||
version = *cp++;
|
version = *cp++;
|
||||||
if (version != KEY_MAP_VER)
|
if (version != KEY_MAP_VER) {
|
||||||
return -1;
|
pr_debug("version found %d should be %d\n",
|
||||||
|
version, KEY_MAP_VER);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
num_keys = *cp;
|
num_keys = *cp;
|
||||||
states = (int)cp[1];
|
states = (int)cp[1];
|
||||||
key_data_len = (states + 1) * (num_keys + 1);
|
key_data_len = (states + 1) * (num_keys + 1);
|
||||||
if (key_data_len + SHIFT_TBL_SIZE + 4 >= sizeof(spk_key_buf))
|
if (key_data_len + SHIFT_TBL_SIZE + 4 >= sizeof(spk_key_buf)) {
|
||||||
return -2;
|
pr_debug("too many key_infos (%d over %u)\n",
|
||||||
|
key_data_len + SHIFT_TBL_SIZE + 4, (unsigned int)(sizeof(spk_key_buf)));
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
memset(k_buffer, 0, SHIFT_TBL_SIZE);
|
memset(k_buffer, 0, SHIFT_TBL_SIZE);
|
||||||
memset(spk_our_keys, 0, sizeof(spk_our_keys));
|
memset(spk_our_keys, 0, sizeof(spk_our_keys));
|
||||||
spk_shift_table = k_buffer;
|
spk_shift_table = k_buffer;
|
||||||
|
@ -1243,14 +1249,19 @@ int spk_set_key_info(const u_char *key_info, u_char *k_buffer)
|
||||||
cp1 += 2; /* now pointing at shift states */
|
cp1 += 2; /* now pointing at shift states */
|
||||||
for (i = 1; i <= states; i++) {
|
for (i = 1; i <= states; i++) {
|
||||||
ch = *cp1++;
|
ch = *cp1++;
|
||||||
if (ch >= SHIFT_TBL_SIZE)
|
if (ch >= SHIFT_TBL_SIZE) {
|
||||||
return -3;
|
pr_debug("(%d) not valid shift state (max_allowed = %d)\n", ch,
|
||||||
|
SHIFT_TBL_SIZE);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
spk_shift_table[ch] = i;
|
spk_shift_table[ch] = i;
|
||||||
}
|
}
|
||||||
keymap_flags = *cp1++;
|
keymap_flags = *cp1++;
|
||||||
while ((ch = *cp1)) {
|
while ((ch = *cp1)) {
|
||||||
if (ch >= MAX_KEY)
|
if (ch >= MAX_KEY) {
|
||||||
return -4;
|
pr_debug("(%d), not valid key, (max_allowed = %d)\n", ch, MAX_KEY);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
spk_our_keys[ch] = cp1;
|
spk_our_keys[ch] = cp1;
|
||||||
cp1 += states + 1;
|
cp1 += states + 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue