]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
audio: st_rate_flow exist a infinite loop
authorPeng Hao <peng.hao2@zte.com.cn>
Sat, 15 Jul 2017 14:14:21 +0000 (22:14 +0800)
committerGerd Hoffmann <kraxel@redhat.com>
Mon, 17 Jul 2017 09:08:59 +0000 (11:08 +0200)
If a voice recording equipment is opened for a long time(several days)
in windows guest, rate->ipos will overflow and rate->opos will never
have a chance to change. It will result to a infinite loop.

Signed-off-by: Peng Hao <peng.hao2@zte.com.cn>
Signed-off-by: Wang Yechao <wang.yechao255@zte.com.cn>
Message-id: 1500128061-20849-1-git-send-email-peng.hao2@zte.com.cn
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
audio/rate_template.h

index bd4b1c768565cda09fdb2c3f5b3ebfbc252f1475..6e93588877d01b90acd29265f3c01c38df3c673e 100644 (file)
@@ -71,6 +71,12 @@ void NAME (void *opaque, struct st_sample *ibuf, struct st_sample *obuf,
         while (rate->ipos <= (rate->opos >> 32)) {
             ilast = *ibuf++;
             rate->ipos++;
+
+            /* if ipos overflow, there is  a infinite loop */
+            if (rate->ipos == 0xffffffff) {
+                rate->ipos = 1;
+                rate->opos = rate->opos & 0xffffffff;
+            }
             /* See if we finished the input buffer yet */
             if (ibuf >= iend) {
                 goto the_end;