Re: [PATCH 2 of 2] lfs: ensure the transfer request is for a known URI

2018-04-01 Thread Yuya Nishihara
On Sun, 01 Apr 2018 00:00:55 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison 
> # Date 1522555088 14400
> #  Sat Mar 31 23:58:08 2018 -0400
> # Node ID 61133b211f50194afc52f576d93c58d3f5f6c529
> # Parent  bdef5a344ebfd54cf454b184e14d0c37400f7547
> lfs: ensure the transfer request is for a known URI

Queued, thanks.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 2 of 2] lfs: ensure the transfer request is for a known URI

2018-03-31 Thread Matt Harbison
# HG changeset patch
# User Matt Harbison 
# Date 1522555088 14400
#  Sat Mar 31 23:58:08 2018 -0400
# Node ID 61133b211f50194afc52f576d93c58d3f5f6c529
# Parent  bdef5a344ebfd54cf454b184e14d0c37400f7547
lfs: ensure the transfer request is for a known URI

Since the dispatching code only checks the beginning of the string, this
enforces that there's only one more path component.

diff --git a/hgext/lfs/wireprotolfsserver.py b/hgext/lfs/wireprotolfsserver.py
--- a/hgext/lfs/wireprotolfsserver.py
+++ b/hgext/lfs/wireprotolfsserver.py
@@ -22,6 +22,7 @@ from mercurial import (
 HTTP_OK = hgwebcommon.HTTP_OK
 HTTP_CREATED = hgwebcommon.HTTP_CREATED
 HTTP_BAD_REQUEST = hgwebcommon.HTTP_BAD_REQUEST
+HTTP_NOT_FOUND = hgwebcommon.HTTP_NOT_FOUND
 
 def handlewsgirequest(orig, rctx, req, res, checkperm):
 """Wrap wireprotoserver.handlewsgirequest() to possibly process an LFS
@@ -241,6 +242,10 @@ def _processbasictransfer(repo, req, res
 oid = req.dispatchparts[-1]
 localstore = repo.svfs.lfslocalblobstore
 
+if len(req.dispatchparts) != 4:
+_sethttperror(res, HTTP_NOT_FOUND)
+return True
+
 if method == b'PUT':
 checkperm('upload')
 
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel