Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions storm-core/src/native/worker-launcher/impl/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,16 @@ int main(int argc, char **argv) {
exit_code = INVALID_ARGUMENT_NUMBER;
} else {
const char * worker_id = argv[optind++];
int pid = get_docker_container_pid(worker_id);
exit_code = profile_oci_container(pid, argv[optind]);
// Validate the worker id (a type 4 UUID, the same shape as a container
// id) before it is used to build the docker command line.
if (!validate_container_id(worker_id)) {
fprintf(ERRORFILE, "ERROR: Bad worker id in profile-docker-container: %s\n", worker_id);
fflush(ERRORFILE);
exit_code = INVALID_ARGUMENT_NUMBER;
} else {
int pid = get_docker_container_pid(worker_id);
exit_code = profile_oci_container(pid, argv[optind]);
}
}
} else if (strcasecmp("profiler", command) == 0) {
if (argc != 5) {
Expand Down
6 changes: 6 additions & 0 deletions storm-core/src/native/worker-launcher/impl/worker-launcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -1249,6 +1249,12 @@ int get_docker_container_pid(const char *worker_id) {
fflush(LOGFILE);
FILE *inspect_docker = popen(docker_inspect_command, "r");
int pid = -1;
if (inspect_docker == NULL) {
fprintf(ERRORFILE,
"ERROR: Could not run %s in get_docker_container_pid\n", docker_inspect_command);
fflush(ERRORFILE);
goto cleanup;
}
int res = fscanf(inspect_docker, "%d", &pid);
if (pclose(inspect_docker) != 0 || res <= 0) {
fprintf(ERRORFILE,
Expand Down
Loading