Package: hddtemp
Version: 0.3-beta15-52+b1
Severity: normal
Tags: patch
Dear Maintainer,
The model names are not shown as they should, sometimes. There is
garbage at the end.
See:
/dev/sda: Samsung SSD 850 PRO 256G B ▒@: 28°C
During the read operation the buffer size is not handled properly.
The *_IDENTIFY command of ATA and SATA delivers a "struct hd_driveid"
with a field of "model[40]" (at byte position 54
(or 27 at 16-bit units)).
Take a look:
$ grep model -n /usr/include/linux/hdreg.h
403: unsigned char model[40]; /* 0 = not_specified */
Interpreting the model as c-string is most likely luck.
ATA is simply relying on that, with strdup().
And SATA is reading only 24 bytes !?
Patch:
Adding a 0-terminator after the end.
Doing the trim spaces, and so.
Copying safely up to 40 characters.
After all of that a SSD could look like this:
/dev/sda: Samsung SSD 850 PRO 256GB: 29°C
Best regards,
Stephan
-- System Information:
Debian Release: 9.3
APT prefers stable-updates
APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)
Kernel: Linux 4.9.0-4-amd64 (SMP w/2 CPU cores)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8),
LANGUAGE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
Versions of packages hddtemp depends on:
ii debconf [debconf-2.0] 1.5.61
ii libc6 2.24-11+deb9u1
ii lsb-base 9.20161125
hddtemp recommends no packages.
Versions of packages hddtemp suggests:
pn ksensors <none>
-- Configuration Files:
/etc/hddtemp.db changed:
"FUJITSU MHM2100AT" 0 C "Fujitsu MHM2100AT"
"HITACHI_DK228A-65" 0 C "Hitachi DK228A-65"
"IBM-DARA-212000" 0 C "IBM Travelstar 12GN"
"IBM-DTTA-35*" 0 C "IBM Deskstar 16GP serie"
"IBM-DJNA-35.*" 231 C "IBM Deskstar 25 GP serie"
"IBM-DJNA-37.*" 231 C "IBM Deskstar 22 GXP serie"
"IBM-DHEA-(34330|36480)" 0 C "IBM Deskstar 5 serie"
"IBM-DHEA-(34331|36481|38451)" 0 C "IBM Deskstar 8 serie"
"IBM-DPTA-37.*" 231 C "IBM Deskstar 34GXP serie"
"IBM-DPTA-35.*" 231 C "IBM Deskstar 37GP serie"
"Maxtor 5(1024|1369|2049|2732|3073|4098)U(2|3|4|6|8)" 0 C "Maxtor
DiamondMax Plus 40"
"Maxtor 5T0[24]0H[24]" 0 C "Maxtor
DiamondMax Plus 60"
"Maxtor 94098U8" 11 C "Maxtor
DiamondMax 40 94098U8"
"QUANTUM FIREBALLP AS40.0" 0 C "Quantum Fireball AS40"
"QUANTUM FIREBALL CX10.2A" 0 C "Quantum Fireball CX10.2A"
"SAMSUNG SW0434A" 0 C "Samsung
SW0434A"
"SAMSUNG SV0432A" 0 C "Samsung
SV0432A"
"SAMSUNG SV3002H" 0 C "Samsung
SpinPoint V30 serie"
"Samsung SSD 850 PRO 256" 190 C "Samsung SSD
850 PRO"
"Seagate Technology 1275MB - ST31276A" 0 C "Seagate ST31276A"
"ST3412A" 0 C "Seagate ST3412A"
"ST38641A" 0 C "Seagate ST38641A"
"ST310210A" 0 C "Seagate ST310210A"
"ST310220A" 0 C "Seagate ST310220A"
"ST313021A" 0 C "Seagate U8 ST313021A"
"ST310240A" 0 C "Seagate Medalist 10240 Ultra
ATA-3"
"ST320423A" 0 C "Seagate U10 20423, Ultra
ATA/66"
"MK4313MAT" 220 C "Toshiba MK4313MAT"
"TOSHIBA MK1517GAP" 0 C "Toshiba MK1517GAP"
"TOSHIBA MK2018GAS" 226 F "Toshiba MK2018GAS"
"TOSHIBA MK3017GAP" 0 C "Toshiba MK3017GAP"
"WDC AC22000L" 0 C "Western
Digital Caviar AC22000"
"WDC AC420400D" 231 C "Western
Digital Caviar AC420400D"
"WDC AC418000D" 231 C "Western
Digital AC418000D"
"WDC WD135BA" 231 C "Western
Digital WD135BA"
"WDC WD100EB-00BHF0" 0 C "Western
Digital 100EB-00BHF0"
"WDC WD200BB-00AUA1" 0 C "Western
Digital Caviar WD200BB"
"WDC WD300BB-00CAA0" 0 C "Western
Digital WD300BB"
"WDC WD400BB-00CAA0" 0 C "Western
Digital 400BB-00CAA0"
"WDC WD400BB-(18CA|00DE)A0" 0 C "Western
Digital Caviar WD400BB"
"WDC WD400EB-00CPF0" 0 C "Western
Digital 400EB-00CPF0"
"WDC WD600BB-32BSA0" 0 C "Western
Digital 600BB-32BSA0"
"WDC WD800BB-00CAA1" 0 C "Western
Digital WD800BB-00CAA1"
"WDC WD800JB-00CRA1" 0 C "Western
Digital Caviar WD800JB"
-- debconf information excluded
diff hddtemp-0.3-beta15/src/ata.c hddtemp-0.3-beta15_fix/src/ata.c
67c67,69
< else
---
> else {
> sbuff[54 + 40] = 0;
> ata_fixstring(sbuff + 54, 40);
68a71
> }
diff hddtemp-0.3-beta15/src/atacmds.c hddtemp-0.3-beta15_fix/src/atacmds.c
43a44,64
> void ata_fixstring(unsigned char *s, int bytecount)
> {
> unsigned char *p;
> unsigned char *end;
>
> p = s;
> end = &s[bytecount];
>
> /* strip leading blanks */
> while (s != end && *s == ' ')
> ++s;
> /* compress internal blanks and strip trailing blanks */
> while (s != end && *s) {
> if (*s++ != ' ' || (s != end && *s && *s != ' '))
> *p++ = *(s-1);
> }
> /* wipe out trailing garbage */
> while (p != end)
> *p++ = '\0';
> }
>
diff hddtemp-0.3-beta15/src/atacmds.h hddtemp-0.3-beta15_fix/src/atacmds.h
21a22
> void ata_fixstring(unsigned char *s, int bytecount);
diff hddtemp-0.3-beta15/src/sata.c hddtemp-0.3-beta15_fix/src/sata.c
91c91,92
< sata_fixstring(identify + 54, 24);
---
> identify[54 + 40] = 0;
> sata_fixstring(identify + 54, 40);