From a8d77fb91a82b6cc68749bfe507a2d4c40255c24 Mon Sep 17 00:00:00 2001 From: Emily Stark Date: Fri, 26 Sep 2014 14:23:57 -0700 Subject: [PATCH] Fix check for valid parent id. Parse as decimal (which means you can't specify --parent-pid in hex, that's fine). And convert back to string to check that the whole string was parsed as an int (i.e. "123foobar" should not be converted to "123"). Thanks Slava and Avital. --- packages/webapp/webapp_server.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/webapp/webapp_server.js b/packages/webapp/webapp_server.js index 448905b51c..3ae194b44e 100644 --- a/packages/webapp/webapp_server.js +++ b/packages/webapp/webapp_server.js @@ -69,8 +69,8 @@ var initKeepalive = function () { // takes the parent process's place before the child process dies. var startCheckForLiveParent = function (parentPid) { if (parentPid) { - // Check that we have a pid that looks like an integer. - if (+parseInt(parentPid) !== parentPid) { + // Check that we have a pid that looks like a decimal integer. + if ("" + parseInt(parentPid, 10) !== parentPid) { console.error("--parent-pid must be a valid process ID."); process.exit(1); }