MCPcopy Create free account
hub / github.com/boostorg/build / exec_check

Function exec_check

src/engine/execnt.c:207–261  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

205 */
206
207int exec_check
208(
209 string const * command,
210 LIST * * pShell,
211 int * error_length,
212 int * error_max_length
213)
214{
215 /* Default shell does nothing when triggered with an empty or a
216 * whitespace-only command so we simply skip running it in that case. We
217 * still pass them on to non-default shells as we do not really know what
218 * they are going to do with such commands.
219 */
220 if ( list_empty( *pShell ) )
221 {
222 char const * s = command->value;
223 while ( isspace( *s ) ) ++s;
224 if ( !*s )
225 return EXEC_CHECK_NOOP;
226 }
227
228 /* Check prerequisites for executing raw commands. */
229 if ( is_raw_command_request( *pShell ) )
230 {
231 int const raw_cmd_length = raw_command_length( command->value );
232 if ( raw_cmd_length < 0 )
233 {
234 /* Invalid characters detected - fallback to default shell. */
235 list_free( *pShell );
236 *pShell = L0;
237 }
238 else if ( raw_cmd_length > MAX_RAW_COMMAND_LENGTH )
239 {
240 *error_length = raw_cmd_length;
241 *error_max_length = MAX_RAW_COMMAND_LENGTH;
242 return EXEC_CHECK_TOO_LONG;
243 }
244 else
245 return raw_cmd_length ? EXEC_CHECK_OK : EXEC_CHECK_NOOP;
246 }
247
248 /* Now we know we are using an external shell. Note that there is no need to
249 * check for too long command strings when using an external shell since we
250 * use a command file and assume no one is going to set up a JAMSHELL format
251 * string longer than a few hundred bytes at most which should be well under
252 * the total command string limit. Should someone actually construct such a
253 * JAMSHELL value it will get reported as an 'invalid parameter'
254 * CreateProcessA() Windows API failure which seems like a good enough
255 * result for such intentional mischief.
256 */
257
258 /* Check for too long command lines. */
259 return check_cmd_for_too_long_lines( command->value, maxline(),
260 error_length, error_max_length );
261}
262
263
264/*

Callers 1

make1cmdsFunction · 0.70

Calls 5

is_raw_command_requestFunction · 0.85
raw_command_lengthFunction · 0.85
list_freeFunction · 0.85
maxlineFunction · 0.85

Tested by

no test coverage detected