Make sure the file_object string will be bigger enough
(e.g., should be 16(for ino) + 1(for dot) + 16(for bno) +
1(for nul terminator) == 34 at maximum).
And update sprintf to snprintf correspondingly, which is
safer.
Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
struct file_object_t {
uint64_t ino, bno;
- mutable char buf[33];
+ mutable char buf[34];
file_object_t(uint64_t i=0, uint64_t b=0) : ino(i), bno(b) {
buf[0] = 0;
const char *c_str() const {
if (!buf[0])
- sprintf(buf, "%llx.%08llx", (long long unsigned)ino, (long long unsigned)bno);
+ snprintf(buf, sizeof(buf), "%llx.%08llx", (long long unsigned)ino, (long long unsigned)bno);
return buf;
}