Skip to content

Commit ac197fd

Browse files
committed
Harden export_debian_orig_from_git a bit
Make sure the name/version from the control file only include allowed characters like defined in the debian policy documentation.
1 parent d1284f8 commit ac197fd

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

build

+1
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,7 @@ copy_sources() {
867867
done
868868
if test -f "$1/debian/control" ; then
869869
echo "exporting debian orig tarballs"
870+
rm -rf "$2/build.origtar"
870871
$BUILD_DIR/export_debian_orig_from_git "$1" "$2/build.origtar" || cleanup_and_exit 1 "export_debian_orig_from_git failed"
871872
fi
872873
else

export_debian_orig_from_git

+5
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ sub get_pristine_commit {
3838

3939
sub export_blob {
4040
my ($blob, $out) = @_;
41+
unlink($out); # just in case
4142
my $fd;
4243
my $pid = open($fd, '|-');
4344
die("fork: $!\n") unless defined $pid;
@@ -86,6 +87,9 @@ my ($name, $version) = get_name_version();
8687
die("Could not determine name and version\n") unless defined $version;
8788
$version =~ s/-.*?$//; # strip release
8889

90+
# verify name/version and construct tar filename
91+
die("Bad package name in changelog\n") unless $name =~ /^[a-zA-Z][a-zA-Z0-9+\-\.]+$/s;
92+
die("Bad package version in changelog\n") unless $version =~ /^[a-zA-Z0-9][a-zA-Z0-9:~+\-\.]*$/s;
8993
my $tarfile = "${name}_$version.orig.tar";
9094

9195
my $tag = $version;
@@ -94,6 +98,7 @@ $tag =~ s/:/%/g;
9498
$tag = "upstream/$tag";
9599

96100
# export the (uncompressed) tar archive
101+
unlink("$to/$tarfile"); # just in case
97102
system('git', 'archive', '--format=tar', "--prefix=$name-$version/", "--output=$to/$tarfile", $tag) && die("git archive $tag failed: $?\n");
98103

99104
# export pristine-tar entries if present

0 commit comments

Comments
 (0)