php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34463 eval/new COM => hang on com_print_typeinfo
Submitted: 2005-09-11 14:40 UTC Modified: 2005-09-11 15:15 UTC
From: csaba at alum dot mit dot edu Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5CVS-2005-09-11 (snap) OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: csaba at alum dot mit dot edu
New email:
PHP Version: OS:

 

 [2005-09-11 14:40 UTC] csaba at alum dot mit dot edu
Description:
------------
If I do eval('$com=new COM("WScript.Shell");');
then gettype($com) is the empty string
while com_print_typeinfo($com) leads to the CLI / Apache error  dialog box asking whether I want to send Microsoft a report about it.

Nevertheless, the $com object is (at least somewhat) valid because I can subsequently (if I didn't do a com_print_typeinfo) do other things with it.  Thus, gettype is incorrect, and com_print_typeinfo should not crash PHP.

Csaba Gabor from Vienna
PS.  Uncomment any of the 3 new COM lines, and it runs
         as expected.
     Marked as a Scripting Engine Problem since the
         problem seems to start in the eval line.

Reproduce code:
---------------
<?php
print "<pre>\n";
$oEnv = newCOM("WScript.Shell")->Environment("process");
foreach ($oEnv as $idx=>$val) print "$idx: $val\n";
print "</pre>";

function newCOM($comSpec) {
  $eval = '$newCom = new COM("' . $comSpec . '");';
  print ("going to eval: $eval\n");
  try { eval($eval); }
  catch (Exception $e) {
    output("Could not load COM: $comSpec"); return null; }

//$newCOM = new COM("WScript.Shell");
//$newCOM = new COM(&$comSpec);
//$newCOM = new COM($comSpec);

  print "newCOM has gettype: " .  gettype($newCOM) . "\n";
  print "          typename: " . typename($newCOM) . "\n\n";
  com_print_typeinfo($newCOM);
  return $newCom;
}

function typename($objCOM) {
    if (is_null($objCOM)) return null;
    $oScript = new COM("MSScriptControl.ScriptControl");
    $oScript->language = "VBScript";
    $oScript->addObject("objCom",$objCOM);
    return $oScript->eval("typename(objCom)");
}
?>

Expected result:
----------------
After the 'going to eval' line, I expect to see:
newCOM has gettype: object
          typename: IWshShell3


Actual result:
--------------
newCOM has gettype: NULL
          typename: 

followed by a PHP crash

If you remove the com_print_typeinfo line, the rest of the code executes as expected.  In other words, the COM object functions so the gettype is still wrong.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-09-11 15:15 UTC] csaba at alum dot mit dot edu
My apologies.  When you stare at $newCom and $newCOM they sometimes look the same, but they aren't.

Csaba

PS.  Sniper: now this report is one you could corrupt!
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 27 07:00:02 2025 UTC