diff options
author | Szymon Janc <szymon.janc@tieto.com> | 2014-09-03 15:13:44 +0200 |
---|---|---|
committer | Szymon Janc <szymon.janc@tieto.com> | 2014-09-03 16:55:14 +0200 |
commit | 2fb65926d438a580ef321d1f8ad22d84d0677925 (patch) | |
tree | 39d8848e791dc1d1ddb513e78ed34a07ea94ada7 /android/avdtptest.c | |
parent | 4fc3bd0466cd5d15140c580d90af9f374925d39f (diff) | |
download | bluez-2fb65926d438a580ef321d1f8ad22d84d0677925.tar.gz |
android/avdtptest: Verify data before processing rtp header
Diffstat (limited to 'android/avdtptest.c')
-rw-r--r-- | android/avdtptest.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/android/avdtptest.c b/android/avdtptest.c index d520bc022..92312fa57 100644 --- a/android/avdtptest.c +++ b/android/avdtptest.c @@ -244,16 +244,22 @@ static gboolean media_reader(GIOChannel *source, GIOCondition condition, struct rtp_header *rtp = (void *) buf; static bool decode = false; uint16_t imtu; - int fd; + int fd, ret; if (!avdtp_stream_get_transport(avdtp_stream, &fd, &imtu, NULL, NULL)) return TRUE; - if (read(fd, buf, imtu) < 0) { + ret = read(fd, buf, imtu); + if (ret < 0) { printf("Reading failed (%s)\n", strerror(errno)); return TRUE; } + if (ret < (int) sizeof(*rtp)) { + printf("Not enough media data received (%u bytes)", ret); + return TRUE; + } + if (!decode) { printf("V=%u P=%u X=%u CC=%u M=%u PT=%u SeqNr=%d\n", rtp->v, rtp->p, rtp->x, rtp->cc, rtp->m, rtp->pt, |