projects
/
paraslash.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
aft: Avoid invalid read.
[paraslash.git]
/
opus_common.c
diff --git
a/opus_common.c
b/opus_common.c
index 927df1f3c2f881fb036b13df50fbd49b43ec568d..f4e18df915d657e43e9f9e583313ef962471a62a 100644
(file)
--- a/
opus_common.c
+++ b/
opus_common.c
@@
-29,8
+29,6
@@
* handler.
*/
* handler.
*/
-#include <ogg/ogg.h>
-
#include "para.h"
#include "error.h"
#include "opus_common.h"
#include "para.h"
#include "error.h"
#include "opus_common.h"
@@
-53,7
+51,7
@@
static int read_chars(struct packet *p, unsigned char *str, int nb_chars)
return 1;
}
return 1;
}
-static int read_uint32(struct packet *p,
ogg_
uint32_t *val)
+static int read_uint32(struct packet *p, uint32_t *val)
{
if (p->pos > p->maxlen - 4)
return 0;
{
if (p->pos > p->maxlen - 4)
return 0;
@@
-62,7
+60,7
@@
static int read_uint32(struct packet *p, ogg_uint32_t *val)
return 1;
}
return 1;
}
-static int read_uint16(struct packet *p,
ogg_
uint16_t *val)
+static int read_uint16(struct packet *p, uint16_t *val)
{
if (p->pos > p->maxlen - 2)
return 0;
{
if (p->pos > p->maxlen - 2)
return 0;
@@
-89,7
+87,6
@@
int opus_parse_header(const char *packet, int len, struct opus_header *h)
char str[9];
struct packet p;
unsigned char ch, channel_mapping;
char str[9];
struct packet p;
unsigned char ch, channel_mapping;
- ogg_uint16_t shortval;
p.data = packet;
p.maxlen = len;
p.data = packet;
p.maxlen = len;
@@
-104,7
+101,7
@@
int opus_parse_header(const char *packet, int len, struct opus_header *h)
if (!read_chars(&p, &ch, 1))
return -E_OPUS_HEADER;
h->version = ch;
if (!read_chars(&p, &ch, 1))
return -E_OPUS_HEADER;
h->version = ch;
- if((h->version & 240) != 0) /* Only major version 0 supported. */
+ if
((h->version & 240) != 0) /* Only major version 0 supported. */
return -E_OPUS_HEADER;
if (!read_chars(&p, &ch, 1))
return -E_OPUS_HEADER;
if (!read_chars(&p, &ch, 1))
@@
-113,16
+110,14
@@
int opus_parse_header(const char *packet, int len, struct opus_header *h)
if (h->channels == 0)
return -E_OPUS_HEADER;
if (h->channels == 0)
return -E_OPUS_HEADER;
- if (!read_uint16(&p, &
shortval
))
+ if (!read_uint16(&p, &
h->preskip
))
return -E_OPUS_HEADER;
return -E_OPUS_HEADER;
- h->preskip = shortval;
if (!read_uint32(&p, &h->input_sample_rate))
return -E_OPUS_HEADER;
if (!read_uint32(&p, &h->input_sample_rate))
return -E_OPUS_HEADER;
- if (!read_uint16(&p, &
shortval
))
+ if (!read_uint16(&p, &
h->gain
))
return -E_OPUS_HEADER;
return -E_OPUS_HEADER;
- h->gain = (short)shortval;
if (!read_chars(&p, &ch, 1))
return -E_OPUS_HEADER;
if (!read_chars(&p, &ch, 1))
return -E_OPUS_HEADER;