From: Frank Lichtenheld Date: Thu, 7 Jun 2007 14:57:00 +0000 (+0200) Subject: cvsserver: Make req_Root more critical of its input data X-Git-Tag: v1.5.3-rc0~145 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=4890888d742e12044b1f4b89a5d10437a6371253;p=git.git cvsserver: Make req_Root more critical of its input data The path submitted with the Root request has to be absolute (cvs does it this way and it may save us some sanity checks later) If multiple roots are specified (e.g. because we use pserver authentication which will already include the root), ensure that they say all the same. Probably neither is a security risk, and neither should ever be triggered by a sane client, but when validating input data, it's better to be save than sorry. Signed-off-by: Frank Lichtenheld Signed-off-by: Junio C Hamano --- diff --git a/git-cvsserver.perl b/git-cvsserver.perl index 2b4825a8e..d41b29f30 100755 --- a/git-cvsserver.perl +++ b/git-cvsserver.perl @@ -167,6 +167,17 @@ sub req_Root my ( $cmd, $data ) = @_; $log->debug("req_Root : $data"); + unless ($data =~ m#^/#) { + print "error 1 Root must be an absolute pathname\n"; + return 0; + } + + if ($state->{CVSROOT} + && ($state->{CVSROOT} ne $data)) { + print "error 1 Conflicting roots specified\n"; + return 0; + } + $state->{CVSROOT} = $data; $ENV{GIT_DIR} = $state->{CVSROOT} . "/"; diff --git a/t/t9400-git-cvsserver-server.sh b/t/t9400-git-cvsserver-server.sh index e9ef31517..41dcf646d 100755 --- a/t/t9400-git-cvsserver-server.sh +++ b/t/t9400-git-cvsserver-server.sh @@ -110,6 +110,40 @@ test_expect_success 'pserver authentication failure (login/non-anonymous user)' tail -n1 log | grep -q "^I HATE YOU$"' +# misuse pserver authentication for testing of req_Root + +cat >request-relative <request-conflict <log 2>&1 + then + echo unexpected success + false + else + true + fi && + tail log | grep -q "^error 1 Root must be an absolute pathname$"' + +test_expect_success 'req_Root failure (conflicting roots)' \ + 'cat request-conflict | git-cvsserver pserver >log 2>&1 && + tail log | grep -q "^error 1 Conflicting roots specified$"' + + #-------------- # CONFIG TESTS #--------------