Commit 03b9f57b authored by Ben Collins's avatar Ben Collins Committed by Linus Torvalds

[PATCH] fs/* conversions for strlcpy

I only converted the cases where it was obvious that the intent was to
truncate on overflow. Lots of places for maxpath/readlink type stuff I
left alone.
parent 9c07f108
...@@ -210,9 +210,7 @@ parse_options(char *options, uid_t *uid, gid_t *gid, int *mode, int *reserved, s ...@@ -210,9 +210,7 @@ parse_options(char *options, uid_t *uid, gid_t *gid, int *mode, int *reserved, s
optn = "volume"; optn = "volume";
if (!value || !*value) if (!value || !*value)
goto out_no_arg; goto out_no_arg;
if (strlen(value) > 30) strlcpy(volume,value,31);
value[30] = 0;
strncpy(volume,value,30);
} else if (!strcmp(this_char,"mode")) { } else if (!strcmp(this_char,"mode")) {
optn = "mode"; optn = "mode";
if (!value || !*value) if (!value || !*value)
......
...@@ -113,10 +113,8 @@ static int load_misc_binary(struct linux_binprm *bprm, struct pt_regs *regs) ...@@ -113,10 +113,8 @@ static int load_misc_binary(struct linux_binprm *bprm, struct pt_regs *regs)
/* to keep locking time low, we copy the interpreter string */ /* to keep locking time low, we copy the interpreter string */
read_lock(&entries_lock); read_lock(&entries_lock);
fmt = check_file(bprm); fmt = check_file(bprm);
if (fmt) { if (fmt)
strncpy(iname, fmt->interpreter, BINPRM_BUF_SIZE - 1); strlcpy(iname, fmt->interpreter, BINPRM_BUF_SIZE);
iname[BINPRM_BUF_SIZE - 1] = '\0';
}
read_unlock(&entries_lock); read_unlock(&entries_lock);
if (!fmt) if (!fmt)
goto _ret; goto _ret;
......
...@@ -2388,7 +2388,7 @@ int presto_do_set_ext_attr(struct presto_file_set *fset, ...@@ -2388,7 +2388,7 @@ int presto_do_set_ext_attr(struct presto_file_set *fset,
/* We first "truncate" name to the maximum allowable in presto */ /* We first "truncate" name to the maximum allowable in presto */
/* This simulates the strncpy_from_use code in fs/ext_attr.c */ /* This simulates the strncpy_from_use code in fs/ext_attr.c */
strncpy(temp,name,sizeof(temp)); strlcpy(temp,name,sizeof(temp));
/* Pass down to cache*/ /* Pass down to cache*/
error = iops->set_ext_attr(inode,temp,buffer,buffer_len,flags); error = iops->set_ext_attr(inode,temp,buffer,buffer_len,flags);
......
...@@ -226,10 +226,8 @@ static void __init root_nfs_parse(char *name, char *buf) ...@@ -226,10 +226,8 @@ static void __init root_nfs_parse(char *name, char *buf)
} }
} }
} }
if (name[0] && strcmp(name, "default")) { if (name[0] && strcmp(name, "default"))
strncpy(buf, name, NFS_MAXPATHLEN-1); strlcpy(buf, name, NFS_MAXPATHLEN);
buf[NFS_MAXPATHLEN-1] = 0;
}
} }
...@@ -340,8 +338,7 @@ int __init nfs_root_setup(char *line) ...@@ -340,8 +338,7 @@ int __init nfs_root_setup(char *line)
{ {
ROOT_DEV = Root_NFS; ROOT_DEV = Root_NFS;
if (line[0] == '/' || line[0] == ',' || (line[0] >= '0' && line[0] <= '9')) { if (line[0] == '/' || line[0] == ',' || (line[0] >= '0' && line[0] <= '9')) {
strncpy(nfs_root_name, line, sizeof(nfs_root_name)); strlcpy(nfs_root_name, line, sizeof(nfs_root_name));
nfs_root_name[sizeof(nfs_root_name)-1] = '\0';
} else { } else {
int n = strlen(line) + strlen(NFS_ROOT); int n = strlen(line) + strlen(NFS_ROOT);
if (n >= sizeof(nfs_root_name)) if (n >= sizeof(nfs_root_name))
......
...@@ -308,7 +308,7 @@ void register_disk(struct gendisk *disk) ...@@ -308,7 +308,7 @@ void register_disk(struct gendisk *disk)
int j; int j;
int err; int err;
strncpy(disk->kobj.name,disk->disk_name,KOBJ_NAME_LEN); strlcpy(disk->kobj.name,disk->disk_name,KOBJ_NAME_LEN);
/* ewww... some of these buggers have / in name... */ /* ewww... some of these buggers have / in name... */
s = strchr(disk->kobj.name, '/'); s = strchr(disk->kobj.name, '/');
if (s) if (s)
......
...@@ -386,11 +386,11 @@ parse_options(struct smb_mount_data_kernel *mnt, char *options) ...@@ -386,11 +386,11 @@ parse_options(struct smb_mount_data_kernel *mnt, char *options)
mnt->dir_mode = (value & S_IRWXUGO) | S_IFDIR; mnt->dir_mode = (value & S_IRWXUGO) | S_IFDIR;
break; break;
case 'i': case 'i':
strncpy(mnt->codepage.local_name, optarg, strlcpy(mnt->codepage.local_name, optarg,
SMB_NLS_MAXNAMELEN); SMB_NLS_MAXNAMELEN);
break; break;
case 'c': case 'c':
strncpy(mnt->codepage.remote_name, optarg, strlcpy(mnt->codepage.remote_name, optarg,
SMB_NLS_MAXNAMELEN); SMB_NLS_MAXNAMELEN);
break; break;
case 't': case 't':
...@@ -535,9 +535,9 @@ int smb_fill_super(struct super_block *sb, void *raw_data, int silent) ...@@ -535,9 +535,9 @@ int smb_fill_super(struct super_block *sb, void *raw_data, int silent)
mnt = server->mnt; mnt = server->mnt;
memset(mnt, 0, sizeof(struct smb_mount_data_kernel)); memset(mnt, 0, sizeof(struct smb_mount_data_kernel));
strncpy(mnt->codepage.local_name, CONFIG_NLS_DEFAULT, strlcpy(mnt->codepage.local_name, CONFIG_NLS_DEFAULT,
SMB_NLS_MAXNAMELEN); SMB_NLS_MAXNAMELEN);
strncpy(mnt->codepage.remote_name, SMB_NLS_REMOTE, strlcpy(mnt->codepage.remote_name, SMB_NLS_REMOTE,
SMB_NLS_MAXNAMELEN); SMB_NLS_MAXNAMELEN);
mnt->ttl = SMB_TTL_DEFAULT; mnt->ttl = SMB_TTL_DEFAULT;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment