Skip to content

Commit

Permalink
revupgrade: avoid possible TOCTOU error
Browse files Browse the repository at this point in the history
Make sure not to use registry entries after they could potentially have
been uninstalled.

Closes: https://trac.macports.org/ticket/66186
  • Loading branch information
jmroot committed Oct 29, 2023
1 parent 980a5c1 commit 1abd73a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/macports1.0/macports.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -5538,8 +5538,16 @@ proc macports::revupgrade_scanandrebuild {broken_port_counts_name opts} {
set status 0
array set my_options [array get macports::global_options]
set my_options(ports_revupgrade) yes

# Depending on the options, calling macports::upgrade could
# uninstall later entries in this list. So get the info we need
# from all the entries first.
set topsort_portnames [list]
foreach port $topsort_ports {
set portname [$port name]
lappend topsort_portnames [$port name]
#registry::entry close $port
}
foreach portname $topsort_portnames {
if {![info exists depscache(port:$portname)]} {
unset -nocomplain my_options(ports_revupgrade_second_run) \
my_options(ports_nodeps)
Expand All @@ -5561,7 +5569,6 @@ proc macports::revupgrade_scanandrebuild {broken_port_counts_name opts} {
error "Error rebuilding $portname"
}
}
#registry::entry close $port
}

if {[info exists options(ports_dryrun)] && $options(ports_dryrun)} {
Expand Down

0 comments on commit 1abd73a

Please sign in to comment.