aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Nieder <jrnieder@gmail.com>2012-03-09 22:07:22 -0600
committerJonathan Nieder <jrnieder@gmail.com>2012-03-09 22:07:22 -0600
commit178e1deaae33f879ea687e85ac72455b3072b0d8 (patch)
tree649d84cda0fd2ee79be730bd3aa37764dc98c6ab
parentfast-import: leakfix for 'ls' of dirty trees (diff)
downloadgit-178e1deaae33f879ea687e85ac72455b3072b0d8.tar.gz
git-178e1deaae33f879ea687e85ac72455b3072b0d8.zip
fast-import: don't allow 'ls' of path with empty components
As the fast-import manual explains: The value of <path> must be in canonical form. That is it must not: . contain an empty directory component (e.g. foo//bar is invalid), . end with a directory separator (e.g. foo/ is invalid), . start with a directory separator (e.g. /foo is invalid), Unfortunately the "ls" command accepts these invalid syntaxes and responds by declaring that the indicated path is missing. This is too subtle and causes importers to silently misbehave; better to error out so the operator knows what's happening. The C, R, and M commands already error out for such paths. Reported-by: Andrew Sayers <andrew-git@pileofstuff.org> Analysis-by: David Barr <davidbarr@google.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
-rw-r--r--fast-import.c2
-rwxr-xr-xt/t9300-fast-import.sh39
2 files changed, 41 insertions, 0 deletions
diff --git a/fast-import.c b/fast-import.c
index fff285cd0f..47f61f3cba 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -1640,6 +1640,8 @@ static int tree_content_get(
n = slash1 - p;
else
n = strlen(p);
+ if (!n)
+ die("Empty path component found in input");
if (!root->tree)
load_tree(root);
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 6b1ba6c858..2cd0f0614d 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -1088,6 +1088,45 @@ test_expect_success \
INPUT_END'
test_expect_success \
+ 'N: reject foo/ syntax in copy source' \
+ 'test_must_fail git fast-import <<-INPUT_END
+ commit refs/heads/N5C
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ copy with invalid syntax
+ COMMIT
+
+ from refs/heads/branch^0
+ C file2/ file3
+ INPUT_END'
+
+test_expect_success \
+ 'N: reject foo/ syntax in rename source' \
+ 'test_must_fail git fast-import <<-INPUT_END
+ commit refs/heads/N5D
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ rename with invalid syntax
+ COMMIT
+
+ from refs/heads/branch^0
+ R file2/ file3
+ INPUT_END'
+
+test_expect_success \
+ 'N: reject foo/ syntax in ls argument' \
+ 'test_must_fail git fast-import <<-INPUT_END
+ commit refs/heads/N5E
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ copy with invalid syntax
+ COMMIT
+
+ from refs/heads/branch^0
+ ls "file2/"
+ INPUT_END'
+
+test_expect_success \
'N: copy to root by id and modify' \
'echo "hello, world" >expect.foo &&
echo hello >expect.bar &&
pan title='2019-12-19 17:37:13 -0800'>2019-12-19nfp: flower: move udp tunnel key match compilation to helper functionJohn Hurley1-22/+35 2019-12-19nfp: flower: pass flow rule pointer directly to match functionsJohn Hurley1-49/+27 2019-12-19hdlcdrv: replace unnecessary assertion in hdlcdrv_registerAditya Pakki1-2/+0 2019-12-19net: mvpp2: cycle comphy to power it downRussell King1-0/+10 2019-12-19net: sfp: report error on failure to read sfp soft statusRussell King1-2/+9 2019-12-19net: phy: marvell: use genphy_check_and_restart_aneg()Russell King1-20/+1 2019-12-19net: phy: marvell: use phy_modify_changed()Russell King1-16/+10 2019-12-19net: phy: marvell: use existing clause 37 definitionsRussell King1-18/+8 2019-12-19net: phy: marvell: consolidate phy status readingRussell King1-43/+17 2019-12-19net: phy: marvell: use positive logic for link stateRussell King1-4/+3 2019-12-19net: phy: marvell: initialise link partner state earlierRussell King1-20/+5 2019-12-19net: phy: marvell: rearrange to use genphy_read_lpa()Russell King1-34/+32 2019-12-19net: phy: provide and use genphy_read_status_fixed()Russell King4-47/+41 2019-12-19net: phy: add genphy_check_and_restart_aneg()Russell King2-17/+32 2019-12-19net: phy: use phy_resolve_aneg_pause()Russell King3-14/+3 2019-12-19net: phy: remove redundant .aneg_done initialisersRussell King2-7/+0 2019-12-18net: stmmac: tc: Fix TAPRIO division operationJose Abreu1-2/+4