Changeset 3784 for branches


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

0.6/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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/libc-0.6/src/emx/src/lib/sys/__spawnve.c

    r3645 r3784  
    164164  while (cbArgs + n > cbArgsBuf) \
    165165    { \
     166      char *pszOld = pszArgsBuf; \
    166167      cbArgsBuf += 512; \
    167168      pszArgsBuf = _trealloc (pszArgsBuf, cbArgsBuf); \
    168       if (pszArgsBuf == NULL) \
     169      if (__predict_false(pszArgsBuf == NULL)) \
    169170        { \
     171          _tfree (pszOld); \
    170172          errno = ENOMEM; \
    171173          LIBCLOG_RETURN_INT(-1); \
     
    222224
    223225    /*
    224      * cmd.exe and 4os2.exe needs different argument handling, and 
    225      * starting with kLIBC 0.6.4 we can pass argv directly to LIBC 
     226     * cmd.exe and 4os2.exe needs different argument handling, and
     227     * starting with kLIBC 0.6.4 we can pass argv directly to LIBC
    226228     * programs.
    227229     * (1 == cmd or 4os2 shell, 0 == anything else)
     
    517519
    518520                /* grow and shift the argument buffer. */
     521                size_t cbToMove = cbArgs; /* (ADD modifies cbArgs) */
    519522                ADD(cch);
    520523                psz = pszArgsBuf + strlen(pszArgsBuf) + 1;
    521                 memmove(psz + cch, psz, cbArgs);
     524                memmove(psz + cch, psz, cbToMove);
    522525
    523526                /* add arguments */
Note: See TracChangeset for help on using the changeset viewer.