presumed bug in magnitude code
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/
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, insensors_read_procandsensors_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/