From d685d693e8d419654633a2647c8389a43f2c6aef Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 11 Mar 2024 15:09:56 +0100 Subject: [PATCH] input/rewind, archive/iso9660: use use std::cmp_*() for safe integer comparison --- src/archive/plugins/Iso9660ArchivePlugin.cxx | 2 +- src/input/RewindInputStream.cxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/archive/plugins/Iso9660ArchivePlugin.cxx b/src/archive/plugins/Iso9660ArchivePlugin.cxx index 2f41cc29d..1ef877732 100644 --- a/src/archive/plugins/Iso9660ArchivePlugin.cxx +++ b/src/archive/plugins/Iso9660ArchivePlugin.cxx @@ -242,7 +242,7 @@ Iso9660InputStream::Read(std::unique_lock &, if (remaining == 0) return 0; - if (offset_type(read_size) > remaining) + if (std::cmp_greater(read_size, remaining)) read_size = remaining; auto r = buffer.Read(); diff --git a/src/input/RewindInputStream.cxx b/src/input/RewindInputStream.cxx index 12bf7829c..6b0147a83 100644 --- a/src/input/RewindInputStream.cxx +++ b/src/input/RewindInputStream.cxx @@ -105,7 +105,7 @@ RewindInputStream::Seek(std::unique_lock &lock, offset_type new_offset) { assert(IsReady()); - if (tail > 0 && new_offset <= (offset_type)tail) { + if (tail > 0 && std::cmp_less_equal(new_offset, tail)) { /* buffered seek */ assert(!ReadingFromBuffer() ||