linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrey Borzenkov <arvidjaar@mail.ru>
To: linux-hotplug@vger.kernel.org
Subject: [PATCH][2.6.0-test9] fix 32/64 bits for input events
Date: Sun, 09 Nov 2003 18:36:11 +0000	[thread overview]
Message-ID: <marc-linux-hotplug-106840503223501@msgid-missing> (raw)

[-- Attachment #1: Type: text/plain, Size: 654 bytes --]

Input bits are kept as array of unsigned long and when no bit is set the whole 
"unsigned long" is represented as single 0 in hotplug events and /proc files. 
It makes rather hard for user-level programs to guess which bits are set - 
programs need to know size of kernel long to correctly interpret output.

One possibility is attached patch. It makes sure every long is always output 
in full. Another possibility (I like it more frankly speaking) is to always 
use 32 bit type for arrays. But it needs more than two lines of trivial 
changes.

regards

-andrey

PS do I miss something or input /proc functions really never check for buffer 
overflow?

[-- Attachment #2: 2.6.0-test9-input_user_bits.patch --]
[-- Type: text/x-diff, Size: 845 bytes --]

--- linux-2.6.0-test9/drivers/input/input.c	2003-11-09 21:17:59.000000000 +0300
+++ ../tmp/linux-2.6.0-test9/drivers/input/input.c	2003-10-25 22:21:42.000000000 +0400
@@ -330,8 +330,7 @@ static struct input_device_id *input_mat
 		for (j = NBITS(max) - 1; j >= 0; j--) \
 			if (dev->bit[j]) break; \
 		for (; j >= 0; j--) \
-			scratch += sprintf(scratch, "%0*lx ", \
-					BITS_PER_LONG/4, dev->bit[j]); \
+			scratch += sprintf(scratch, "%lx ", dev->bit[j]); \
 		scratch++; \
 	} while (0)
 
@@ -584,8 +583,7 @@ static struct file_operations input_fops
 		for (i = NBITS(max) - 1; i >= 0; i--) \
 			if (dev->bit[i]) break; \
 		for (; i >= 0; i--) \
-			len += sprintf(buf + len, "%0*lx ", \
-					BITS_PER_LONG/4, dev->bit[i]); \
+			len += sprintf(buf + len, "%lx ", dev->bit[i]); \
 		len += sprintf(buf + len, "\n"); \
 	} while (0)
 

                 reply	other threads:[~2003-11-09 18:36 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=marc-linux-hotplug-106840503223501@msgid-missing \
    --to=arvidjaar@mail.ru \
    --cc=linux-hotplug@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).