github-advanced-security[bot] commented on code in PR #1258:
URL: https://github.com/apache/tomcat/pull/1258#discussion_r4629489838
##########
java/org/apache/catalina/servlets/WebdavServlet.java:
##########
@@ -2091,6 +2097,7 @@
if (slash < 0) {
break;
}
+ directParent = memberChange && parentPath == path;
Review Comment:
## CodeQL / Reference equality test on strings
String values compared with ==.
[Show more
details](https://github.com/apache/tomcat/security/code-scanning/1298)
##########
java/org/apache/catalina/servlets/WebdavServlet.java:
##########
@@ -2037,33 +2039,37 @@
ifHeader = "";
}
- return isLocked(path, req.getRemoteUser(), ifHeader);
+ return isLocked(path, req.getRemoteUser(), ifHeader, memberChange);
}
/**
* Check to see if a resource is currently write locked.
*
- * @param path Path of the resource
- * @param principal The authenticated principal name
- * @param ifHeader "If" HTTP header which was included in the request
+ * @param path Path of the resource
+ * @param principal The authenticated principal name
+ * @param ifHeader "If" HTTP header which was included in the request
+ * @param memberChange {@code true} if the request adds or removes the
resource as an internal member of its parent
+ * collection
*
* @return <code>true</code> if the resource is locked (and no appropriate
lock token has been found for at least
* one of the non-shared locks which are present on the
resource).
*/
- private boolean isLocked(String path, String principal, String ifHeader) {
+ private boolean isLocked(String path, String principal, String ifHeader,
boolean memberChange) {
boolean unmatchedSharedLock = false;
// Check if the resource or a parent is already locked
String parentPath = path;
+ // RFC 4918, section 7.5: a write lock on a collection, including a
depth 0 lock, protects its internal members
+ boolean directParent = false;
do {
LockInfo parentLock = resourceLocks.get(parentPath);
if (parentLock != null) {
if (parentLock.hasExpired()) {
resourceLocks.remove(parentPath);
} else {
// parentPath == path is a check for the first loop
- if (parentPath == path || parentLock.depth > 0) {
+ if (parentPath == path || parentLock.depth > 0 ||
directParent) {
Review Comment:
## CodeQL / Reference equality test on strings
String values compared with ==.
[Show more
details](https://github.com/apache/tomcat/security/code-scanning/1296)
##########
java/org/apache/catalina/servlets/WebdavServlet.java:
##########
@@ -2072,7 +2078,7 @@
LockInfo lock = sharedLocks.get(token);
if (lock != null) {
// The shared lock might not have the same
depth
- if (parentPath == path || lock.depth > 0) {
+ if (parentPath == path || lock.depth > 0
|| directParent) {
Review Comment:
## CodeQL / Reference equality test on strings
String values compared with ==.
[Show more
details](https://github.com/apache/tomcat/security/code-scanning/1297)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]