Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F149265079
D14027.1789786809.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D14027.1789786809.diff
View Options
Index: sys/arm/samsung/exynos/chrome_kb.c
===================================================================
--- sys/arm/samsung/exynos/chrome_kb.c
+++ sys/arm/samsung/exynos/chrome_kb.c
@@ -514,17 +514,8 @@
if (!KBD_HAS_DEVICE(kbd)) {
return (0);
}
- if (((int *)arg)[1] < 0) {
- return (EINVAL);
- }
- if (((int *)arg)[0] < 0) {
- return (EINVAL);
- }
- if (((int *)arg)[0] < 200) /* fastest possible value */
- kbd->kb_delay1 = 200;
- else
- kbd->kb_delay1 = ((int *)arg)[0];
- kbd->kb_delay2 = ((int *)arg)[1];
+ kbd->kb_delay1 = KEYBOARD_REPEAT_GET(arg,0,200,1000);
+ kbd->kb_delay2 = KEYBOARD_REPEAT_GET(arg,1,34,504);
return (0);
case KDSETRAD: /* set keyboard repeat rate (old
Index: sys/arm/versatile/pl050.c
===================================================================
--- sys/arm/versatile/pl050.c
+++ sys/arm/versatile/pl050.c
@@ -418,17 +418,8 @@
if (!KBD_HAS_DEVICE(kbd)) {
return (0);
}
- if (((int *)arg)[1] < 0) {
- return (EINVAL);
- }
- if (((int *)arg)[0] < 0) {
- return (EINVAL);
- }
- if (((int *)arg)[0] < 200) /* fastest possible value */
- kbd->kb_delay1 = 200;
- else
- kbd->kb_delay1 = ((int *)arg)[0];
- kbd->kb_delay2 = ((int *)arg)[1];
+ kbd->kb_delay1 = KEYBOARD_REPEAT_GET(arg,0,200,1000);
+ kbd->kb_delay2 = KEYBOARD_REPEAT_GET(arg,1,34,504);
return (0);
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
Index: sys/dev/adb/adb_kbd.c
===================================================================
--- sys/dev/adb/adb_kbd.c
+++ sys/dev/adb/adb_kbd.c
@@ -780,16 +780,8 @@
case KDSETREPEAT:
if (!KBD_HAS_DEVICE(kbd))
return 0;
- if (((int *)data)[1] < 0)
- return EINVAL;
- if (((int *)data)[0] < 0)
- return EINVAL;
- else if (((int *)data)[0] == 0) /* fastest possible value */
- kbd->kb_delay1 = 200;
- else
- kbd->kb_delay1 = ((int *)data)[0];
- kbd->kb_delay2 = ((int *)data)[1];
-
+ kbd->kb_delay1 = KEYBOARD_REPEAT_GET(data,0,200,1000);
+ kbd->kb_delay2 = KEYBOARD_REPEAT_GET(data,1,34,504);
break;
case KDSETRAD:
Index: sys/dev/gpio/gpiokeys.c
===================================================================
--- sys/dev/gpio/gpiokeys.c
+++ sys/dev/gpio/gpiokeys.c
@@ -822,17 +822,8 @@
if (!KBD_HAS_DEVICE(kbd)) {
return (0);
}
- if (((int *)arg)[1] < 0) {
- return (EINVAL);
- }
- if (((int *)arg)[0] < 0) {
- return (EINVAL);
- }
- if (((int *)arg)[0] < 200) /* fastest possible value */
- kbd->kb_delay1 = 200;
- else
- kbd->kb_delay1 = ((int *)arg)[0];
- kbd->kb_delay2 = ((int *)arg)[1];
+ kbd->kb_delay1 = KEYBOARD_REPEAT_GET(arg,0,200,1000);
+ kbd->kb_delay2 = KEYBOARD_REPEAT_GET(arg,1,34,504);
return (0);
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
Index: sys/dev/usb/input/ukbd.c
===================================================================
--- sys/dev/usb/input/ukbd.c
+++ sys/dev/usb/input/ukbd.c
@@ -1946,14 +1946,8 @@
if (!KBD_HAS_DEVICE(kbd)) {
return (0);
}
- /*
- * Convert negative, zero and tiny args to the same limits
- * as atkbd. We could support delays of 1 msec, but
- * anything much shorter than the shortest atkbd value
- * of 250.34 is almost unusable as well as incompatible.
- */
- kbd->kb_delay1 = imax(((int *)arg)[0], 250);
- kbd->kb_delay2 = imax(((int *)arg)[1], 34);
+ kbd->kb_delay1 = KEYBOARD_REPEAT_GET(arg,0,200,1000);
+ kbd->kb_delay2 = KEYBOARD_REPEAT_GET(arg,1,34,504);
#ifdef EVDEV_SUPPORT
if (sc->sc_evdev != NULL)
evdev_push_repeats(sc->sc_evdev, kbd);
Index: sys/sys/kbio.h
===================================================================
--- sys/sys/kbio.h
+++ sys/sys/kbio.h
@@ -87,6 +87,15 @@
int kb_repeat[2];
};
typedef struct keyboard_repeat keyboard_repeat_t;
+
+#define KEYBOARD_REPEAT_GET(p,i,min,max) ({ \
+ const struct keyboard_repeat *__ptr = \
+ (const struct keyboard_repeat *)(p); \
+ __ptr->kb_repeat[i] < (min) ? (int)(min) : \
+ __ptr->kb_repeat[i] > (max) ? (int)(max) : \
+ __ptr->kb_repeat[i]; \
+})
+
#define KDSETREPEAT _IOW('K', 102, keyboard_repeat_t)
#define KDGETREPEAT _IOR('K', 103, keyboard_repeat_t)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Sep 19, 3:00 AM (7 h, 17 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29769948
Default Alt Text
D14027.1789786809.diff (4 KB)
Attached To
Mode
D14027: Properly range check the keyboard repeat values in the KDSETREPEAT IOCTLs in the kernel
Attached
Detach File
Event Timeline
Log In to Comment