Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 1 | src/file_io.c : Prevent potential divide-by-zero. |
| 2 | |
| 3 | Closes: https://github.com/erikd/libsndfile/issues/92 |
| 4 | |
| 5 | Upstream-Status: Backport |
| 6 | |
| 7 | Fixes CVE-2014-9756 |
| 8 | |
| 9 | Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com> |
| 10 | Signed-off-by: Maxin B. John <maxin.john@intel.com> |
| 11 | --- |
| 12 | diff -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 | |