diff options
author | waker <wakeroid@gmail.com> | 2012-06-11 23:02:13 +0200 |
---|---|---|
committer | waker <wakeroid@gmail.com> | 2012-06-11 23:02:13 +0200 |
commit | d03c19cf09c2c3e0e0381d64cb99e9ab55929557 (patch) | |
tree | a2f678c92d0cebacb6a49b57de3803d5e876c80e /plugins/sndfile | |
parent | e7592deb6bc8d636b13ed4b26e7cb95e721c7c73 (diff) |
sndfile: fixed big/little endian byte swap buffer overrun bug
Diffstat (limited to 'plugins/sndfile')
-rw-r--r-- | plugins/sndfile/sndfile.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/plugins/sndfile/sndfile.c b/plugins/sndfile/sndfile.c index 1f7ddc41..49571642 100644 --- a/plugins/sndfile/sndfile.c +++ b/plugins/sndfile/sndfile.c @@ -288,7 +288,7 @@ sndfile_read (DB_fileinfo_t *_info, char *bytes, int size) { case 16: { uint16_t *data = (uint16_t *)bytes; - for (int i = 0; i < n; i++, data++) { + for (int i = 0; i < n/2; i++, data++) { *data = ((*data & 0xff) << 8) | ((*data & 0xff00) >> 8); } } @@ -296,7 +296,7 @@ sndfile_read (DB_fileinfo_t *_info, char *bytes, int size) { case 24: { uint8_t *data = bytes; - for (int i = 0; i < n; i++, data += 3) { + for (int i = 0; i < n/3; i++, data += 3) { uint8_t temp = data[0]; data[0] = data[2]; data[2] = temp; @@ -306,7 +306,7 @@ sndfile_read (DB_fileinfo_t *_info, char *bytes, int size) { case 32: { uint32_t *data = (uint32_t *)bytes; - for (int i = 0; i < n; i++, data++) { + for (int i = 0; i < n/4; i++, data++) { *data = ((*data & 0xff) << 24) | ((*data & 0xff00) << 8) | ((*data & 0xff0000) >> 8) | ((*data & 0xff0000) >> 24); } } |