Skip to contentSkip to conversation

staging: speakup: kobjects.c: Use correct values when changing voice.

PATCH In review Christopher Brannon 2 participants 2 messages Sep 11, 2013 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: speakup: kobjects.c: Use correct values when changing voice.

When a new voice is selected, we set volume and pitch appropriate for the voice. We need to use the numeric index corresponding to the voice when indexing into the volume and pitch tables, rather than the raw user input that was used to select the voice.
Note that using the raw input can also lead to an invalid memory read in the case of invalid or malicious user input.

---
 drivers/staging/speakup/kobjects.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/staging/speakup/kobjects.c +4 -1
index 61a3f7a..f31afa2 100644
@@ -651,7 +651,10 @@ ssize_t spk_var_store(struct kobject *kobj, struct kobj_attribute *attr,
 		* If voice was just changed, we might need to reset our default
 		* pitch and volume.
 		*/
-		if (param->var_id == VOICE) {
+		if (param->var_id == VOICE && synth &&
+		    (ret == 0 || ret == -ERESTART)) {
+			var_data = param->data;
+			value = var_data->u.n.value;
 			spk_reset_default_value("pitch", synth->default_pitch,
 				value);
 			spk_reset_default_value("vol", synth->default_vol,
Signature · 1 line
1.8.1.5
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Christopher Brannon, le Wed 11 Sep 2013 10:05:27 -0700, a écrit :

When a new voice is selected, we set volume and pitch appropriate for the voice. We need to use the numeric index corresponding to the voice when indexing into the volume and pitch tables, rather than the raw user input that was used to select the voice.
Note that using the raw input can also lead to an invalid memory read in the case of invalid or malicious user input.

Quoted 23 lines
---
 drivers/staging/speakup/kobjects.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/staging/speakup/kobjects.c +4 -1
index 61a3f7a..f31afa2 100644
@@ -651,7 +651,10 @@ ssize_t spk_var_store(struct kobject *kobj, struct kobj_attribute *attr,
 		* If voice was just changed, we might need to reset our default
 		* pitch and volume.
 		*/
-		if (param->var_id == VOICE) {
+		if (param->var_id == VOICE && synth &&
+		    (ret == 0 || ret == -ERESTART)) {
+			var_data = param->data;
+			value = var_data->u.n.value;
 			spk_reset_default_value("pitch", synth->default_pitch,
 				value);
 			spk_reset_default_value("vol", synth->default_vol,
Signature · 1 line
1.8.1.5
Signature · 2 lines
Samuel
Hi ! I'm a .signature virus ! Copy me into your ~/.signature, please !