Skip to content

Commit

Permalink
Fix bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
willnode committed Mar 8, 2024
1 parent 9ae155c commit 96f767a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion sudoutil.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,19 @@ switch (cli.args.shift()) {
while (m = r.exec(df)) {
if (!m) return false;
if ((m[2] || '').startsWith('/boot')) return false;
let bytes_str = m[1];
if (bytes_str.match(/^\d+$/)) {
bytes_str += "B";
}
var size = parseFloat(m[1].slice(0, -1));
var unit = m[1].slice(-1);
size = size * (unit === 'T' ? 1024 * 1024 : unit === 'G' ? 1024 : unit === 'M' ? 1 : 0.001);
size = size * {
T: 1024 * 1024,
G: 1024,
M: 1,
K: 1 / 1024,
B: 1 / (1024 * 1024),
}[unit];
if (size < 1536) {
return true;
}
Expand Down

0 comments on commit 96f767a

Please sign in to comment.