From reviews-return-32686-apmail-mesos-reviews-archive=mesos.apache.org@mesos.apache.org Sat Apr 30 01:04:39 2016 Return-Path: X-Original-To: apmail-mesos-reviews-archive@minotaur.apache.org Delivered-To: apmail-mesos-reviews-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5D7A3199EC for ; Sat, 30 Apr 2016 01:04:39 +0000 (UTC) Received: (qmail 32109 invoked by uid 500); 30 Apr 2016 01:04:39 -0000 Delivered-To: apmail-mesos-reviews-archive@mesos.apache.org Received: (qmail 32079 invoked by uid 500); 30 Apr 2016 01:04:39 -0000 Mailing-List: contact reviews-help@mesos.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: reviews@mesos.apache.org Delivered-To: mailing list reviews@mesos.apache.org Received: (qmail 32056 invoked by uid 99); 30 Apr 2016 01:04:38 -0000 Received: from reviews-vm.apache.org (HELO reviews.apache.org) (140.211.11.40) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 30 Apr 2016 01:04:38 +0000 Received: from reviews.apache.org (localhost [127.0.0.1]) by reviews.apache.org (Postfix) with ESMTP id 955382B3F9D; Sat, 30 Apr 2016 01:04:33 +0000 (UTC) Content-Type: multipart/alternative; boundary="===============6430606699756749158==" MIME-Version: 1.0 Subject: Re: Review Request 46608: Libprocess: Implemented `subprocess_windows.cpp`. From: Michael Park To: M Lawindi , Alex Naparu , Michael Park , Joris Van Remoortere , Artem Harutyunyan , Daniel Pravat , Yi Sun Cc: mesos , Alex Clemmer Date: Sat, 30 Apr 2016 01:04:33 -0000 Message-ID: <20160430010433.26196.99963@reviews.apache.org> X-ReviewBoard-URL: https://reviews.apache.org/ Auto-Submitted: auto-generated Sender: Michael Park X-ReviewGroup: mesos X-Auto-Response-Suppress: DR, RN, OOF, AutoReply X-ReviewRequest-URL: https://reviews.apache.org/r/46608/ X-Sender: Michael Park References: <20160423234155.8135.77581@reviews.apache.org> In-Reply-To: <20160423234155.8135.77581@reviews.apache.org> X-ReviewBoard-Diff-For: 3rdparty/libprocess/src/subprocess_windows.cpp Reply-To: Michael Park X-ReviewRequest-Repository: mesos --===============6430606699756749158== MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/46608/#review131235 ----------------------------------------------------------- 3rdparty/libprocess/src/subprocess_windows.cpp (lines 305 - 352) (1) According to the "Security Remarks" section of https://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx, it's recommended that we set the `lpApplicationName` parameter, rather than embedding the module name inside the `lpCommandLine` parameter since we need to make sure that the modulen name in `lpCommandLine` needs to be wrapped in quotes in case of spaces in the name. We don't seem to be doing this correctly. (2) `argumentsEscaped` is `new`ed, but not `delete`d, and according to the documentation for `CreateProcess`, it does not call `delete` on `lpCommandLine`. It looks like we're leaking? (3) Are we required to escape the quotes like we're doing here for `argumentsEscaped`...? I don't see anything like this in the documentation. What I would prefer to do here I think is to take a `argv` by value, then do: ```cpp string program = argv[0]; argv.erase(argv.begin()); string args = strings::join(" ", argv); ... = CreateProcess( program.data(), args.data(), ...); ``` If we wanted to avoid using `lpApplicationName` for whatever reason, how about: ```cpp string program = "\"" + argv[0] + "\""; argv.erase(argv.begin()); string args = strings::join(" ", argv); string cmd = strings::join(" ", program, args); ... = CreateProcess( NULL, cmd.data(), ...); ``` - Michael Park On April 23, 2016, 11:41 p.m., Alex Clemmer wrote: > > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > https://reviews.apache.org/r/46608/ > ----------------------------------------------------------- > > (Updated April 23, 2016, 11:41 p.m.) > > > Review request for mesos, Alex Naparu, Daniel Pravat, Artem Harutyunyan, Joris Van Remoortere, Michael Park, M Lawindi, and Yi Sun. > > > Bugs: MESOS-3637 > https://issues.apache.org/jira/browse/MESOS-3637 > > > Repository: mesos > > > Description > ------- > > Libprocess: Implemented `subprocess_windows.cpp`. > > > Diffs > ----- > > 3rdparty/libprocess/src/subprocess_windows.cpp PRE-CREATION > > Diff: https://reviews.apache.org/r/46608/diff/ > > > Testing > ------- > > > Thanks, > > Alex Clemmer > > --===============6430606699756749158==--