patch-1.3.68 linux/fs/exec.c
Next file: linux/fs/fat/inode.c
Previous file: linux/drivers/scsi/scsi.c
Back to the patch index
Back to the overall index
- Lines: 45
- Date:
Wed Feb 21 08:33:22 1996
- Orig file:
v1.3.67/linux/fs/exec.c
- Orig date:
Tue Feb 20 14:37:26 1996
diff -u --recursive --new-file v1.3.67/linux/fs/exec.c linux/fs/exec.c
@@ -290,7 +290,7 @@
unsigned long copy_strings(int argc,char ** argv,unsigned long *page,
unsigned long p, int from_kmem)
{
- char *tmp, *pag = NULL;
+ char *tmp, *tmp1, *pag = NULL;
int len, offset = 0;
unsigned long old_fs, new_fs;
@@ -303,14 +303,12 @@
while (argc-- > 0) {
if (from_kmem == 1)
set_fs(new_fs);
- if (!(tmp = get_user(argv+argc)))
+ if (!(tmp1 = tmp = get_user(argv+argc)))
panic("VFS: argc is wrong");
if (from_kmem == 1)
set_fs(old_fs);
- len=0; /* remember zero-padding */
- do {
- len++;
- } while (get_user(tmp++));
+ while (get_user(tmp++));
+ len = tmp - tmp1;
if (p < len) { /* this shouldn't happen - 128kB */
set_fs(old_fs);
return 0;
@@ -329,7 +327,16 @@
set_fs(new_fs);
}
- *(pag + offset) = get_user(tmp);
+ if (len == 0 || offset == 0)
+ *(pag + offset) = get_user(tmp);
+ else {
+ int bytes_to_copy = (len > offset) ? offset : len;
+ tmp -= bytes_to_copy;
+ p -= bytes_to_copy;
+ offset -= bytes_to_copy;
+ len -= bytes_to_copy;
+ memcpy_fromfs(pag + offset, tmp, bytes_to_copy + 1);
+ }
}
}
if (from_kmem==2)
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov
with Sam's (original) version of this