@matheusbsbs / matheus-bagliano / commits / 4890888d74
Fork 0

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 <frank@lichtenheld.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Frank Lichtenheld committed Jun 7, 2007 at 16:57 UTC 4890888d742e12044b1f4b89a5d10437a6371253
2 files changed +45
git-cvsserver.perl
+11
@@ -167,6 +167,17 @@ sub req_Root
167 my ( $cmd, $data ) = @_;
168 $log->debug("req_Root : $data");
169
170 + unless ($data =~ m#^/#) {
171 + print "error 1 Root must be an absolute pathname\n";
172 + return 0;
173 + }
174 +
175 + if ($state->{CVSROOT}
176 + && ($state->{CVSROOT} ne $data)) {
177 + print "error 1 Conflicting roots specified\n";
178 + return 0;
179 + }
180 +
181 $state->{CVSROOT} = $data;
182
183 $ENV{GIT_DIR} = $state->{CVSROOT} . "/";
t/t9400-git-cvsserver-server.sh
+34
@@ -110,6 +110,40 @@ test_expect_success 'pserver authentication failure (login/non-anonymous user)'
110 tail -n1 log | grep -q "^I HATE YOU$"'
111
112
113 +# misuse pserver authentication for testing of req_Root
114 +
115 +cat >request-relative <<EOF
116 +BEGIN AUTH REQUEST
117 +gitcvs.git
118 +anonymous
119 +
120 +END AUTH REQUEST
121 +EOF
122 +
123 +cat >request-conflict <<EOF
124 +BEGIN AUTH REQUEST
125 +$SERVERDIR
126 +anonymous
127 +
128 +END AUTH REQUEST
129 +Root $WORKDIR
130 +EOF
131 +
132 +test_expect_success 'req_Root failure (relative pathname)' \
133 + 'if cat request-relative | git-cvsserver pserver >log 2>&1
134 + then
135 + echo unexpected success
136 + false
137 + else
138 + true
139 + fi &&
140 + tail log | grep -q "^error 1 Root must be an absolute pathname$"'
141 +
142 +test_expect_success 'req_Root failure (conflicting roots)' \
143 + 'cat request-conflict | git-cvsserver pserver >log 2>&1 &&
144 + tail log | grep -q "^error 1 Conflicting roots specified$"'
145 +
146 +
147 #--------------
148 # CONFIG TESTS
149 #--------------