Changeset 3785


Ignore:
Timestamp:
Mar 22, 2012, 7:36:39 PM (13 years ago)
Author:
bird
Message:

spawnve.c: fixed memmove in the bang-hash-script path that moved too much and could cause heap trouble under the right weather conditions. Fixes #253.

Location:
trunk/libc/src/kNIX/os2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/libc/src/kNIX/os2

  • trunk/libc/src/kNIX/os2/__spawnve.c

    r3644 r3785  
    178178  while (cbArgs + n > cbArgsBuf) \
    179179    { \
     180      char *pszOld = pszArgsBuf; \
    180181      cbArgsBuf += 512; \
    181182      pszArgsBuf = _trealloc (pszArgsBuf, cbArgsBuf); \
    182       if (pszArgsBuf == NULL) \
     183      if (__predict_false(pszArgsBuf == NULL)) \
    183184        { \
     185          _tfree (pszOld); \
    184186          errno = ENOMEM; \
    185187          LIBCLOG_RETURN_INT(-1); \
     
    236238
    237239    /*
    238      * cmd.exe and 4os2.exe needs different argument handling, and 
    239      * starting with kLIBC 0.6.4 we can pass argv directly to LIBC 
     240     * cmd.exe and 4os2.exe needs different argument handling, and
     241     * starting with kLIBC 0.6.4 we can pass argv directly to LIBC
    240242     * programs.
    241243     * (1 == cmd or 4os2 shell, 0 == anything else)
     
    531533
    532534                /* grow and shift the argument buffer. */
     535                size_t cbToMove = cbArgs; /* (ADD modifies cbArgs) */
    533536                ADD(cch);
    534537                psz = pszArgsBuf + strlen(pszArgsBuf) + 1;
    535                 memmove(psz + cch, psz, cbArgs);
     538                memmove(psz + cch, psz, cbToMove);
    536539
    537540                /* add arguments */
Note: See TracChangeset for help on using the changeset viewer.