]> git.alsa-project.org Git - tinycompress.git/commitdiff
compress: fix arithmetic exception in compress_get_hpointer
authorXuemin Su <xuemin.su@intel.com>
Tue, 30 Oct 2012 05:09:00 +0000 (13:09 +0800)
committerVinod Koul <vinod.koul@intel.com>
Mon, 18 Feb 2013 14:14:08 +0000 (19:44 +0530)
In compress_get_hpointer, check for invalid sample
rate to prevent devide-by-zero exceptions

Signed-off-by: Xuemin Su <xuemin.su@intel.com>
Signed-off-by: He Bo <bo.he@intel.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
compress.c

index b035e4a5a79f47966eeca169ce08a45d0cd97fc8..27c03d9977090114d365046eb76b6b295173f1dd 100644 (file)
@@ -286,6 +286,8 @@ int compress_get_hpointer(struct compress *compress,
 
        if (ioctl(compress->fd, SNDRV_COMPRESS_AVAIL, &kavail))
                return oops(compress, errno, "cannot get avail");
+       if (0 == kavail.tstamp.sampling_rate)
+               return oops(compress, errno, "invalid paramter");
        *avail = (unsigned int)kavail.avail;
        time = kavail.tstamp.pcm_io_frames / kavail.tstamp.sampling_rate;
        tstamp->tv_sec = time;