dankamongmen / growlight

notcurses block device manager / system installation tool
https://nick-black.com/dankwiki/index.php/Growlight
GNU General Public License v3.0
85 stars 12 forks source link

valgrind warning in lex_diskstats #39

Closed dankamongmen closed 4 years ago

dankamongmen commented 4 years ago
Couldn't read link at /sys/class/block/hugetlbfs (No such file or directory)
Couldn't read link at /sys/class/block/zhomez (No such file or directory)
Couldn't read link at /sys/class/block/chungus (No such file or directory)
Couldn't read link at /sys/class/block/tracefs (No such file or directory)
==26135== Thread 2:
==26135== Conditional jump or move depends on uninitialised value(s)
==26135==    at 0x483D3D6: rawmemchr (vg_replace_strmem.c:1422)
==26135==    by 0x52C09E1: _IO_str_init_static_internal (strops.c:41)
==26135==    by 0x529517E: _IO_strfile_read (strfile.h:95)
==26135==    by 0x529517E: __isoc99_sscanf (isoc99_sscanf.c:28)
==26135==    by 0x1204FA: lex_diskstats (stats.c:150)
==26135==    by 0x1204FA: read_diskstats (stats.c:176)
==26135==    by 0x1141FD: event_posix_thread (growlight.c:1679)
==26135==    by 0x5226FB6: start_thread (pthread_create.c:486)
==26135==    by 0x533949E: clone (clone.S:95)
==26135== 
[growlight](0)> 
dankamongmen commented 4 years ago

We weren't terminating the buffer passed to sscanf(), arising from read_procfs_file(). We now terminate it at read time, and the warning has gone away.