[Ocfs2-devel] [PATCH] fs/ocfs2: change %8s to %s for mlog of ocfs2_sb_probe

Mark Fasheh mfasheh at suse.de
Wed Nov 7 15:52:07 PST 2012


On Wed, Nov 07, 2012 at 02:23:40PM +0800, Chen Gang wrote:
> 
>    at least, the hdr->signature len is 9 (OCFS1_VOLUME_SIGNATURE)
> 	at ocfs1_fs_compat.h:39:
> 	#define OCFS1_VOLUME_SIGNATURE		 "OracleCFS"
>    so change %8s to %s

Ok, good catch - OCFS1_VOLUME_SIGNATURE is 9 bytes wide. And yes, the
->signature field in ocfs1_vol_disk_hdr is 64 bytes wide so we would always
hit a NULL byte in a valid ocfs1 disk header.


>   additional information:
> 
>     %8s  limit the width, not for the original string output length
>          if name length is more than 8, it still can be fully displayed.
>          if name length is less than 8, the ' ' will be filled before name.
> 
>     %.8s truly limit the original string output length (precision)

However, we can't guarantee that the block will always contain a valid
ocfs1 disk header, with a valid signature field. So we have to still limit
the print, otherwise we could go off the end of our struct if the data read
is garbage (which is exacly what this check is supposed to catch).

I think that instead we should simply change the %8s to %9s.
	--Mark

--
Mark Fasheh



More information about the Ocfs2-devel mailing list