android/avdtptest: Verify data before processing rtp header

This commit is contained in:
Szymon Janc 2014-09-03 15:13:44 +02:00
parent 4fc3bd0466
commit 2fb65926d4

View File

@ -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,