@@ -742,7 +742,7 @@ int DOCKER_CONN::init(DOCKER_TYPE docker_type, bool _verbose) {
742742}
743743#endif
744744
745- // issue a Docker command and return its output
745+ // issue a Docker command and return its output (stdout + stderr)
746746// as a vector of lines (\n-terminated)
747747//
748748int DOCKER_CONN::command (const char * cmd, vector<string> &out) {
@@ -758,7 +758,7 @@ int DOCKER_CONN::command(const char* cmd, vector<string> &out) {
758758 // In the Win case we read the output from a pipe.
759759 // Append 'EOM' to the output so we know when we've reached the end
760760
761- snprintf (buf, sizeof (buf), " %s %s; echo EOM\n " , cli_prog, cmd);
761+ snprintf (buf, sizeof (buf), " %s %s 2>&1 ; echo EOM\n " , cli_prog, cmd);
762762 write_to_pipe (ctl_wc.in_write , buf);
763763 retval = read_from_pipe (
764764 ctl_wc.out_read , ctl_wc.proc_handle , output, CMD_TIMEOUT, " EOM"
@@ -770,7 +770,7 @@ int DOCKER_CONN::command(const char* cmd, vector<string> &out) {
770770 out = split (output, ' \n ' );
771771#else
772772 snprintf (buf, sizeof (buf),
773- " %s %s" ,
773+ " %s %s 2>&1 " ,
774774 cli_prog, cmd
775775 );
776776 retval = run_command (buf, out);
@@ -799,7 +799,7 @@ int DOCKER_CONN::command(const char* cmd, vector<string> &out) {
799799//
800800int DOCKER_CONN::parse_image_name (string line, string &name) {
801801 char buf[1024 ];
802- strcpy (buf, line.c_str ());
802+ safe_strcpy (buf, line.c_str ());
803803 if (strstr (buf, " REPOSITORY" )) return -1 ;
804804 if (strstr (buf, " localhost/" ) != buf) return -1 ;
805805 char *p = buf + strlen (" localhost/" );
@@ -822,7 +822,7 @@ int DOCKER_CONN::parse_image_name(string line, string &name) {
822822
823823int DOCKER_CONN::parse_container_name (string line, string &name) {
824824 char buf[1024 ];
825- strcpy (buf, line.c_str ());
825+ safe_strcpy (buf, line.c_str ());
826826 if (strstr (buf, " CONTAINER" )) return -1 ;
827827 char *p = strrchr (buf, ' ' );
828828 if (!p) return -1 ;
0 commit comments