Skip to contentSkip to conversation

fs/ocfs2: change %8s to %s for mlog of ocfs2_sb_probe

PATCH New Mark Fasheh 1 participant 1 message Nov 7, 2012 1 message not in the archive OCFS2

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 fs/ocfs2: change %8s to %s for mlog of ocfs2_sb_probe

Quoted 5 lines · Chen Gang

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.

Quoted 7 lines

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