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
optn = "volume";
if (!value || !*value)
goto out_no_arg;
if (strlen(value) > 30)
value[30] = 0;
strncpy(volume,value,30);
strlcpy(volume,value,31);
} else if (!strcmp(this_char,"mode")) {
optn = "mode";
if (!value || !*value)
......
......@@ -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 */
read_lock(&entries_lock);
fmt = check_file(bprm);
if (fmt) {
strncpy(iname, fmt->interpreter, BINPRM_BUF_SIZE - 1);
iname[BINPRM_BUF_SIZE - 1] = '\0';
}
if (fmt)
strlcpy(iname, fmt->interpreter, BINPRM_BUF_SIZE);
read_unlock(&entries_lock);
if (!fmt)
goto _ret;
......
......@@ -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 */
/* 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*/
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)
}
}
}
if (name[0] && strcmp(name, "default")) {
strncpy(buf, name, NFS_MAXPATHLEN-1);
buf[NFS_MAXPATHLEN-1] = 0;
}
if (name[0] && strcmp(name, "default"))
strlcpy(buf, name, NFS_MAXPATHLEN);
}
......@@ -340,8 +338,7 @@ int __init nfs_root_setup(char *line)
{
ROOT_DEV = Root_NFS;
if (line[0] == '/' || line[0] == ',' || (line[0] >= '0' && line[0] <= '9')) {
strncpy(nfs_root_name, line, sizeof(nfs_root_name));
nfs_root_name[sizeof(nfs_root_name)-1] = '\0';
strlcpy(nfs_root_name, line, sizeof(nfs_root_name));
} else {
int n = strlen(line) + strlen(NFS_ROOT);
if (n >= sizeof(nfs_root_name))
......
......@@ -308,7 +308,7 @@ void register_disk(struct gendisk *disk)
int j;
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... */
s = strchr(disk->kobj.name, '/');
if (s)
......
......@@ -386,11 +386,11 @@ parse_options(struct smb_mount_data_kernel *mnt, char *options)
mnt->dir_mode = (value & S_IRWXUGO) | S_IFDIR;
break;
case 'i':
strncpy(mnt->codepage.local_name, optarg,
strlcpy(mnt->codepage.local_name, optarg,
SMB_NLS_MAXNAMELEN);
break;
case 'c':
strncpy(mnt->codepage.remote_name, optarg,
strlcpy(mnt->codepage.remote_name, optarg,
SMB_NLS_MAXNAMELEN);
break;
case 't':
......@@ -535,9 +535,9 @@ int smb_fill_super(struct super_block *sb, void *raw_data, int silent)
mnt = server->mnt;
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);
strncpy(mnt->codepage.remote_name, SMB_NLS_REMOTE,
strlcpy(mnt->codepage.remote_name, SMB_NLS_REMOTE,
SMB_NLS_MAXNAMELEN);
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