From: Max Kellermann <max@duempel.org>
To: git@vger.kernel.org
Subject: [stgit PATCH] commands.{new,rename}: verify patch names
Date: Tue, 05 Oct 2010 14:56:31 +0200 [thread overview]
Message-ID: <20101005125631.17466.95192.stgit@woodpecker.blarg.de> (raw)
Don't allow patches with invalid names. For example, a patch with a
slash in the name will cause the underlying git command to fail, and
stgit doesn't handle this error condition properly.
---
stgit/commands/new.py | 3 +++
stgit/commands/rename.py | 3 +++
stgit/utils.py | 6 ++++++
3 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/stgit/commands/new.py b/stgit/commands/new.py
index d5c5382..6bd7314 100644
--- a/stgit/commands/new.py
+++ b/stgit/commands/new.py
@@ -61,6 +61,9 @@ def func(parser, options, args):
name = args[0]
if stack.patches.exists(name):
raise common.CmdException('%s: patch already exists' % name)
+
+ if not utils.check_patch_name(name):
+ raise common.CmdException('%s: invalid patch name' % name)
else:
parser.error('incorrect number of arguments')
diff --git a/stgit/commands/rename.py b/stgit/commands/rename.py
index db898cb..7c229be 100644
--- a/stgit/commands/rename.py
+++ b/stgit/commands/rename.py
@@ -51,6 +51,9 @@ def func(parser, options, args):
else:
parser.error('incorrect number of arguments')
+ if not check_patch_name(new):
+ raise CmdException('%s: invalid patch name' % new)
+
out.start('Renaming patch "%s" to "%s"' % (old, new))
crt_series.rename_patch(old, new)
diff --git a/stgit/utils.py b/stgit/utils.py
index 2955adf..a41457b 100644
--- a/stgit/utils.py
+++ b/stgit/utils.py
@@ -241,6 +241,12 @@ def make_patch_name(msg, unacceptable, default_name = 'patch'):
patchname = default_name
return find_patch_name(patchname, unacceptable)
+def check_patch_name(name):
+ """Checks if the specified name is a valid patch name. For
+ technical reasons, we cannot allow a slash and other characters."""
+ return len(name) > 0 and name[0] not in '.-' and '/' not in name and \
+ '..' not in name and re.search(r'[\x00-\x20]', name) is None
+
# any and all functions are builtin in Python 2.5 and higher, but not
# in 2.4.
if not 'any' in dir(__builtins__):
next reply other threads:[~2010-10-05 12:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-05 12:56 Max Kellermann [this message]
2010-11-03 2:43 ` [stgit PATCH] commands.{new,rename}: verify patch names Shinya Kuribayashi
-- strict thread matches above, loose matches on Subject: below --
2010-10-05 11:45 Max Kellermann
2010-10-05 12:44 ` Gustav Hållberg
2010-10-05 12:52 ` Max Kellermann
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101005125631.17466.95192.stgit@woodpecker.blarg.de \
--to=max@duempel.org \
--cc=git@vger.kernel.org \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).