All of lore.kernel.org
 help / color / mirror / Atom feed
From: khali@linux-fr.org (Jean Delvare)
To: lm-sensors@vger.kernel.org
Subject: Parsing bug fixed in i2c-proc
Date: Thu, 19 May 2005 06:25:18 +0000	[thread overview]
Message-ID: <20041012222850.23dc6c15.khali@linux-fr.org> (raw)

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/

                 reply	other threads:[~2005-05-19  6:25 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=20041012222850.23dc6c15.khali@linux-fr.org \
    --to=khali@linux-fr.org \
    --cc=lm-sensors@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.