Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 19 Apr 2015 12:11:08 +0000 (UTC)
From:      Jakub Wojciech Klama <jceel@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r281739 - user/jceel/soc2014_evdev/head/sys/dev/evdev
Message-ID:  <201504191211.t3JCB8or017735@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jceel
Date: Sun Apr 19 12:11:07 2015
New Revision: 281739
URL: https://svnweb.freebsd.org/changeset/base/281739

Log:
  Add futher checks to ensure that supported event types array won't
  get overwritten by provider.

Modified:
  user/jceel/soc2014_evdev/head/sys/dev/evdev/evdev.c
  user/jceel/soc2014_evdev/head/sys/dev/evdev/evdev.h

Modified: user/jceel/soc2014_evdev/head/sys/dev/evdev/evdev.c
==============================================================================
--- user/jceel/soc2014_evdev/head/sys/dev/evdev/evdev.c	Sun Apr 19 11:34:41 2015	(r281738)
+++ user/jceel/soc2014_evdev/head/sys/dev/evdev/evdev.c	Sun Apr 19 12:11:07 2015	(r281739)
@@ -186,65 +186,96 @@ evdev_set_softc(struct evdev_dev *evdev,
 	evdev->ev_softc = softc;
 }
 
-inline void
+inline int
 evdev_support_event(struct evdev_dev *evdev, uint16_t type)
 {
 
+	if (type >= EV_CNT)
+		return (EINVAL);
+
 	set_bit(evdev->ev_type_flags, type);
+	return (0);
 }
 
-inline void
+inline int
 evdev_support_key(struct evdev_dev *evdev, uint16_t code)
 {
 
+	if (code >= KEY_CNT)
+		return (EINVAL);
+
 	set_bit(evdev->ev_key_flags, code);
+	return (0);
 }
 
-inline void
+inline int
 evdev_support_rel(struct evdev_dev *evdev, uint16_t code)
 {
 
+	if (code >= REL_CNT)
+		return (EINVAL);
+
 	set_bit(evdev->ev_rel_flags, code);
+	return (0);
 }
 
-inline void
+inline int
 evdev_support_abs(struct evdev_dev *evdev, uint16_t code)
 {
 
+	if (code >= ABS_CNT)
+		return (EINVAL);
+
 	set_bit(evdev->ev_abs_flags, code);
+	return (0);
 }
 
 
-inline void
+inline int
 evdev_support_msc(struct evdev_dev *evdev, uint16_t code)
 {
 
+	if (code >= MSC_CNT)
+		return (EINVAL);
+
 	set_bit(evdev->ev_msc_flags, code);
+	return (0);
 }
 
 
-inline void
+inline int
 evdev_support_led(struct evdev_dev *evdev, uint16_t code)
 {
 
+	if (code >= LED_CNT)
+		return (EINVAL);
+
 	set_bit(evdev->ev_led_flags, code);
+	return (0);
 }
 
-inline void
+inline int
 evdev_support_snd(struct evdev_dev *evdev, uint16_t code)
 {
 
+	if (code >= SND_CNT)
+		return (EINVAL);
+
 	set_bit(evdev->ev_snd_flags, code);
+	return (0);
 }
 
-inline void
+inline int
 evdev_support_sw(struct evdev_dev *evdev, uint16_t code)
 {
+	if (code >= SW_CNT)
+		return (EINVAL);
 
 	set_bit(evdev->ev_sw_flags, code);
+	return (0);
 }
 
-inline void
+inline int
 evdev_support_repeat(struct evdev_dev *evdev, enum evdev_repeat_mode mode)
 {
 
@@ -252,6 +283,7 @@ evdev_support_repeat(struct evdev_dev *e
 		set_bit(evdev->ev_type_flags, EV_REP);
 
 	evdev->ev_repeat_mode = mode;
+	return (0);
 }
 
 

Modified: user/jceel/soc2014_evdev/head/sys/dev/evdev/evdev.h
==============================================================================
--- user/jceel/soc2014_evdev/head/sys/dev/evdev/evdev.h	Sun Apr 19 11:34:41 2015	(r281738)
+++ user/jceel/soc2014_evdev/head/sys/dev/evdev/evdev.h	Sun Apr 19 12:11:07 2015	(r281739)
@@ -152,15 +152,15 @@ int evdev_sync(struct evdev_dev *);
 int evdev_mt_sync(struct evdev_dev *);
 int evdev_cdev_create(struct evdev_dev *);
 int evdev_cdev_destroy(struct evdev_dev *);
-void evdev_support_event(struct evdev_dev *, uint16_t);
-void evdev_support_key(struct evdev_dev *, uint16_t);
-void evdev_support_rel(struct evdev_dev *, uint16_t);
-void evdev_support_abs(struct evdev_dev *, uint16_t);
-void evdev_support_msc(struct evdev_dev *, uint16_t);
-void evdev_support_led(struct evdev_dev *, uint16_t);
-void evdev_support_snd(struct evdev_dev *, uint16_t);
-void evdev_support_sw(struct evdev_dev *, uint16_t);
-void evdev_support_repeat(struct evdev_dev *, enum evdev_repeat_mode);
+int evdev_support_event(struct evdev_dev *, uint16_t);
+int evdev_support_key(struct evdev_dev *, uint16_t);
+int evdev_support_rel(struct evdev_dev *, uint16_t);
+int evdev_support_abs(struct evdev_dev *, uint16_t);
+int evdev_support_msc(struct evdev_dev *, uint16_t);
+int evdev_support_led(struct evdev_dev *, uint16_t);
+int evdev_support_snd(struct evdev_dev *, uint16_t);
+int evdev_support_sw(struct evdev_dev *, uint16_t);
+int evdev_support_repeat(struct evdev_dev *, enum evdev_repeat_mode);
 void evdev_set_absinfo(struct evdev_dev *, uint16_t, struct input_absinfo *);
 void evdev_set_repeat_params(struct evdev_dev *, uint16_t, int);
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201504191211.t3JCB8or017735>