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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: pegasus at vaultwiki dot org
New email:
PHP Version: OS:

 

 [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

Add a Patch

Pull Requests

Add a Pull Request

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: Wed Apr 24 08:01:29 2024 UTC