Skip to content

Commit bb68327

Browse files
palismfrench
authored andcommitted
cifs: Put explicit zero byte into SFU block/char types
SFU types IntxCHR and IntxBLK are 8 bytes with zero as last byte. Make it explicit in memcpy and memset calls, so the zero byte is visible in the code (and not hidden as string trailing nul byte). It is important for reader to show the last byte for block and char types because it differs from the last byte of symlink type (which has it 0x01). Also it is important to show that the type is not nul-term string, but rather 8 bytes (with some printable bytes). Signed-off-by: Pali Rohár <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent cf2ce67 commit bb68327

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

fs/smb/client/inode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ cifs_sfu_type(struct cifs_fattr *fattr, const char *path,
586586
rc = tcon->ses->server->ops->sync_read(xid, &fid, &io_parms,
587587
&bytes_read, &pbuf, &buf_type);
588588
if ((rc == 0) && (bytes_read >= 8)) {
589-
if (memcmp("IntxBLK", pbuf, 8) == 0) {
589+
if (memcmp("IntxBLK\0", pbuf, 8) == 0) {
590590
cifs_dbg(FYI, "Block device\n");
591591
fattr->cf_mode |= S_IFBLK;
592592
fattr->cf_dtype = DT_BLK;
@@ -598,7 +598,7 @@ cifs_sfu_type(struct cifs_fattr *fattr, const char *path,
598598
mnr = le64_to_cpu(*(__le64 *)(pbuf+16));
599599
fattr->cf_rdev = MKDEV(mjr, mnr);
600600
}
601-
} else if (memcmp("IntxCHR", pbuf, 8) == 0) {
601+
} else if (memcmp("IntxCHR\0", pbuf, 8) == 0) {
602602
cifs_dbg(FYI, "Char device\n");
603603
fattr->cf_mode |= S_IFCHR;
604604
fattr->cf_dtype = DT_CHR;

fs/smb/client/smb2ops.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5072,12 +5072,12 @@ static int __cifs_sfu_make_node(unsigned int xid, struct inode *inode,
50725072

50735073
switch (mode & S_IFMT) {
50745074
case S_IFCHR:
5075-
strscpy(pdev.type, "IntxCHR");
5075+
memcpy(pdev.type, "IntxCHR\0", 8);
50765076
pdev.major = cpu_to_le64(MAJOR(dev));
50775077
pdev.minor = cpu_to_le64(MINOR(dev));
50785078
break;
50795079
case S_IFBLK:
5080-
strscpy(pdev.type, "IntxBLK");
5080+
memcpy(pdev.type, "IntxBLK\0", 8);
50815081
pdev.major = cpu_to_le64(MAJOR(dev));
50825082
pdev.minor = cpu_to_le64(MINOR(dev));
50835083
break;

0 commit comments

Comments
 (0)