diff options
author | Max Kellermann <max@duempel.org> | 2009-10-11 23:15:38 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-10-11 23:15:38 +0200 |
commit | 9a3f5ff977951781453fbe1e597dbd6eb5f7494a (patch) | |
tree | 25496e5bd1aa6d3e9c1acc79dc4180e41a32ec83 | |
parent | a1d868eb56bab5063f367e392624e3b3de5ea4d3 (diff) | |
download | mpd-9a3f5ff977951781453fbe1e597dbd6eb5f7494a.tar.gz mpd-9a3f5ff977951781453fbe1e597dbd6eb5f7494a.tar.xz mpd-9a3f5ff977951781453fbe1e597dbd6eb5f7494a.zip |
riff, aiff: fixed "limited range" gcc warning
On 32 bit systems with large file support enabled (i.e. "sizeof(off_t)
> sizeof(size_t)") gcc emits a warning because a size_t cast to off_t
can never become negative.
Diffstat (limited to '')
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | src/aiff.c | 10 | ||||
-rw-r--r-- | src/riff.c | 10 |
3 files changed, 12 insertions, 10 deletions
@@ -1,6 +1,8 @@ ver 0.15.5 (2009/??/??) * input: - curl: don't abort if a packet has only metadata +* tags: + - riff, aiff: fixed "limited range" gcc warning * decoder_thread: change the fallback decoder name to "mad" diff --git a/src/aiff.c b/src/aiff.c index f77e86d2b..d4bec628b 100644 --- a/src/aiff.c +++ b/src/aiff.c @@ -84,6 +84,11 @@ aiff_seek_id3(FILE *file) return 0; size = GUINT32_FROM_BE(chunk.size); + if (size > G_MAXINT32) + /* too dangerous, bail out: possible integer + underflow when casting to off_t */ + return 0; + if (size % 2 != 0) /* pad byte */ ++size; @@ -92,11 +97,6 @@ aiff_seek_id3(FILE *file) /* found it! */ return size; - if ((off_t)size < 0) - /* integer underflow after cast to signed - type */ - return 0; - ret = fseek(file, size, SEEK_CUR); if (ret != 0) return 0; diff --git a/src/riff.c b/src/riff.c index 7227fd3c8..a8ea9dd42 100644 --- a/src/riff.c +++ b/src/riff.c @@ -83,6 +83,11 @@ riff_seek_id3(FILE *file) return 0; size = GUINT32_FROM_LE(chunk.size); + if (size > G_MAXINT32) + /* too dangerous, bail out: possible integer + underflow when casting to off_t */ + return 0; + if (size % 2 != 0) /* pad byte */ ++size; @@ -91,11 +96,6 @@ riff_seek_id3(FILE *file) /* found it! */ return size; - if ((off_t)size < 0) - /* integer underflow after cast to signed - type */ - return 0; - ret = fseek(file, size, SEEK_CUR); if (ret != 0) return 0; |