git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git-quiltimport: fix security risk because of un-sanitized $level.
@ 2008-03-12 20:46 Pierre Habouzit
  2008-03-12 20:55 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Pierre Habouzit @ 2008-03-12 20:46 UTC (permalink / raw)
  To: Git ML, Junio C Hamano

[-- Attachment #1: Type: text/plain, Size: 895 bytes --]

Signed-off-by: Pierre Habouzit <madcoder@debian.org>
---

  I assume that nobody will have a series with -p1000 in it :)
  sorry for this gross mistake in the first place.

  [ for the inattentive readers $level was used without quoting, for
    good reasons as it's sometime empty and then we don't want to pass
    an empty argument to git-apply, though someone could use that to run
    arbitrary commands, not nice ]

 git-quiltimport.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/git-quiltimport.sh b/git-quiltimport.sh
index 84c8b8e..d35cb02 100755
--- a/git-quiltimport.sh
+++ b/git-quiltimport.sh
@@ -67,7 +67,7 @@ while read patch_name level garbage
 do
 	case "$patch_name" in ''|'#'*) continue;; esac
 	case "$level" in
-	-p*);;
+	-p[0-9]|-p[0-9][0-9]|-p[0-9][0-9][0-9]);;
 	''|'#'*)
 		level=;;
 	*)
-- 
1.5.4.4.599.gba501

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] git-quiltimport: fix security risk because of un-sanitized $level.
  2008-03-12 20:46 [PATCH] git-quiltimport: fix security risk because of un-sanitized $level Pierre Habouzit
@ 2008-03-12 20:55 ` Junio C Hamano
  2008-03-12 22:29   ` Pierre Habouzit
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2008-03-12 20:55 UTC (permalink / raw)
  To: Pierre Habouzit; +Cc: Git ML

Pierre Habouzit <madcoder@debian.org> writes:

> Signed-off-by: Pierre Habouzit <madcoder@debian.org>
> ---
>
>   I assume that nobody will have a series with -p1000 in it :)
>   sorry for this gross mistake in the first place.
>
>   [ for the inattentive readers $level was used without quoting, for
>     good reasons as it's sometime empty and then we don't want to pass
>     an empty argument to git-apply, though someone could use that to run
>     arbitrary commands, not nice ]

A traditional way to deal with that situation in shell scripts is to use
this idiom:

	${var_that_may_not_be_set+"$var_that_may_not_be_set"}

You can use :+ in place of + to also reject empty string on modern
systems.

#!/bin/sh
not_set=t ; unset not_set
is_set=t

report () {
	echo "I got $# args"
        i=1
        for it
        do
        	echo "$i: $it"
                i=$(( $i+1 ))
	done
        echo
}

report sending not_set ${not_set:+"$not_set"} string
report sending is_set ${is_set:+"$is_set"} string

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] git-quiltimport: fix security risk because of  un-sanitized $level.
  2008-03-12 20:55 ` Junio C Hamano
@ 2008-03-12 22:29   ` Pierre Habouzit
  0 siblings, 0 replies; 3+ messages in thread
From: Pierre Habouzit @ 2008-03-12 22:29 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git ML

[-- Attachment #1: Type: text/plain, Size: 1231 bytes --]

On Wed, Mar 12, 2008 at 08:55:56PM +0000, Junio C Hamano wrote:
> Pierre Habouzit <madcoder@debian.org> writes:
> 
> > Signed-off-by: Pierre Habouzit <madcoder@debian.org>
> > ---
> >
> >   I assume that nobody will have a series with -p1000 in it :)
> >   sorry for this gross mistake in the first place.
> >
> >   [ for the inattentive readers $level was used without quoting, for
> >     good reasons as it's sometime empty and then we don't want to pass
> >     an empty argument to git-apply, though someone could use that to run
> >     arbitrary commands, not nice ]
> 
> A traditional way to deal with that situation in shell scripts is to use
> this idiom:
> 
> 	${var_that_may_not_be_set+"$var_that_may_not_be_set"}

  Oh this is nicer than what I used indeed. My shell scripting skills
are quite limited :)

  Anyways, I happened to notice this stupid mistake when I re-read the
patch you merged. You probably want to use that trick instead (rather
than my poor sanitizing thing), and let git-apply sort out the rest.
-- 
·O·  Pierre Habouzit
··O                                                madcoder@debian.org
OOO                                                http://www.madism.org

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-03-12 22:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-12 20:46 [PATCH] git-quiltimport: fix security risk because of un-sanitized $level Pierre Habouzit
2008-03-12 20:55 ` Junio C Hamano
2008-03-12 22:29   ` Pierre Habouzit

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).