Skip to contentSkip to conversation

presumed bug in magnitude code

DISCUSSION Jean Delvare 2 participants 2 messages May 19, 2005

lore
Share & tools
lore
#0 lore raw

Hi everyone.

I think I have located a potential bug in the magnitude code. If you take a look at lm_sensors2/lib/proc.c, in sensors_read_proc and sensors_write_proc, you'll see:

  for (mag = the_feature->scaling; mag > 0; mag --)
    value *= 10.0;
  for (; mag < 0; mag --)
    value /= 10.0;

It looks obvious to me that any negative magnitude would result in a crash. It's "mag ++" on the third line, right? We never caught it because we never had negative magnitudes, but should it happen someday, I better commit a fix right now.

Signature · 2 lines
Jean Delvare
http://www.ensicaen.ismra.fr/~delvare/
#1 lore raw

agreed.

Quoted 20 lines · Jean Delvare

Hi everyone.

I think I have located a potential bug in the magnitude code. If you take a look at lm_sensors2/lib/proc.c, in sensors_read_proc and sensors_write_proc, you'll see:

  for (mag = the_feature->scaling; mag > 0; mag --)
    value *= 10.0;
  for (; mag < 0; mag --)
    value /= 10.0;

It looks obvious to me that any negative magnitude would result in a crash. It's "mag ++" on the third line, right? We never caught it because we never had negative magnitudes, but should it happen someday, I better commit a fix right now.

--
Jean Delvare
http://www.ensicaen.ismra.fr/~delvare/