Skip to content

Commit

Permalink
misc src/: switch from "string is integer" to "string is entier".
Browse files Browse the repository at this point in the history
The "string is integer" check bails out of the passed data does not fit
in an 32bit (signed) integer data type. Contrary to that, "string is
entier" has bignum support and no constraints on the actual value.

All this said, sqlite3 might fail if the value doesn't fit into a signed
8-byte-integer, but we don't actually have a recovery plan for that
yet... and beside `port lint`, we don't check for such an overflow in
the first place.

Fixes: https://trac.macports.org/ticket/53489
  • Loading branch information
Ionic committed Feb 4, 2017
1 parent 70a2ae0 commit eb0a577
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/macports1.0/macports_util.tcl
Expand Up @@ -108,15 +108,15 @@ proc ldindex {varName args} {
set idx [lindex $args 0]
set size [llength $var]
set badrange? 0
if {[string is integer -strict $idx]} {
if {[string is entier -strict $idx]} {
if {$idx < 0 || $idx >= $size} {
set badrange? 1
}
} elseif {$idx eq "end"} {
if {$size == 0} {
set badrange? 1
}
} elseif {[string match "end-*" $idx] && [string is integer -strict [string range $idx 4 end]]} {
} elseif {[string match "end-*" $idx] && [string is entier -strict [string range $idx 4 end]]} {
set i [expr {$size - 1 - [string range $idx 4 end]}]
if {$i < 0 || $i >= $size} {
set badrange? 1
Expand Down
2 changes: 1 addition & 1 deletion src/macports1.0/reclaim.tcl
Expand Up @@ -354,7 +354,7 @@ namespace eval reclaim {

set time [read_last_run_file]

if {![string is integer -strict $time]} {
if {![string is entier -strict $time]} {
return
}

Expand Down
4 changes: 2 additions & 2 deletions src/port/port.tcl
Expand Up @@ -5480,7 +5480,7 @@ namespace eval portclient::questions {
throw
}
signal -restart error {TERM INT}
if {($input <= [llength $ports] && [string is integer -strict $input])} {
if {($input <= [llength $ports] && [string is entier -strict $input])} {
return [expr {$input - 1}]
} else {
puts "Please enter an index from the above list."
Expand Down Expand Up @@ -5545,7 +5545,7 @@ namespace eval portclient::questions {

set err_flag 1
foreach num $input {
if {[string is integer -strict $num] && $num <= [llength $ports] && $num > 0} {
if {[string is entier -strict $num] && $num <= [llength $ports] && $num > 0} {
lappend selected_opt [expr {$num -1}]
} elseif {[regexp {(\d+)-(\d+)} $input _ start end]
&& $start <= [llength $ports]
Expand Down
4 changes: 2 additions & 2 deletions src/port1.0/portbuild.tcl
Expand Up @@ -148,7 +148,7 @@ proc portbuild::build_getjobs {args} {
}
} catch {*} {}
}
if {![string is integer -strict $jobs] || $jobs <= 1} {
if {![string is entier -strict $jobs] || $jobs <= 1} {
set jobs 1
}
return $jobs
Expand Down Expand Up @@ -177,7 +177,7 @@ proc portbuild::build_getjobsarg {args} {
return ""
}
set jobs [option build.jobs]
if {![string is integer -strict $jobs] || $jobs <= 1} {
if {![string is entier -strict $jobs] || $jobs <= 1} {
return ""
}
return " -j$jobs"
Expand Down
8 changes: 4 additions & 4 deletions src/port1.0/portlint.tcl
Expand Up @@ -426,11 +426,11 @@ proc portlint::lint_main {args} {
}
}

if {![string is integer -strict $epoch]} {
ui_error "Port epoch is not numeric: $epoch"
if {![string is entier -strict $epoch]} {
ui_error "Port epoch is not numeric: $epoch"
incr errors
}
if {![string is integer -strict $revision]} {
if {![string is entier -strict $revision]} {
ui_error "Port revision is not numeric: $revision"
incr errors
}
Expand Down Expand Up @@ -635,7 +635,7 @@ proc portlint::lint_main {args} {
# if the last character of license name is a number or plus sign
# then a hyphen is missing
set license_end [string index $subtest end]
if {"+" eq $license_end || [string is integer -strict $license_end]} {
if {"+" eq $license_end || [string is entier -strict $license_end]} {
ui_error "invalid license '${test}': missing hyphen before version"
incr errors
}
Expand Down

0 comments on commit eb0a577

Please sign in to comment.