diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-07-24 10:31:18 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-07-24 10:31:18 +0100 |
| commit | 989092c04649ff07bbb552b2ccc7c9f44569b75c (patch) | |
| tree | 62fe8e3f331179c4a0cf2ae692cabe53c2d36920 /tooling/libmkfs | |
| parent | 5dcf3ce391288e9d4f5f25120cf722f962e30881 (diff) | |
fix: tooling: fix 'fsck.hefs', 'mkfs.hefs', and 'mk_img.py' tools.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'tooling/libmkfs')
| -rw-r--r-- | tooling/libmkfs/mkfs.h | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/tooling/libmkfs/mkfs.h b/tooling/libmkfs/mkfs.h index 1765e1d4..31f7a26a 100644 --- a/tooling/libmkfs/mkfs.h +++ b/tooling/libmkfs/mkfs.h @@ -34,10 +34,17 @@ namespace detail { } inline bool parse_signed(const std::string& opt, long& out, int base = 10) { - if (opt.empty()) return false; + out = 0L; + + if (opt.empty()) return true; + char* endptr = nullptr; long val = std::strtol(opt.c_str(), &endptr, base); - if (endptr == opt.c_str() || *endptr != '\0' || val < 0) return false; + auto err = errno; + + if (err == ERANGE || err == EINVAL) return false; + if (endptr == opt.c_str() || *endptr != '\0') return false; + out = val; return true; } |
