summaryrefslogtreecommitdiffstats
path: root/fs/exec.c
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>1999-12-04 03:58:56 +0000
committerRalf Baechle <ralf@linux-mips.org>1999-12-04 03:58:56 +0000
commit1d67e90f19a7acfd9a05dc59678e7d0c5090bd0d (patch)
tree357efc7b93f8f5102110d20d293f41360ec212fc /fs/exec.c
parentaea27b2e18d69af87e673972246e66657b4fa274 (diff)
Merge with Linux 2.3.21.
Diffstat (limited to 'fs/exec.c')
-rw-r--r--fs/exec.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/fs/exec.c b/fs/exec.c
index 4d3295137..b3f31fd0a 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -169,7 +169,7 @@ out:
/*
* count() counts the number of arguments/envelopes
*/
-static int count(char ** argv)
+static int count(char ** argv, int max)
{
int i = 0;
@@ -184,7 +184,8 @@ static int count(char ** argv)
if (!p)
break;
argv++;
- i++;
+ if(++i > max)
+ return -E2BIG;
}
}
return i;
@@ -202,7 +203,7 @@ int copy_strings(int argc,char ** argv, struct linux_binprm *bprm)
int len;
unsigned long pos;
- if (get_user(str, argv+argc) || !str || !(len = strlen_user(str)))
+ if (get_user(str, argv+argc) || !str || !(len = strnlen_user(str, bprm->p)))
return -EFAULT;
if (bprm->p < len)
return -E2BIG;
@@ -211,7 +212,7 @@ int copy_strings(int argc,char ** argv, struct linux_binprm *bprm)
/* XXX: add architecture specific overflow check here. */
pos = bprm->p;
- while (len) {
+ while (len>0) {
char *pag;
int offset, bytes_to_copy;
@@ -274,7 +275,7 @@ int setup_arg_pages(struct linux_binprm *bprm)
mpnt->vm_ops = NULL;
mpnt->vm_offset = 0;
mpnt->vm_file = NULL;
- mpnt->vm_private_data = NULL;
+ mpnt->vm_private_data = (void *) 0;
insert_vm_struct(current->mm, mpnt);
current->mm->total_vm = (mpnt->vm_end - mpnt->vm_start) >> PAGE_SHIFT;
}
@@ -753,12 +754,12 @@ int do_execve(char * filename, char ** argv, char ** envp, struct pt_regs * regs
bprm.sh_bang = 0;
bprm.loader = 0;
bprm.exec = 0;
- if ((bprm.argc = count(argv)) < 0) {
+ if ((bprm.argc = count(argv, bprm.p / sizeof(void *))) < 0) {
dput(dentry);
return bprm.argc;
}
- if ((bprm.envc = count(envp)) < 0) {
+ if ((bprm.envc = count(envp, bprm.p / sizeof(void *))) < 0) {
dput(dentry);
return bprm.envc;
}