VirtualBox

Changeset 1838 in kBuild for trunk/src/kmk


Ignore:
Timestamp:
Oct 11, 2008 7:34:24 PM (16 years ago)
Author:
bird
Message:

kmk: fixed string termination for three strcache_add_len calls. (it will copy the string to the stack if it's not terminated.)

Location:
trunk/src/kmk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/function.c

    r1836 r1838  
    289289        }
    290290    }
     291#ifndef CONFIG_WITH_VALUE_LENGTH
    291292  if (doneany)
    292293    /* Kill the last space.  */
    293294    --o;
     295#else
     296  /* Kill the last space and make sure there is a terminator there
     297     so that strcache_add_len doesn't have to do a lot of exacty work
     298     when expand_deps sends the output its way. */
     299  if (doneany)
     300    *--o = '\0';
     301  else
     302    o = variable_buffer_output (o, "\0", 1) - 1;
     303#endif
    294304
    295305  return o;
  • trunk/src/kmk/read.c

    r1831 r1838  
    14261426            /* Put all the prerequisites here; they'll be parsed later.  */
    14271427            deps = alloc_dep ();
     1428#ifndef CONFIG_WITH_VALUE_LENGTH
    14281429            deps->name = strcache_add_len (beg, end - beg + 1);
     1430#else  /* CONFIG_WITH_VALUE_LENGTH */
     1431            {
     1432              /* Make sure the strcache_add_len input is terminated so it
     1433                 doesn't have to make a temporary copy on the stack. */
     1434              char saved = end[1];
     1435              ((char *)end)[1] = '\0';
     1436            deps->name = strcache_add_len (beg, end - beg + 1);
     1437              ((char *)end)[1] = saved;
     1438            }
     1439#endif /* CONFIG_WITH_VALUE_LENGTH */
    14291440          }
    14301441        else
     
    29782989          free (qbase);
    29792990        }
    2980 #else
     2991#elif !defined(CONFIG_WITH_VALUE_LENGTH)
    29812992        name = strcache_add_len (q, p - q);
    2982 #endif
     2993#else  /* CONFIG_WITH_VALUE_LENGTH */
     2994       {
     2995         /* Make sure it's terminated, strcache_add_len has to make a
     2996            temp copy on the stack otherwise. */
     2997         char saved = *p;
     2998         *p = '\0';
     2999         name = strcache_add_len (q, p - q);
     3000         *p = saved;
     3001       }
     3002#endif /* CONFIG_WITH_VALUE_LENGTH */
    29833003
    29843004      /* Add it to the front of the chain.  */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette