- Timestamp:
- Apr 19, 2011, 11:12:07 PM (14 years ago)
- Location:
- clamav/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
clamav/trunk ¶
-
Property svn:mergeinfo
set to
/clamav/vendor/0.97 merged eligible
-
Property svn:mergeinfo
set to
-
TabularUnified clamav/trunk/libclamav/c++/llvm/lib/System/Win32/Program.inc ¶
r189 r319 139 139 } 140 140 141 142 /// ArgLenWithQuotes - Check whether argument needs to be quoted when calling 143 /// CreateProcess and returns length of quoted arg with escaped quotes 144 static 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 141 159 bool 142 160 Program::Execute(const Path& path, … … 166 184 unsigned len = 0; 167 185 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; 171 187 } 172 188 … … 177 193 for (unsigned i = 0; args[i]; i++) { 178 194 const char *arg = args[i]; 179 size_t len = strlen(arg); 195 180 196 bool needsQuoting = ArgNeedsQuotes(arg); 181 197 if (needsQuoting) 182 198 *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 185 207 if (needsQuoting) 186 208 *p++ = '"';
Note:
See TracChangeset
for help on using the changeset viewer.