From: "H. Peter Anvin" <hpa@zytor.com>
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: Junio C Hamano <junkio@cox.net>, git@vger.kernel.org
Subject: [PATCH] Revised - git-daemon extra paranoia
Date: Tue, 18 Oct 2005 15:13:28 -0700 [thread overview]
Message-ID: <43557388.2060508@zytor.com> (raw)
In-Reply-To: <43557254.3010807@zytor.com>
[-- Attachment #1: Type: text/plain, Size: 318 bytes --]
This patch adds some extra paranoia to the git-daemon filename test. In
particular, it now rejects pathnames containing //; it also adds a
redundant test for pathname absoluteness (belts and suspenders.)
A single / at the end of the path is still permitted, however.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 833 bytes --]
diff --git a/daemon.c b/daemon.c
--- a/daemon.c
+++ b/daemon.c
@@ -80,17 +80,29 @@ static int path_ok(const char *dir)
{
const char *p = dir;
char **pp;
- int sl = 1, ndot = 0;
+ int sl, ndot;
+
+ /* The pathname here should be an absolute path. */
+ if ( *p++ != '/' )
+ return 0;
+
+ sl = 1; ndot = 0;
for (;;) {
if ( *p == '.' ) {
ndot++;
- } else if ( *p == '/' || *p == '\0' ) {
+ } else if ( *p == '\0' ) {
+ /* Reject "." and ".." at the end of the path */
if ( sl && ndot > 0 && ndot < 3 )
- return 0; /* . or .. in path */
+ return 0;
+
+ /* Otherwise OK */
+ break;
+ } else if ( *p == '/' ) {
+ /* Refuse "", "." or ".." */
+ if ( sl && ndot < 3 )
+ return 0;
sl = 1;
- if ( *p == '\0' )
- break; /* End of string and all is good */
} else {
sl = ndot = 0;
}
next prev parent reply other threads:[~2005-10-18 22:13 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-10-18 20:54 [PATCH] git-daemon extra paranoia H. Peter Anvin
2005-10-18 21:19 ` Junio C Hamano
2005-10-18 21:29 ` H. Peter Anvin
2005-10-18 22:08 ` H. Peter Anvin
2005-10-18 22:13 ` H. Peter Anvin [this message]
2005-10-18 22:25 ` Linus Torvalds
2005-10-18 22:47 ` Junio C Hamano
2005-10-18 23:21 ` Linus Torvalds
2005-10-19 0:21 ` H. Peter Anvin
2005-10-19 0:41 ` Linus Torvalds
2005-10-19 0:43 ` H. Peter Anvin
2005-10-19 1:18 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=43557388.2060508@zytor.com \
--to=hpa@zytor.com \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).