Ignore:
Timestamp:
Apr 19, 2011, 11:12:07 PM (14 years ago)
Author:
Yuri Dario
Message:

clamav: update trunk to 0.97.

Location:
clamav/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • clamav/trunk

  • TabularUnified clamav/trunk/libclamav/c++/llvm/lib/System/Win32/Program.inc

    r189 r319  
    139139}
    140140
     141
     142/// ArgLenWithQuotes - Check whether argument needs to be quoted when calling
     143/// CreateProcess and returns length of quoted arg with escaped quotes
     144static unsigned int ArgLenWithQuotes(const char *Str) {
     145  unsigned int len = ArgNeedsQuotes(Str) ? 2 : 0;
     146
     147  while (*Str != '\0') {
     148    if (*Str == '\"')
     149      ++len;
     150
     151    ++len;
     152    ++Str;
     153  }
     154
     155  return len;
     156}
     157
     158
    141159bool
    142160Program::Execute(const Path& path,
     
    166184  unsigned len = 0;
    167185  for (unsigned i = 0; args[i]; i++) {
    168     len += strlen(args[i]) + 1;
    169     if (ArgNeedsQuotes(args[i]))
    170       len += 2;
     186    len += ArgLenWithQuotes(args[i]) + 1;
    171187  }
    172188
     
    177193  for (unsigned i = 0; args[i]; i++) {
    178194    const char *arg = args[i];
    179     size_t len = strlen(arg);
     195
    180196    bool needsQuoting = ArgNeedsQuotes(arg);
    181197    if (needsQuoting)
    182198      *p++ = '"';
    183     memcpy(p, arg, len);
    184     p += len;
     199
     200    while (*arg != '\0') {
     201      if (*arg == '\"')
     202        *p++ = '\\';
     203
     204      *p++ = *arg++;
     205    }
     206
    185207    if (needsQuoting)
    186208      *p++ = '"';
Note: See TracChangeset for help on using the changeset viewer.