aboutsummaryrefslogtreecommitdiff
path: root/src/pcm.c
diff options
context:
space:
mode:
authorTaylor Holberton <taylorcholberton@gmail.com>2017-04-06 23:12:01 -0700
committerTaylor Holberton <taylorcholberton@gmail.com>2017-04-06 23:12:01 -0700
commit851dd8073e08200836bf18c8d9c8283bbc35c299 (patch)
tree8ac7c99d7c104d0c100acea819047b0bfa027f69 /src/pcm.c
parent1137fc70bb4ceeea07ba2399b40c4485d2ccc168 (diff)
checking limits of frame counts
Diffstat (limited to 'src/pcm.c')
-rw-r--r--src/pcm.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/pcm.c b/src/pcm.c
index 62489a6..63afeb0 100644
--- a/src/pcm.c
+++ b/src/pcm.c
@@ -525,6 +525,8 @@ int pcm_get_htimestamp(struct pcm *pcm, unsigned int *avail,
* @param pcm A PCM handle.
* @param data The audio sample array
* @param frame_count The number of frames occupied by the sample array.
+ * This value should not be greater than @ref TINYALSA_FRAMES_MAX
+ * or INT_MAX.
* @return On success, this function returns the number of frames written; otherwise, a negative number.
* @ingroup libtinyalsa-pcm
*/
@@ -534,6 +536,9 @@ 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))
+ return -EINVAL;
x.buf = (void*)data;
x.frames = frame_count;
@@ -573,6 +578,8 @@ int pcm_writei(struct pcm *pcm, const void *data, unsigned int frame_count)
* @param pcm A PCM handle.
* @param data The audio sample array
* @param frame_count The number of frames occupied by the sample array.
+ * This value should not be greater than @ref TINYALSA_FRAMES_MAX
+ * or INT_MAX.
* @return On success, this function returns the number of frames written; otherwise, a negative number.
* @ingroup libtinyalsa-pcm
*/
@@ -582,6 +589,9 @@ 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))
+ return -EINVAL;
x.buf = data;
x.frames = frame_count;