Don't limit the copy to the size of the target string *pointer* (always
4 on 32-bit / 8 on 64-bit); limit the copy to the size of the target
string *buffer*.
THis is Coverity issue 1386912.
Differential D14790
jedec_dimm: Use correct string length when populating sc->slotid_str rpokala on Mar 22 2018, 1:12 AM. Authored by Tags None Referenced Files
Details Don't limit the copy to the size of the target string *pointer* (always THis is Coverity issue 1386912.
Diff Detail
Event Timeline
Comment Actions @imp correctly observed that since the buffer is allocated to fit, then
Comment Actions what, no strdup.9 man page? Geeze :) This is has now reached perfect: there's nothing left to take away. Comment Actions # Much longer than sizeof(sc->slotid_str) % kenv hint.jedec_dimm.0.slotid DIMM0LONGERSTRING Before: % sysctl dev.jedec_dimm.0.slotid dev.jedec_dimm.0.slotid: DIMM0LO After: % sysctl dev.jedec_dimm.0.slotid dev.jedec_dimm.0.slotid: DIMM0LONGERSTRING Comment Actions Feel free to spend a bunch of time documenting libkern if you want. It's definitely valuable and shouldn't be too hard. Mostly just tedious. Maybe a thin document that just defines all of the libc-alike aliases and gets linked in a million places would be enough to start. |