diff options
author | Taylor Holberton <taylorcholberton@gmail.com> | 2017-04-10 12:42:06 -0700 |
---|---|---|
committer | Taylor Holberton <taylorcholberton@gmail.com> | 2017-04-10 12:42:06 -0700 |
commit | 001b25ef86c1b3843a6c05d41968eb77b2abf905 (patch) | |
tree | 88c0ee29057643867e824d0dfc92a2991eec5930 /src | |
parent | 04b47b083101a6855557cde6d638e1e3f26095bb (diff) |
adding bounds check only when needed
Diffstat (limited to 'src')
-rw-r--r-- | src/pcm.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -677,8 +677,11 @@ int pcm_writei(struct pcm *pcm, const void *data, unsigned int frame_count) if (pcm->flags & PCM_IN) return -EINVAL; - else if ((frame_count > TINYALSA_FRAMES_MAX) - || (frame_count > INT_MAX)) +#if UINT_MAX > TINYALSA_FRAMES_MAX + if (frame_count > TINYALSA_FRAMES_MAX) + return -EINVAL; +#endif + if (frame_count > INT_MAX) return -EINVAL; x.buf = (void*)data; @@ -730,8 +733,11 @@ int pcm_readi(struct pcm *pcm, void *data, unsigned int frame_count) if (!(pcm->flags & PCM_IN)) return -EINVAL; - else if ((frame_count > TINYALSA_FRAMES_MAX) - || (frame_count > INT_MAX)) +#if UINT_MAX > TINYALSA_FRAMES_MAX + if (frame_count > TINYALSA_FRAMES_MAX) + return -EINVAL; +#endif + if (frame_count > INT_MAX) return -EINVAL; x.buf = data; |