[BACK]Return to kern_exec.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / kern

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/sys/kern/kern_exec.c between version 1.203 and 1.204

version 1.203, 2005/07/10 04:20:34 version 1.204, 2005/07/11 20:15:26
Line 363  bad1:
Line 363  bad1:
 #define STACK_PTHREADSPACE 0  #define STACK_PTHREADSPACE 0
 #endif  #endif
   
   static int
   execve_fetch_element(char * const *array, size_t index, char **value)
   {
           return copyin(array + index, value, sizeof(*value));
   }
   
 /*  /*
  * exec system call   * exec system call
  */   */
Line 375  sys_execve(struct lwp *l, void *v, regis
Line 381  sys_execve(struct lwp *l, void *v, regis
                 syscallarg(char * const *)      argp;                  syscallarg(char * const *)      argp;
                 syscallarg(char * const *)      envp;                  syscallarg(char * const *)      envp;
         } */ *uap = v;          } */ *uap = v;
   
           return execve1(l, SCARG(uap, path), SCARG(uap, argp),
               SCARG(uap, envp), execve_fetch_element);
   }
   
   int
   execve1(struct lwp *l, const char *path, char * const *args,
       char * const *envs, execve_fetch_element_t fetch_element)
   {
         int                     error;          int                     error;
         u_int                   i;          u_int                   i;
         struct exec_package     pack;          struct exec_package     pack;
Line 383  sys_execve(struct lwp *l, void *v, regis
Line 398  sys_execve(struct lwp *l, void *v, regis
         struct proc             *p;          struct proc             *p;
         struct ucred            *cred;          struct ucred            *cred;
         char                    *argp;          char                    *argp;
         char * const            *cpp;  
         char                    *dp, *sp;          char                    *dp, *sp;
         long                    argc, envc;          long                    argc, envc;
         size_t                  len;          size_t                  len;
Line 428  sys_execve(struct lwp *l, void *v, regis
Line 442  sys_execve(struct lwp *l, void *v, regis
         if (ISSET(p->p_flag, P_SYSTRACE))          if (ISSET(p->p_flag, P_SYSTRACE))
                 systrace_execve0(p);                  systrace_execve0(p);
   
         error = copyinstr(SCARG(uap, path), pathbuf, sizeof(pathbuf),          error = copyinstr(path, pathbuf, sizeof(pathbuf),
                           &pathbuflen);                            &pathbuflen);
         if (error)          if (error)
                 goto clrflg;                  goto clrflg;
   
         NDINIT(&nid, LOOKUP, NOFOLLOW, UIO_SYSSPACE, pathbuf, p);          NDINIT(&nid, LOOKUP, NOFOLLOW, UIO_SYSSPACE, pathbuf, p);
 #else  #else
         NDINIT(&nid, LOOKUP, NOFOLLOW, UIO_USERSPACE, SCARG(uap, path), p);          NDINIT(&nid, LOOKUP, NOFOLLOW, UIO_USERSPACE, path, p);
 #endif /* SYSTRACE */  #endif /* SYSTRACE */
   
         /*          /*
Line 444  sys_execve(struct lwp *l, void *v, regis
Line 458  sys_execve(struct lwp *l, void *v, regis
 #ifdef SYSTRACE  #ifdef SYSTRACE
         pack.ep_name = pathbuf;          pack.ep_name = pathbuf;
 #else  #else
         pack.ep_name = SCARG(uap, path);          pack.ep_name = path;
 #endif /* SYSTRACE */  #endif /* SYSTRACE */
         pack.ep_hdr = malloc(exec_maxhdrsz, M_EXEC, M_WAITOK);          pack.ep_hdr = malloc(exec_maxhdrsz, M_EXEC, M_WAITOK);
         pack.ep_hdrlen = exec_maxhdrsz;          pack.ep_hdrlen = exec_maxhdrsz;
Line 499  sys_execve(struct lwp *l, void *v, regis
Line 513  sys_execve(struct lwp *l, void *v, regis
         }          }
   
         /* Now get argv & environment */          /* Now get argv & environment */
         if (!(cpp = SCARG(uap, argp))) {          if (args == NULL) {
                 error = EINVAL;                  error = EINVAL;
                 goto bad;                  goto bad;
         }          }
           /* 'i' will index the argp/envp element to be retrieved */
           i = 0;
         if (pack.ep_flags & EXEC_SKIPARG)          if (pack.ep_flags & EXEC_SKIPARG)
                 cpp++;                  i++;
   
         while (1) {          while (1) {
                 len = argp + ARG_MAX - dp;                  len = argp + ARG_MAX - dp;
                 if ((error = copyin(cpp, &sp, sizeof(sp))) != 0)                  if ((error = (*fetch_element)(args, i, &sp)) != 0)
                         goto bad;                          goto bad;
                 if (!sp)                  if (!sp)
                         break;                          break;
Line 523  sys_execve(struct lwp *l, void *v, regis
Line 538  sys_execve(struct lwp *l, void *v, regis
                         ktrkmem(p, KTR_EXEC_ARG, dp, len - 1);                          ktrkmem(p, KTR_EXEC_ARG, dp, len - 1);
 #endif  #endif
                 dp += len;                  dp += len;
                 cpp++;                  i++;
                 argc++;                  argc++;
         }          }
   
         envc = 0;          envc = 0;
         /* environment need not be there */          /* environment need not be there */
         if ((cpp = SCARG(uap, envp)) != NULL ) {          if (envs != NULL) {
                   i = 0;
                 while (1) {                  while (1) {
                         len = argp + ARG_MAX - dp;                          len = argp + ARG_MAX - dp;
                         if ((error = copyin(cpp, &sp, sizeof(sp))) != 0)                          if ((error = (*fetch_element)(envs, i, &sp)) != 0)
                                 goto bad;                                  goto bad;
                         if (!sp)                          if (!sp)
                                 break;                                  break;
Line 546  sys_execve(struct lwp *l, void *v, regis
Line 562  sys_execve(struct lwp *l, void *v, regis
                                 ktrkmem(p, KTR_EXEC_ENV, dp, len - 1);                                  ktrkmem(p, KTR_EXEC_ENV, dp, len - 1);
 #endif  #endif
                         dp += len;                          dp += len;
                         cpp++;                          i++;
                         envc++;                          envc++;
                 }                  }
         }          }

Legend:
Removed from v.1.203  
changed lines
  Added in v.1.204

CVSweb <webmaster@jp.NetBSD.org>