blob: b54b3ba669b29903c34163c39324eba92de6a5ee [file] [log] [blame]
Patrick Williamsf1e5d692016-03-30 15:21:19 -05001src/file_io.c : Prevent potential divide-by-zero.
2
3Closes: https://github.com/erikd/libsndfile/issues/92
4
5Upstream-Status: Backport
6
7Fixes CVE-2014-9756
8
9Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
10Signed-off-by: Maxin B. John <maxin.john@intel.com>
11---
12diff -Naur libsndfile-1.0.25-orig/src/file_io.c libsndfile-1.0.25/src/file_io.c
13--- libsndfile-1.0.25-orig/src/file_io.c 2011-01-19 12:12:28.000000000 +0200
14+++ libsndfile-1.0.25/src/file_io.c 2015-11-04 15:02:04.337395618 +0200
15@@ -358,6 +358,9 @@
16 { sf_count_t total = 0 ;
17 ssize_t count ;
18
19+ if (bytes == 0 || items == 0)
20+ return 0 ;
21+
22 if (psf->virtual_io)
23 return psf->vio.write (ptr, bytes*items, psf->vio_user_data) / bytes ;
24