php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68146 Condition Grouping Review (zend_virtual_cwd.h)
Submitted: 2014-10-03 19:06 UTC Modified: 2014-10-03 19:51 UTC
From: pegasus at vaultwiki dot org Assigned:
Status: Not a bug Package: *General Issues
PHP Version: master-Git-2014-10-03 (Git) OS:
Private report: No CVE-ID: None
 [2014-10-03 19:06 UTC] pegasus at vaultwiki dot org
Description:
------------
I was just reading through recent commits and saw this for zend/zend_virtual_cwd.h (commit# 647ebe6bf214d1a30627bab1758b66262d2f780f)

-       (len >= 2 && ((/* is local */isalpha(path[0]) && path[1] == ':') || /* is UNC */IS_SLASH(path[0]) && IS_SLASH(path[1])))
+       (len >= 2 && (/* is local */isalpha(path[0]) && path[1] == ':' || /* is UNC */IS_SLASH(path[0]) && IS_SLASH(path[1])))

I could be forgetting my order of operations, but I think the lack of grouping and similar operations causes LTR here... Shouldn't the proper parenthetical grouping be:

       (len >= 2 && ((/* is local */isalpha(path[0]) && path[1] == ':') || (/* is UNC */IS_SLASH(path[0]) && IS_SLASH(path[1]))))

Here it is tabulated for clarity:

(
	len >= 2 &&
	(
		(
			/* is local */
			isalpha(path[0]) &&
			path[1] == ':'
		) ||
		(
			/* is UNC */
			IS_SLASH(path[0]) &&
			IS_SLASH(path[1])
		)
	)
)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-10-03 19:51 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2014-10-03 19:51 UTC] requinix@php.net
&& has higher precedence than || so the parentheses aren't needed.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 06:01:30 2024 UTC