Dataset Viewer
cve_id
stringlengths 13
16
| hash
stringlengths 40
40
| repo_url
stringlengths 56
159
| cve_description
stringlengths 30
33
| cvss2_base_score
null | cvss3_base_score
null | published_date
null | severity
null | cwe_id
stringclasses 171
values | cwe_name
stringclasses 1
value | cwe_description
stringclasses 1
value | commit_message
stringlengths 17
20
| commit_date
null | version_tag
null | repo_total_files
null | repo_total_commits
null | file_paths
stringlengths 8
104
| language
stringclasses 2
values | diff_stats
stringlengths 48
146
| diff_with_context
null | vulnerable_code
stringlengths 10
83k
⌀ | fixed_code
stringlengths 8
83.3k
| security_keywords
stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
CVE-2016-2538
|
7381aa893c7974195fb964c328d74b63a03953ab
|
https://github.com/qemu/qemu/commit/fe3c546c5ff2a6210f9a4d8561cc64051ca8603e
|
Vulnerability in CVE-2016-2538
| null | null | null | null |
CWE-189
|
Fix CVE-2016-2538
| null | null | null | null |
["hw/usb/dev-network.c"]
|
C
|
{"hw/usb/dev-network.c": {"lines_added": 45, "lines_deleted": 44}}
| null |
static int rndis_query_response(USBNetState *s,
rndis_query_msg_type *buf, unsigned int length)
{
rndis_query_cmplt_type *resp;
/* oid_supported_list is the largest data reply */
uint8_t infobuf[sizeof(oid_supported_list)];
uint32_t bufoffs, buflen;
int infobuflen;
unsigned int resplen;
bufoffs = le32_to_cpu(buf->InformationBufferOffset) + 8;
buflen = le32_to_cpu(buf->InformationBufferLength);
if (bufoffs + buflen > length)
return USB_RET_STALL;
infobuflen = ndis_query(s, le32_to_cpu(buf->OID),
bufoffs + (uint8_t *) buf, buflen, infobuf,
sizeof(infobuf));
resplen = sizeof(rndis_query_cmplt_type) +
((infobuflen < 0) ? 0 : infobuflen);
resp = rndis_queue_response(s, resplen);
if (!resp)
return USB_RET_STALL;
resp->MessageType = cpu_to_le32(RNDIS_QUERY_CMPLT);
resp->RequestID = buf->RequestID; /* Still LE in msg buffer */
resp->MessageLength = cpu_to_le32(resplen);
if (infobuflen < 0) {
/* OID not supported */
resp->Status = cpu_to_le32(RNDIS_STATUS_NOT_SUPPORTED);
resp->InformationBufferLength = cpu_to_le32(0);
resp->InformationBufferOffset = cpu_to_le32(0);
return 0;
}
resp->Status = cpu_to_le32(RNDIS_STATUS_SUCCESS);
resp->InformationBufferOffset =
cpu_to_le32(infobuflen ? sizeof(rndis_query_cmplt_type) - 8 : 0);
resp->InformationBufferLength = cpu_to_le32(infobuflen);
memcpy(resp + 1, infobuf, infobuflen);
return 0;
}
|
static int rndis_query_response(USBNetState *s,
rndis_query_msg_type *buf, unsigned int length)
{
rndis_query_cmplt_type *resp;
/* oid_supported_list is the largest data reply */
uint8_t infobuf[sizeof(oid_supported_list)];
uint32_t bufoffs, buflen;
int infobuflen;
unsigned int resplen;
bufoffs = le32_to_cpu(buf->InformationBufferOffset) + 8;
buflen = le32_to_cpu(buf->InformationBufferLength);
if (buflen > length || bufoffs >= length || bufoffs + buflen > length) {
return USB_RET_STALL;
}
infobuflen = ndis_query(s, le32_to_cpu(buf->OID),
bufoffs + (uint8_t *) buf, buflen, infobuf,
sizeof(infobuf));
resplen = sizeof(rndis_query_cmplt_type) +
((infobuflen < 0) ? 0 : infobuflen);
resp = rndis_queue_response(s, resplen);
if (!resp)
return USB_RET_STALL;
resp->MessageType = cpu_to_le32(RNDIS_QUERY_CMPLT);
resp->RequestID = buf->RequestID; /* Still LE in msg buffer */
resp->MessageLength = cpu_to_le32(resplen);
if (infobuflen < 0) {
/* OID not supported */
resp->Status = cpu_to_le32(RNDIS_STATUS_NOT_SUPPORTED);
resp->InformationBufferLength = cpu_to_le32(0);
resp->InformationBufferOffset = cpu_to_le32(0);
return 0;
}
resp->Status = cpu_to_le32(RNDIS_STATUS_SUCCESS);
resp->InformationBufferOffset =
cpu_to_le32(infobuflen ? sizeof(rndis_query_cmplt_type) - 8 : 0);
resp->InformationBufferLength = cpu_to_le32(infobuflen);
memcpy(resp + 1, infobuf, infobuflen);
return 0;
}
|
[]
|
||
CVE-2016-2538
|
76a04b79622385425afe6b68d6f549247ddb877c
|
https://github.com/qemu/qemu/commit/fe3c546c5ff2a6210f9a4d8561cc64051ca8603e
|
Vulnerability in CVE-2016-2538
| null | null | null | null |
CWE-189
|
Fix CVE-2016-2538
| null | null | null | null |
["hw/usb/dev-network.c"]
|
C
|
{"hw/usb/dev-network.c": {"lines_added": 31, "lines_deleted": 30}}
| null |
static int rndis_set_response(USBNetState *s,
rndis_set_msg_type *buf, unsigned int length)
{
rndis_set_cmplt_type *resp =
rndis_queue_response(s, sizeof(rndis_set_cmplt_type));
uint32_t bufoffs, buflen;
int ret;
if (!resp)
return USB_RET_STALL;
bufoffs = le32_to_cpu(buf->InformationBufferOffset) + 8;
buflen = le32_to_cpu(buf->InformationBufferLength);
if (bufoffs + buflen > length)
return USB_RET_STALL;
ret = ndis_set(s, le32_to_cpu(buf->OID),
bufoffs + (uint8_t *) buf, buflen);
resp->MessageType = cpu_to_le32(RNDIS_SET_CMPLT);
resp->RequestID = buf->RequestID; /* Still LE in msg buffer */
resp->MessageLength = cpu_to_le32(sizeof(rndis_set_cmplt_type));
if (ret < 0) {
/* OID not supported */
resp->Status = cpu_to_le32(RNDIS_STATUS_NOT_SUPPORTED);
return 0;
}
resp->Status = cpu_to_le32(RNDIS_STATUS_SUCCESS);
return 0;
}
|
static int rndis_set_response(USBNetState *s,
rndis_set_msg_type *buf, unsigned int length)
{
rndis_set_cmplt_type *resp =
rndis_queue_response(s, sizeof(rndis_set_cmplt_type));
uint32_t bufoffs, buflen;
int ret;
if (!resp)
return USB_RET_STALL;
bufoffs = le32_to_cpu(buf->InformationBufferOffset) + 8;
buflen = le32_to_cpu(buf->InformationBufferLength);
if (buflen > length || bufoffs >= length || bufoffs + buflen > length) {
return USB_RET_STALL;
}
ret = ndis_set(s, le32_to_cpu(buf->OID),
bufoffs + (uint8_t *) buf, buflen);
resp->MessageType = cpu_to_le32(RNDIS_SET_CMPLT);
resp->RequestID = buf->RequestID; /* Still LE in msg buffer */
resp->MessageLength = cpu_to_le32(sizeof(rndis_set_cmplt_type));
if (ret < 0) {
/* OID not supported */
resp->Status = cpu_to_le32(RNDIS_STATUS_NOT_SUPPORTED);
return 0;
}
resp->Status = cpu_to_le32(RNDIS_STATUS_SUCCESS);
return 0;
}
|
[]
|
||
CVE-2016-2538
|
8ef1d95d4604e5e32f8e9af794ffa351c27df08b
|
https://github.com/qemu/qemu/commit/fe3c546c5ff2a6210f9a4d8561cc64051ca8603e
|
Vulnerability in CVE-2016-2538
| null | null | null | null |
CWE-189
|
Fix CVE-2016-2538
| null | null | null | null |
["hw/usb/dev-network.c"]
|
C
|
{"hw/usb/dev-network.c": {"lines_added": 39, "lines_deleted": 38}}
| null |
static void usb_net_handle_dataout(USBNetState *s, USBPacket *p)
{
int sz = sizeof(s->out_buf) - s->out_ptr;
struct rndis_packet_msg_type *msg =
(struct rndis_packet_msg_type *) s->out_buf;
uint32_t len;
#ifdef TRAFFIC_DEBUG
fprintf(stderr, "usbnet: data out len %zu\n", p->iov.size);
iov_hexdump(p->iov.iov, p->iov.niov, stderr, "usbnet", p->iov.size);
#endif
if (sz > p->iov.size) {
sz = p->iov.size;
}
usb_packet_copy(p, &s->out_buf[s->out_ptr], sz);
s->out_ptr += sz;
if (!is_rndis(s)) {
if (p->iov.size < 64) {
qemu_send_packet(qemu_get_queue(s->nic), s->out_buf, s->out_ptr);
s->out_ptr = 0;
}
return;
}
len = le32_to_cpu(msg->MessageLength);
if (s->out_ptr < 8 || s->out_ptr < len) {
return;
}
if (le32_to_cpu(msg->MessageType) == RNDIS_PACKET_MSG) {
uint32_t offs = 8 + le32_to_cpu(msg->DataOffset);
uint32_t size = le32_to_cpu(msg->DataLength);
if (offs + size <= len)
qemu_send_packet(qemu_get_queue(s->nic), s->out_buf + offs, size);
}
s->out_ptr -= len;
memmove(s->out_buf, &s->out_buf[len], s->out_ptr);
}
|
static void usb_net_handle_dataout(USBNetState *s, USBPacket *p)
{
int sz = sizeof(s->out_buf) - s->out_ptr;
struct rndis_packet_msg_type *msg =
(struct rndis_packet_msg_type *) s->out_buf;
uint32_t len;
#ifdef TRAFFIC_DEBUG
fprintf(stderr, "usbnet: data out len %zu\n", p->iov.size);
iov_hexdump(p->iov.iov, p->iov.niov, stderr, "usbnet", p->iov.size);
#endif
if (sz > p->iov.size) {
sz = p->iov.size;
}
usb_packet_copy(p, &s->out_buf[s->out_ptr], sz);
s->out_ptr += sz;
if (!is_rndis(s)) {
if (p->iov.size < 64) {
qemu_send_packet(qemu_get_queue(s->nic), s->out_buf, s->out_ptr);
s->out_ptr = 0;
}
return;
}
len = le32_to_cpu(msg->MessageLength);
if (s->out_ptr < 8 || s->out_ptr < len) {
return;
}
if (le32_to_cpu(msg->MessageType) == RNDIS_PACKET_MSG) {
uint32_t offs = 8 + le32_to_cpu(msg->DataOffset);
uint32_t size = le32_to_cpu(msg->DataLength);
if (offs < len && size < len && offs + size <= len) {
qemu_send_packet(qemu_get_queue(s->nic), s->out_buf + offs, size);
}
}
s->out_ptr -= len;
memmove(s->out_buf, &s->out_buf[len], s->out_ptr);
}
|
[]
|
||
CVE-2016-2841
|
c850d0af2e3aef52362f6400c3db026d6aa23791
|
https://github.com/qemu/qemu/commit/415ab35a441eca767d033a2702223e785b9d5190
|
Vulnerability in CVE-2016-2841
| null | null | null | null |
CWE-20
|
Fix CVE-2016-2841
| null | null | null | null |
["hw/net/ne2000.c"]
|
C
|
{"hw/net/ne2000.c": {"lines_added": 18, "lines_deleted": 14}}
| null |
static int ne2000_buffer_full(NE2000State *s)
{
int avail, index, boundary;
index = s->curpag << 8;
boundary = s->boundary << 8;
if (index < boundary)
avail = boundary - index;
else
avail = (s->stop - s->start) - (index - boundary);
if (avail < (MAX_ETH_FRAME_SIZE + 4))
return 1;
return 0;
}
|
static int ne2000_buffer_full(NE2000State *s)
{
int avail, index, boundary;
if (s->stop <= s->start) {
return 1;
}
index = s->curpag << 8;
boundary = s->boundary << 8;
if (index < boundary)
avail = boundary - index;
else
avail = (s->stop - s->start) - (index - boundary);
if (avail < (MAX_ETH_FRAME_SIZE + 4))
return 1;
return 0;
}
|
[]
|
||
CVE-2016-2841
|
bcd29f20ad400b95990dac5f741c4bf70e6f6e8a
|
https://github.com/qemu/qemu/commit/415ab35a441eca767d033a2702223e785b9d5190
|
Vulnerability in CVE-2016-2841
| null | null | null | null |
CWE-20
|
Fix CVE-2016-2841
| null | null | null | null |
["hw/net/ne2000.c"]
|
C
|
{"hw/net/ne2000.c": {"lines_added": 11, "lines_deleted": 0}}
| null | null |
static inline uint32_t ne2000_mem_readl(NE2000State *s, uint32_t addr)
{
addr &= ~1; /* XXX: check exact behaviour if not even */
if (addr < 32
|| (addr >= NE2000_PMEM_START
&& addr + sizeof(uint32_t) <= NE2000_MEM_SIZE)) {
return ldl_le_p(s->mem + addr);
} else {
return 0xffffffff;
}
}
|
[]
|
||
CVE-2016-2841
|
bcd29f20ad400b95990dac5f741c4bf70e6f6e8a
|
https://github.com/qemu/qemu/commit/415ab35a441eca767d033a2702223e785b9d5190
|
Vulnerability in CVE-2016-2841
| null | null | null | null |
CWE-20
|
Fix CVE-2016-2841
| null | null | null | null |
["hw/net/ne2000.c"]
|
C
|
{"hw/net/ne2000.c": {"lines_added": 10, "lines_deleted": 0}}
| null | null |
static inline void ne2000_mem_writel(NE2000State *s, uint32_t addr,
uint32_t val)
{
addr &= ~1; /* XXX: check exact behaviour if not even */
if (addr < 32
|| (addr >= NE2000_PMEM_START
&& addr + sizeof(uint32_t) <= NE2000_MEM_SIZE)) {
stl_le_p(s->mem + addr, val);
}
}
|
[]
|
||
CVE-2016-3062
|
49e83785fb9310c31438b0710bc8d017fb35867e
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 107, "lines_deleted": 106}}
| null |
static int mov_read_dref(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
MOVStreamContext *sc;
int entries, i, j;
if (c->fc->nb_streams < 1)
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
avio_rb32(pb); // version + flags
entries = avio_rb32(pb);
if (entries >= UINT_MAX / sizeof(*sc->drefs))
return AVERROR_INVALIDDATA;
av_free(sc->drefs);
sc->drefs = av_mallocz(entries * sizeof(*sc->drefs));
if (!sc->drefs)
return AVERROR(ENOMEM);
sc->drefs_count = entries;
for (i = 0; i < sc->drefs_count; i++) {
MOVDref *dref = &sc->drefs[i];
uint32_t size = avio_rb32(pb);
int64_t next = avio_tell(pb) + size - 4;
if (size < 12)
return AVERROR_INVALIDDATA;
dref->type = avio_rl32(pb);
avio_rb32(pb); // version + flags
av_dlog(c->fc, "type %.4s size %d\n", (char*)&dref->type, size);
if (dref->type == MKTAG('a','l','i','s') && size > 150) {
/* macintosh alias record */
uint16_t volume_len, len;
int16_t type;
avio_skip(pb, 10);
volume_len = avio_r8(pb);
volume_len = FFMIN(volume_len, 27);
avio_read(pb, dref->volume, 27);
dref->volume[volume_len] = 0;
av_log(c->fc, AV_LOG_DEBUG, "volume %s, len %d\n", dref->volume, volume_len);
avio_skip(pb, 12);
len = avio_r8(pb);
len = FFMIN(len, 63);
avio_read(pb, dref->filename, 63);
dref->filename[len] = 0;
av_log(c->fc, AV_LOG_DEBUG, "filename %s, len %d\n", dref->filename, len);
avio_skip(pb, 16);
/* read next level up_from_alias/down_to_target */
dref->nlvl_from = avio_rb16(pb);
dref->nlvl_to = avio_rb16(pb);
av_log(c->fc, AV_LOG_DEBUG, "nlvl from %d, nlvl to %d\n",
dref->nlvl_from, dref->nlvl_to);
avio_skip(pb, 16);
for (type = 0; type != -1 && avio_tell(pb) < next; ) {
if(url_feof(pb))
return AVERROR_EOF;
type = avio_rb16(pb);
len = avio_rb16(pb);
av_log(c->fc, AV_LOG_DEBUG, "type %d, len %d\n", type, len);
if (len&1)
len += 1;
if (type == 2) { // absolute path
av_free(dref->path);
dref->path = av_mallocz(len+1);
if (!dref->path)
return AVERROR(ENOMEM);
avio_read(pb, dref->path, len);
if (len > volume_len && !strncmp(dref->path, dref->volume, volume_len)) {
len -= volume_len;
memmove(dref->path, dref->path+volume_len, len);
dref->path[len] = 0;
}
for (j = 0; j < len; j++)
if (dref->path[j] == ':')
dref->path[j] = '/';
av_log(c->fc, AV_LOG_DEBUG, "path %s\n", dref->path);
} else if (type == 0) { // directory name
av_free(dref->dir);
dref->dir = av_malloc(len+1);
if (!dref->dir)
return AVERROR(ENOMEM);
avio_read(pb, dref->dir, len);
dref->dir[len] = 0;
for (j = 0; j < len; j++)
if (dref->dir[j] == ':')
dref->dir[j] = '/';
av_log(c->fc, AV_LOG_DEBUG, "dir %s\n", dref->dir);
} else
avio_skip(pb, len);
}
}
avio_seek(pb, next, SEEK_SET);
}
return 0;
}
|
static int mov_read_dref(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
MOVStreamContext *sc;
int entries, i, j;
if (c->fc->nb_streams < 1)
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
avio_rb32(pb); // version + flags
entries = avio_rb32(pb);
if (entries >= UINT_MAX / sizeof(*sc->drefs))
return AVERROR_INVALIDDATA;
av_free(sc->drefs);
sc->drefs_count = 0;
sc->drefs = av_mallocz(entries * sizeof(*sc->drefs));
if (!sc->drefs)
return AVERROR(ENOMEM);
sc->drefs_count = entries;
for (i = 0; i < sc->drefs_count; i++) {
MOVDref *dref = &sc->drefs[i];
uint32_t size = avio_rb32(pb);
int64_t next = avio_tell(pb) + size - 4;
if (size < 12)
return AVERROR_INVALIDDATA;
dref->type = avio_rl32(pb);
avio_rb32(pb); // version + flags
av_dlog(c->fc, "type %.4s size %d\n", (char*)&dref->type, size);
if (dref->type == MKTAG('a','l','i','s') && size > 150) {
/* macintosh alias record */
uint16_t volume_len, len;
int16_t type;
avio_skip(pb, 10);
volume_len = avio_r8(pb);
volume_len = FFMIN(volume_len, 27);
avio_read(pb, dref->volume, 27);
dref->volume[volume_len] = 0;
av_log(c->fc, AV_LOG_DEBUG, "volume %s, len %d\n", dref->volume, volume_len);
avio_skip(pb, 12);
len = avio_r8(pb);
len = FFMIN(len, 63);
avio_read(pb, dref->filename, 63);
dref->filename[len] = 0;
av_log(c->fc, AV_LOG_DEBUG, "filename %s, len %d\n", dref->filename, len);
avio_skip(pb, 16);
/* read next level up_from_alias/down_to_target */
dref->nlvl_from = avio_rb16(pb);
dref->nlvl_to = avio_rb16(pb);
av_log(c->fc, AV_LOG_DEBUG, "nlvl from %d, nlvl to %d\n",
dref->nlvl_from, dref->nlvl_to);
avio_skip(pb, 16);
for (type = 0; type != -1 && avio_tell(pb) < next; ) {
if(url_feof(pb))
return AVERROR_EOF;
type = avio_rb16(pb);
len = avio_rb16(pb);
av_log(c->fc, AV_LOG_DEBUG, "type %d, len %d\n", type, len);
if (len&1)
len += 1;
if (type == 2) { // absolute path
av_free(dref->path);
dref->path = av_mallocz(len+1);
if (!dref->path)
return AVERROR(ENOMEM);
avio_read(pb, dref->path, len);
if (len > volume_len && !strncmp(dref->path, dref->volume, volume_len)) {
len -= volume_len;
memmove(dref->path, dref->path+volume_len, len);
dref->path[len] = 0;
}
for (j = 0; j < len; j++)
if (dref->path[j] == ':')
dref->path[j] = '/';
av_log(c->fc, AV_LOG_DEBUG, "path %s\n", dref->path);
} else if (type == 0) { // directory name
av_free(dref->dir);
dref->dir = av_malloc(len+1);
if (!dref->dir)
return AVERROR(ENOMEM);
avio_read(pb, dref->dir, len);
dref->dir[len] = 0;
for (j = 0; j < len; j++)
if (dref->dir[j] == ':')
dref->dir[j] = '/';
av_log(c->fc, AV_LOG_DEBUG, "dir %s\n", dref->dir);
} else
avio_skip(pb, len);
}
}
avio_seek(pb, next, SEEK_SET);
}
return 0;
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 11, "lines_deleted": 0}}
| null | null |
static int mov_read_moov(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
int ret;
if ((ret = mov_read_default(c, pb, atom)) < 0)
return ret;
/* we parsed the 'moov' atom, we can terminate the parsing as soon as we find the 'mdat' */
/* so we don't parse the whole file if over a network */
c->found_moov=1;
return 0; /* now go for mdat */
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 6, "lines_deleted": 0}}
| null | null |
static int mov_read_moof(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
c->fragment.moof_offset = avio_tell(pb) - 8;
av_dlog(c->fc, "moof offset %"PRIx64"\n", c->fragment.moof_offset);
return mov_read_default(c, pb, atom);
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 93, "lines_deleted": 0}}
| null | null |
static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
MOVStreamContext *sc;
int ret;
st = avformat_new_stream(c->fc, NULL);
if (!st) return AVERROR(ENOMEM);
st->id = c->fc->nb_streams;
sc = av_mallocz(sizeof(MOVStreamContext));
if (!sc) return AVERROR(ENOMEM);
st->priv_data = sc;
st->codec->codec_type = AVMEDIA_TYPE_DATA;
sc->ffindex = st->index;
if ((ret = mov_read_default(c, pb, atom)) < 0)
return ret;
/* sanity checks */
if (sc->chunk_count && (!sc->stts_count || !sc->stsc_count ||
(!sc->sample_size && !sc->sample_count))) {
av_log(c->fc, AV_LOG_ERROR, "stream %d, missing mandatory atoms, broken header\n",
st->index);
return 0;
}
if (sc->time_scale <= 0) {
av_log(c->fc, AV_LOG_WARNING, "stream %d, timescale not set\n", st->index);
sc->time_scale = c->time_scale;
if (sc->time_scale <= 0)
sc->time_scale = 1;
}
avpriv_set_pts_info(st, 64, 1, sc->time_scale);
mov_build_index(c, st);
if (sc->dref_id-1 < sc->drefs_count && sc->drefs[sc->dref_id-1].path) {
MOVDref *dref = &sc->drefs[sc->dref_id - 1];
if (mov_open_dref(&sc->pb, c->fc->filename, dref, &c->fc->interrupt_callback,
c->use_absolute_path, c->fc) < 0)
av_log(c->fc, AV_LOG_ERROR,
"stream %d, error opening alias: path='%s', dir='%s', "
"filename='%s', volume='%s', nlvl_from=%d, nlvl_to=%d\n",
st->index, dref->path, dref->dir, dref->filename,
dref->volume, dref->nlvl_from, dref->nlvl_to);
} else
sc->pb = c->fc->pb;
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if (!st->sample_aspect_ratio.num &&
(st->codec->width != sc->width || st->codec->height != sc->height)) {
st->sample_aspect_ratio = av_d2q(((double)st->codec->height * sc->width) /
((double)st->codec->width * sc->height), INT_MAX);
}
av_reduce(&st->avg_frame_rate.num, &st->avg_frame_rate.den,
sc->time_scale*st->nb_frames, st->duration, INT_MAX);
if (sc->stts_count == 1 || (sc->stts_count == 2 && sc->stts_data[1].count == 1))
av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den,
sc->time_scale, sc->stts_data[0].duration, INT_MAX);
}
switch (st->codec->codec_id) {
#if CONFIG_H261_DECODER
case CODEC_ID_H261:
#endif
#if CONFIG_H263_DECODER
case CODEC_ID_H263:
#endif
#if CONFIG_H264_DECODER
case CODEC_ID_H264:
#endif
#if CONFIG_MPEG4_DECODER
case CODEC_ID_MPEG4:
#endif
st->codec->width = 0; /* let decoder init width/height */
st->codec->height= 0;
break;
}
/* Do not need those anymore. */
av_freep(&sc->chunk_offsets);
av_freep(&sc->stsc_data);
av_freep(&sc->sample_sizes);
av_freep(&sc->keyframes);
av_freep(&sc->stts_data);
av_freep(&sc->stps_data);
return 0;
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 85, "lines_deleted": 0}}
| null | null |
static int mov_read_packet(AVFormatContext *s, AVPacket *pkt)
{
MOVContext *mov = s->priv_data;
MOVStreamContext *sc;
AVIndexEntry *sample;
AVStream *st = NULL;
int ret;
mov->fc = s;
retry:
sample = mov_find_next_sample(s, &st);
if (!sample) {
mov->found_mdat = 0;
if (!mov->next_root_atom)
return AVERROR_EOF;
avio_seek(s->pb, mov->next_root_atom, SEEK_SET);
mov->next_root_atom = 0;
if (mov_read_default(mov, s->pb, (MOVAtom){ AV_RL32("root"), INT64_MAX }) < 0 ||
url_feof(s->pb))
return AVERROR_EOF;
av_dlog(s, "read fragments, offset 0x%"PRIx64"\n", avio_tell(s->pb));
goto retry;
}
sc = st->priv_data;
/* must be done just before reading, to avoid infinite loop on sample */
sc->current_sample++;
if (st->discard != AVDISCARD_ALL) {
if (avio_seek(sc->pb, sample->pos, SEEK_SET) != sample->pos) {
av_log(mov->fc, AV_LOG_ERROR, "stream %d, offset 0x%"PRIx64": partial file\n",
sc->ffindex, sample->pos);
return AVERROR_INVALIDDATA;
}
ret = av_get_packet(sc->pb, pkt, sample->size);
if (ret < 0)
return ret;
if (sc->has_palette) {
uint8_t *pal;
pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, AVPALETTE_SIZE);
if (!pal) {
av_log(mov->fc, AV_LOG_ERROR, "Cannot append palette to packet\n");
} else {
memcpy(pal, sc->palette, AVPALETTE_SIZE);
sc->has_palette = 0;
}
}
#if CONFIG_DV_DEMUXER
if (mov->dv_demux && sc->dv_audio_container) {
avpriv_dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size, pkt->pos);
av_free(pkt->data);
pkt->size = 0;
ret = avpriv_dv_get_packet(mov->dv_demux, pkt);
if (ret < 0)
return ret;
}
#endif
}
pkt->stream_index = sc->ffindex;
pkt->dts = sample->timestamp;
if (sc->ctts_data && sc->ctts_index < sc->ctts_count) {
pkt->pts = pkt->dts + sc->dts_shift + sc->ctts_data[sc->ctts_index].duration;
/* update ctts context */
sc->ctts_sample++;
if (sc->ctts_index < sc->ctts_count &&
sc->ctts_data[sc->ctts_index].count == sc->ctts_sample) {
sc->ctts_index++;
sc->ctts_sample = 0;
}
if (sc->wrong_dts)
pkt->dts = AV_NOPTS_VALUE;
} else {
int64_t next_dts = (sc->current_sample < st->nb_index_entries) ?
st->index_entries[sc->current_sample].timestamp : st->duration;
pkt->duration = next_dts - pkt->dts;
pkt->pts = pkt->dts;
}
if (st->discard == AVDISCARD_ALL)
goto retry;
pkt->flags |= sample->flags & AVINDEX_KEYFRAME ? AV_PKT_FLAG_KEY : 0;
pkt->pos = sample->pos;
av_dlog(s, "stream %d, pts %"PRId64", dts %"PRId64", pos 0x%"PRIx64", duration %d\n",
pkt->stream_index, pkt->pts, pkt->dts, pkt->pos, pkt->duration);
return 0;
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 15, "lines_deleted": 0}}
| null | null |
static int mov_metadata_int8_bypass_padding(MOVContext *c, AVIOContext *pb,
unsigned len, const char *key)
{
char buf[16];
/* bypass padding bytes */
avio_r8(pb);
avio_r8(pb);
avio_r8(pb);
snprintf(buf, sizeof(buf), "%d", avio_r8(pb));
av_dict_set(&c->fc->metadata, key, buf, 0);
return 0;
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 48, "lines_deleted": 0}}
| null | null |
static int mov_read_header(AVFormatContext *s)
{
MOVContext *mov = s->priv_data;
AVIOContext *pb = s->pb;
int err;
MOVAtom atom = { AV_RL32("root") };
mov->fc = s;
/* .mov and .mp4 aren't streamable anyway (only progressive download if moov is before mdat) */
if (pb->seekable)
atom.size = avio_size(pb);
else
atom.size = INT64_MAX;
/* check MOV header */
if ((err = mov_read_default(mov, pb, atom)) < 0) {
av_log(s, AV_LOG_ERROR, "error reading header: %d\n", err);
mov_read_close(s);
return err;
}
if (!mov->found_moov) {
av_log(s, AV_LOG_ERROR, "moov atom not found\n");
mov_read_close(s);
return AVERROR_INVALIDDATA;
}
av_dlog(mov->fc, "on_parse_exit_offset=%"PRId64"\n", avio_tell(pb));
if (pb->seekable) {
int i;
if (mov->chapter_track > 0)
mov_read_chapters(s);
for (i = 0; i < s->nb_streams; i++)
if (s->streams[i]->codec->codec_tag == AV_RL32("tmcd"))
mov_read_timecode_track(s, s->streams[i]);
}
if (mov->trex_data) {
int i;
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
MOVStreamContext *sc = st->priv_data;
if (st->duration)
st->codec->bit_rate = sc->data_size * 8 * sc->time_scale / st->duration;
}
}
return 0;
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 4, "lines_deleted": 0}}
| null | null |
static int mov_read_esds(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
return ff_mov_read_esds(c->fc, pb, atom);
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 10, "lines_deleted": 0}}
| null | null |
static int mov_metadata_int8_no_padding(MOVContext *c, AVIOContext *pb,
unsigned len, const char *key)
{
char buf[16];
snprintf(buf, sizeof(buf), "%d", avio_r8(pb));
av_dict_set(&c->fc->metadata, key, buf, 0);
return 0;
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 8, "lines_deleted": 0}}
| null | null |
static int mov_read_chan2(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
if (atom.size < 16)
return 0;
avio_skip(pb, 4);
ff_mov_read_chan(c->fc, atom.size - 4, c->fc->streams[0]->codec);
return 0;
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 39, "lines_deleted": 0}}
| null | null |
static int mov_read_close(AVFormatContext *s)
{
MOVContext *mov = s->priv_data;
int i, j;
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
MOVStreamContext *sc = st->priv_data;
av_freep(&sc->ctts_data);
for (j = 0; j < sc->drefs_count; j++) {
av_freep(&sc->drefs[j].path);
av_freep(&sc->drefs[j].dir);
}
av_freep(&sc->drefs);
if (sc->pb && sc->pb != s->pb)
avio_close(sc->pb);
sc->pb = NULL;
av_freep(&sc->chunk_offsets);
av_freep(&sc->keyframes);
av_freep(&sc->sample_sizes);
av_freep(&sc->stps_data);
av_freep(&sc->stsc_data);
av_freep(&sc->stts_data);
}
if (mov->dv_demux) {
for (i = 0; i < mov->dv_fctx->nb_streams; i++) {
av_freep(&mov->dv_fctx->streams[i]->codec);
av_freep(&mov->dv_fctx->streams[i]);
}
av_freep(&mov->dv_fctx);
av_freep(&mov->dv_demux);
}
av_freep(&mov->trex_data);
return 0;
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 51, "lines_deleted": 0}}
| null | null |
static int mov_read_hdlr(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
uint32_t type;
uint32_t av_unused ctype;
int title_size;
char *title_str;
if (c->fc->nb_streams < 1) // meta before first trak
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
avio_r8(pb); /* version */
avio_rb24(pb); /* flags */
/* component type */
ctype = avio_rl32(pb);
type = avio_rl32(pb); /* component subtype */
av_dlog(c->fc, "ctype= %.4s (0x%08x)\n", (char*)&ctype, ctype);
av_dlog(c->fc, "stype= %.4s\n", (char*)&type);
if (type == MKTAG('v','i','d','e'))
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
else if (type == MKTAG('s','o','u','n'))
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
else if (type == MKTAG('m','1','a',' '))
st->codec->codec_id = CODEC_ID_MP2;
else if ((type == MKTAG('s','u','b','p')) || (type == MKTAG('c','l','c','p')))
st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
avio_rb32(pb); /* component manufacture */
avio_rb32(pb); /* component flags */
avio_rb32(pb); /* component flags mask */
title_size = atom.size - 24;
if (title_size > 0) {
title_str = av_malloc(title_size + 1); /* Add null terminator */
if (!title_str)
return AVERROR(ENOMEM);
avio_read(pb, title_str, title_size);
title_str[title_size] = 0;
if (title_str[0])
av_dict_set(&st->metadata, "handler_name", title_str +
(!c->isom && title_str[0] == title_size - 1), 0);
av_freep(&title_str);
}
return 0;
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 4, "lines_deleted": 0}}
| null | null |
static int mov_read_alac(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
return mov_read_extradata(c, pb, atom, CODEC_ID_ALAC);
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 72, "lines_deleted": 0}}
| null | null |
static int mov_read_stsz(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
MOVStreamContext *sc;
unsigned int i, entries, sample_size, field_size, num_bytes;
GetBitContext gb;
unsigned char* buf;
if (c->fc->nb_streams < 1)
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
avio_r8(pb); /* version */
avio_rb24(pb); /* flags */
if (atom.type == MKTAG('s','t','s','z')) {
sample_size = avio_rb32(pb);
if (!sc->sample_size) /* do not overwrite value computed in stsd */
sc->sample_size = sample_size;
sc->alt_sample_size = sample_size;
field_size = 32;
} else {
sample_size = 0;
avio_rb24(pb); /* reserved */
field_size = avio_r8(pb);
}
entries = avio_rb32(pb);
av_dlog(c->fc, "sample_size = %d sample_count = %d\n", sc->sample_size, entries);
sc->sample_count = entries;
if (sample_size)
return 0;
if (field_size != 4 && field_size != 8 && field_size != 16 && field_size != 32) {
av_log(c->fc, AV_LOG_ERROR, "Invalid sample field size %d\n", field_size);
return AVERROR_INVALIDDATA;
}
if (!entries)
return 0;
if (entries >= UINT_MAX / sizeof(int) || entries >= (UINT_MAX - 4) / field_size)
return AVERROR_INVALIDDATA;
sc->sample_sizes = av_malloc(entries * sizeof(int));
if (!sc->sample_sizes)
return AVERROR(ENOMEM);
num_bytes = (entries*field_size+4)>>3;
buf = av_malloc(num_bytes+FF_INPUT_BUFFER_PADDING_SIZE);
if (!buf) {
av_freep(&sc->sample_sizes);
return AVERROR(ENOMEM);
}
if (avio_read(pb, buf, num_bytes) < num_bytes) {
av_freep(&sc->sample_sizes);
av_free(buf);
return AVERROR_INVALIDDATA;
}
init_get_bits(&gb, buf, 8*num_bytes);
for (i = 0; i < entries; i++) {
sc->sample_sizes[i] = get_bits_long(&gb, field_size);
sc->data_size += sc->sample_sizes[i];
}
av_free(buf);
return 0;
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 97, "lines_deleted": 0}}
| null | null |
static int mov_read_tkhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
int i;
int width;
int height;
int64_t disp_transform[2];
int display_matrix[3][2];
AVStream *st;
MOVStreamContext *sc;
int version;
if (c->fc->nb_streams < 1)
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
version = avio_r8(pb);
avio_rb24(pb); /* flags */
/*
MOV_TRACK_ENABLED 0x0001
MOV_TRACK_IN_MOVIE 0x0002
MOV_TRACK_IN_PREVIEW 0x0004
MOV_TRACK_IN_POSTER 0x0008
*/
if (version == 1) {
avio_rb64(pb);
avio_rb64(pb);
} else {
avio_rb32(pb); /* creation time */
avio_rb32(pb); /* modification time */
}
st->id = (int)avio_rb32(pb); /* track id (NOT 0 !)*/
avio_rb32(pb); /* reserved */
/* highlevel (considering edits) duration in movie timebase */
(version == 1) ? avio_rb64(pb) : avio_rb32(pb);
avio_rb32(pb); /* reserved */
avio_rb32(pb); /* reserved */
avio_rb16(pb); /* layer */
avio_rb16(pb); /* alternate group */
avio_rb16(pb); /* volume */
avio_rb16(pb); /* reserved */
//read in the display matrix (outlined in ISO 14496-12, Section 6.2.2)
// they're kept in fixed point format through all calculations
// ignore u,v,z b/c we don't need the scale factor to calc aspect ratio
for (i = 0; i < 3; i++) {
display_matrix[i][0] = avio_rb32(pb); // 16.16 fixed point
display_matrix[i][1] = avio_rb32(pb); // 16.16 fixed point
avio_rb32(pb); // 2.30 fixed point (not used)
}
width = avio_rb32(pb); // 16.16 fixed point track width
height = avio_rb32(pb); // 16.16 fixed point track height
sc->width = width >> 16;
sc->height = height >> 16;
//Assign clockwise rotate values based on transform matrix so that
//we can compensate for iPhone orientation during capture.
if (display_matrix[1][0] == -65536 && display_matrix[0][1] == 65536) {
av_dict_set(&st->metadata, "rotate", "90", 0);
}
if (display_matrix[0][0] == -65536 && display_matrix[1][1] == -65536) {
av_dict_set(&st->metadata, "rotate", "180", 0);
}
if (display_matrix[1][0] == 65536 && display_matrix[0][1] == -65536) {
av_dict_set(&st->metadata, "rotate", "270", 0);
}
// transform the display width/height according to the matrix
// skip this if the display matrix is the default identity matrix
// or if it is rotating the picture, ex iPhone 3GS
// to keep the same scale, use [width height 1<<16]
if (width && height &&
((display_matrix[0][0] != 65536 ||
display_matrix[1][1] != 65536) &&
!display_matrix[0][1] &&
!display_matrix[1][0] &&
!display_matrix[2][0] && !display_matrix[2][1])) {
for (i = 0; i < 2; i++)
disp_transform[i] =
(int64_t) width * display_matrix[0][i] +
(int64_t) height * display_matrix[1][i] +
((int64_t) display_matrix[2][i] << 16);
//sample aspect ratio is new width/height divided by old width/height
st->sample_aspect_ratio = av_d2q(
((double) disp_transform[0] * height) /
((double) disp_transform[1] * width), INT_MAX);
}
return 0;
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 18, "lines_deleted": 0}}
| null | null |
static int mov_metadata_track_or_disc_number(MOVContext *c, AVIOContext *pb,
unsigned len, const char *key)
{
char buf[16];
short current, total = 0;
avio_rb16(pb); // unknown
current = avio_rb16(pb);
if (len >= 6)
total = avio_rb16(pb);
if (!total)
snprintf(buf, sizeof(buf), "%d", current);
else
snprintf(buf, sizeof(buf), "%d/%d", current, total);
av_dict_set(&c->fc->metadata, key, buf, 0);
return 0;
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 104, "lines_deleted": 0}}
| null | null |
static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
#ifdef MOV_EXPORT_ALL_METADATA
char tmp_key[5];
#endif
char str[1024], key2[16], language[4] = {0};
const char *key = NULL;
uint16_t str_size, langcode = 0;
uint32_t data_type = 0;
int (*parse)(MOVContext*, AVIOContext*, unsigned, const char*) = NULL;
switch (atom.type) {
case MKTAG(0xa9,'n','a','m'): key = "title"; break;
case MKTAG(0xa9,'a','u','t'):
case MKTAG(0xa9,'A','R','T'): key = "artist"; break;
case MKTAG( 'a','A','R','T'): key = "album_artist"; break;
case MKTAG(0xa9,'w','r','t'): key = "composer"; break;
case MKTAG( 'c','p','r','t'):
case MKTAG(0xa9,'c','p','y'): key = "copyright"; break;
case MKTAG(0xa9,'g','r','p'): key = "grouping"; break;
case MKTAG(0xa9,'l','y','r'): key = "lyrics"; break;
case MKTAG(0xa9,'c','m','t'):
case MKTAG(0xa9,'i','n','f'): key = "comment"; break;
case MKTAG(0xa9,'a','l','b'): key = "album"; break;
case MKTAG(0xa9,'d','a','y'): key = "date"; break;
case MKTAG(0xa9,'g','e','n'): key = "genre"; break;
case MKTAG( 'g','n','r','e'): key = "genre";
parse = mov_metadata_gnre; break;
case MKTAG(0xa9,'t','o','o'):
case MKTAG(0xa9,'s','w','r'): key = "encoder"; break;
case MKTAG(0xa9,'e','n','c'): key = "encoder"; break;
case MKTAG( 'd','e','s','c'): key = "description";break;
case MKTAG( 'l','d','e','s'): key = "synopsis"; break;
case MKTAG( 't','v','s','h'): key = "show"; break;
case MKTAG( 't','v','e','n'): key = "episode_id";break;
case MKTAG( 't','v','n','n'): key = "network"; break;
case MKTAG( 't','r','k','n'): key = "track";
parse = mov_metadata_track_or_disc_number; break;
case MKTAG( 'd','i','s','k'): key = "disc";
parse = mov_metadata_track_or_disc_number; break;
case MKTAG( 't','v','e','s'): key = "episode_sort";
parse = mov_metadata_int8_bypass_padding; break;
case MKTAG( 't','v','s','n'): key = "season_number";
parse = mov_metadata_int8_bypass_padding; break;
case MKTAG( 's','t','i','k'): key = "media_type";
parse = mov_metadata_int8_no_padding; break;
case MKTAG( 'h','d','v','d'): key = "hd_video";
parse = mov_metadata_int8_no_padding; break;
case MKTAG( 'p','g','a','p'): key = "gapless_playback";
parse = mov_metadata_int8_no_padding; break;
}
if (c->itunes_metadata && atom.size > 8) {
int data_size = avio_rb32(pb);
int tag = avio_rl32(pb);
if (tag == MKTAG('d','a','t','a')) {
data_type = avio_rb32(pb); // type
avio_rb32(pb); // unknown
str_size = data_size - 16;
atom.size -= 16;
} else return 0;
} else if (atom.size > 4 && key && !c->itunes_metadata) {
str_size = avio_rb16(pb); // string length
langcode = avio_rb16(pb);
ff_mov_lang_to_iso639(langcode, language);
atom.size -= 4;
} else
str_size = atom.size;
#ifdef MOV_EXPORT_ALL_METADATA
if (!key) {
snprintf(tmp_key, 5, "%.4s", (char*)&atom.type);
key = tmp_key;
}
#endif
if (!key)
return 0;
if (atom.size < 0)
return AVERROR_INVALIDDATA;
str_size = FFMIN3(sizeof(str)-1, str_size, atom.size);
if (parse)
parse(c, pb, str_size, key);
else {
if (data_type == 3 || (data_type == 0 && (langcode < 0x400 || langcode == 0x7fff))) { // MAC Encoded
mov_read_mac_string(c, pb, str_size, str, sizeof(str));
} else {
avio_read(pb, str, str_size);
str[str_size] = 0;
}
av_dict_set(&c->fc->metadata, key, str, 0);
if (*language && strcmp(language, "und")) {
snprintf(key2, sizeof(key2), "%s-%s", key, language);
av_dict_set(&c->fc->metadata, key2, str, 0);
}
}
av_dlog(c->fc, "lang \"%3s\" ", language);
av_dlog(c->fc, "tag \"%s\" value \"%s\" atom \"%.4s\" %d %"PRId64"\n",
key, str, (char*)&atom.type, str_size, atom.size);
return 0;
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 30, "lines_deleted": 0}}
| null | null |
enum CodecID ff_mov_get_lpcm_codec_id(int bps, int flags)
{
if (flags & 1) { // floating point
if (flags & 2) { // big endian
if (bps == 32) return CODEC_ID_PCM_F32BE;
else if (bps == 64) return CODEC_ID_PCM_F64BE;
} else {
if (bps == 32) return CODEC_ID_PCM_F32LE;
else if (bps == 64) return CODEC_ID_PCM_F64LE;
}
} else {
if (flags & 2) {
if (bps == 8)
// signed integer
if (flags & 4) return CODEC_ID_PCM_S8;
else return CODEC_ID_PCM_U8;
else if (bps == 16) return CODEC_ID_PCM_S16BE;
else if (bps == 24) return CODEC_ID_PCM_S24BE;
else if (bps == 32) return CODEC_ID_PCM_S32BE;
} else {
if (bps == 8)
if (flags & 4) return CODEC_ID_PCM_S8;
else return CODEC_ID_PCM_U8;
else if (bps == 16) return CODEC_ID_PCM_S16LE;
else if (bps == 24) return CODEC_ID_PCM_S24LE;
else if (bps == 32) return CODEC_ID_PCM_S32LE;
}
}
return CODEC_ID_NONE;
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 30, "lines_deleted": 0}}
| null | null |
static int mov_read_ftyp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
uint32_t minor_ver;
int comp_brand_size;
char minor_ver_str[11]; /* 32 bit integer -> 10 digits + null */
char* comp_brands_str;
uint8_t type[5] = {0};
avio_read(pb, type, 4);
if (strcmp(type, "qt "))
c->isom = 1;
av_log(c->fc, AV_LOG_DEBUG, "ISO: File Type Major Brand: %.4s\n",(char *)&type);
av_dict_set(&c->fc->metadata, "major_brand", type, 0);
minor_ver = avio_rb32(pb); /* minor version */
snprintf(minor_ver_str, sizeof(minor_ver_str), "%d", minor_ver);
av_dict_set(&c->fc->metadata, "minor_version", minor_ver_str, 0);
comp_brand_size = atom.size - 8;
if (comp_brand_size < 0)
return AVERROR_INVALIDDATA;
comp_brands_str = av_malloc(comp_brand_size + 1); /* Add null terminator */
if (!comp_brands_str)
return AVERROR(ENOMEM);
avio_read(pb, comp_brands_str, comp_brand_size);
comp_brands_str[comp_brand_size] = 0;
av_dict_set(&c->fc->metadata, "compatible_brands", comp_brands_str, 0);
av_freep(&comp_brands_str);
return 0;
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 95, "lines_deleted": 0}}
| null | null |
static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
MOVFragment *frag = &c->fragment;
AVStream *st = NULL;
MOVStreamContext *sc;
MOVStts *ctts_data;
uint64_t offset;
int64_t dts;
int data_offset = 0;
unsigned entries, first_sample_flags = frag->flags;
int flags, distance, i, found_keyframe = 0;
for (i = 0; i < c->fc->nb_streams; i++) {
if (c->fc->streams[i]->id == frag->track_id) {
st = c->fc->streams[i];
break;
}
}
if (!st) {
av_log(c->fc, AV_LOG_ERROR, "could not find corresponding track id %d\n", frag->track_id);
return AVERROR_INVALIDDATA;
}
sc = st->priv_data;
if (sc->pseudo_stream_id+1 != frag->stsd_id)
return 0;
avio_r8(pb); /* version */
flags = avio_rb24(pb);
entries = avio_rb32(pb);
av_dlog(c->fc, "flags 0x%x entries %d\n", flags, entries);
/* Always assume the presence of composition time offsets.
* Without this assumption, for instance, we cannot deal with a track in fragmented movies that meet the following.
* 1) in the initial movie, there are no samples.
* 2) in the first movie fragment, there is only one sample without composition time offset.
* 3) in the subsequent movie fragments, there are samples with composition time offset. */
if (!sc->ctts_count && sc->sample_count)
{
/* Complement ctts table if moov atom doesn't have ctts atom. */
ctts_data = av_malloc(sizeof(*sc->ctts_data));
if (!ctts_data)
return AVERROR(ENOMEM);
sc->ctts_data = ctts_data;
sc->ctts_data[sc->ctts_count].count = sc->sample_count;
sc->ctts_data[sc->ctts_count].duration = 0;
sc->ctts_count++;
}
if ((uint64_t)entries+sc->ctts_count >= UINT_MAX/sizeof(*sc->ctts_data))
return AVERROR_INVALIDDATA;
ctts_data = av_realloc(sc->ctts_data,
(entries+sc->ctts_count)*sizeof(*sc->ctts_data));
if (!ctts_data)
return AVERROR(ENOMEM);
sc->ctts_data = ctts_data;
if (flags & MOV_TRUN_DATA_OFFSET) data_offset = avio_rb32(pb);
if (flags & MOV_TRUN_FIRST_SAMPLE_FLAGS) first_sample_flags = avio_rb32(pb);
dts = sc->track_end - sc->time_offset;
offset = frag->base_data_offset + data_offset;
distance = 0;
av_dlog(c->fc, "first sample flags 0x%x\n", first_sample_flags);
for (i = 0; i < entries; i++) {
unsigned sample_size = frag->size;
int sample_flags = i ? frag->flags : first_sample_flags;
unsigned sample_duration = frag->duration;
int keyframe = 0;
if (flags & MOV_TRUN_SAMPLE_DURATION) sample_duration = avio_rb32(pb);
if (flags & MOV_TRUN_SAMPLE_SIZE) sample_size = avio_rb32(pb);
if (flags & MOV_TRUN_SAMPLE_FLAGS) sample_flags = avio_rb32(pb);
sc->ctts_data[sc->ctts_count].count = 1;
sc->ctts_data[sc->ctts_count].duration = (flags & MOV_TRUN_SAMPLE_CTS) ?
avio_rb32(pb) : 0;
sc->ctts_count++;
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
keyframe = 1;
else if (!found_keyframe)
keyframe = found_keyframe =
!(sample_flags & (MOV_FRAG_SAMPLE_FLAG_IS_NON_SYNC |
MOV_FRAG_SAMPLE_FLAG_DEPENDS_YES));
if (keyframe)
distance = 0;
av_add_index_entry(st, offset, dts, sample_size, distance,
keyframe ? AVINDEX_KEYFRAME : 0);
av_dlog(c->fc, "AVIndex stream %d, sample %d, offset %"PRIx64", dts %"PRId64", "
"size %d, distance %d, keyframe %d\n", st->index, sc->sample_count+i,
offset, dts, sample_size, distance, keyframe);
distance++;
dts += sample_duration;
offset += sample_size;
sc->data_size += sample_size;
}
frag->moof_offset = offset;
st->duration = sc->track_end = dts + sc->time_offset;
return 0;
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 16, "lines_deleted": 0}}
| null | null |
static int mov_metadata_gnre(MOVContext *c, AVIOContext *pb,
unsigned len, const char *key)
{
short genre;
char buf[20];
avio_r8(pb); // unknown
genre = avio_r8(pb);
if (genre < 1 || genre > ID3v1_GENRE_MAX)
return 0;
snprintf(buf, sizeof(buf), "%s", ff_id3v1_genre_str[genre-1]);
av_dict_set(&c->fc->metadata, key, buf, 0);
return 0;
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 12, "lines_deleted": 0}}
| null | null |
static int mov_read_wfex(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
if (c->fc->nb_streams < 1)
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
ff_get_wav_header(pb, st->codec, atom.size);
return 0;
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 36, "lines_deleted": 0}}
| null | null |
static int mov_read_stss(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
MOVStreamContext *sc;
unsigned int i, entries;
if (c->fc->nb_streams < 1)
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
avio_r8(pb); /* version */
avio_rb24(pb); /* flags */
entries = avio_rb32(pb);
av_dlog(c->fc, "keyframe_count = %d\n", entries);
if (!entries)
{
sc->keyframe_absent = 1;
return 0;
}
if (entries >= UINT_MAX / sizeof(int))
return AVERROR_INVALIDDATA;
sc->keyframes = av_malloc(entries * sizeof(int));
if (!sc->keyframes)
return AVERROR(ENOMEM);
sc->keyframe_count = entries;
for (i=0; i<entries; i++) {
sc->keyframes[i] = avio_rb32(pb);
//av_dlog(c->fc, "keyframes[]=%d\n", sc->keyframes[i]);
}
return 0;
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 40, "lines_deleted": 0}}
| null | null |
static int mov_read_mvhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
time_t creation_time;
int version = avio_r8(pb); /* version */
avio_rb24(pb); /* flags */
if (version == 1) {
creation_time = avio_rb64(pb);
avio_rb64(pb);
} else {
creation_time = avio_rb32(pb);
avio_rb32(pb); /* modification time */
}
mov_metadata_creation_time(&c->fc->metadata, creation_time);
c->time_scale = avio_rb32(pb); /* time scale */
av_dlog(c->fc, "time scale = %i\n", c->time_scale);
c->duration = (version == 1) ? avio_rb64(pb) : avio_rb32(pb); /* duration */
// set the AVCodecContext duration because the duration of individual tracks
// may be inaccurate
if (c->time_scale > 0)
c->fc->duration = av_rescale(c->duration, AV_TIME_BASE, c->time_scale);
avio_rb32(pb); /* preferred scale */
avio_rb16(pb); /* preferred volume */
avio_skip(pb, 10); /* reserved */
avio_skip(pb, 36); /* display matrix */
avio_rb32(pb); /* preview time */
avio_rb32(pb); /* preview duration */
avio_rb32(pb); /* poster time */
avio_rb32(pb); /* selection time */
avio_rb32(pb); /* selection duration */
avio_rb32(pb); /* current time */
avio_rb32(pb); /* next track ID */
return 0;
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 51, "lines_deleted": 0}}
| null | null |
static int mov_read_chan(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
uint8_t version;
uint32_t flags, layout_tag, bitmap, num_descr, label_mask;
int i;
if (c->fc->nb_streams < 1)
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
if (atom.size < 16)
return 0;
version = avio_r8(pb);
flags = avio_rb24(pb);
layout_tag = avio_rb32(pb);
bitmap = avio_rb32(pb);
num_descr = avio_rb32(pb);
if (atom.size < 16ULL + num_descr * 20ULL)
return 0;
av_dlog(c->fc, "chan: size=%" PRId64 " version=%u flags=%u layout=%u bitmap=%u num_descr=%u\n",
atom.size, version, flags, layout_tag, bitmap, num_descr);
label_mask = 0;
for (i = 0; i < num_descr; i++) {
uint32_t av_unused label, cflags;
label = avio_rb32(pb); // mChannelLabel
cflags = avio_rb32(pb); // mChannelFlags
avio_rl32(pb); // mCoordinates[0]
avio_rl32(pb); // mCoordinates[1]
avio_rl32(pb); // mCoordinates[2]
if (layout_tag == 0) {
uint32_t mask_incr = ff_mov_get_channel_label(label);
if (mask_incr == 0) {
label_mask = 0;
break;
}
label_mask |= mask_incr;
}
}
if (layout_tag == 0)
st->codec->channel_layout = label_mask;
else
st->codec->channel_layout = ff_mov_get_channel_layout(layout_tag, bitmap);
return 0;
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 36, "lines_deleted": 0}}
| null | null |
static int mov_read_tfhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
MOVFragment *frag = &c->fragment;
MOVTrackExt *trex = NULL;
int flags, track_id, i;
avio_r8(pb); /* version */
flags = avio_rb24(pb);
track_id = avio_rb32(pb);
if (!track_id)
return AVERROR_INVALIDDATA;
frag->track_id = track_id;
for (i = 0; i < c->trex_count; i++)
if (c->trex_data[i].track_id == frag->track_id) {
trex = &c->trex_data[i];
break;
}
if (!trex) {
av_log(c->fc, AV_LOG_ERROR, "could not find corresponding trex\n");
return AVERROR_INVALIDDATA;
}
frag->base_data_offset = flags & MOV_TFHD_BASE_DATA_OFFSET ?
avio_rb64(pb) : frag->moof_offset;
frag->stsd_id = flags & MOV_TFHD_STSD_ID ? avio_rb32(pb) : trex->stsd_id;
frag->duration = flags & MOV_TFHD_DEFAULT_DURATION ?
avio_rb32(pb) : trex->duration;
frag->size = flags & MOV_TFHD_DEFAULT_SIZE ?
avio_rb32(pb) : trex->size;
frag->flags = flags & MOV_TFHD_DEFAULT_FLAGS ?
avio_rb32(pb) : trex->flags;
av_dlog(c->fc, "frag flags 0x%x\n", frag->flags);
return 0;
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 26, "lines_deleted": 0}}
| null | null |
static int mov_read_dvc1(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
uint8_t profile_level;
if (c->fc->nb_streams < 1)
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
if (atom.size >= (1<<28) || atom.size < 7)
return AVERROR_INVALIDDATA;
profile_level = avio_r8(pb);
if (profile_level & 0xf0 != 0xc0)
return 0;
av_free(st->codec->extradata);
st->codec->extradata_size = 0;
st->codec->extradata = av_mallocz(atom.size - 7 + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
return AVERROR(ENOMEM);
st->codec->extradata_size = atom.size - 7;
avio_seek(pb, 6, SEEK_CUR);
avio_read(pb, st->codec->extradata, st->codec->extradata_size);
return 0;
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 4, "lines_deleted": 0}}
| null | null |
static int mov_read_avss(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
return mov_read_extradata(c, pb, atom, CODEC_ID_AVS);
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 30, "lines_deleted": 0}}
| null | null |
static int mov_read_seek(AVFormatContext *s, int stream_index, int64_t sample_time, int flags)
{
AVStream *st;
int64_t seek_timestamp, timestamp;
int sample;
int i;
if (stream_index >= s->nb_streams)
return AVERROR_INVALIDDATA;
if (sample_time < 0)
sample_time = 0;
st = s->streams[stream_index];
sample = mov_seek_stream(s, st, sample_time, flags);
if (sample < 0)
return sample;
/* adjust seek timestamp to found sample timestamp */
seek_timestamp = st->index_entries[sample].timestamp;
for (i = 0; i < s->nb_streams; i++) {
st = s->streams[i];
if (stream_index == i)
continue;
timestamp = av_rescale_q(seek_timestamp, s->streams[stream_index]->time_base, st->time_base);
mov_seek_stream(s, st, timestamp, flags);
}
return 0;
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 31, "lines_deleted": 0}}
| null | null |
static int mov_read_enda(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
int little_endian;
if (c->fc->nb_streams < 1)
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
little_endian = avio_rb16(pb) & 0xFF;
av_dlog(c->fc, "enda %d\n", little_endian);
if (little_endian == 1) {
switch (st->codec->codec_id) {
case CODEC_ID_PCM_S24BE:
st->codec->codec_id = CODEC_ID_PCM_S24LE;
break;
case CODEC_ID_PCM_S32BE:
st->codec->codec_id = CODEC_ID_PCM_S32LE;
break;
case CODEC_ID_PCM_F32BE:
st->codec->codec_id = CODEC_ID_PCM_F32LE;
break;
case CODEC_ID_PCM_F64BE:
st->codec->codec_id = CODEC_ID_PCM_F64LE;
break;
default:
break;
}
}
return 0;
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 24, "lines_deleted": 0}}
| null | null |
static int mov_read_smi(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
if (c->fc->nb_streams < 1)
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
if ((uint64_t)atom.size > (1<<30))
return AVERROR_INVALIDDATA;
// currently SVQ3 decoder expect full STSD header - so let's fake it
// this should be fixed and just SMI header should be passed
av_free(st->codec->extradata);
st->codec->extradata_size = 0;
st->codec->extradata = av_mallocz(atom.size + 0x5a + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
return AVERROR(ENOMEM);
st->codec->extradata_size = 0x5a + atom.size;
memcpy(st->codec->extradata, "SVQ3", 4); // fake
avio_read(pb, st->codec->extradata + 0x5a, atom.size);
av_dlog(c->fc, "Reading SMI %"PRId64" %s\n", atom.size, st->codec->extradata + 0x5a);
return 0;
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 29, "lines_deleted": 0}}
| null | null |
static int mov_read_glbl(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
if (c->fc->nb_streams < 1)
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
if ((uint64_t)atom.size > (1<<30))
return AVERROR_INVALIDDATA;
if (atom.size >= 10) {
// Broken files created by legacy versions of Libav and FFmpeg will
// wrap a whole fiel atom inside of a glbl atom.
unsigned size = avio_rb32(pb);
unsigned type = avio_rl32(pb);
avio_seek(pb, -8, SEEK_CUR);
if (type == MKTAG('f','i','e','l') && size == atom.size)
return mov_read_default(c, pb, atom);
}
av_free(st->codec->extradata);
st->codec->extradata_size = 0;
st->codec->extradata = av_mallocz(atom.size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
return AVERROR(ENOMEM);
st->codec->extradata_size = atom.size;
avio_read(pb, st->codec->extradata, atom.size);
return 0;
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 43, "lines_deleted": 0}}
| null | null |
static int mov_probe(AVProbeData *p)
{
unsigned int offset;
uint32_t tag;
int score = 0;
/* check file header */
offset = 0;
for (;;) {
/* ignore invalid offset */
if ((offset + 8) > (unsigned int)p->buf_size)
return score;
tag = AV_RL32(p->buf + offset + 4);
switch(tag) {
/* check for obvious tags */
case MKTAG('j','P',' ',' '): /* jpeg 2000 signature */
case MKTAG('m','o','o','v'):
case MKTAG('m','d','a','t'):
case MKTAG('p','n','o','t'): /* detect movs with preview pics like ew.mov and april.mov */
case MKTAG('u','d','t','a'): /* Packet Video PVAuthor adds this and a lot of more junk */
case MKTAG('f','t','y','p'):
return AVPROBE_SCORE_MAX;
/* those are more common words, so rate then a bit less */
case MKTAG('e','d','i','w'): /* xdcam files have reverted first tags */
case MKTAG('w','i','d','e'):
case MKTAG('f','r','e','e'):
case MKTAG('j','u','n','k'):
case MKTAG('p','i','c','t'):
return AVPROBE_SCORE_MAX - 5;
case MKTAG(0x82,0x82,0x7f,0x7d):
case MKTAG('s','k','i','p'):
case MKTAG('u','u','i','d'):
case MKTAG('p','r','f','l'):
offset = AV_RB32(p->buf+offset) + offset;
/* if we only find those cause probedata is too small at least rate them */
score = AVPROBE_SCORE_MAX - 50;
break;
default:
/* unrecognized tag */
return score;
}
}
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 4, "lines_deleted": 0}}
| null | null |
static int mov_read_jp2h(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
return mov_read_extradata(c, pb, atom, CODEC_ID_JPEG2000);
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 47, "lines_deleted": 0}}
| null | null |
static int mov_read_cmov(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
#if CONFIG_ZLIB
AVIOContext ctx;
uint8_t *cmov_data;
uint8_t *moov_data; /* uncompressed data */
long cmov_len, moov_len;
int ret = -1;
avio_rb32(pb); /* dcom atom */
if (avio_rl32(pb) != MKTAG('d','c','o','m'))
return AVERROR_INVALIDDATA;
if (avio_rl32(pb) != MKTAG('z','l','i','b')) {
av_log(c->fc, AV_LOG_ERROR, "unknown compression for cmov atom !");
return AVERROR_INVALIDDATA;
}
avio_rb32(pb); /* cmvd atom */
if (avio_rl32(pb) != MKTAG('c','m','v','d'))
return AVERROR_INVALIDDATA;
moov_len = avio_rb32(pb); /* uncompressed size */
cmov_len = atom.size - 6 * 4;
cmov_data = av_malloc(cmov_len);
if (!cmov_data)
return AVERROR(ENOMEM);
moov_data = av_malloc(moov_len);
if (!moov_data) {
av_free(cmov_data);
return AVERROR(ENOMEM);
}
avio_read(pb, cmov_data, cmov_len);
if (uncompress (moov_data, (uLongf *) &moov_len, (const Bytef *)cmov_data, cmov_len) != Z_OK)
goto free_and_return;
if (ffio_init_context(&ctx, moov_data, moov_len, 0, NULL, NULL, NULL, NULL) != 0)
goto free_and_return;
atom.type = MKTAG('m','o','o','v');
atom.size = moov_len;
ret = mov_read_default(c, &ctx, atom);
free_and_return:
av_free(moov_data);
av_free(cmov_data);
return ret;
#else
av_log(c->fc, AV_LOG_ERROR, "this file requires zlib support compiled in\n");
return AVERROR(ENOSYS);
#endif
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 41, "lines_deleted": 0}}
| null | null |
static int mov_read_elst(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
MOVStreamContext *sc;
int i, edit_count, version, edit_start_index = 0;
if (c->fc->nb_streams < 1)
return 0;
sc = c->fc->streams[c->fc->nb_streams-1]->priv_data;
version = avio_r8(pb); /* version */
avio_rb24(pb); /* flags */
edit_count = avio_rb32(pb); /* entries */
if ((uint64_t)edit_count*12+8 > atom.size)
return AVERROR_INVALIDDATA;
for (i=0; i<edit_count; i++){
int64_t time;
int64_t duration;
if (version == 1) {
duration = avio_rb64(pb);
time = avio_rb64(pb);
} else {
duration = avio_rb32(pb); /* segment duration */
time = (int32_t)avio_rb32(pb); /* media time */
}
avio_rb32(pb); /* Media rate */
if (i == 0 && time == -1) {
sc->empty_duration = duration;
edit_start_index = 1;
} else if (i == edit_start_index && time >= 0)
sc->start_time = time;
}
if (edit_count > 1)
av_log(c->fc, AV_LOG_WARNING, "multiple edit list entries, "
"a/v desync might occur, patch welcome\n");
av_dlog(c->fc, "track[%i].edit_count = %i\n", c->fc->nb_streams-1, edit_count);
return 0;
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 23, "lines_deleted": 0}}
| null | null |
static int mov_read_strf(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
if (c->fc->nb_streams < 1)
return 0;
if (atom.size <= 40)
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
if ((uint64_t)atom.size > (1<<30))
return AVERROR_INVALIDDATA;
av_free(st->codec->extradata);
st->codec->extradata_size = 0;
st->codec->extradata = av_mallocz(atom.size - 40 + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
return AVERROR(ENOMEM);
st->codec->extradata_size = atom.size - 40;
avio_skip(pb, 40);
avio_read(pb, st->codec->extradata, atom.size - 40);
return 0;
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 28, "lines_deleted": 0}}
| null | null |
static int mov_read_stps(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
MOVStreamContext *sc;
unsigned i, entries;
if (c->fc->nb_streams < 1)
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
avio_rb32(pb); // version + flags
entries = avio_rb32(pb);
if (entries >= UINT_MAX / sizeof(*sc->stps_data))
return AVERROR_INVALIDDATA;
sc->stps_data = av_malloc(entries * sizeof(*sc->stps_data));
if (!sc->stps_data)
return AVERROR(ENOMEM);
sc->stps_count = entries;
for (i = 0; i < entries; i++) {
sc->stps_data[i] = avio_rb32(pb);
//av_dlog(c->fc, "stps %d\n", sc->stps_data[i]);
}
return 0;
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 39, "lines_deleted": 0}}
| null | null |
static int mov_read_mdhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
MOVStreamContext *sc;
int version;
char language[4] = {0};
unsigned lang;
time_t creation_time;
if (c->fc->nb_streams < 1)
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
version = avio_r8(pb);
if (version > 1) {
av_log_ask_for_sample(c, "unsupported version %d\n", version);
return AVERROR_PATCHWELCOME;
}
avio_rb24(pb); /* flags */
if (version == 1) {
creation_time = avio_rb64(pb);
avio_rb64(pb);
} else {
creation_time = avio_rb32(pb);
avio_rb32(pb); /* modification time */
}
mov_metadata_creation_time(&st->metadata, creation_time);
sc->time_scale = avio_rb32(pb);
st->duration = (version == 1) ? avio_rb64(pb) : avio_rb32(pb); /* duration */
lang = avio_rb16(pb); /* language */
if (ff_mov_lang_to_iso639(lang, language))
av_dict_set(&st->metadata, "language", language, 0);
avio_rb16(pb); /* quality */
return 0;
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 28, "lines_deleted": 0}}
| null | null |
static int mov_read_wave(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
if (c->fc->nb_streams < 1)
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
if ((uint64_t)atom.size > (1<<30))
return AVERROR_INVALIDDATA;
if (st->codec->codec_id == CODEC_ID_QDM2 || st->codec->codec_id == CODEC_ID_QDMC) {
// pass all frma atom to codec, needed at least for QDMC and QDM2
av_free(st->codec->extradata);
st->codec->extradata_size = 0;
st->codec->extradata = av_mallocz(atom.size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
return AVERROR(ENOMEM);
st->codec->extradata_size = atom.size;
avio_read(pb, st->codec->extradata, atom.size);
} else if (atom.size > 8) { /* to read frma, esds atoms */
int ret;
if ((ret = mov_read_default(c, pb, atom)) < 0)
return ret;
} else
avio_skip(pb, atom.size);
return 0;
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 34, "lines_deleted": 0}}
| null | null |
static int mov_read_stsc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
MOVStreamContext *sc;
unsigned int i, entries;
if (c->fc->nb_streams < 1)
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
avio_r8(pb); /* version */
avio_rb24(pb); /* flags */
entries = avio_rb32(pb);
av_dlog(c->fc, "track[%i].stsc.entries = %i\n", c->fc->nb_streams-1, entries);
if (!entries)
return 0;
if (entries >= UINT_MAX / sizeof(*sc->stsc_data))
return AVERROR_INVALIDDATA;
sc->stsc_data = av_malloc(entries * sizeof(*sc->stsc_data));
if (!sc->stsc_data)
return AVERROR(ENOMEM);
sc->stsc_count = entries;
for (i=0; i<entries; i++) {
sc->stsc_data[i].first = avio_rb32(pb);
sc->stsc_data[i].count = avio_rb32(pb);
sc->stsc_data[i].id = avio_rb32(pb);
}
return 0;
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 23, "lines_deleted": 0}}
| null | null |
static int mov_read_trex(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
MOVTrackExt *trex;
if ((uint64_t)c->trex_count+1 >= UINT_MAX / sizeof(*c->trex_data))
return AVERROR_INVALIDDATA;
trex = av_realloc(c->trex_data, (c->trex_count+1)*sizeof(*c->trex_data));
if (!trex)
return AVERROR(ENOMEM);
c->fc->duration = AV_NOPTS_VALUE; // the duration from mvhd is not representing the whole file when fragments are used.
c->trex_data = trex;
trex = &c->trex_data[c->trex_count++];
avio_r8(pb); /* version */
avio_rb24(pb); /* flags */
trex->track_id = avio_rb32(pb);
trex->stsd_id = avio_rb32(pb);
trex->duration = avio_rb32(pb);
trex->size = avio_rb32(pb);
trex->flags = avio_rb32(pb);
return 0;
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 56, "lines_deleted": 0}}
| null | null |
static int mov_read_stts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
MOVStreamContext *sc;
unsigned int i, entries;
int64_t duration=0;
int64_t total_sample_count=0;
if (c->fc->nb_streams < 1)
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
avio_r8(pb); /* version */
avio_rb24(pb); /* flags */
entries = avio_rb32(pb);
av_dlog(c->fc, "track[%i].stts.entries = %i\n",
c->fc->nb_streams-1, entries);
if (entries >= UINT_MAX / sizeof(*sc->stts_data))
return -1;
sc->stts_data = av_malloc(entries * sizeof(*sc->stts_data));
if (!sc->stts_data)
return AVERROR(ENOMEM);
sc->stts_count = entries;
for (i=0; i<entries; i++) {
int sample_duration;
int sample_count;
sample_count=avio_rb32(pb);
sample_duration = avio_rb32(pb);
/* sample_duration < 0 is invalid based on the spec */
if (sample_duration < 0) {
av_log(c->fc, AV_LOG_ERROR, "Invalid SampleDelta in STTS %d\n", sample_duration);
sample_duration = 1;
}
sc->stts_data[i].count= sample_count;
sc->stts_data[i].duration= sample_duration;
av_dlog(c->fc, "sample_count=%d, sample_duration=%d\n",
sample_count, sample_duration);
duration+=(int64_t)sample_duration*sample_count;
total_sample_count+=sample_count;
}
st->nb_frames= total_sample_count;
if (duration)
st->duration= duration;
sc->track_end = duration;
return 0;
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 37, "lines_deleted": 0}}
| null | null |
static int mov_read_stco(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
MOVStreamContext *sc;
unsigned int i, entries;
if (c->fc->nb_streams < 1)
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
avio_r8(pb); /* version */
avio_rb24(pb); /* flags */
entries = avio_rb32(pb);
if (!entries)
return 0;
if (entries >= UINT_MAX/sizeof(int64_t))
return AVERROR_INVALIDDATA;
sc->chunk_offsets = av_malloc(entries * sizeof(int64_t));
if (!sc->chunk_offsets)
return AVERROR(ENOMEM);
sc->chunk_count = entries;
if (atom.type == MKTAG('s','t','c','o'))
for (i=0; i<entries; i++)
sc->chunk_offsets[i] = avio_rb32(pb);
else if (atom.type == MKTAG('c','o','6','4'))
for (i=0; i<entries; i++)
sc->chunk_offsets[i] = avio_rb64(pb);
else
return AVERROR_INVALIDDATA;
return 0;
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 68, "lines_deleted": 0}}
| null | null |
static void mov_read_chapters(AVFormatContext *s)
{
MOVContext *mov = s->priv_data;
AVStream *st = NULL;
MOVStreamContext *sc;
int64_t cur_pos;
int i;
for (i = 0; i < s->nb_streams; i++)
if (s->streams[i]->id == mov->chapter_track) {
st = s->streams[i];
break;
}
if (!st) {
av_log(s, AV_LOG_ERROR, "Referenced QT chapter track not found\n");
return;
}
st->discard = AVDISCARD_ALL;
sc = st->priv_data;
cur_pos = avio_tell(sc->pb);
for (i = 0; i < st->nb_index_entries; i++) {
AVIndexEntry *sample = &st->index_entries[i];
int64_t end = i+1 < st->nb_index_entries ? st->index_entries[i+1].timestamp : st->duration;
uint8_t *title;
uint16_t ch;
int len, title_len;
if (avio_seek(sc->pb, sample->pos, SEEK_SET) != sample->pos) {
av_log(s, AV_LOG_ERROR, "Chapter %d not found in file\n", i);
goto finish;
}
// the first two bytes are the length of the title
len = avio_rb16(sc->pb);
if (len > sample->size-2)
continue;
title_len = 2*len + 1;
if (!(title = av_mallocz(title_len)))
goto finish;
// The samples could theoretically be in any encoding if there's an encd
// atom following, but in practice are only utf-8 or utf-16, distinguished
// instead by the presence of a BOM
if (!len) {
title[0] = 0;
} else {
ch = avio_rb16(sc->pb);
if (ch == 0xfeff)
avio_get_str16be(sc->pb, len, title, title_len);
else if (ch == 0xfffe)
avio_get_str16le(sc->pb, len, title, title_len);
else {
AV_WB16(title, ch);
if (len == 1 || len == 2)
title[len] = 0;
else
avio_get_str(sc->pb, INT_MAX, title + 2, len - 1);
}
}
avpriv_new_chapter(s, i, st->time_base, sample->timestamp, end, title);
av_freep(&title);
}
finish:
avio_seek(sc->pb, cur_pos, SEEK_SET);
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 12, "lines_deleted": 0}}
| null | null |
static void mov_metadata_creation_time(AVDictionary **metadata, time_t time)
{
char buffer[32];
if (time) {
struct tm *ptm;
time -= 2082844800; /* seconds between 1904-01-01 and Epoch */
ptm = gmtime(&time);
if (!ptm) return;
strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", ptm);
av_dict_set(metadata, "creation_time", buffer, 0);
}
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 21, "lines_deleted": 0}}
| null | null |
int ff_mov_read_esds(AVFormatContext *fc, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
int tag;
if (fc->nb_streams < 1)
return 0;
st = fc->streams[fc->nb_streams-1];
avio_rb32(pb); /* version + flags */
ff_mp4_read_descr(fc, pb, &tag);
if (tag == MP4ESDescrTag) {
ff_mp4_parse_es_descr(pb, NULL);
} else
avio_rb16(pb); /* ID */
ff_mp4_read_descr(fc, pb, &tag);
if (tag == MP4DecConfigDescrTag)
ff_mp4_read_dec_config_descr(fc, st, pb);
return 0;
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 28, "lines_deleted": 0}}
| null | null |
static int mov_read_extradata(MOVContext *c, AVIOContext *pb, MOVAtom atom,
enum CodecID codec_id)
{
AVStream *st;
uint64_t size;
uint8_t *buf;
if (c->fc->nb_streams < 1) // will happen with jp2 files
return 0;
st= c->fc->streams[c->fc->nb_streams-1];
if (st->codec->codec_id != codec_id)
return 0; /* unexpected codec_id - don't mess with extradata */
size= (uint64_t)st->codec->extradata_size + atom.size + 8 + FF_INPUT_BUFFER_PADDING_SIZE;
if (size > INT_MAX || (uint64_t)atom.size > INT_MAX)
return AVERROR_INVALIDDATA;
buf= av_realloc(st->codec->extradata, size);
if (!buf)
return AVERROR(ENOMEM);
st->codec->extradata= buf;
buf+= st->codec->extradata_size;
st->codec->extradata_size= size - FF_INPUT_BUFFER_PADDING_SIZE;
AV_WB32( buf , atom.size + 8);
AV_WL32( buf + 4, atom.type);
avio_read(pb, buf + 8, atom.size);
return 0;
}
|
[]
|
||
CVE-2016-3062
|
bbee8354c6384c7be291db978b673fe0eebdf4a1
|
https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746
|
Vulnerability in CVE-2016-3062
| null | null | null | null |
CWE-119
|
Fix CVE-2016-3062
| null | null | null | null |
["libavformat/mov.c"]
|
C
|
{"libavformat/mov.c": {"lines_added": 48, "lines_deleted": 0}}
| null | null |
static int mov_read_ctts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
MOVStreamContext *sc;
unsigned int i, entries;
if (c->fc->nb_streams < 1)
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
avio_r8(pb); /* version */
avio_rb24(pb); /* flags */
entries = avio_rb32(pb);
av_dlog(c->fc, "track[%i].ctts.entries = %i\n", c->fc->nb_streams-1, entries);
if (!entries)
return 0;
if (entries >= UINT_MAX / sizeof(*sc->ctts_data))
return AVERROR_INVALIDDATA;
sc->ctts_data = av_malloc(entries * sizeof(*sc->ctts_data));
if (!sc->ctts_data)
return AVERROR(ENOMEM);
sc->ctts_count = entries;
for (i=0; i<entries; i++) {
int count =avio_rb32(pb);
int duration =avio_rb32(pb);
sc->ctts_data[i].count = count;
sc->ctts_data[i].duration= duration;
if (FFABS(duration) > (1<<28) && i+2<entries) {
av_log(c->fc, AV_LOG_WARNING, "CTTS invalid\n");
av_freep(&sc->ctts_data);
sc->ctts_count = 0;
return 0;
}
if (duration < 0 && i+2<entries)
sc->dts_shift = FFMAX(sc->dts_shift, -duration);
}
av_dlog(c->fc, "dts shift %d\n", sc->dts_shift);
return 0;
}
|
[]
|
||
CVE-2016-4817
|
8b2c4657bb35940b8da5af7f03b524b9150fef34
|
https://github.com/h2o/h2o/commit/1c0808d580da09fdec5a9a74ff09e103ea058dd4
|
Vulnerability in CVE-2016-4817
| null | null | null | null |
CWE-Other
|
Fix CVE-2016-4817
| null | null | null | null |
["lib/http2/connection.c"]
|
C
|
{"lib/http2/connection.c": {"lines_added": 12, "lines_deleted": 10}}
| null |
void close_connection(h2o_http2_conn_t *conn)
{
conn->state = H2O_HTTP2_CONN_STATE_IS_CLOSING;
if (conn->_write.buf_in_flight != NULL || h2o_timeout_is_linked(&conn->_write.timeout_entry)) {
/* there is a pending write, let on_write_complete actually close the connection */
} else {
close_connection_now(conn);
}
}
|
int close_connection(h2o_http2_conn_t *conn)
{
conn->state = H2O_HTTP2_CONN_STATE_IS_CLOSING;
if (conn->_write.buf_in_flight != NULL || h2o_timeout_is_linked(&conn->_write.timeout_entry)) {
/* there is a pending write, let on_write_complete actually close the connection */
} else {
close_connection_now(conn);
return -1;
}
return 0;
}
|
[]
|
||
CVE-2016-4817
|
2b3b80948d3a8aa0890f6ff300d1b487e783e085
|
https://github.com/h2o/h2o/commit/1c0808d580da09fdec5a9a74ff09e103ea058dd4
|
Vulnerability in CVE-2016-4817
| null | null | null | null |
CWE-Other
|
Fix CVE-2016-4817
| null | null | null | null |
["lib/http2/connection.c"]
|
C
|
{"lib/http2/connection.c": {"lines_added": 38, "lines_deleted": 38}}
| null |
static void parse_input(h2o_http2_conn_t *conn)
{
size_t http2_max_concurrent_requests_per_connection = conn->super.ctx->globalconf->http2.max_concurrent_requests_per_connection;
int perform_early_exit = 0;
if (conn->num_streams.pull.half_closed + conn->num_streams.push.half_closed != http2_max_concurrent_requests_per_connection)
perform_early_exit = 1;
/* handle the input */
while (conn->state < H2O_HTTP2_CONN_STATE_IS_CLOSING && conn->sock->input->size != 0) {
if (perform_early_exit == 1 &&
conn->num_streams.pull.half_closed + conn->num_streams.push.half_closed == http2_max_concurrent_requests_per_connection)
goto EarlyExit;
/* process a frame */
const char *err_desc = NULL;
ssize_t ret = conn->_read_expect(conn, (uint8_t *)conn->sock->input->bytes, conn->sock->input->size, &err_desc);
if (ret == H2O_HTTP2_ERROR_INCOMPLETE) {
break;
} else if (ret < 0) {
if (ret != H2O_HTTP2_ERROR_PROTOCOL_CLOSE_IMMEDIATELY) {
enqueue_goaway(conn, (int)ret,
err_desc != NULL ? (h2o_iovec_t){(char *)err_desc, strlen(err_desc)} : (h2o_iovec_t){});
}
close_connection(conn);
return;
}
/* advance to the next frame */
h2o_buffer_consume(&conn->sock->input, ret);
}
if (!h2o_socket_is_reading(conn->sock))
h2o_socket_read_start(conn->sock, on_read);
return;
EarlyExit:
if (h2o_socket_is_reading(conn->sock))
h2o_socket_read_stop(conn->sock);
}
|
static int parse_input(h2o_http2_conn_t *conn)
{
size_t http2_max_concurrent_requests_per_connection = conn->super.ctx->globalconf->http2.max_concurrent_requests_per_connection;
int perform_early_exit = 0;
if (conn->num_streams.pull.half_closed + conn->num_streams.push.half_closed != http2_max_concurrent_requests_per_connection)
perform_early_exit = 1;
/* handle the input */
while (conn->state < H2O_HTTP2_CONN_STATE_IS_CLOSING && conn->sock->input->size != 0) {
if (perform_early_exit == 1 &&
conn->num_streams.pull.half_closed + conn->num_streams.push.half_closed == http2_max_concurrent_requests_per_connection)
goto EarlyExit;
/* process a frame */
const char *err_desc = NULL;
ssize_t ret = conn->_read_expect(conn, (uint8_t *)conn->sock->input->bytes, conn->sock->input->size, &err_desc);
if (ret == H2O_HTTP2_ERROR_INCOMPLETE) {
break;
} else if (ret < 0) {
if (ret != H2O_HTTP2_ERROR_PROTOCOL_CLOSE_IMMEDIATELY) {
enqueue_goaway(conn, (int)ret,
err_desc != NULL ? (h2o_iovec_t){(char *)err_desc, strlen(err_desc)} : (h2o_iovec_t){});
}
return close_connection(conn);
}
/* advance to the next frame */
h2o_buffer_consume(&conn->sock->input, ret);
}
if (!h2o_socket_is_reading(conn->sock))
h2o_socket_read_start(conn->sock, on_read);
return 0;
EarlyExit:
if (h2o_socket_is_reading(conn->sock))
h2o_socket_read_stop(conn->sock);
return 0;
}
|
[]
|
||
CVE-2016-4817
|
72d245d8f341a813c18d6c6969b81931f9f4d87d
|
https://github.com/h2o/h2o/commit/1c0808d580da09fdec5a9a74ff09e103ea058dd4
|
Vulnerability in CVE-2016-4817
| null | null | null | null |
CWE-Other
|
Fix CVE-2016-4817
| null | null | null | null |
["lib/http2/connection.c"]
|
C
|
{"lib/http2/connection.c": {"lines_added": 20, "lines_deleted": 19}}
| null |
static void on_read(h2o_socket_t *sock, int status)
{
h2o_http2_conn_t *conn = sock->data;
if (status != 0) {
h2o_socket_read_stop(conn->sock);
close_connection(conn);
return;
}
update_idle_timeout(conn);
parse_input(conn);
/* write immediately, if there is no write in flight and if pending write exists */
if (h2o_timeout_is_linked(&conn->_write.timeout_entry)) {
h2o_timeout_unlink(&conn->_write.timeout_entry);
do_emit_writereq(conn);
}
}
|
static void on_read(h2o_socket_t *sock, int status)
{
h2o_http2_conn_t *conn = sock->data;
if (status != 0) {
h2o_socket_read_stop(conn->sock);
close_connection(conn);
return;
}
update_idle_timeout(conn);
if (parse_input(conn) != 0)
return;
/* write immediately, if there is no write in flight and if pending write exists */
if (h2o_timeout_is_linked(&conn->_write.timeout_entry)) {
h2o_timeout_unlink(&conn->_write.timeout_entry);
do_emit_writereq(conn);
}
}
|
[]
|
||
CVE-2016-4817
|
030c1bddaf347cd52eb889cb6c90cbd0b43430d1
|
https://github.com/h2o/h2o/commit/1c0808d580da09fdec5a9a74ff09e103ea058dd4
|
Vulnerability in CVE-2016-4817
| null | null | null | null |
CWE-Other
|
Fix CVE-2016-4817
| null | null | null | null |
["lib/http2/connection.c"]
|
C
|
{"lib/http2/connection.c": {"lines_added": 19, "lines_deleted": 0}}
| null | null |
static void execute_or_enqueue_request(h2o_http2_conn_t *conn, h2o_http2_stream_t *stream)
{
assert(stream->state < H2O_HTTP2_STREAM_STATE_REQ_PENDING);
if (stream->_req_body != NULL && stream->_expected_content_length != SIZE_MAX &&
stream->_req_body->size != stream->_expected_content_length) {
send_stream_error(conn, stream->stream_id, H2O_HTTP2_ERROR_PROTOCOL);
h2o_http2_stream_reset(conn, stream);
return;
}
h2o_http2_stream_set_state(conn, stream, H2O_HTTP2_STREAM_STATE_REQ_PENDING);
/* TODO schedule the pending reqs using the scheduler */
h2o_linklist_insert(&conn->_pending_reqs, &stream->_refs.link);
run_pending_requests(conn);
update_idle_timeout(conn);
}
|
[]
|
||
CVE-2016-4817
|
030c1bddaf347cd52eb889cb6c90cbd0b43430d1
|
https://github.com/h2o/h2o/commit/1c0808d580da09fdec5a9a74ff09e103ea058dd4
|
Vulnerability in CVE-2016-4817
| null | null | null | null |
CWE-Other
|
Fix CVE-2016-4817
| null | null | null | null |
["lib/http2/connection.c"]
|
C
|
{"lib/http2/connection.c": {"lines_added": 40, "lines_deleted": 0}}
| null | null |
static int handle_window_update_frame(h2o_http2_conn_t *conn, h2o_http2_frame_t *frame, const char **err_desc)
{
h2o_http2_window_update_payload_t payload;
int ret, err_is_stream_level;
if ((ret = h2o_http2_decode_window_update_payload(&payload, frame, err_desc, &err_is_stream_level)) != 0) {
if (err_is_stream_level) {
h2o_http2_stream_t *stream = h2o_http2_conn_get_stream(conn, frame->stream_id);
if (stream != NULL)
h2o_http2_stream_reset(conn, stream);
send_stream_error(conn, frame->stream_id, ret);
return 0;
} else {
return ret;
}
}
if (frame->stream_id == 0) {
if (h2o_http2_window_update(&conn->_write.window, payload.window_size_increment) != 0) {
*err_desc = "flow control window overflow";
return H2O_HTTP2_ERROR_FLOW_CONTROL;
}
} else if (!is_idle_stream_id(conn, frame->stream_id)) {
h2o_http2_stream_t *stream = h2o_http2_conn_get_stream(conn, frame->stream_id);
if (stream != NULL) {
if (update_stream_output_window(stream, payload.window_size_increment) != 0) {
h2o_http2_stream_reset(conn, stream);
send_stream_error(conn, frame->stream_id, H2O_HTTP2_ERROR_FLOW_CONTROL);
return 0;
}
}
} else {
*err_desc = "invalid stream id in WINDOW_UPDATE frame";
return H2O_HTTP2_ERROR_PROTOCOL;
}
resume_send(conn);
return 0;
}
|
[]
|
||
CVE-2016-4817
|
030c1bddaf347cd52eb889cb6c90cbd0b43430d1
|
https://github.com/h2o/h2o/commit/1c0808d580da09fdec5a9a74ff09e103ea058dd4
|
Vulnerability in CVE-2016-4817
| null | null | null | null |
CWE-Other
|
Fix CVE-2016-4817
| null | null | null | null |
["lib/http2/connection.c"]
|
C
|
{"lib/http2/connection.c": {"lines_added": 15, "lines_deleted": 0}}
| null | null |
static int handle_trailing_headers(h2o_http2_conn_t *conn, h2o_http2_stream_t *stream, const uint8_t *src, size_t len,
const char **err_desc)
{
size_t dummy_content_length;
int ret;
assert(stream->state == H2O_HTTP2_STREAM_STATE_RECV_BODY);
if ((ret = h2o_hpack_parse_headers(&stream->req, &conn->_input_header_table, src, len, NULL, &dummy_content_length,
err_desc)) != 0)
return ret;
execute_or_enqueue_request(conn, stream);
return 0;
}
|
[]
|
||
CVE-2016-4817
|
030c1bddaf347cd52eb889cb6c90cbd0b43430d1
|
https://github.com/h2o/h2o/commit/1c0808d580da09fdec5a9a74ff09e103ea058dd4
|
Vulnerability in CVE-2016-4817
| null | null | null | null |
CWE-Other
|
Fix CVE-2016-4817
| null | null | null | null |
["lib/http2/connection.c"]
|
C
|
{"lib/http2/connection.c": {"lines_added": 19, "lines_deleted": 0}}
| null | null |
static ssize_t expect_preface(h2o_http2_conn_t *conn, const uint8_t *src, size_t len, const char **err_desc)
{
if (len < CONNECTION_PREFACE.len) {
return H2O_HTTP2_ERROR_INCOMPLETE;
}
if (memcmp(src, CONNECTION_PREFACE.base, CONNECTION_PREFACE.len) != 0) {
return H2O_HTTP2_ERROR_PROTOCOL_CLOSE_IMMEDIATELY;
}
{ /* send SETTINGS */
h2o_iovec_t vec = h2o_buffer_reserve(&conn->_write.buf, SETTINGS_HOST_BIN.len);
memcpy(vec.base, SETTINGS_HOST_BIN.base, SETTINGS_HOST_BIN.len);
conn->_write.buf->size += SETTINGS_HOST_BIN.len;
h2o_http2_conn_request_write(conn);
}
conn->_read_expect = expect_default;
return CONNECTION_PREFACE.len;
}
|
[]
|
||
CVE-2016-4817
|
030c1bddaf347cd52eb889cb6c90cbd0b43430d1
|
https://github.com/h2o/h2o/commit/1c0808d580da09fdec5a9a74ff09e103ea058dd4
|
Vulnerability in CVE-2016-4817
| null | null | null | null |
CWE-Other
|
Fix CVE-2016-4817
| null | null | null | null |
["lib/http2/connection.c"]
|
C
|
{"lib/http2/connection.c": {"lines_added": 22, "lines_deleted": 0}}
| null | null |
static int emit_writereq_of_openref(h2o_http2_scheduler_openref_t *ref, int *still_is_active, void *cb_arg)
{
h2o_http2_conn_t *conn = cb_arg;
h2o_http2_stream_t *stream = H2O_STRUCT_FROM_MEMBER(h2o_http2_stream_t, _refs.scheduler, ref);
assert(h2o_http2_stream_has_pending_data(stream) || stream->state >= H2O_HTTP2_STREAM_STATE_SEND_BODY_IS_FINAL);
*still_is_active = 0;
h2o_http2_stream_send_pending_data(conn, stream);
if (h2o_http2_stream_has_pending_data(stream)) {
if (h2o_http2_window_get_window(&stream->output_window) <= 0) {
/* is blocked */
} else {
*still_is_active = 1;
}
} else {
h2o_linklist_insert(&conn->_write.streams_to_proceed, &stream->_refs.link);
}
return h2o_http2_conn_get_buffer_window(conn) > 0 ? 0 : -1;
}
|
[]
|
||
CVE-2016-4817
|
030c1bddaf347cd52eb889cb6c90cbd0b43430d1
|
https://github.com/h2o/h2o/commit/1c0808d580da09fdec5a9a74ff09e103ea058dd4
|
Vulnerability in CVE-2016-4817
| null | null | null | null |
CWE-Other
|
Fix CVE-2016-4817
| null | null | null | null |
["lib/http2/connection.c"]
|
C
|
{"lib/http2/connection.c": {"lines_added": 11, "lines_deleted": 0}}
| null | null |
static int handle_goaway_frame(h2o_http2_conn_t *conn, h2o_http2_frame_t *frame, const char **err_desc)
{
h2o_http2_goaway_payload_t payload;
int ret;
if ((ret = h2o_http2_decode_goaway_payload(&payload, frame, err_desc)) != 0)
return ret;
/* nothing to do, since we do not open new streams by ourselves */
return 0;
}
|
[]
|
||
CVE-2016-4817
|
030c1bddaf347cd52eb889cb6c90cbd0b43430d1
|
https://github.com/h2o/h2o/commit/1c0808d580da09fdec5a9a74ff09e103ea058dd4
|
Vulnerability in CVE-2016-4817
| null | null | null | null |
CWE-Other
|
Fix CVE-2016-4817
| null | null | null | null |
["lib/http2/connection.c"]
|
C
|
{"lib/http2/connection.c": {"lines_added": 50, "lines_deleted": 0}}
| null | null |
static ssize_t expect_continuation_of_headers(h2o_http2_conn_t *conn, const uint8_t *src, size_t len, const char **err_desc)
{
h2o_http2_frame_t frame;
ssize_t ret;
h2o_http2_stream_t *stream;
int hret;
if ((ret = h2o_http2_decode_frame(&frame, src, len, &H2O_HTTP2_SETTINGS_HOST, err_desc)) < 0)
return ret;
if (frame.type != H2O_HTTP2_FRAME_TYPE_CONTINUATION) {
*err_desc = "expected CONTINUATION frame";
return H2O_HTTP2_ERROR_PROTOCOL;
}
if (conn->state >= H2O_HTTP2_CONN_STATE_HALF_CLOSED)
return 0;
if ((stream = h2o_http2_conn_get_stream(conn, frame.stream_id)) == NULL ||
!(stream->state == H2O_HTTP2_STREAM_STATE_RECV_HEADERS || stream->state == H2O_HTTP2_STREAM_STATE_RECV_BODY)) {
*err_desc = "unexpected stream id in CONTINUATION frame";
return H2O_HTTP2_ERROR_PROTOCOL;
}
h2o_buffer_reserve(&conn->_headers_unparsed, frame.length);
memcpy(conn->_headers_unparsed->bytes + conn->_headers_unparsed->size, frame.payload, frame.length);
conn->_headers_unparsed->size += frame.length;
if (conn->_headers_unparsed->size <= H2O_MAX_REQLEN) {
if ((frame.flags & H2O_HTTP2_FRAME_FLAG_END_HEADERS) != 0) {
conn->_read_expect = expect_default;
if (stream->state == H2O_HTTP2_STREAM_STATE_RECV_HEADERS) {
hret = handle_incoming_request(conn, stream, (const uint8_t *)conn->_headers_unparsed->bytes,
conn->_headers_unparsed->size, err_desc);
} else {
hret = handle_trailing_headers(conn, stream, (const uint8_t *)conn->_headers_unparsed->bytes,
conn->_headers_unparsed->size, err_desc);
}
if (hret != 0)
ret = hret;
h2o_buffer_dispose(&conn->_headers_unparsed);
conn->_headers_unparsed = NULL;
}
} else {
/* request is too large (TODO log) */
send_stream_error(conn, stream->stream_id, H2O_HTTP2_ERROR_REFUSED_STREAM);
h2o_http2_stream_reset(conn, stream);
}
return ret;
}
|
[]
|
||
CVE-2016-4817
|
030c1bddaf347cd52eb889cb6c90cbd0b43430d1
|
https://github.com/h2o/h2o/commit/1c0808d580da09fdec5a9a74ff09e103ea058dd4
|
Vulnerability in CVE-2016-4817
| null | null | null | null |
CWE-Other
|
Fix CVE-2016-4817
| null | null | null | null |
["lib/http2/connection.c"]
|
C
|
{"lib/http2/connection.c": {"lines_added": 31, "lines_deleted": 0}}
| null | null |
static void set_priority(h2o_http2_conn_t *conn, h2o_http2_stream_t *stream, const h2o_http2_priority_t *priority,
int scheduler_is_open)
{
h2o_http2_scheduler_node_t *parent_sched;
/* determine the parent */
if (priority->dependency != 0) {
h2o_http2_stream_t *parent_stream = h2o_http2_conn_get_stream(conn, priority->dependency);
if (parent_stream != NULL) {
parent_sched = &parent_stream->_refs.scheduler.node;
} else {
/* A dependency on a stream that is not currently in the tree - such as a stream in the "idle" state - results in that
* stream being given a default priority. (RFC 7540 5.3.1)
* It is possible for a stream to become closed while prioritization information that creates a dependency on that
* stream is in transit. If a stream identified in a dependency has no associated priority information, then the
* dependent stream is instead assigned a default priority. (RFC 7540 5.3.4)
*/
parent_sched = &conn->scheduler;
priority = &h2o_http2_default_priority;
}
} else {
parent_sched = &conn->scheduler;
}
/* setup the scheduler */
if (!scheduler_is_open) {
h2o_http2_scheduler_open(&stream->_refs.scheduler, parent_sched, priority->weight, priority->exclusive);
} else {
h2o_http2_scheduler_rebind(&stream->_refs.scheduler, parent_sched, priority->weight, priority->exclusive);
}
}
|
[]
|
||
CVE-2016-4817
|
030c1bddaf347cd52eb889cb6c90cbd0b43430d1
|
https://github.com/h2o/h2o/commit/1c0808d580da09fdec5a9a74ff09e103ea058dd4
|
Vulnerability in CVE-2016-4817
| null | null | null | null |
CWE-Other
|
Fix CVE-2016-4817
| null | null | null | null |
["lib/http2/connection.c"]
|
C
|
{"lib/http2/connection.c": {"lines_added": 25, "lines_deleted": 0}}
| null | null |
static void on_upgrade_complete(void *_conn, h2o_socket_t *sock, size_t reqsize)
{
h2o_http2_conn_t *conn = _conn;
if (sock == NULL) {
close_connection(conn);
return;
}
conn->sock = sock;
sock->data = conn;
conn->_http1_req_input = sock->input;
h2o_buffer_init(&sock->input, &h2o_socket_buffer_prototype);
/* setup inbound */
h2o_socket_read_start(conn->sock, on_read);
/* handle the request */
execute_or_enqueue_request(conn, h2o_http2_conn_get_stream(conn, 1));
if (conn->_http1_req_input->size != reqsize) {
/* FIXME copy the remaining data to conn->_input and call handle_input */
assert(0);
}
}
|
[]
|
||
CVE-2016-4817
|
030c1bddaf347cd52eb889cb6c90cbd0b43430d1
|
https://github.com/h2o/h2o/commit/1c0808d580da09fdec5a9a74ff09e103ea058dd4
|
Vulnerability in CVE-2016-4817
| null | null | null | null |
CWE-Other
|
Fix CVE-2016-4817
| null | null | null | null |
["lib/http2/connection.c"]
|
C
|
{"lib/http2/connection.c": {"lines_added": 25, "lines_deleted": 0}}
| null | null |
static void initiate_graceful_shutdown(h2o_context_t *ctx)
{
/* draft-16 6.8
* A server that is attempting to gracefully shut down a connection SHOULD send an initial GOAWAY frame with the last stream
* identifier set to 231-1 and a NO_ERROR code. This signals to the client that a shutdown is imminent and that no further
* requests can be initiated. After waiting at least one round trip time, the server can send another GOAWAY frame with an
* updated last stream identifier. This ensures that a connection can be cleanly shut down without losing requests.
*/
h2o_linklist_t *node;
/* only doit once */
if (ctx->http2._graceful_shutdown_timeout.cb != NULL)
return;
ctx->http2._graceful_shutdown_timeout.cb = graceful_shutdown_resend_goaway;
for (node = ctx->http2._conns.next; node != &ctx->http2._conns; node = node->next) {
h2o_http2_conn_t *conn = H2O_STRUCT_FROM_MEMBER(h2o_http2_conn_t, _conns, node);
if (conn->state < H2O_HTTP2_CONN_STATE_HALF_CLOSED) {
h2o_http2_encode_goaway_frame(&conn->_write.buf, INT32_MAX, H2O_HTTP2_ERROR_NONE,
(h2o_iovec_t){H2O_STRLIT("graceful shutdown")});
h2o_http2_conn_request_write(conn);
}
}
h2o_timeout_link(ctx->loop, &ctx->one_sec_timeout, &ctx->http2._graceful_shutdown_timeout);
}
|
[]
|
||
CVE-2016-4817
|
030c1bddaf347cd52eb889cb6c90cbd0b43430d1
|
https://github.com/h2o/h2o/commit/1c0808d580da09fdec5a9a74ff09e103ea058dd4
|
Vulnerability in CVE-2016-4817
| null | null | null | null |
CWE-Other
|
Fix CVE-2016-4817
| null | null | null | null |
["lib/http2/connection.c"]
|
C
|
{"lib/http2/connection.c": {"lines_added": 10, "lines_deleted": 0}}
| null | null |
static void update_idle_timeout(h2o_http2_conn_t *conn)
{
h2o_timeout_unlink(&conn->_timeout_entry);
if (conn->num_streams.pull.half_closed + conn->num_streams.push.half_closed == 0) {
assert(h2o_linklist_is_empty(&conn->_pending_reqs));
conn->_timeout_entry.cb = on_idle_timeout;
h2o_timeout_link(conn->super.ctx->loop, &conn->super.ctx->http2.idle_timeout, &conn->_timeout_entry);
}
}
|
[]
|
||
CVE-2016-4817
|
030c1bddaf347cd52eb889cb6c90cbd0b43430d1
|
https://github.com/h2o/h2o/commit/1c0808d580da09fdec5a9a74ff09e103ea058dd4
|
Vulnerability in CVE-2016-4817
| null | null | null | null |
CWE-Other
|
Fix CVE-2016-4817
| null | null | null | null |
["lib/http2/connection.c"]
|
C
|
{"lib/http2/connection.c": {"lines_added": 32, "lines_deleted": 0}}
| null | null |
static int handle_settings_frame(h2o_http2_conn_t *conn, h2o_http2_frame_t *frame, const char **err_desc)
{
if (frame->stream_id != 0) {
*err_desc = "invalid stream id in SETTINGS frame";
return H2O_HTTP2_ERROR_PROTOCOL;
}
if ((frame->flags & H2O_HTTP2_FRAME_FLAG_ACK) != 0) {
if (frame->length != 0) {
*err_desc = "invalid SETTINGS frame (+ACK)";
return H2O_HTTP2_ERROR_FRAME_SIZE;
}
} else {
uint32_t prev_initial_window_size = conn->peer_settings.initial_window_size;
/* FIXME handle SETTINGS_HEADER_TABLE_SIZE */
int ret = h2o_http2_update_peer_settings(&conn->peer_settings, frame->payload, frame->length, err_desc);
if (ret != 0)
return ret;
{ /* schedule ack */
h2o_iovec_t header_buf = h2o_buffer_reserve(&conn->_write.buf, H2O_HTTP2_FRAME_HEADER_SIZE);
h2o_http2_encode_frame_header((void *)header_buf.base, 0, H2O_HTTP2_FRAME_TYPE_SETTINGS, H2O_HTTP2_FRAME_FLAG_ACK, 0);
conn->_write.buf->size += H2O_HTTP2_FRAME_HEADER_SIZE;
h2o_http2_conn_request_write(conn);
}
/* apply the change to window size (to all the streams but not the connection, see 6.9.2 of draft-15) */
if (prev_initial_window_size != conn->peer_settings.initial_window_size) {
ssize_t delta = conn->peer_settings.initial_window_size - prev_initial_window_size;
h2o_http2_stream_t *stream;
kh_foreach_value(conn->streams, stream, { update_stream_output_window(stream, delta); });
resume_send(conn);
}
}
|
[]
|
||
CVE-2016-4817
|
030c1bddaf347cd52eb889cb6c90cbd0b43430d1
|
https://github.com/h2o/h2o/commit/1c0808d580da09fdec5a9a74ff09e103ea058dd4
|
Vulnerability in CVE-2016-4817
| null | null | null | null |
CWE-Other
|
Fix CVE-2016-4817
| null | null | null | null |
["lib/http2/connection.c"]
|
C
|
{"lib/http2/connection.c": {"lines_added": 53, "lines_deleted": 0}}
| null | null |
static void on_write_complete(h2o_socket_t *sock, int status)
{
h2o_http2_conn_t *conn = sock->data;
assert(conn->_write.buf_in_flight != NULL);
/* close by error if necessary */
if (status != 0) {
close_connection_now(conn);
return;
}
/* reset the other memory pool */
h2o_buffer_dispose(&conn->_write.buf_in_flight);
assert(conn->_write.buf_in_flight == NULL);
/* call the proceed callback of the streams that have been flushed (while unlinking them from the list) */
if (status == 0 && conn->state < H2O_HTTP2_CONN_STATE_IS_CLOSING) {
while (!h2o_linklist_is_empty(&conn->_write.streams_to_proceed)) {
h2o_http2_stream_t *stream =
H2O_STRUCT_FROM_MEMBER(h2o_http2_stream_t, _refs.link, conn->_write.streams_to_proceed.next);
assert(!h2o_http2_stream_has_pending_data(stream));
h2o_linklist_unlink(&stream->_refs.link);
h2o_http2_stream_proceed(conn, stream);
}
}
/* cancel the write callback if scheduled (as the generator may have scheduled a write just before this function gets called) */
if (h2o_timeout_is_linked(&conn->_write.timeout_entry))
h2o_timeout_unlink(&conn->_write.timeout_entry);
/* write more, if possible */
if (do_emit_writereq(conn))
return;
/* close the connection if necessary */
switch (conn->state) {
case H2O_HTTP2_CONN_STATE_OPEN:
break;
case H2O_HTTP2_CONN_STATE_HALF_CLOSED:
if (conn->num_streams.pull.half_closed + conn->num_streams.push.half_closed != 0)
break;
conn->state = H2O_HTTP2_CONN_STATE_IS_CLOSING;
/* fall-thru */
case H2O_HTTP2_CONN_STATE_IS_CLOSING:
close_connection_now(conn);
return;
}
/* start receiving input if necessary, as well as parse the pending input */
if (conn->sock->input->size != 0)
parse_input(conn);
}
|
[]
|
||
CVE-2016-4817
|
030c1bddaf347cd52eb889cb6c90cbd0b43430d1
|
https://github.com/h2o/h2o/commit/1c0808d580da09fdec5a9a74ff09e103ea058dd4
|
Vulnerability in CVE-2016-4817
| null | null | null | null |
CWE-Other
|
Fix CVE-2016-4817
| null | null | null | null |
["lib/http2/connection.c"]
|
C
|
{"lib/http2/connection.c": {"lines_added": 6, "lines_deleted": 0}}
| null | null |
static void emit_writereq(h2o_timeout_entry_t *entry)
{
h2o_http2_conn_t *conn = H2O_STRUCT_FROM_MEMBER(h2o_http2_conn_t, _write.timeout_entry, entry);
do_emit_writereq(conn);
}
|
[]
|
||
CVE-2016-4817
|
030c1bddaf347cd52eb889cb6c90cbd0b43430d1
|
https://github.com/h2o/h2o/commit/1c0808d580da09fdec5a9a74ff09e103ea058dd4
|
Vulnerability in CVE-2016-4817
| null | null | null | null |
CWE-Other
|
Fix CVE-2016-4817
| null | null | null | null |
["lib/http2/connection.c"]
|
C
|
{"lib/http2/connection.c": {"lines_added": 11, "lines_deleted": 0}}
| null | null |
static void graceful_shutdown_resend_goaway(h2o_timeout_entry_t *entry)
{
h2o_context_t *ctx = H2O_STRUCT_FROM_MEMBER(h2o_context_t, http2._graceful_shutdown_timeout, entry);
h2o_linklist_t *node;
for (node = ctx->http2._conns.next; node != &ctx->http2._conns; node = node->next) {
h2o_http2_conn_t *conn = H2O_STRUCT_FROM_MEMBER(h2o_http2_conn_t, _conns, node);
if (conn->state < H2O_HTTP2_CONN_STATE_HALF_CLOSED)
enqueue_goaway(conn, H2O_HTTP2_ERROR_NONE, (h2o_iovec_t){});
}
}
|
[]
|
||
CVE-2016-4817
|
030c1bddaf347cd52eb889cb6c90cbd0b43430d1
|
https://github.com/h2o/h2o/commit/1c0808d580da09fdec5a9a74ff09e103ea058dd4
|
Vulnerability in CVE-2016-4817
| null | null | null | null |
CWE-Other
|
Fix CVE-2016-4817
| null | null | null | null |
["lib/http2/connection.c"]
|
C
|
{"lib/http2/connection.c": {"lines_added": 12, "lines_deleted": 0}}
| null | null |
void h2o_http2_conn_register_stream(h2o_http2_conn_t *conn, h2o_http2_stream_t *stream)
{
khiter_t iter;
int r;
if (!h2o_http2_stream_is_push(stream->stream_id) && conn->pull_stream_ids.max_open < stream->stream_id)
conn->pull_stream_ids.max_open = stream->stream_id;
iter = kh_put(h2o_http2_stream_t, conn->streams, stream->stream_id, &r);
assert(iter != kh_end(conn->streams));
kh_val(conn->streams, iter) = stream;
}
|
[]
|
||
CVE-2016-4817
|
030c1bddaf347cd52eb889cb6c90cbd0b43430d1
|
https://github.com/h2o/h2o/commit/1c0808d580da09fdec5a9a74ff09e103ea058dd4
|
Vulnerability in CVE-2016-4817
| null | null | null | null |
CWE-Other
|
Fix CVE-2016-4817
| null | null | null | null |
["lib/http2/connection.c"]
|
C
|
{"lib/http2/connection.c": {"lines_added": 10, "lines_deleted": 0}}
| null | null |
static void update_input_window(h2o_http2_conn_t *conn, uint32_t stream_id, h2o_http2_window_t *window, size_t consumed)
{
h2o_http2_window_consume_window(window, consumed);
if (h2o_http2_window_get_window(window) * 2 < H2O_HTTP2_SETTINGS_HOST.initial_window_size) {
int32_t delta = (int32_t)(H2O_HTTP2_SETTINGS_HOST.initial_window_size - h2o_http2_window_get_window(window));
h2o_http2_encode_window_update_frame(&conn->_write.buf, stream_id, delta);
h2o_http2_conn_request_write(conn);
h2o_http2_window_update(window, delta);
}
}
|
[]
|
||
CVE-2016-4817
|
030c1bddaf347cd52eb889cb6c90cbd0b43430d1
|
https://github.com/h2o/h2o/commit/1c0808d580da09fdec5a9a74ff09e103ea058dd4
|
Vulnerability in CVE-2016-4817
| null | null | null | null |
CWE-Other
|
Fix CVE-2016-4817
| null | null | null | null |
["lib/http2/connection.c"]
|
C
|
{"lib/http2/connection.c": {"lines_added": 30, "lines_deleted": 0}}
| null | null |
ssize_t expect_default(h2o_http2_conn_t *conn, const uint8_t *src, size_t len, const char **err_desc)
{
h2o_http2_frame_t frame;
ssize_t ret;
static int (*FRAME_HANDLERS[])(h2o_http2_conn_t *conn, h2o_http2_frame_t *frame, const char **err_desc) = {
handle_data_frame, /* DATA */
handle_headers_frame, /* HEADERS */
handle_priority_frame, /* PRIORITY */
handle_rst_stream_frame, /* RST_STREAM */
handle_settings_frame, /* SETTINGS */
handle_push_promise_frame, /* PUSH_PROMISE */
handle_ping_frame, /* PING */
handle_goaway_frame, /* GOAWAY */
handle_window_update_frame, /* WINDOW_UPDATE */
handle_invalid_continuation_frame /* CONTINUATION */
};
if ((ret = h2o_http2_decode_frame(&frame, src, len, &H2O_HTTP2_SETTINGS_HOST, err_desc)) < 0)
return ret;
if (frame.type < sizeof(FRAME_HANDLERS) / sizeof(FRAME_HANDLERS[0])) {
int hret = FRAME_HANDLERS[frame.type](conn, &frame, err_desc);
if (hret != 0)
ret = hret;
} else {
fprintf(stderr, "skipping frame (type:%d)\n", frame.type);
}
return ret;
}
|
[]
|
||
CVE-2016-4817
|
030c1bddaf347cd52eb889cb6c90cbd0b43430d1
|
https://github.com/h2o/h2o/commit/1c0808d580da09fdec5a9a74ff09e103ea058dd4
|
Vulnerability in CVE-2016-4817
| null | null | null | null |
CWE-Other
|
Fix CVE-2016-4817
| null | null | null | null |
["lib/http2/connection.c"]
|
C
|
{"lib/http2/connection.c": {"lines_added": 19, "lines_deleted": 0}}
| null | null |
int do_emit_writereq(h2o_http2_conn_t *conn)
{
assert(conn->_write.buf_in_flight == NULL);
/* push DATA frames */
if (conn->state < H2O_HTTP2_CONN_STATE_IS_CLOSING && h2o_http2_conn_get_buffer_window(conn) > 0)
h2o_http2_scheduler_run(&conn->scheduler, emit_writereq_of_openref, conn);
if (conn->_write.buf->size == 0)
return 0;
{ /* write */
h2o_iovec_t buf = {conn->_write.buf->bytes, conn->_write.buf->size};
h2o_socket_write(conn->sock, &buf, 1, on_write_complete);
conn->_write.buf_in_flight = conn->_write.buf;
h2o_buffer_init(&conn->_write.buf, &wbuf_buffer_prototype);
}
return 1;
}
|
[]
|
||
CVE-2016-4817
|
030c1bddaf347cd52eb889cb6c90cbd0b43430d1
|
https://github.com/h2o/h2o/commit/1c0808d580da09fdec5a9a74ff09e103ea058dd4
|
Vulnerability in CVE-2016-4817
| null | null | null | null |
CWE-Other
|
Fix CVE-2016-4817
| null | null | null | null |
["lib/http2/connection.c"]
|
C
|
{"lib/http2/connection.c": {"lines_added": 7, "lines_deleted": 0}}
| null | null |
static void on_idle_timeout(h2o_timeout_entry_t *entry)
{
h2o_http2_conn_t *conn = H2O_STRUCT_FROM_MEMBER(h2o_http2_conn_t, _timeout_entry, entry);
enqueue_goaway(conn, H2O_HTTP2_ERROR_NONE, h2o_iovec_init(H2O_STRLIT("idle timeout")));
close_connection(conn);
}
|
[]
|
||
CVE-2016-4817
|
030c1bddaf347cd52eb889cb6c90cbd0b43430d1
|
https://github.com/h2o/h2o/commit/1c0808d580da09fdec5a9a74ff09e103ea058dd4
|
Vulnerability in CVE-2016-4817
| null | null | null | null |
CWE-Other
|
Fix CVE-2016-4817
| null | null | null | null |
["lib/http2/connection.c"]
|
C
|
{"lib/http2/connection.c": {"lines_added": 38, "lines_deleted": 0}}
| null | null |
static int handle_incoming_request(h2o_http2_conn_t *conn, h2o_http2_stream_t *stream, const uint8_t *src, size_t len,
const char **err_desc)
{
int ret, header_exists_map;
assert(stream->state == H2O_HTTP2_STREAM_STATE_RECV_HEADERS);
header_exists_map = 0;
if ((ret = h2o_hpack_parse_headers(&stream->req, &conn->_input_header_table, src, len, &header_exists_map,
&stream->_expected_content_length, err_desc)) != 0)
return ret;
#define EXPECTED_MAP \
(H2O_HPACK_PARSE_HEADERS_METHOD_EXISTS | H2O_HPACK_PARSE_HEADERS_PATH_EXISTS | H2O_HPACK_PARSE_HEADERS_SCHEME_EXISTS)
if ((header_exists_map & EXPECTED_MAP) != EXPECTED_MAP) {
ret = H2O_HTTP2_ERROR_PROTOCOL;
goto SendRSTStream;
}
#undef EXPECTED_MAP
/* handle the request */
if (conn->num_streams.pull.open > H2O_HTTP2_SETTINGS_HOST.max_concurrent_streams) {
ret = H2O_HTTP2_ERROR_REFUSED_STREAM;
goto SendRSTStream;
}
if (stream->_req_body == NULL) {
execute_or_enqueue_request(conn, stream);
} else {
h2o_http2_stream_set_state(conn, stream, H2O_HTTP2_STREAM_STATE_RECV_BODY);
}
return 0;
SendRSTStream:
send_stream_error(conn, stream->stream_id, ret);
h2o_http2_stream_reset(conn, stream);
return 0;
}
|
[]
|
||
CVE-2016-4817
|
030c1bddaf347cd52eb889cb6c90cbd0b43430d1
|
https://github.com/h2o/h2o/commit/1c0808d580da09fdec5a9a74ff09e103ea058dd4
|
Vulnerability in CVE-2016-4817
| null | null | null | null |
CWE-Other
|
Fix CVE-2016-4817
| null | null | null | null |
["lib/http2/connection.c"]
|
C
|
{"lib/http2/connection.c": {"lines_added": 65, "lines_deleted": 0}}
| null | null |
static int handle_headers_frame(h2o_http2_conn_t *conn, h2o_http2_frame_t *frame, const char **err_desc)
{
h2o_http2_headers_payload_t payload;
h2o_http2_stream_t *stream;
int ret;
/* decode */
if ((ret = h2o_http2_decode_headers_payload(&payload, frame, err_desc)) != 0)
return ret;
if ((frame->stream_id & 1) == 0) {
*err_desc = "invalid stream id in HEADERS frame";
return H2O_HTTP2_ERROR_PROTOCOL;
}
if (!(conn->pull_stream_ids.max_open < frame->stream_id)) {
if ((stream = h2o_http2_conn_get_stream(conn, frame->stream_id)) != NULL &&
stream->state == H2O_HTTP2_STREAM_STATE_RECV_BODY) {
/* is a trailer */
if ((frame->flags & H2O_HTTP2_FRAME_FLAG_END_STREAM) == 0) {
*err_desc = "trailing HEADERS frame MUST have END_STREAM flag set";
return H2O_HTTP2_ERROR_PROTOCOL;
}
stream->req.entity = h2o_iovec_init(stream->_req_body->bytes, stream->_req_body->size);
if ((frame->flags & H2O_HTTP2_FRAME_FLAG_END_HEADERS) == 0)
goto PREPARE_FOR_CONTINUATION;
return handle_trailing_headers(conn, stream, payload.headers, payload.headers_len, err_desc);
}
*err_desc = "invalid stream id in HEADERS frame";
return H2O_HTTP2_ERROR_STREAM_CLOSED;
}
if (frame->stream_id == payload.priority.dependency) {
*err_desc = "stream cannot depend on itself";
return H2O_HTTP2_ERROR_PROTOCOL;
}
if (conn->state >= H2O_HTTP2_CONN_STATE_HALF_CLOSED)
return 0;
/* open or determine the stream and prepare */
if ((stream = h2o_http2_conn_get_stream(conn, frame->stream_id)) != NULL) {
if ((frame->flags & H2O_HTTP2_FRAME_FLAG_PRIORITY) != 0)
set_priority(conn, stream, &payload.priority, 1);
} else {
stream = h2o_http2_stream_open(conn, frame->stream_id, NULL);
set_priority(conn, stream, &payload.priority, 0);
}
h2o_http2_stream_prepare_for_request(conn, stream);
/* setup container for request body if it is expected to arrive */
if ((frame->flags & H2O_HTTP2_FRAME_FLAG_END_STREAM) == 0)
h2o_buffer_init(&stream->_req_body, &h2o_socket_buffer_prototype);
if ((frame->flags & H2O_HTTP2_FRAME_FLAG_END_HEADERS) != 0) {
/* request is complete, handle it */
return handle_incoming_request(conn, stream, payload.headers, payload.headers_len, err_desc);
}
PREPARE_FOR_CONTINUATION:
/* request is not complete, store in buffer */
conn->_read_expect = expect_continuation_of_headers;
h2o_buffer_init(&conn->_headers_unparsed, &h2o_socket_buffer_prototype);
h2o_buffer_reserve(&conn->_headers_unparsed, payload.headers_len);
memcpy(conn->_headers_unparsed->bytes, payload.headers, payload.headers_len);
conn->_headers_unparsed->size = payload.headers_len;
return 0;
}
|
[]
|
||
CVE-2016-4817
|
030c1bddaf347cd52eb889cb6c90cbd0b43430d1
|
https://github.com/h2o/h2o/commit/1c0808d580da09fdec5a9a74ff09e103ea058dd4
|
Vulnerability in CVE-2016-4817
| null | null | null | null |
CWE-Other
|
Fix CVE-2016-4817
| null | null | null | null |
["lib/http2/connection.c"]
|
C
|
{"lib/http2/connection.c": {"lines_added": 33, "lines_deleted": 0}}
| null | null |
static int handle_priority_frame(h2o_http2_conn_t *conn, h2o_http2_frame_t *frame, const char **err_desc)
{
h2o_http2_priority_t payload;
h2o_http2_stream_t *stream;
int ret;
if ((ret = h2o_http2_decode_priority_payload(&payload, frame, err_desc)) != 0)
return ret;
if (frame->stream_id == payload.dependency) {
*err_desc = "stream cannot depend on itself";
return H2O_HTTP2_ERROR_PROTOCOL;
}
if ((stream = h2o_http2_conn_get_stream(conn, frame->stream_id)) != NULL) {
/* ignore priority changes to pushed streams with weight=257, since that is where we are trying to be smarter than the web
* browsers
*/
if (h2o_http2_scheduler_get_weight(&stream->_refs.scheduler) != 257)
set_priority(conn, stream, &payload, 1);
} else {
if (conn->num_streams.priority.open >= conn->super.ctx->globalconf->http2.max_streams_for_priority) {
*err_desc = "too many streams in idle/closed state";
/* RFC 7540 10.5: An endpoint MAY treat activity that is suspicious as a connection error (Section 5.4.1) of type
* ENHANCE_YOUR_CALM.
*/
return H2O_HTTP2_ERROR_ENHANCE_YOUR_CALM;
}
stream = h2o_http2_stream_open(conn, frame->stream_id, NULL);
set_priority(conn, stream, &payload, 0);
}
return 0;
}
|
[]
|
||
CVE-2016-4817
|
030c1bddaf347cd52eb889cb6c90cbd0b43430d1
|
https://github.com/h2o/h2o/commit/1c0808d580da09fdec5a9a74ff09e103ea058dd4
|
Vulnerability in CVE-2016-4817
| null | null | null | null |
CWE-Other
|
Fix CVE-2016-4817
| null | null | null | null |
["lib/http2/connection.c"]
|
C
|
{"lib/http2/connection.c": {"lines_added": 76, "lines_deleted": 0}}
| null | null |
static void push_path(h2o_req_t *src_req, const char *abspath, size_t abspath_len)
{
h2o_http2_conn_t *conn = (void *)src_req->conn;
h2o_http2_stream_t *src_stream = H2O_STRUCT_FROM_MEMBER(h2o_http2_stream_t, req, src_req);
if (!conn->peer_settings.enable_push || conn->num_streams.push.open >= conn->peer_settings.max_concurrent_streams)
return;
if (conn->push_stream_ids.max_open >= 0x7ffffff0)
return;
if (!(h2o_linklist_is_empty(&conn->_pending_reqs) && can_run_requests(conn)))
return;
/* casper-related code */
if (src_stream->req.hostconf->http2.casper.capacity_bits != 0 && !h2o_http2_stream_is_push(src_stream->stream_id)) {
size_t header_index;
switch (src_stream->pull.casper_state) {
case H2O_HTTP2_STREAM_CASPER_STATE_TBD:
/* disable casper for this request if intermediary exists */
if (h2o_find_header(&src_stream->req.headers, H2O_TOKEN_X_FORWARDED_FOR, -1) != -1) {
src_stream->pull.casper_state = H2O_HTTP2_STREAM_CASPER_DISABLED;
return;
}
/* casper enabled for this request */
if (conn->casper == NULL)
h2o_http2_conn_init_casper(conn, src_stream->req.hostconf->http2.casper.capacity_bits);
/* consume casper cookie */
for (header_index = -1;
(header_index = h2o_find_header(&src_stream->req.headers, H2O_TOKEN_COOKIE, header_index)) != -1;) {
h2o_header_t *header = src_stream->req.headers.entries + header_index;
h2o_http2_casper_consume_cookie(conn->casper, header->value.base, header->value.len);
}
src_stream->pull.casper_state = H2O_HTTP2_STREAM_CASPER_READY;
case H2O_HTTP2_STREAM_CASPER_READY:
break;
case H2O_HTTP2_STREAM_CASPER_DISABLED:
return;
}
}
/* open the stream */
conn->push_stream_ids.max_open += 2;
h2o_http2_stream_t *stream = h2o_http2_stream_open(conn, conn->push_stream_ids.max_open, NULL);
stream->push.parent_stream_id = src_stream->stream_id;
h2o_http2_scheduler_open(&stream->_refs.scheduler, &src_stream->_refs.scheduler.node, 16, 0);
h2o_http2_stream_prepare_for_request(conn, stream);
/* setup request */
stream->req.input.method = (h2o_iovec_t){H2O_STRLIT("GET")};
stream->req.input.scheme = src_stream->req.input.scheme;
stream->req.input.authority =
h2o_strdup(&stream->req.pool, src_stream->req.input.authority.base, src_stream->req.input.authority.len);
stream->req.input.path = h2o_strdup(&stream->req.pool, abspath, abspath_len);
stream->req.version = 0x200;
{ /* copy headers that may affect the response (of a cacheable response) */
size_t i;
for (i = 0; i != src_stream->req.headers.size; ++i) {
h2o_header_t *src_header = src_stream->req.headers.entries + i;
if (h2o_iovec_is_token(src_header->name)) {
h2o_token_t *token = H2O_STRUCT_FROM_MEMBER(h2o_token_t, buf, src_header->name);
if (token->copy_for_push_request) {
h2o_add_header(&stream->req.pool, &stream->req.headers, token,
h2o_strdup(&stream->req.pool, src_header->value.base, src_header->value.len).base,
src_header->value.len);
}
}
}
}
execute_or_enqueue_request(conn, stream);
/* send push-promise ASAP (before the parent stream gets closed), even if execute_or_enqueue_request did not trigger the
* invocation of send_headers */
if (!stream->push.promise_sent && stream->state != H2O_HTTP2_STREAM_STATE_END_STREAM)
h2o_http2_stream_send_push_promise(conn, stream);
}
|
[]
|
||
CVE-2016-4817
|
030c1bddaf347cd52eb889cb6c90cbd0b43430d1
|
https://github.com/h2o/h2o/commit/1c0808d580da09fdec5a9a74ff09e103ea058dd4
|
Vulnerability in CVE-2016-4817
| null | null | null | null |
CWE-Other
|
Fix CVE-2016-4817
| null | null | null | null |
["lib/http2/connection.c"]
|
C
|
{"lib/http2/connection.c": {"lines_added": 7, "lines_deleted": 0}}
| null | null |
static void close_connection_now(h2o_http2_conn_t *conn)
{
h2o_http2_stream_t *stream;
assert(!h2o_timeout_is_linked(&conn->_write.timeout_entry));
kh_foreach_value(conn->streams, stream, { h2o_http2_stream_close(conn, stream); }
|
[]
|
||
CVE-2016-4817
|
030c1bddaf347cd52eb889cb6c90cbd0b43430d1
|
https://github.com/h2o/h2o/commit/1c0808d580da09fdec5a9a74ff09e103ea058dd4
|
Vulnerability in CVE-2016-4817
| null | null | null | null |
CWE-Other
|
Fix CVE-2016-4817
| null | null | null | null |
["lib/http2/connection.c"]
|
C
|
{"lib/http2/connection.c": {"lines_added": 13, "lines_deleted": 0}}
| null | null |
void h2o_http2_conn_register_for_proceed_callback(h2o_http2_conn_t *conn, h2o_http2_stream_t *stream)
{
h2o_http2_conn_request_write(conn);
if (h2o_http2_stream_has_pending_data(stream) || stream->state >= H2O_HTTP2_STREAM_STATE_SEND_BODY_IS_FINAL) {
if (h2o_http2_window_get_window(&stream->output_window) > 0) {
assert(!h2o_linklist_is_linked(&stream->_refs.link));
h2o_http2_scheduler_activate(&stream->_refs.scheduler);
}
} else {
h2o_linklist_insert(&conn->_write.streams_to_proceed, &stream->_refs.link);
}
}
|
[]
|
||
CVE-2016-4817
|
030c1bddaf347cd52eb889cb6c90cbd0b43430d1
|
https://github.com/h2o/h2o/commit/1c0808d580da09fdec5a9a74ff09e103ea058dd4
|
Vulnerability in CVE-2016-4817
| null | null | null | null |
CWE-Other
|
Fix CVE-2016-4817
| null | null | null | null |
["lib/http2/connection.c"]
|
C
|
{"lib/http2/connection.c": {"lines_added": 6, "lines_deleted": 0}}
| null | null |
void h2o_http2_conn_request_write(h2o_http2_conn_t *conn)
{
if (conn->state == H2O_HTTP2_CONN_STATE_IS_CLOSING)
return;
request_gathered_write(conn);
}
|
[]
|
||
CVE-2016-4817
|
030c1bddaf347cd52eb889cb6c90cbd0b43430d1
|
https://github.com/h2o/h2o/commit/1c0808d580da09fdec5a9a74ff09e103ea058dd4
|
Vulnerability in CVE-2016-4817
| null | null | null | null |
CWE-Other
|
Fix CVE-2016-4817
| null | null | null | null |
["lib/http2/connection.c"]
|
C
|
{"lib/http2/connection.c": {"lines_added": 8, "lines_deleted": 0}}
| null | null |
static void request_gathered_write(h2o_http2_conn_t *conn)
{
assert(conn->state < H2O_HTTP2_CONN_STATE_IS_CLOSING);
if (conn->_write.buf_in_flight == NULL) {
if (!h2o_timeout_is_linked(&conn->_write.timeout_entry))
h2o_timeout_link(conn->super.ctx->loop, &conn->super.ctx->zero_timeout, &conn->_write.timeout_entry);
}
}
|
[]
|
||
CVE-2016-4817
|
030c1bddaf347cd52eb889cb6c90cbd0b43430d1
|
https://github.com/h2o/h2o/commit/1c0808d580da09fdec5a9a74ff09e103ea058dd4
|
Vulnerability in CVE-2016-4817
| null | null | null | null |
CWE-Other
|
Fix CVE-2016-4817
| null | null | null | null |
["lib/http2/connection.c"]
|
C
|
{"lib/http2/connection.c": {"lines_added": 13, "lines_deleted": 0}}
| null | null |
static int handle_ping_frame(h2o_http2_conn_t *conn, h2o_http2_frame_t *frame, const char **err_desc)
{
h2o_http2_ping_payload_t payload;
int ret;
if ((ret = h2o_http2_decode_ping_payload(&payload, frame, err_desc)) != 0)
return ret;
h2o_http2_encode_ping_frame(&conn->_write.buf, 1, payload.data);
h2o_http2_conn_request_write(conn);
return 0;
}
|
[]
|
||
CVE-2016-4817
|
030c1bddaf347cd52eb889cb6c90cbd0b43430d1
|
https://github.com/h2o/h2o/commit/1c0808d580da09fdec5a9a74ff09e103ea058dd4
|
Vulnerability in CVE-2016-4817
| null | null | null | null |
CWE-Other
|
Fix CVE-2016-4817
| null | null | null | null |
["lib/http2/connection.c"]
|
C
|
{"lib/http2/connection.c": {"lines_added": 11, "lines_deleted": 0}}
| null | null |
static int update_stream_output_window(h2o_http2_stream_t *stream, ssize_t delta)
{
ssize_t cur = h2o_http2_window_get_window(&stream->output_window);
if (h2o_http2_window_update(&stream->output_window, delta) != 0)
return -1;
if (cur <= 0 && h2o_http2_window_get_window(&stream->output_window) > 0 && h2o_http2_stream_has_pending_data(stream)) {
assert(!h2o_linklist_is_linked(&stream->_refs.link));
h2o_http2_scheduler_activate(&stream->_refs.scheduler);
}
return 0;
}
|
[]
|
||
CVE-2016-4817
|
030c1bddaf347cd52eb889cb6c90cbd0b43430d1
|
https://github.com/h2o/h2o/commit/1c0808d580da09fdec5a9a74ff09e103ea058dd4
|
Vulnerability in CVE-2016-4817
| null | null | null | null |
CWE-Other
|
Fix CVE-2016-4817
| null | null | null | null |
["lib/http2/connection.c"]
|
C
|
{"lib/http2/connection.c": {"lines_added": 56, "lines_deleted": 0}}
| null | null |
static int handle_data_frame(h2o_http2_conn_t *conn, h2o_http2_frame_t *frame, const char **err_desc)
{
h2o_http2_data_payload_t payload;
h2o_http2_stream_t *stream;
int ret;
if ((ret = h2o_http2_decode_data_payload(&payload, frame, err_desc)) != 0)
return ret;
if (conn->state >= H2O_HTTP2_CONN_STATE_HALF_CLOSED)
return 0;
stream = h2o_http2_conn_get_stream(conn, frame->stream_id);
/* save the input in the request body buffer, or send error (and close the stream) */
if (stream == NULL) {
if (frame->stream_id <= conn->pull_stream_ids.max_open) {
send_stream_error(conn, frame->stream_id, H2O_HTTP2_ERROR_STREAM_CLOSED);
} else {
*err_desc = "invalid DATA frame";
return H2O_HTTP2_ERROR_PROTOCOL;
}
} else if (stream->state != H2O_HTTP2_STREAM_STATE_RECV_BODY) {
send_stream_error(conn, frame->stream_id, H2O_HTTP2_ERROR_STREAM_CLOSED);
h2o_http2_stream_reset(conn, stream);
stream = NULL;
} else if (stream->_req_body->size + payload.length > conn->super.ctx->globalconf->max_request_entity_size) {
send_stream_error(conn, frame->stream_id, H2O_HTTP2_ERROR_REFUSED_STREAM);
h2o_http2_stream_reset(conn, stream);
stream = NULL;
} else {
h2o_iovec_t buf = h2o_buffer_reserve(&stream->_req_body, payload.length);
if (buf.base != NULL) {
memcpy(buf.base, payload.data, payload.length);
stream->_req_body->size += payload.length;
/* handle request if request body is complete */
if ((frame->flags & H2O_HTTP2_FRAME_FLAG_END_STREAM) != 0) {
stream->req.entity = h2o_iovec_init(stream->_req_body->bytes, stream->_req_body->size);
execute_or_enqueue_request(conn, stream);
stream = NULL; /* no need to send window update for this stream */
}
} else {
/* memory allocation failed */
send_stream_error(conn, frame->stream_id, H2O_HTTP2_ERROR_STREAM_CLOSED);
h2o_http2_stream_reset(conn, stream);
stream = NULL;
}
}
/* consume buffer (and set window_update) */
update_input_window(conn, 0, &conn->_input_window, frame->length);
if (stream != NULL)
update_input_window(conn, stream->stream_id, &stream->input_window, frame->length);
return 0;
}
|
[]
|
||
CVE-2016-4817
|
030c1bddaf347cd52eb889cb6c90cbd0b43430d1
|
https://github.com/h2o/h2o/commit/1c0808d580da09fdec5a9a74ff09e103ea058dd4
|
Vulnerability in CVE-2016-4817
| null | null | null | null |
CWE-Other
|
Fix CVE-2016-4817
| null | null | null | null |
["lib/http2/connection.c"]
|
C
|
{"lib/http2/connection.c": {"lines_added": 8, "lines_deleted": 0}}
| null | null |
void send_stream_error(h2o_http2_conn_t *conn, uint32_t stream_id, int errnum)
{
assert(stream_id != 0);
assert(conn->state < H2O_HTTP2_CONN_STATE_IS_CLOSING);
h2o_http2_encode_rst_stream_frame(&conn->_write.buf, stream_id, -errnum);
h2o_http2_conn_request_write(conn);
}
|
[]
|
||
CVE-2016-4817
|
030c1bddaf347cd52eb889cb6c90cbd0b43430d1
|
https://github.com/h2o/h2o/commit/1c0808d580da09fdec5a9a74ff09e103ea058dd4
|
Vulnerability in CVE-2016-4817
| null | null | null | null |
CWE-Other
|
Fix CVE-2016-4817
| null | null | null | null |
["lib/http2/connection.c"]
|
C
|
{"lib/http2/connection.c": {"lines_added": 9, "lines_deleted": 0}}
| null | null |
void h2o_http2_accept(h2o_accept_ctx_t *ctx, h2o_socket_t *sock, struct timeval connected_at)
{
h2o_http2_conn_t *conn = create_conn(ctx->ctx, ctx->hosts, sock, connected_at);
sock->data = conn;
h2o_socket_read_start(conn->sock, on_read);
update_idle_timeout(conn);
if (sock->input->size != 0)
on_read(sock, 0);
}
|
[]
|
||
CVE-2016-4817
|
030c1bddaf347cd52eb889cb6c90cbd0b43430d1
|
https://github.com/h2o/h2o/commit/1c0808d580da09fdec5a9a74ff09e103ea058dd4
|
Vulnerability in CVE-2016-4817
| null | null | null | null |
CWE-Other
|
Fix CVE-2016-4817
| null | null | null | null |
["lib/http2/connection.c"]
|
C
|
{"lib/http2/connection.c": {"lines_added": 47, "lines_deleted": 0}}
| null | null |
int h2o_http2_handle_upgrade(h2o_req_t *req, struct timeval connected_at)
{
h2o_http2_conn_t *http2conn = create_conn(req->conn->ctx, req->conn->hosts, NULL, connected_at);
h2o_http2_stream_t *stream;
ssize_t connection_index, settings_index;
h2o_iovec_t settings_decoded;
const char *err_desc;
assert(req->version < 0x200); /* from HTTP/1.x */
/* check that "HTTP2-Settings" is declared in the connection header */
connection_index = h2o_find_header(&req->headers, H2O_TOKEN_CONNECTION, -1);
assert(connection_index != -1);
if (!h2o_contains_token(req->headers.entries[connection_index].value.base, req->headers.entries[connection_index].value.len,
H2O_STRLIT("http2-settings"), ',')) {
goto Error;
}
/* decode the settings */
if ((settings_index = h2o_find_header(&req->headers, H2O_TOKEN_HTTP2_SETTINGS, -1)) == -1) {
goto Error;
}
if ((settings_decoded = h2o_decode_base64url(&req->pool, req->headers.entries[settings_index].value.base,
req->headers.entries[settings_index].value.len)).base == NULL) {
goto Error;
}
if (h2o_http2_update_peer_settings(&http2conn->peer_settings, (uint8_t *)settings_decoded.base, settings_decoded.len,
&err_desc) != 0) {
goto Error;
}
/* open the stream, now that the function is guaranteed to succeed */
stream = h2o_http2_stream_open(http2conn, 1, req);
h2o_http2_scheduler_open(&stream->_refs.scheduler, &http2conn->scheduler, h2o_http2_default_priority.weight, 0);
h2o_http2_stream_prepare_for_request(http2conn, stream);
/* send response */
req->res.status = 101;
req->res.reason = "Switching Protocols";
h2o_add_header(&req->pool, &req->res.headers, H2O_TOKEN_UPGRADE, H2O_STRLIT("h2c"));
h2o_http1_upgrade(req, (h2o_iovec_t *)&SETTINGS_HOST_BIN, 1, on_upgrade_complete, http2conn);
return 0;
Error:
free(http2conn);
return -1;
}
|
[]
|
||
CVE-2017-9732
|
86b5fb979ee75a1925c6714b7df82c1a7abfe282
|
https://github.com/elric1/knc/commit/f237f3e09ecbaf59c897f5046538a7b1a3fa40c1
|
Vulnerability in CVE-2017-9732
| null | null | null | null |
CWE-400
|
Fix CVE-2017-9732
| null | null | null | null |
["bin/gssstdio.c"]
|
C
|
{"bin/gssstdio.c": {"lines_added": 48, "lines_deleted": 45}}
| null |
void *
gstd_accept(int fd, char **display_creds, char **export_name, char **mech)
{
gss_name_t client;
gss_OID mech_oid;
struct gstd_tok *tok;
gss_ctx_id_t ctx = GSS_C_NO_CONTEXT;
gss_buffer_desc in, out;
OM_uint32 maj, min;
int ret;
*display_creds = NULL;
*export_name = NULL;
out.length = 0;
in.length = 0;
read_packet(fd, &in, 60000, 1);
again:
while ((ret = read_packet(fd, &in, 60000, 0)) == -2)
;
if (ret < 1)
return NULL;
maj = gss_accept_sec_context(&min, &ctx, GSS_C_NO_CREDENTIAL,
&in, GSS_C_NO_CHANNEL_BINDINGS, &client, &mech_oid, &out, NULL,
NULL, NULL);
if (out.length && write_packet(fd, &out)) {
gss_release_buffer(&min, &out);
return NULL;
}
GSTD_GSS_ERROR(maj, min, NULL, "gss_accept_sec_context");
if (maj & GSS_S_CONTINUE_NEEDED)
goto again;
*display_creds = gstd_get_display_name(client);
*export_name = gstd_get_export_name(client);
*mech = gstd_get_mech(mech_oid);
gss_release_name(&min, &client);
SETUP_GSTD_TOK(tok, ctx, fd, "gstd_accept");
return tok;
}
|
void *
gstd_accept(int fd, char **display_creds, char **export_name, char **mech)
{
gss_name_t client;
gss_OID mech_oid;
struct gstd_tok *tok;
gss_ctx_id_t ctx = GSS_C_NO_CONTEXT;
gss_buffer_desc in, out;
OM_uint32 maj, min;
int ret;
*display_creds = NULL;
*export_name = NULL;
out.length = 0;
in.length = 0;
read_packet(fd, &in, 60000, 1);
again:
while ((ret = read_packet(fd, &in, 60000, 0)) == -2)
;
if (ret < 1)
return NULL;
maj = gss_accept_sec_context(&min, &ctx, GSS_C_NO_CREDENTIAL,
&in, GSS_C_NO_CHANNEL_BINDINGS, &client, &mech_oid, &out, NULL,
NULL, NULL);
gss_release_buffer(&min, &in);
if (out.length && write_packet(fd, &out)) {
gss_release_buffer(&min, &out);
return NULL;
}
gss_release_buffer(&min, &out);
GSTD_GSS_ERROR(maj, min, NULL, "gss_accept_sec_context");
if (maj & GSS_S_CONTINUE_NEEDED)
goto again;
*display_creds = gstd_get_display_name(client);
*export_name = gstd_get_export_name(client);
*mech = gstd_get_mech(mech_oid);
gss_release_name(&min, &client);
SETUP_GSTD_TOK(tok, ctx, fd, "gstd_accept");
return tok;
}
|
[]
|
||
CVE-2017-9732
|
a2b3bb9d7db1a3c11f18efaf1b21fdeaae13098d
|
https://github.com/elric1/knc/commit/f237f3e09ecbaf59c897f5046538a7b1a3fa40c1
|
Vulnerability in CVE-2017-9732
| null | null | null | null |
CWE-400
|
Fix CVE-2017-9732
| null | null | null | null |
["bin/gssstdio.c"]
|
C
|
{"bin/gssstdio.c": {"lines_added": 103, "lines_deleted": 96}}
| null |
static int
read_packet(int fd, gss_buffer_t buf, int timeout, int first)
{
int ret;
static uint32_t len = 0;
static char len_buf[4];
static int len_buf_pos = 0;
static char * tmpbuf = 0;
static int tmpbuf_pos = 0;
if (first) {
len_buf_pos = 0;
return -2;
}
if (len_buf_pos < 4) {
ret = timed_read(fd, &len_buf[len_buf_pos], 4 - len_buf_pos,
timeout);
if (ret == -1) {
if (errno == EINTR || errno == EAGAIN)
return -2;
LOG(LOG_ERR, ("%s", strerror(errno)));
return -1;
}
if (ret == 0) { /* EOF */
/* Failure to read ANY length just means we're done */
if (len_buf_pos == 0)
return 0;
/*
* Otherwise, we got EOF mid-length, and that's
* a protocol error.
*/
LOG(LOG_INFO, ("EOF reading packet len"));
return -1;
}
len_buf_pos += ret;
}
/* Not done reading the length? */
if (len_buf_pos != 4)
return -2;
/* We have the complete length */
len = ntohl(*(uint32_t *)len_buf);
/*
* We make sure recvd length is reasonable, allowing for some
* slop in enc overhead, beyond the actual maximum number of
* bytes of decrypted payload.
*/
if (len > GSTD_MAXPACKETCONTENTS + 512) {
LOG(LOG_ERR, ("ridiculous length, %ld", len));
return -1;
}
if (!tmpbuf) {
if ((tmpbuf = malloc(len)) == NULL) {
LOG(LOG_CRIT, ("malloc failure, %ld bytes", len));
return -1;
}
}
ret = timed_read(fd, tmpbuf + tmpbuf_pos, len - tmpbuf_pos, timeout);
if (ret == -1) {
if (errno == EINTR || errno == EAGAIN)
return -2;
LOG(LOG_ERR, ("%s", strerror(errno)));
return -1;
}
if (ret == 0) {
LOG(LOG_ERR, ("EOF while reading packet (len=%d)", len));
return -1;
}
tmpbuf_pos += ret;
if (tmpbuf_pos == len) {
buf->length = len;
buf->value = tmpbuf;
len = len_buf_pos = tmpbuf_pos = 0;
tmpbuf = NULL;
LOG(LOG_DEBUG, ("read packet of length %d", buf->length));
return 1;
}
return -2;
}
|
static int
read_packet(int fd, gss_buffer_t buf, int timeout, int first)
{
int ret;
static uint32_t len = 0;
static char len_buf[4];
static int len_buf_pos = 0;
static char * tmpbuf = 0;
static int tmpbuf_pos = 0;
if (first) {
len_buf_pos = 0;
return -2;
}
if (len_buf_pos < 4) {
ret = timed_read(fd, &len_buf[len_buf_pos], 4 - len_buf_pos,
timeout);
if (ret == -1) {
if (errno == EINTR || errno == EAGAIN)
return -2;
LOG(LOG_ERR, ("%s", strerror(errno)));
goto bail;
}
if (ret == 0) { /* EOF */
/* Failure to read ANY length just means we're done */
if (len_buf_pos == 0)
return 0;
/*
* Otherwise, we got EOF mid-length, and that's
* a protocol error.
*/
LOG(LOG_INFO, ("EOF reading packet len"));
goto bail;
}
len_buf_pos += ret;
}
/* Not done reading the length? */
if (len_buf_pos != 4)
return -2;
/* We have the complete length */
len = ntohl(*(uint32_t *)len_buf);
/*
* We make sure recvd length is reasonable, allowing for some
* slop in enc overhead, beyond the actual maximum number of
* bytes of decrypted payload.
*/
if (len > GSTD_MAXPACKETCONTENTS + 512) {
LOG(LOG_ERR, ("ridiculous length, %ld", len));
goto bail;
}
if (!tmpbuf) {
if ((tmpbuf = malloc(len)) == NULL) {
LOG(LOG_CRIT, ("malloc failure, %ld bytes", len));
goto bail;
}
}
ret = timed_read(fd, tmpbuf + tmpbuf_pos, len - tmpbuf_pos, timeout);
if (ret == -1) {
if (errno == EINTR || errno == EAGAIN)
return -2;
LOG(LOG_ERR, ("%s", strerror(errno)));
goto bail;
}
if (ret == 0) {
LOG(LOG_ERR, ("EOF while reading packet (len=%d)", len));
goto bail;
}
tmpbuf_pos += ret;
if (tmpbuf_pos == len) {
buf->length = len;
buf->value = tmpbuf;
len = len_buf_pos = tmpbuf_pos = 0;
tmpbuf = NULL;
LOG(LOG_DEBUG, ("read packet of length %d", buf->length));
return 1;
}
return -2;
bail:
free(tmpbuf);
tmpbuf = NULL;
return -1;
}
|
[]
|
||
CVE-2017-9732
|
85ca9c323aca36487650c96938d1b85334e91d4f
|
https://github.com/elric1/knc/commit/f237f3e09ecbaf59c897f5046538a7b1a3fa40c1
|
Vulnerability in CVE-2017-9732
| null | null | null | null |
CWE-400
|
Fix CVE-2017-9732
| null | null | null | null |
["bin/gssstdio.c"]
|
C
|
{"bin/gssstdio.c": {"lines_added": 23, "lines_deleted": 0}}
| null | null |
static ssize_t
timed_read(int fd, void *buf, size_t bytes, int timeout)
{
struct pollfd fds[1];
int ret;
if (timeout > 0) {
fds[0].fd = fd;
fds[0].events = POLLIN;
ret = poll(fds, 1, timeout);
if (ret == -1)
return -1;
if (ret != 1) {
errno = ETIMEDOUT;
return -1;
}
}
return read(fd, buf, bytes);
}
|
[]
|
||
CVE-2017-9732
|
85ca9c323aca36487650c96938d1b85334e91d4f
|
https://github.com/elric1/knc/commit/f237f3e09ecbaf59c897f5046538a7b1a3fa40c1
|
Vulnerability in CVE-2017-9732
| null | null | null | null |
CWE-400
|
Fix CVE-2017-9732
| null | null | null | null |
["bin/gssstdio.c"]
|
C
|
{"bin/gssstdio.c": {"lines_added": 12, "lines_deleted": 0}}
| null | null |
void
gstd_error(int pri, int min_stat, const char *s)
{
char *t1;
if (gstd_errstring(&t1, min_stat) < 1)
LOG(pri, ("%s: couldn't form GSSAPI error string", s));
else {
LOG(pri, ("%s: %s", s, t1));
free(t1);
}
}
|
[]
|
||
CVE-2017-9732
|
85ca9c323aca36487650c96938d1b85334e91d4f
|
https://github.com/elric1/knc/commit/f237f3e09ecbaf59c897f5046538a7b1a3fa40c1
|
Vulnerability in CVE-2017-9732
| null | null | null | null |
CWE-400
|
Fix CVE-2017-9732
| null | null | null | null |
["bin/gssstdio.c"]
|
C
|
{"bin/gssstdio.c": {"lines_added": 6, "lines_deleted": 0}}
| null | null |
void
gstd_release_context(void *ctx) {
OM_uint32 min;
gss_delete_sec_context(&min, (gss_ctx_id_t *)ctx, GSS_C_NO_BUFFER);
}
|
[]
|
End of preview. Expand
in Data Studio
YAML Metadata
Warning:
The task_categories "code-generation" is not in the official list: text-classification, token-classification, table-question-answering, question-answering, zero-shot-classification, translation, summarization, feature-extraction, text-generation, fill-mask, sentence-similarity, text-to-speech, text-to-audio, automatic-speech-recognition, audio-to-audio, audio-classification, audio-text-to-text, voice-activity-detection, depth-estimation, image-classification, object-detection, image-segmentation, text-to-image, image-to-text, image-to-image, image-to-video, unconditional-image-generation, video-classification, reinforcement-learning, robotics, tabular-classification, tabular-regression, tabular-to-text, table-to-text, multiple-choice, text-ranking, text-retrieval, time-series-forecasting, text-to-video, image-text-to-text, visual-question-answering, document-question-answering, zero-shot-image-classification, graph-ml, mask-generation, zero-shot-object-detection, text-to-3d, image-to-3d, image-feature-extraction, video-text-to-text, keypoint-detection, visual-document-retrieval, any-to-any, video-to-video, other
MegaVul Dataset (CVEfixes-Compatible Format)
Dataset Description
This is a processed version of the MegaVul dataset converted to match the CVEfixes schema format for unified vulnerability analysis and model training.
Source Kaggle Dataset: marcdamie/megavul-a-cc-java-vulnerability-dataset Original Project: Icyrockton/MegaVul
Dataset Summary
MegaVul is a large, high-quality, extensible, continuously updated C/C++/Java function-level vulnerability dataset.
This processed version provides:
- 671,797 vulnerability records
- 8,476 unique CVEs
- 9,284 unique repositories
- CVEfixes-compatible schema for combined training
Languages
| Language | Count | Percentage |
|---|---|---|
| C | 538269 | 80.1% |
| C++ | 133528 | 19.9% |
Dataset Structure
See the project's megavul_dataset_loader.py for full schema details.
Source Data
Original Dataset
This dataset is derived from the MegaVul project.
- Original Repository: https://github.com/Icyrockton/MegaVul
- Academic Paper: MegaVul: A C/C++ Vulnerability Dataset with Comprehensive Code Representations
- License: GPL-3.0
Data Collection
This dataset was created by:
- Downloading the version of the dataset from Kaggle.
- Converting it to the CVEfixes commit-level schema.
- Generating synthetic commit hashes and other metadata.
Licensing & Attribution
License
This dataset is licensed under GPL-3.0 to match the original MegaVul license.
Citation
If you use this dataset, please cite the original MegaVul paper:
@inproceedings{megavul2024,
title={MegaVul: A C/C++ Vulnerability Dataset with Comprehensive Code Representations},
author={Chen Ni and Zhuo Xu and Yun Zhang and Yang Liu and others},
booktitle={Proceedings of the 21st International Conference on Mining Software Repositories},
year={2024},
publisher={ACM}
}
And acknowledge this processed version:
@misc{hitoshura25_megavul,
title={MegaVul Dataset in CVEfixes Format},
author={Your Name},
year={2025},
howpublished={\url{https://huggingface.co/datasets/hitoshura25/megavul}},
note={Processed from the Kaggle dataset by Marc Damie, based on the original MegaVul project.}
}
Usage
from datasets import load_dataset
dataset = load_dataset("hitoshura25/megavul")
- Downloads last month
- 45