Parsing bug fixed in i2c-proc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

Yesterday I spotted an odd bug in i2c-proc. The parsing code for reals
is broken. It doesn't properly "eat" extra characters after values. The
part of the code which supposedly does this is:

       /* Skip everything until we hit whitespace */
       while (bufsize && 
              !((ret=get_user(nextchar, (char *) buffer))) &&
              isspace((int) nextchar)) {
               bufsize--;
               ((char *) buffer)++;
       }

It actually does the exact contrary, i.e. skip everyting until we hit
*non* whitespace.

You can reproduce the bug by trying to write "70.55" to a procfs
temperature file with magnitude 1. The first limit (typically max) will
be set to 70.5, which is fine. The second limit (typically min or hyst)
will be set to 5, which you certainly wouldn't expect.

I just commited the fix to the CVS repository. It is as simple as:

-              isspace((int) nextchar)) {
+              !isspace((int) nextchar)) {

I am a bit surprised that this bug seems to be there for several years
and nobody ever hit it. Thus, I would appreciate if someone else could
verify, test and confirm.

I will send a patch to Marcelo for Linux 2.4.

Thanks.

-- 
Jean Delvare
http://khali.linux-fr.org/



[Index of Archives]     [Linux Kernel]     [Linux Hardware Monitoring]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux