diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2005-06-18 11:42:50 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2005-06-18 11:42:50 +0000 |
commit | 0dfd514c0cbb4efbe029d6eab2d3651c6de9bf9b (patch) | |
tree | 12342c913df7f9c6dae6ffc6d6538d47c16ee1f2 /usr.sbin/pkg_add | |
parent | 9cda040913008ed18b4c04d58416e49cadeecd82 (diff) |
fix prefix/name cut (found out by aanriot)
Diffstat (limited to 'usr.sbin/pkg_add')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Ustar.pm | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Ustar.pm b/usr.sbin/pkg_add/OpenBSD/Ustar.pm index 1012cfd031f..d49a1138de7 100644 --- a/usr.sbin/pkg_add/OpenBSD/Ustar.pm +++ b/usr.sbin/pkg_add/OpenBSD/Ustar.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Ustar.pm,v 1.23 2005/06/13 18:38:59 espie Exp $ +# $OpenBSD: Ustar.pm,v 1.24 2005/06/18 11:42:49 espie Exp $ # # Copyright (c) 2002-2004 Marc Espie <espie@openbsd.org> # @@ -159,11 +159,17 @@ sub mkheader $prefix = ''; } elsif (length($name) > 255) { die "Can't fit such a name $name\n"; - } elsif ($name =~ m|^(.*)/(.{,100})$|) { - $prefix = $1; - $name = $2; } else { - die "Can't fit such a name $name\n"; + my @c = split('/', $name); + $prefix = ''; + while (length($prefix.$c[0].'/') <= 155 and @c > 1) { + $prefix.=(shift @c).'/'; + } + $name = join('/', @c); + $prefix =~ s|/$||; + if (length $prefix > 155 or length $name > 100) { + die "Can't fit such a name $prefix/$name\n"; + } } my $linkname = $entry->{linkname}; my $size = $entry->{size}; |