cosmos72 / fstransform

tool for in-place filesystem conversion (for example from jfs/xfs/reiser to ext2/ext3/ext4) without backup
GNU General Public License v2.0
278 stars 28 forks source link

src/arch/mem_linux.cc:70: off by one error ? #42

Closed dcb314 closed 2 years ago

dcb314 commented 2 years ago

static analyser cppcheck says:

mem_linux.cc:70:20: error: Width 256 given in format string (no. 1) is larger than destination buffer 'label[256]', use %255s to prevent overflowing it. [invalidScanfFormatWidth]

and

mem_linux.cc:70:20: error: Width 8 given in format string (no. 3) is larger than destination buffer 'unit[8]', use %7s to prevent overflowing it. [invalidScanfFormatWidth]

Source code is

    if ((err = fscanf(f, "%256s %" FT_ULL " %8s\n", label, & n_ull, unit)) <= 0) {
cosmos72 commented 2 years ago

Thanks for spotting this! Fixed in commit ad5ceb6803781f6fb1aed556095120e35af816bb