From 17bd32aa9311af5b10800402f4ca79a29290985a Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Sun, 11 Aug 2024 08:22:50 +0200 Subject: [PATCH 1/2] reproduce panic when parsing refspecs (#1508) --- .../make_rev_spec_parse_repos.tar | Bin 1122816 -> 1125888 bytes .../fixtures/make_rev_spec_parse_repos.sh | 8 ++++++++ gix/tests/revision/spec/from_bytes/mod.rs | 10 ++++++++++ 3 files changed, 18 insertions(+) diff --git a/gix/tests/fixtures/generated-archives/make_rev_spec_parse_repos.tar b/gix/tests/fixtures/generated-archives/make_rev_spec_parse_repos.tar index 68372e1999f6e36a7c6c6c173ede912c126fb6f6..d6c7fa1911450d0143e01e675d0f2924c84ea221 100644 GIT binary patch delta 16460 zcmcgze|%KMwa@*1_wJ9oAtB`Fx;$U|R(J3jTJlu}ETN<|y}_$(^5XsueLmZpgE&dls)Z?aoTNniiC z*_(6EocVdabLN~gs}D_F{qDq_e0a0wz>d|Ls-hg1epB1m1qwD=wa2-U&(3@xuvNXW zA@<9qrRhVz+rA(z?VirGH102HX=$0r^9VmF^X54Zgg<)Wxt6&jjxMUWvs$=)N4Ac= zF78e)yw;kH@=BdI60yiIoL>CU667;I0?w(7*2Dqd8p`MC z$JcCamC%^oT6v3GYITX&SY`ch0p~2YekGt`VVxFlGom2z9qnEYxn9vHGl^%UF&H_l z_u5f`>b#!O{BkJ{PqA)DN8?N6%Uj&TLE?jk6ADkXu2E1yE@Q;T9Ba3LT%W{cO%n?6 zx>9QxXf9_={+AArUu(TrKn1;eO#V(4Xk)GSDQLVHmyeBnYnOxy_Qjd@=}_NkZOu?r zFoM+yMfWu7#T#~bvQ`_j<00n5l1_XN!S zQJ=%%@4v>K74Y|uagPZtZaG|Pb)oTxq*(Wm(J4Tq-qr4f`VPh0aMl6?p;}i-XjpN4 z3RKdFCfbM*@kY?;3u|QhO7z(D(W!bwTgRdCu0$;pNw4;5p9#s0_Ib+uUQ?rAvidmm z{3^kPP?27Q?#h&M-QT&re#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`_qALWRD-$;7SOg-Yi*$sO>Ptc<6}21lOfO^(pVrw z)6xbGcZ~Cb7h^p3hj5JS%}#OOkSpQL&?Rdrl08-flD!@Po=El>ETnlYKD8nVk~9)T z4I@{ryD+$kDN*Kfg(_WjYB|*~0p2BRLe@a`6fkQbM297iy|7%&k*RZ2-Ze+on5=x* zDob+My4D1VxD(Lhrt9wngw2lG1BN)x$`Sd36E>90xa8zT0!9G{Rfkm4S7=a5 z@!++0F(?JUwWa^t5|{ozcm8wQrjmcD`I)^vz2MY7^XotSQAeQh)mpXh58R(aAy*cG zm466ThsAz>X32<<9Z#93Oy9R?97e7B=<}}3ZwA{${-x`R2r(#;kn47qnQxyt0`RNAk)`JE?`6u=Z*@hpJgLUMbRovblwFvlGCm}nn#SK^`d#i zK64E~im;uU7R@8}sp}=0M+~)C9LiS&L567WHUb%VXzE?W!zepQRli{i&;UGO8ix>2wgN^nIwqb?a^hlO|n>ChXAz3 z#YHzCWw@8JjAGYQW|EWbifum1uFP8L%7Gcek2@-8xbtVMT->p92uud4*cwwyQ#U3Ye6IK4iX(t(@ zQ~%o@DVA(}*me|_ux)PGt=@JrzJx7N5DRfEWXD;ln^VVIaA8{~Jp%evJ+1E#?5Ra7bpbdm-AXEdP8VJ=us0Knc5UPPtZ!JPyA*E~U z;0T_G-!J`AP{+L)g-NO(JUjSu4|%FbSjP=+`H?6UwSduo?a+_5z9@uNNMqHkP|Ex$ zgpv@DwM&niwUuxN$S6i#A$6P8%=RdHQvDD?P1HJReX6!H&UER@c#{Ot(c}8#jesa> zq6VZ#1vT?file && git add file && git commit -m "init" + rm .git/refs/heads/main + baseline 'HEAD' + baseline 'HEAD:file' +) \ No newline at end of file diff --git a/gix/tests/revision/spec/from_bytes/mod.rs b/gix/tests/revision/spec/from_bytes/mod.rs index 87e92a80d5e..713a8da8510 100644 --- a/gix/tests/revision/spec/from_bytes/mod.rs +++ b/gix/tests/revision/spec/from_bytes/mod.rs @@ -144,6 +144,16 @@ fn access_blob_through_tree() { ); } +#[test] +fn invalid_head() { + let repo = repo("invalid-head").unwrap(); + let err = parse_spec("HEAD", &repo).unwrap_err(); + assert_eq!(err.to_string(), "The rev-spec is malformed and misses a ref name"); + + let err = parse_spec("HEAD:file", &repo).unwrap_err(); + assert_eq!(err.to_string(), "TBD"); +} + #[test] fn empty_tree_as_full_name() { let repo = repo("complex_graph").unwrap(); From e74095e0a035b090284135c88133106ba6a19fc3 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Sun, 11 Aug 2024 08:24:51 +0200 Subject: [PATCH 2/2] fix: prevent panic in `Repository::rev_parse_single()` when `HEAD` was invalid. When using a refspec like `HEAD:file`. --- gix/src/revision/spec/parse/delegate/mod.rs | 15 ++++++++++----- gix/src/revision/spec/parse/types.rs | 5 +++++ gix/tests/revision/spec/from_bytes/mod.rs | 6 +++--- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/gix/src/revision/spec/parse/delegate/mod.rs b/gix/src/revision/spec/parse/delegate/mod.rs index 9f1f4523a8c..8dd313358c6 100644 --- a/gix/src/revision/spec/parse/delegate/mod.rs +++ b/gix/src/revision/spec/parse/delegate/mod.rs @@ -203,11 +203,16 @@ impl<'repo> Delegate<'repo> { for (r, obj) in self.refs.iter().zip(self.objs.iter_mut()) { if let (Some(ref_), obj_opt @ None) = (r, obj) { if let Some(id) = ref_.target.try_id().map(ToOwned::to_owned).or_else(|| { - ref_.clone() - .attach(repo) - .peel_to_id_in_place() - .ok() - .map(crate::Id::detach) + match ref_.clone().attach(repo).peel_to_id_in_place() { + Err(err) => { + self.err.push(Error::PeelToId { + name: ref_.name.clone(), + source: err, + }); + None + } + Ok(id) => Some(id.detach()), + } }) { obj_opt.get_or_insert_with(HashSet::default).insert(id); }; diff --git a/gix/src/revision/spec/parse/types.rs b/gix/src/revision/spec/parse/types.rs index 9629b0b34d4..3bc6cdd079e 100644 --- a/gix/src/revision/spec/parse/types.rs +++ b/gix/src/revision/spec/parse/types.rs @@ -55,6 +55,11 @@ pub struct Options { #[derive(Debug, thiserror::Error)] #[allow(missing_docs)] pub enum Error { + #[error("Could not peel '{}' to obtain its target", name)] + PeelToId { + name: gix_ref::FullName, + source: reference::peel::Error, + }, #[error("The rev-spec is malformed and misses a ref name")] Malformed, #[error("Unborn heads do not have a reflog yet")] diff --git a/gix/tests/revision/spec/from_bytes/mod.rs b/gix/tests/revision/spec/from_bytes/mod.rs index 713a8da8510..78eb9f55dae 100644 --- a/gix/tests/revision/spec/from_bytes/mod.rs +++ b/gix/tests/revision/spec/from_bytes/mod.rs @@ -147,11 +147,11 @@ fn access_blob_through_tree() { #[test] fn invalid_head() { let repo = repo("invalid-head").unwrap(); + let err = parse_spec("HEAD:file", &repo).unwrap_err(); + assert_eq!(err.to_string(), "Could not peel 'HEAD' to obtain its target"); + let err = parse_spec("HEAD", &repo).unwrap_err(); assert_eq!(err.to_string(), "The rev-spec is malformed and misses a ref name"); - - let err = parse_spec("HEAD:file", &repo).unwrap_err(); - assert_eq!(err.to_string(), "TBD"); } #[test]