for extraction, deal with created temp file directly:
authorespie <espie@openbsd.org>
Mon, 9 Aug 2021 16:41:21 +0000 (16:41 +0000)
committerespie <espie@openbsd.org>
Mon, 9 Aug 2021 16:41:21 +0000 (16:41 +0000)
- don't adjust the file object, just extract_to_fh
- for may_check_digest, explicitly pass the path instead of a file object

usr.sbin/pkg_add/OpenBSD/Add.pm
usr.sbin/pkg_add/OpenBSD/PackingElement.pm

index 6c686d8..cc40120 100644 (file)
@@ -1,5 +1,5 @@
 # ex:ts=8 sw=4:
-# $OpenBSD: Add.pm,v 1.185 2021/08/09 13:34:00 espie Exp $
+# $OpenBSD: Add.pm,v 1.186 2021/08/09 16:41:21 espie Exp $
 #
 # Copyright (c) 2003-2014 Marc Espie <espie@openbsd.org>
 #
@@ -540,10 +540,6 @@ sub extract
                        return;
                }
 
-               # XXX don't apply destdir twice
-               $file->{destdir} = '';
-               $file->set_name($tempname);
-
                $state->say("extract #1 -> #2", $self->name, $tempname) 
                    if $state->verbose >= 3;
 
@@ -552,8 +548,8 @@ sub extract
                        $state->fatal("can't extract #1, it's not a file", 
                            $self->stringize);
                }
-               $file->create;
-               $self->may_check_digest($file, $state);
+               $file->extract_to_fh($fh);
+               $self->may_check_digest($tempname, $state);
        }
 }
 
index 09aa645..7f7846a 100644 (file)
@@ -1,5 +1,5 @@
 # ex:ts=8 sw=4:
-# $OpenBSD: PackingElement.pm,v 1.277 2020/06/09 20:16:12 sthen Exp $
+# $OpenBSD: PackingElement.pm,v 1.278 2021/08/09 16:41:21 espie Exp $
 #
 # Copyright (c) 2003-2014 Marc Espie <espie@openbsd.org>
 #
@@ -434,21 +434,21 @@ sub make_hardlink
 
 sub may_check_digest
 {
-       my ($self, $file, $state) = @_;
+       my ($self, $path, $state) = @_;
        if ($state->{check_digest}) {
-               $self->check_digest($file, $state);
+               $self->check_digest($path, $state);
        }
 }
 
 sub check_digest
 {
-       my ($self, $file, $state) = @_;
+       my ($self, $path, $state) = @_;
        return if $self->{link} or $self->{symlink};
        if (!defined $self->{d}) {
                $state->log->fatal($state->f("#1 does not have a signature",
                    $self->fullname));
        }
-       my $d = $self->compute_digest($file->{destdir}.$file->name);
+       my $d = $self->compute_digest($path);
        if (!$d->equals($self->{d})) {
                $state->log->fatal($state->f("checksum for #1 does not match",
                    $self->fullname));