Changeset 3322


Ignore:
Timestamp:
Nov 10, 2008, 11:51:29 PM (11 years ago)
Author:
Pascal Terjan
Message:
  • Add comments to mytrace_exec
File:
1 edited

Legend:

Unmodified
Added
Removed
  • neercs/trunk/src/mytrace.c

    r3320 r3322  
    335335    ssize_t envsize = 16*1024;
    336336    int ret, fd, l, l2;
    337     char *newargv[] = { NULL };
     337    char *nullp = NULL;
    338338    ssize_t r;
    339339
     
    373373    }
    374374    envsize = r;
     375    l2 = sizeof(char *); /* Size of a pointer */
     376    p2 = regs.RSP;
     377
     378    /* First argument is the command string */
    375379    l = strlen(command)+1;
    376     l2 = sizeof(char *);
    377     p2 = regs.RSP;
    378380    memcpy_into_target(t, p2, command, l);
    379381    p2 += l;
     382
     383    /* Second argument is argv */
    380384    argvaddr = p2;
     385    /* argv[0] is a pointer to the command string */
    381386    memcpy_into_target(t, p2, (char *)&regs.RSP, l2);
    382387    p2 += l2;
    383     memcpy_into_target(t, p2, (char *)&newargv, l2);
     388    /* Then follows a NULL pointer */
     389    memcpy_into_target(t, p2, (char *)&nullp, l2);
    384390    p2 += l2;
     391
     392    /* Third argument is the environment */
     393    /* First, copy all the strings */
    385394    memcpy_into_target(t, p2, env, envsize);
    386395    envaddr = p2;
    387396    p2 += envsize;
     397    /* Then write an array of pointers to the strings */
    388398    envptraddr = p2;
    389399    p = env;
     
    395405        p += strlen(p)+1;
    396406    }
    397     memcpy_into_target(t, p2, (char *)&newargv, l2);
     407    /* And have a NULL pointer at the end of the array */
     408    memcpy_into_target(t, p2, (char *)&nullp, l2);
    398409    free(env);
     410
    399411    ret = remote_syscall(t, MYCALL_EXECVE, regs.RSP, argvaddr, envptraddr);
    400412
Note: See TracChangeset for help on using the changeset viewer.