cve_id
stringlengths 13
16
| obtain_all_privilege
stringclasses 3
values | obtain_user_privilege
stringclasses 2
values | obtain_other_privilege
stringclasses 2
values | user_interaction_required
stringclasses 3
values | cvss2_vector_string
stringclasses 106
values | cvss2_access_vector
stringclasses 4
values | cvss2_access_complexity
stringclasses 4
values | cvss2_authentication
stringclasses 3
values | cvss2_confidentiality_impact
stringclasses 4
values | cvss2_integrity_impact
stringclasses 4
values | cvss2_availability_impact
stringclasses 4
values | cvss2_base_score
stringclasses 50
values | cvss3_vector_string
stringclasses 226
values | cvss3_attack_vector
stringclasses 5
values | cvss3_attack_complexity
stringclasses 3
values | cvss3_privileges_required
stringclasses 4
values | cvss3_user_interaction
stringclasses 3
values | cvss3_scope
stringclasses 3
values | cvss3_confidentiality_impact
stringclasses 4
values | cvss3_integrity_impact
stringclasses 4
values | cvss3_availability_impact
stringclasses 4
values | cvss3_base_score
stringclasses 55
values | cvss3_base_severity
stringclasses 5
values | exploitability_score
stringclasses 22
values | impact_score
stringclasses 15
values | ac_insuf_info
stringclasses 3
values | reference_json
stringlengths 221
23.3k
| problemtype_json
stringclasses 200
values | severity
stringclasses 4
values | cve_nodes
stringlengths 2
33.1k
| cve_description
stringlengths 64
1.99k
| cve_last_modified_date
stringlengths 17
17
| cve_published_date
stringlengths 17
17
| cwe_name
stringclasses 125
values | cwe_description
stringclasses 124
values | cwe_extended_description
stringclasses 95
values | cwe_url
stringclasses 124
values | cwe_is_category
int64 0
1
| commit_author
stringlengths 0
34
| commit_author_date
stringlengths 25
25
| commit_msg
stringlengths 0
13.3k
| commit_hash
stringlengths 40
40
| commit_is_merge
stringclasses 1
value | repo_name
stringclasses 467
values | repo_description
stringclasses 459
values | repo_date_created
stringclasses 467
values | repo_date_last_push
stringclasses 467
values | repo_homepage
stringclasses 294
values | repo_owner
stringclasses 470
values | repo_stars
stringclasses 406
values | repo_forks
stringclasses 352
values | function_name
stringlengths 3
120
| function_signature
stringlengths 6
640
| function_parameters
stringlengths 2
302
| function
stringlengths 12
114k
| function_token_count
stringlengths 1
5
| function_before_change
stringclasses 1
value | labels
int64 1
1
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
CVE-2022-21722 | False | False | False | False | AV:N/AC:L/Au:N/C:P/I:N/A:P | NETWORK | LOW | NONE | PARTIAL | NONE | PARTIAL | 6.4 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | HIGH | NONE | HIGH | 9.1 | CRITICAL | 3.9 | 5.2 | False | [{'url': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-m66q-q64c-hv36', 'name': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-m66q-q64c-hv36', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/pjsip/pjproject/commit/22af44e68a0c7d190ac1e25075e1382f77e9397a', 'name': 'https://github.com/pjsip/pjproject/commit/22af44e68a0c7d190ac1e25075e1382f77e9397a', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2022/03/msg00035.html', 'name': '[debian-lts-announce] 20220328 [SECURITY] [DLA 2962-1] pjproject security update', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:teluu:pjsip:*:*:*:*:*:*:*:*', 'versionEndIncluding': '2.11.1', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:debian:debian_linux:9.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'PJSIP is a free and open source multimedia communication library written in C language implementing standard based protocols such as SIP, SDP, RTP, STUN, TURN, and ICE. In version 2.11.1 and prior, there are various cases where it is possible that certain incoming RTP/RTCP packets can potentially cause out-of-bound read access. This issue affects all users that use PJMEDIA and accept incoming RTP/RTCP. A patch is available as a commit in the `master` branch. There are no known workarounds.'}] | 2022-06-05T02:45Z | 2022-01-27T00:15Z | Out-of-bounds Read | The software reads data past the end, or before the beginning, of the intended buffer. | Typically, this can allow attackers to read sensitive information from other memory locations or cause a crash. A crash can occur when the code reads a variable amount of data and assumes that a sentinel exists to stop the read operation, such as a NUL in a string. The expected sentinel might not be located in the out-of-bounds memory, causing excessive data to be read, leading to a segmentation fault or a buffer overflow. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent read operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/125.html | 0 | sauwming | 2022-01-26 08:03:48+08:00 | Merge pull request from GHSA-m66q-q64c-hv36
* Prevent OOB read during RTP/RTCP parsing
* Add log
* Add more logs | 22af44e68a0c7d190ac1e25075e1382f77e9397a | False | pjsip/pjproject | PJSIP project | 2016-01-24 05:00:33 | 2022-08-26 15:35:55 | http://www.pjsip.org | pjsip | 1248.0 | 567.0 | pjmedia_rtcp_rx_rtcp | pjmedia_rtcp_rx_rtcp( pjmedia_rtcp_session * sess , const void * pkt , pj_size_t size) | ['sess', 'pkt', 'size'] | PJ_DEF(void) pjmedia_rtcp_rx_rtcp( pjmedia_rtcp_session *sess,
const void *pkt,
pj_size_t size)
{
pj_uint8_t *p, *p_end;
p = (pj_uint8_t*)pkt;
p_end = p + size;
while (p < p_end) {
pjmedia_rtcp_common *common = (pjmedia_rtcp_common*)p;
unsigned len;
len = (pj_ntohs((pj_uint16_t)common->length)+1) * 4;
if (p + len > p_end)
break;
switch(common->pt) {
case RTCP_SR:
case RTCP_RR:
case RTCP_XR:
parse_rtcp_report(sess, p, len);
break;
case RTCP_SDES:
parse_rtcp_sdes(sess, p, len);
break;
case RTCP_BYE:
parse_rtcp_bye(sess, p, len);
break;
case RTCP_RTPFB:
case RTCP_PSFB:
parse_rtcp_fb(sess, p, len);
break;
default:
/* Ignore unknown RTCP */
TRACE_((sess->name, "Received unknown RTCP packet type=%d",
common->pt));
break;
}
p += len;
}
} | 181 | True | 1 |
CVE-2022-21722 | False | False | False | False | AV:N/AC:L/Au:N/C:P/I:N/A:P | NETWORK | LOW | NONE | PARTIAL | NONE | PARTIAL | 6.4 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | HIGH | NONE | HIGH | 9.1 | CRITICAL | 3.9 | 5.2 | False | [{'url': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-m66q-q64c-hv36', 'name': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-m66q-q64c-hv36', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/pjsip/pjproject/commit/22af44e68a0c7d190ac1e25075e1382f77e9397a', 'name': 'https://github.com/pjsip/pjproject/commit/22af44e68a0c7d190ac1e25075e1382f77e9397a', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2022/03/msg00035.html', 'name': '[debian-lts-announce] 20220328 [SECURITY] [DLA 2962-1] pjproject security update', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:teluu:pjsip:*:*:*:*:*:*:*:*', 'versionEndIncluding': '2.11.1', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:debian:debian_linux:9.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'PJSIP is a free and open source multimedia communication library written in C language implementing standard based protocols such as SIP, SDP, RTP, STUN, TURN, and ICE. In version 2.11.1 and prior, there are various cases where it is possible that certain incoming RTP/RTCP packets can potentially cause out-of-bound read access. This issue affects all users that use PJMEDIA and accept incoming RTP/RTCP. A patch is available as a commit in the `master` branch. There are no known workarounds.'}] | 2022-06-05T02:45Z | 2022-01-27T00:15Z | Out-of-bounds Read | The software reads data past the end, or before the beginning, of the intended buffer. | Typically, this can allow attackers to read sensitive information from other memory locations or cause a crash. A crash can occur when the code reads a variable amount of data and assumes that a sentinel exists to stop the read operation, such as a NUL in a string. The expected sentinel might not be located in the out-of-bounds memory, causing excessive data to be read, leading to a segmentation fault or a buffer overflow. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent read operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/125.html | 0 | sauwming | 2022-01-26 08:03:48+08:00 | Merge pull request from GHSA-m66q-q64c-hv36
* Prevent OOB read during RTP/RTCP parsing
* Add log
* Add more logs | 22af44e68a0c7d190ac1e25075e1382f77e9397a | False | pjsip/pjproject | PJSIP project | 2016-01-24 05:00:33 | 2022-08-26 15:35:55 | http://www.pjsip.org | pjsip | 1248.0 | 567.0 | pjmedia_rtcp_fb_parse_nack | pjmedia_rtcp_fb_parse_nack( const void * buf , pj_size_t length , unsigned * nack_cnt , pjmedia_rtcp_fb_nack nack [ ]) | ['buf', 'length', 'nack_cnt'] | PJ_DEF(pj_status_t) pjmedia_rtcp_fb_parse_nack(
const void *buf,
pj_size_t length,
unsigned *nack_cnt,
pjmedia_rtcp_fb_nack nack[])
{
pjmedia_rtcp_common *hdr = (pjmedia_rtcp_common*) buf;
pj_uint8_t *p;
unsigned cnt, i;
PJ_ASSERT_RETURN(buf && nack_cnt && nack, PJ_EINVAL);
PJ_ASSERT_RETURN(length >= sizeof(pjmedia_rtcp_common), PJ_ETOOSMALL);
/* Generic NACK uses pt==RTCP_RTPFB and FMT==1 */
if (hdr->pt != RTCP_RTPFB || hdr->count != 1)
return PJ_ENOTFOUND;
cnt = pj_ntohs((pj_uint16_t)hdr->length) - 2;
if (length < (cnt+3)*4)
return PJ_ETOOSMALL;
*nack_cnt = PJ_MIN(*nack_cnt, cnt);
p = (pj_uint8_t*)hdr + sizeof(*hdr);
for (i = 0; i < *nack_cnt; ++i) {
pj_uint16_t val;
pj_memcpy(&val, p, 2);
nack[i].pid = pj_ntohs(val);
pj_memcpy(&val, p+2, 2);
nack[i].blp = pj_ntohs(val);
p += 4;
}
return PJ_SUCCESS;
} | 205 | True | 1 |
CVE-2022-21722 | False | False | False | False | AV:N/AC:L/Au:N/C:P/I:N/A:P | NETWORK | LOW | NONE | PARTIAL | NONE | PARTIAL | 6.4 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | HIGH | NONE | HIGH | 9.1 | CRITICAL | 3.9 | 5.2 | False | [{'url': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-m66q-q64c-hv36', 'name': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-m66q-q64c-hv36', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/pjsip/pjproject/commit/22af44e68a0c7d190ac1e25075e1382f77e9397a', 'name': 'https://github.com/pjsip/pjproject/commit/22af44e68a0c7d190ac1e25075e1382f77e9397a', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2022/03/msg00035.html', 'name': '[debian-lts-announce] 20220328 [SECURITY] [DLA 2962-1] pjproject security update', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:teluu:pjsip:*:*:*:*:*:*:*:*', 'versionEndIncluding': '2.11.1', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:debian:debian_linux:9.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'PJSIP is a free and open source multimedia communication library written in C language implementing standard based protocols such as SIP, SDP, RTP, STUN, TURN, and ICE. In version 2.11.1 and prior, there are various cases where it is possible that certain incoming RTP/RTCP packets can potentially cause out-of-bound read access. This issue affects all users that use PJMEDIA and accept incoming RTP/RTCP. A patch is available as a commit in the `master` branch. There are no known workarounds.'}] | 2022-06-05T02:45Z | 2022-01-27T00:15Z | Out-of-bounds Read | The software reads data past the end, or before the beginning, of the intended buffer. | Typically, this can allow attackers to read sensitive information from other memory locations or cause a crash. A crash can occur when the code reads a variable amount of data and assumes that a sentinel exists to stop the read operation, such as a NUL in a string. The expected sentinel might not be located in the out-of-bounds memory, causing excessive data to be read, leading to a segmentation fault or a buffer overflow. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent read operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/125.html | 0 | sauwming | 2022-01-26 08:03:48+08:00 | Merge pull request from GHSA-m66q-q64c-hv36
* Prevent OOB read during RTP/RTCP parsing
* Add log
* Add more logs | 22af44e68a0c7d190ac1e25075e1382f77e9397a | False | pjsip/pjproject | PJSIP project | 2016-01-24 05:00:33 | 2022-08-26 15:35:55 | http://www.pjsip.org | pjsip | 1248.0 | 567.0 | pjmedia_rtcp_fb_parse_pli | pjmedia_rtcp_fb_parse_pli( const void * buf , pj_size_t length) | ['buf', 'length'] | PJ_DEF(pj_status_t) pjmedia_rtcp_fb_parse_pli(
const void *buf,
pj_size_t length)
{
pjmedia_rtcp_common *hdr = (pjmedia_rtcp_common*) buf;
PJ_ASSERT_RETURN(buf, PJ_EINVAL);
PJ_ASSERT_RETURN(length >= 12, PJ_ETOOSMALL);
/* PLI uses pt==RTCP_PSFB and FMT==1 */
if (hdr->pt != RTCP_PSFB || hdr->count != 1)
return PJ_ENOTFOUND;
return PJ_SUCCESS;
} | 57 | True | 1 |
CVE-2022-21723 | False | False | False | False | AV:N/AC:L/Au:N/C:P/I:N/A:P | NETWORK | LOW | NONE | PARTIAL | NONE | PARTIAL | 6.4 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | HIGH | NONE | HIGH | 9.1 | CRITICAL | 3.9 | 5.2 | False | [{'url': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-7fw8-54cv-r7pm', 'name': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-7fw8-54cv-r7pm', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/pjsip/pjproject/commit/077b465c33f0aec05a49cd2ca456f9a1b112e896', 'name': 'https://github.com/pjsip/pjproject/commit/077b465c33f0aec05a49cd2ca456f9a1b112e896', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Mar/2', 'name': '20220304 AST-2022-006: pjproject: unconstrained malformed multipart SIP message', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Patch', 'Third Party Advisory']}, {'url': 'http://packetstormsecurity.com/files/166227/Asterisk-Project-Security-Advisory-AST-2022-006.html', 'name': 'http://packetstormsecurity.com/files/166227/Asterisk-Project-Security-Advisory-AST-2022-006.html', 'refsource': 'MISC', 'tags': ['Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2022/03/msg00035.html', 'name': '[debian-lts-announce] 20220328 [SECURITY] [DLA 2962-1] pjproject security update', 'refsource': 'MLIST', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:teluu:pjsip:*:*:*:*:*:*:*:*', 'versionEndIncluding': '2.11.1', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:asterisk:certified_asterisk:16.8.0:cert12:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:asterisk:certified_asterisk:16.8.0:cert11:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:asterisk:certified_asterisk:16.8.0:cert10:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:asterisk:certified_asterisk:16.8.0:cert9:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:asterisk:certified_asterisk:16.8.0:cert8:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:asterisk:certified_asterisk:16.8.0:cert7:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:asterisk:certified_asterisk:16.8.0:cert6:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:asterisk:certified_asterisk:16.8.0:cert5:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:asterisk:certified_asterisk:16.8.0:cert4:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:asterisk:certified_asterisk:16.8.0:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:asterisk:certified_asterisk:16.8.0:cert1:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:asterisk:certified_asterisk:16.8.0:cert2:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:asterisk:certified_asterisk:16.8.0:cert3:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:sangoma:asterisk:*:*:*:*:*:*:*:*', 'versionStartIncluding': '16.0.0', 'versionEndExcluding': '16.24.1', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:sangoma:asterisk:*:*:*:*:*:*:*:*', 'versionStartIncluding': '18.0.0', 'versionEndExcluding': '18.10.1', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:sangoma:asterisk:*:*:*:*:*:*:*:*', 'versionStartIncluding': '19.0.0', 'versionEndExcluding': '19.2.1', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:debian:debian_linux:9.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'PJSIP is a free and open source multimedia communication library written in C language implementing standard based protocols such as SIP, SDP, RTP, STUN, TURN, and ICE. In versions 2.11.1 and prior, parsing an incoming SIP message that contains a malformed multipart can potentially cause out-of-bound read access. This issue affects all PJSIP users that accept SIP multipart. The patch is available as commit in the `master` branch. There are no known workarounds.'}] | 2022-04-25T15:41Z | 2022-01-27T00:15Z | Out-of-bounds Read | The software reads data past the end, or before the beginning, of the intended buffer. | Typically, this can allow attackers to read sensitive information from other memory locations or cause a crash. A crash can occur when the code reads a variable amount of data and assumes that a sentinel exists to stop the read operation, such as a NUL in a string. The expected sentinel might not be located in the out-of-bounds memory, causing excessive data to be read, leading to a segmentation fault or a buffer overflow. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent read operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/125.html | 0 | sauwming | 2022-01-26 13:28:57+08:00 | Merge pull request from GHSA-7fw8-54cv-r7pm | 077b465c33f0aec05a49cd2ca456f9a1b112e896 | False | pjsip/pjproject | PJSIP project | 2016-01-24 05:00:33 | 2022-08-26 15:35:55 | http://www.pjsip.org | pjsip | 1248.0 | 567.0 | pj_scan_get_char | pj_scan_get_char( pj_scanner * scanner) | ['scanner'] | PJ_DEF(int) pj_scan_get_char( pj_scanner *scanner )
{
int chr = *scanner->curptr;
if (!chr) {
pj_scan_syntax_err(scanner);
return 0;
}
++scanner->curptr;
if (PJ_SCAN_IS_PROBABLY_SPACE(*scanner->curptr) && scanner->skip_ws) {
pj_scan_skip_whitespace(scanner);
}
return chr;
} | 59 | True | 1 |
CVE-2022-23608 | False | False | False | False | AV:N/AC:L/Au:N/C:P/I:P/A:P | NETWORK | LOW | NONE | PARTIAL | PARTIAL | PARTIAL | 7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | HIGH | HIGH | HIGH | 9.8 | CRITICAL | 3.9 | 5.9 | False | [{'url': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-ffff-m5fm-qm62', 'name': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-ffff-m5fm-qm62', 'refsource': 'CONFIRM', 'tags': ['Issue Tracking', 'Patch', 'Third Party Advisory']}, {'url': 'https://github.com/pjsip/pjproject/commit/db3235953baa56d2fb0e276ca510fefca751643f', 'name': 'https://github.com/pjsip/pjproject/commit/db3235953baa56d2fb0e276ca510fefca751643f', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Mar/1', 'name': '20220304 AST-2022-005: pjproject: undefined behavior after freeing a dialog set', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Patch', 'Third Party Advisory']}, {'url': 'http://packetstormsecurity.com/files/166226/Asterisk-Project-Security-Advisory-AST-2022-005.html', 'name': 'http://packetstormsecurity.com/files/166226/Asterisk-Project-Security-Advisory-AST-2022-005.html', 'refsource': 'MISC', 'tags': ['Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2022/03/msg00035.html', 'name': '[debian-lts-announce] 20220328 [SECURITY] [DLA 2962-1] pjproject security update', 'refsource': 'MLIST', 'tags': ['Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2022/03/msg00040.html', 'name': '[debian-lts-announce] 20220331 [SECURITY] [DLA 2962-2] pjproject regression update', 'refsource': 'MLIST', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-416'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:teluu:pjsip:*:*:*:*:*:*:*:*', 'versionEndIncluding': '2.11.1', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:asterisk:certified_asterisk:16.8.0:cert12:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:asterisk:certified_asterisk:16.8.0:cert11:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:asterisk:certified_asterisk:16.8.0:cert10:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:asterisk:certified_asterisk:16.8.0:cert9:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:asterisk:certified_asterisk:16.8.0:cert8:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:asterisk:certified_asterisk:16.8.0:cert7:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:asterisk:certified_asterisk:16.8.0:cert6:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:asterisk:certified_asterisk:16.8.0:cert5:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:asterisk:certified_asterisk:16.8.0:cert4:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:asterisk:certified_asterisk:*:*:*:*:*:*:*:*', 'versionEndExcluding': '16.8.0', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:asterisk:certified_asterisk:16.8.0:cert1:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:asterisk:certified_asterisk:16.8.0:cert2:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:asterisk:certified_asterisk:16.8.0:cert3:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:sangoma:asterisk:*:*:*:*:*:*:*:*', 'versionStartIncluding': '16.0.0', 'versionEndExcluding': '16.24.1', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:sangoma:asterisk:*:*:*:*:*:*:*:*', 'versionStartIncluding': '18.0.0', 'versionEndExcluding': '18.10.1', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:sangoma:asterisk:*:*:*:*:*:*:*:*', 'versionStartIncluding': '19.0.0', 'versionEndExcluding': '19.2.1', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:debian:debian_linux:9.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'PJSIP is a free and open source multimedia communication library written in C language implementing standard based protocols such as SIP, SDP, RTP, STUN, TURN, and ICE. In versions up to and including 2.11.1 when in a dialog set (or forking) scenario, a hash key shared by multiple UAC dialogs can potentially be prematurely freed when one of the dialogs is destroyed . The issue may cause a dialog set to be registered in the hash table multiple times (with different hash keys) leading to undefined behavior such as dialog list collision which eventually leading to endless loop. A patch is available in commit db3235953baa56d2fb0e276ca510fefca751643f which will be included in the next release. There are no known workarounds for this issue.'}] | 2022-04-25T15:46Z | 2022-02-22T20:15Z | Use After Free | Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code. |
The use of previously-freed memory can have any number of adverse consequences, ranging from the corruption of valid data to the execution of arbitrary code, depending on the instantiation and timing of the flaw. The simplest way data corruption may occur involves the system's reuse of the freed memory. Use-after-free errors have two common and sometimes overlapping causes:
Error conditions and other exceptional circumstances.
Confusion over which part of the program is responsible for freeing the memory.
In this scenario, the memory in question is allocated to another pointer validly at some point after it has been freed. The original pointer to the freed memory is used again and points to somewhere within the new allocation. As the data is changed, it corrupts the validly used memory; this induces undefined behavior in the process.
If the newly allocated data chances to hold a class, in C++ for example, various function pointers may be scattered within the heap data. If one of these function pointers is overwritten with an address to valid shellcode, execution of arbitrary code can be achieved.
| https://cwe.mitre.org/data/definitions/416.html | 0 | Nanang Izzuddin | 2022-02-21 06:24:52+07:00 | Merge pull request from GHSA-ffff-m5fm-qm62
* Update pjsip_ua_unregister_dlg():
- update the hash key if the dialog being unregistered is used as hash key.
- add an assertion check to make sure that the dlg_set to be removed is valid (can be found in the hash table).
* Change hash key string comparison method. | db3235953baa56d2fb0e276ca510fefca751643f | False | pjsip/pjproject | PJSIP project | 2016-01-24 05:00:33 | 2022-08-26 15:35:55 | http://www.pjsip.org | pjsip | 1248.0 | 567.0 | pjsip_ua_register_dlg | pjsip_ua_register_dlg( pjsip_user_agent * ua , pjsip_dialog * dlg) | ['ua', 'dlg'] | PJ_DEF(pj_status_t) pjsip_ua_register_dlg( pjsip_user_agent *ua,
pjsip_dialog *dlg )
{
/* Sanity check. */
PJ_ASSERT_RETURN(ua && dlg, PJ_EINVAL);
/* For all dialogs, local tag (inc hash) must has been initialized. */
PJ_ASSERT_RETURN(dlg->local.info && dlg->local.info->tag.slen &&
dlg->local.tag_hval != 0, PJ_EBUG);
/* For UAS dialog, remote tag (inc hash) must have been initialized. */
//PJ_ASSERT_RETURN(dlg->role==PJSIP_ROLE_UAC ||
// (dlg->role==PJSIP_ROLE_UAS && dlg->remote.info->tag.slen
// && dlg->remote.tag_hval != 0), PJ_EBUG);
/* Lock the user agent. */
pj_mutex_lock(mod_ua.mutex);
/* For UAC, check if there is existing dialog in the same set. */
if (dlg->role == PJSIP_ROLE_UAC) {
struct dlg_set *dlg_set;
dlg_set = (struct dlg_set*)
pj_hash_get_lower( mod_ua.dlg_table,
dlg->local.info->tag.ptr,
(unsigned)dlg->local.info->tag.slen,
&dlg->local.tag_hval);
if (dlg_set) {
/* This is NOT the first dialog in the dialog set.
* Just add this dialog in the list.
*/
pj_assert(dlg_set->dlg_list.next != (void*)&dlg_set->dlg_list);
pj_list_push_back(&dlg_set->dlg_list, dlg);
dlg->dlg_set = dlg_set;
} else {
/* This is the first dialog in the dialog set.
* Create the dialog set and add this dialog to it.
*/
dlg_set = alloc_dlgset_node();
pj_list_init(&dlg_set->dlg_list);
pj_list_push_back(&dlg_set->dlg_list, dlg);
dlg->dlg_set = dlg_set;
/* Register the dialog set in the hash table. */
pj_hash_set_np_lower(mod_ua.dlg_table,
dlg->local.info->tag.ptr,
(unsigned)dlg->local.info->tag.slen,
dlg->local.tag_hval, dlg_set->ht_entry,
dlg_set);
}
} else {
/* For UAS, create the dialog set with a single dialog as member. */
struct dlg_set *dlg_set;
dlg_set = alloc_dlgset_node();
pj_list_init(&dlg_set->dlg_list);
pj_list_push_back(&dlg_set->dlg_list, dlg);
dlg->dlg_set = dlg_set;
pj_hash_set_np_lower(mod_ua.dlg_table,
dlg->local.info->tag.ptr,
(unsigned)dlg->local.info->tag.slen,
dlg->local.tag_hval, dlg_set->ht_entry, dlg_set);
}
/* Unlock user agent. */
pj_mutex_unlock(mod_ua.mutex);
/* Done. */
return PJ_SUCCESS;
} | 320 | True | 1 |
CVE-2022-23608 | False | False | False | False | AV:N/AC:L/Au:N/C:P/I:P/A:P | NETWORK | LOW | NONE | PARTIAL | PARTIAL | PARTIAL | 7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | HIGH | HIGH | HIGH | 9.8 | CRITICAL | 3.9 | 5.9 | False | [{'url': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-ffff-m5fm-qm62', 'name': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-ffff-m5fm-qm62', 'refsource': 'CONFIRM', 'tags': ['Issue Tracking', 'Patch', 'Third Party Advisory']}, {'url': 'https://github.com/pjsip/pjproject/commit/db3235953baa56d2fb0e276ca510fefca751643f', 'name': 'https://github.com/pjsip/pjproject/commit/db3235953baa56d2fb0e276ca510fefca751643f', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Mar/1', 'name': '20220304 AST-2022-005: pjproject: undefined behavior after freeing a dialog set', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Patch', 'Third Party Advisory']}, {'url': 'http://packetstormsecurity.com/files/166226/Asterisk-Project-Security-Advisory-AST-2022-005.html', 'name': 'http://packetstormsecurity.com/files/166226/Asterisk-Project-Security-Advisory-AST-2022-005.html', 'refsource': 'MISC', 'tags': ['Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2022/03/msg00035.html', 'name': '[debian-lts-announce] 20220328 [SECURITY] [DLA 2962-1] pjproject security update', 'refsource': 'MLIST', 'tags': ['Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2022/03/msg00040.html', 'name': '[debian-lts-announce] 20220331 [SECURITY] [DLA 2962-2] pjproject regression update', 'refsource': 'MLIST', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-416'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:teluu:pjsip:*:*:*:*:*:*:*:*', 'versionEndIncluding': '2.11.1', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:asterisk:certified_asterisk:16.8.0:cert12:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:asterisk:certified_asterisk:16.8.0:cert11:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:asterisk:certified_asterisk:16.8.0:cert10:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:asterisk:certified_asterisk:16.8.0:cert9:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:asterisk:certified_asterisk:16.8.0:cert8:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:asterisk:certified_asterisk:16.8.0:cert7:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:asterisk:certified_asterisk:16.8.0:cert6:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:asterisk:certified_asterisk:16.8.0:cert5:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:asterisk:certified_asterisk:16.8.0:cert4:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:asterisk:certified_asterisk:*:*:*:*:*:*:*:*', 'versionEndExcluding': '16.8.0', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:asterisk:certified_asterisk:16.8.0:cert1:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:asterisk:certified_asterisk:16.8.0:cert2:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:asterisk:certified_asterisk:16.8.0:cert3:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:sangoma:asterisk:*:*:*:*:*:*:*:*', 'versionStartIncluding': '16.0.0', 'versionEndExcluding': '16.24.1', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:sangoma:asterisk:*:*:*:*:*:*:*:*', 'versionStartIncluding': '18.0.0', 'versionEndExcluding': '18.10.1', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:sangoma:asterisk:*:*:*:*:*:*:*:*', 'versionStartIncluding': '19.0.0', 'versionEndExcluding': '19.2.1', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:debian:debian_linux:9.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'PJSIP is a free and open source multimedia communication library written in C language implementing standard based protocols such as SIP, SDP, RTP, STUN, TURN, and ICE. In versions up to and including 2.11.1 when in a dialog set (or forking) scenario, a hash key shared by multiple UAC dialogs can potentially be prematurely freed when one of the dialogs is destroyed . The issue may cause a dialog set to be registered in the hash table multiple times (with different hash keys) leading to undefined behavior such as dialog list collision which eventually leading to endless loop. A patch is available in commit db3235953baa56d2fb0e276ca510fefca751643f which will be included in the next release. There are no known workarounds for this issue.'}] | 2022-04-25T15:46Z | 2022-02-22T20:15Z | Use After Free | Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code. |
The use of previously-freed memory can have any number of adverse consequences, ranging from the corruption of valid data to the execution of arbitrary code, depending on the instantiation and timing of the flaw. The simplest way data corruption may occur involves the system's reuse of the freed memory. Use-after-free errors have two common and sometimes overlapping causes:
Error conditions and other exceptional circumstances.
Confusion over which part of the program is responsible for freeing the memory.
In this scenario, the memory in question is allocated to another pointer validly at some point after it has been freed. The original pointer to the freed memory is used again and points to somewhere within the new allocation. As the data is changed, it corrupts the validly used memory; this induces undefined behavior in the process.
If the newly allocated data chances to hold a class, in C++ for example, various function pointers may be scattered within the heap data. If one of these function pointers is overwritten with an address to valid shellcode, execution of arbitrary code can be achieved.
| https://cwe.mitre.org/data/definitions/416.html | 0 | Nanang Izzuddin | 2022-02-21 06:24:52+07:00 | Merge pull request from GHSA-ffff-m5fm-qm62
* Update pjsip_ua_unregister_dlg():
- update the hash key if the dialog being unregistered is used as hash key.
- add an assertion check to make sure that the dlg_set to be removed is valid (can be found in the hash table).
* Change hash key string comparison method. | db3235953baa56d2fb0e276ca510fefca751643f | False | pjsip/pjproject | PJSIP project | 2016-01-24 05:00:33 | 2022-08-26 15:35:55 | http://www.pjsip.org | pjsip | 1248.0 | 567.0 | pjsip_ua_unregister_dlg | pjsip_ua_unregister_dlg( pjsip_user_agent * ua , pjsip_dialog * dlg) | ['ua', 'dlg'] | PJ_DEF(pj_status_t) pjsip_ua_unregister_dlg( pjsip_user_agent *ua,
pjsip_dialog *dlg )
{
struct dlg_set *dlg_set;
pjsip_dialog *d;
/* Sanity-check arguments. */
PJ_ASSERT_RETURN(ua && dlg, PJ_EINVAL);
/* Check that dialog has been registered. */
PJ_ASSERT_RETURN(dlg->dlg_set, PJ_EINVALIDOP);
/* Lock user agent. */
pj_mutex_lock(mod_ua.mutex);
/* Find this dialog from the dialog set. */
dlg_set = (struct dlg_set*) dlg->dlg_set;
d = dlg_set->dlg_list.next;
while (d != (pjsip_dialog*)&dlg_set->dlg_list && d != dlg) {
d = d->next;
}
if (d != dlg) {
pj_assert(!"Dialog is not registered!");
pj_mutex_unlock(mod_ua.mutex);
return PJ_EINVALIDOP;
}
/* Remove this dialog from the list. */
pj_list_erase(dlg);
/* If dialog list is empty, remove the dialog set from the hash table. */
if (pj_list_empty(&dlg_set->dlg_list)) {
pj_hash_set_lower(NULL, mod_ua.dlg_table, dlg->local.info->tag.ptr,
(unsigned)dlg->local.info->tag.slen,
dlg->local.tag_hval, NULL);
/* Return dlg_set to free nodes. */
pj_list_push_back(&mod_ua.free_dlgset_nodes, dlg_set);
}
/* Unlock user agent. */
pj_mutex_unlock(mod_ua.mutex);
/* Done. */
return PJ_SUCCESS;
} | 190 | True | 1 |
CVE-2022-24754 | False | False | False | False | AV:N/AC:L/Au:N/C:P/I:P/A:P | NETWORK | LOW | NONE | PARTIAL | PARTIAL | PARTIAL | 7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | HIGH | HIGH | HIGH | 9.8 | CRITICAL | 3.9 | 5.9 | False | [{'url': 'https://github.com/pjsip/pjproject/commit/d27f79da11df7bc8bb56c2f291d71e54df8d2c47', 'name': 'https://github.com/pjsip/pjproject/commit/d27f79da11df7bc8bb56c2f291d71e54df8d2c47', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-73f7-48m9-w662', 'name': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-73f7-48m9-w662', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2022/03/msg00035.html', 'name': '[debian-lts-announce] 20220328 [SECURITY] [DLA 2962-1] pjproject security update', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-120'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:teluu:pjsip:*:*:*:*:*:*:*:*', 'versionEndIncluding': '2.12', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:debian:debian_linux:9.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'PJSIP is a free and open source multimedia communication library written in C language. In versions prior to and including 2.12 PJSIP there is a stack-buffer overflow vulnerability which only impacts PJSIP users who accept hashed digest credentials (credentials with data_type `PJSIP_CRED_DATA_DIGEST`). This issue has been patched in the master branch of the PJSIP repository and will be included with the next release. Users unable to upgrade need to check that the hashed digest data length must be equal to `PJSIP_MD5STRLEN` before passing to PJSIP.'}] | 2022-06-05T02:46Z | 2022-03-11T20:15Z | Buffer Copy without Checking Size of Input ('Classic Buffer Overflow') | The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow. | A buffer overflow condition exists when a program attempts to put more data in a buffer than it can hold, or when a program attempts to put data in a memory area outside of the boundaries of a buffer. The simplest type of error, and the most common cause of buffer overflows, is the "classic" case in which the program copies the buffer without restricting how much is copied. Other variants exist, but the existence of a classic overflow strongly suggests that the programmer is not considering even the most basic of security protections.
| https://cwe.mitre.org/data/definitions/120.html | 0 | Riza Sulistyo | 2022-03-08 22:20:39+07:00 | Use PJ_ASSERT_RETURN() on pjsip_auth_create_digest() and pjsua_init_tpselector() (#3009)
* Use PJ_ASSERT_RETURN on pjsip_auth_create_digest
* Use PJ_ASSERT_RETURN on pjsua_init_tpselector()
* Fix incorrect check.
* Add return value to pjsip_auth_create_digest() and pjsip_auth_create_digestSHA256()
* Modification based on comments. | d27f79da11df7bc8bb56c2f291d71e54df8d2c47 | False | pjsip/pjproject | PJSIP project | 2016-01-24 05:00:33 | 2022-08-26 15:35:55 | http://www.pjsip.org | pjsip | 1248.0 | 567.0 | pjsip_auth_create_aka_response | pjsip_auth_create_aka_response( pj_pool_t * pool , const pjsip_digest_challenge * chal , const pjsip_cred_info * cred , const pj_str_t * method , pjsip_digest_credential * auth) | ['pool', 'chal', 'cred', 'method', 'auth'] | PJ_DEF(pj_status_t) pjsip_auth_create_aka_response(
pj_pool_t *pool,
const pjsip_digest_challenge *chal,
const pjsip_cred_info *cred,
const pj_str_t *method,
pjsip_digest_credential *auth)
{
pj_str_t nonce_bin;
int aka_version;
const pj_str_t pjsip_AKAv1_MD5 = { "AKAv1-MD5", 9 };
const pj_str_t pjsip_AKAv2_MD5 = { "AKAv2-MD5", 9 };
pj_uint8_t *chal_rand, *chal_sqnxoraka, *chal_mac;
pj_uint8_t k[PJSIP_AKA_KLEN];
pj_uint8_t op[PJSIP_AKA_OPLEN];
pj_uint8_t amf[PJSIP_AKA_AMFLEN];
pj_uint8_t res[PJSIP_AKA_RESLEN];
pj_uint8_t ck[PJSIP_AKA_CKLEN];
pj_uint8_t ik[PJSIP_AKA_IKLEN];
pj_uint8_t ak[PJSIP_AKA_AKLEN];
pj_uint8_t sqn[PJSIP_AKA_SQNLEN];
pj_uint8_t xmac[PJSIP_AKA_MACLEN];
pjsip_cred_info aka_cred;
int i, len;
pj_status_t status;
/* Check the algorithm is supported. */
if (chal->algorithm.slen==0 || pj_stricmp2(&chal->algorithm, "md5") == 0) {
/*
* A normal MD5 authentication is requested. Fallbackt to the usual
* MD5 digest creation.
*/
pjsip_auth_create_digest(&auth->response, &auth->nonce, &auth->nc,
&auth->cnonce, &auth->qop, &auth->uri,
&auth->realm, cred, method);
return PJ_SUCCESS;
} else if (pj_stricmp(&chal->algorithm, &pjsip_AKAv1_MD5) == 0) {
/*
* AKA version 1 is requested.
*/
aka_version = 1;
} else if (pj_stricmp(&chal->algorithm, &pjsip_AKAv2_MD5) == 0) {
/*
* AKA version 2 is requested.
*/
aka_version = 2;
} else {
/* Unsupported algorithm */
return PJSIP_EINVALIDALGORITHM;
}
/* Decode nonce */
nonce_bin.slen = len = PJ_BASE64_TO_BASE256_LEN(chal->nonce.slen);
nonce_bin.ptr = pj_pool_alloc(pool, nonce_bin.slen + 1);
status = pj_base64_decode(&chal->nonce, (pj_uint8_t*)nonce_bin.ptr, &len);
nonce_bin.slen = len;
if (status != PJ_SUCCESS)
return PJSIP_EAUTHINNONCE;
if (nonce_bin.slen < PJSIP_AKA_RANDLEN + PJSIP_AKA_AUTNLEN)
return PJSIP_EAUTHINNONCE;
/* Get RAND, AUTN, and MAC */
chal_rand = (pj_uint8_t*)(nonce_bin.ptr + 0);
chal_sqnxoraka = (pj_uint8_t*) (nonce_bin.ptr + PJSIP_AKA_RANDLEN);
chal_mac = (pj_uint8_t*) (nonce_bin.ptr + PJSIP_AKA_RANDLEN +
PJSIP_AKA_SQNLEN + PJSIP_AKA_AMFLEN);
/* Copy k. op, and amf */
pj_bzero(k, sizeof(k));
pj_bzero(op, sizeof(op));
pj_bzero(amf, sizeof(amf));
if (cred->ext.aka.k.slen)
pj_memcpy(k, cred->ext.aka.k.ptr, cred->ext.aka.k.slen);
if (cred->ext.aka.op.slen)
pj_memcpy(op, cred->ext.aka.op.ptr, cred->ext.aka.op.slen);
if (cred->ext.aka.amf.slen)
pj_memcpy(amf, cred->ext.aka.amf.ptr, cred->ext.aka.amf.slen);
/* Given key K and random challenge RAND, compute response RES,
* confidentiality key CK, integrity key IK and anonymity key AK.
*/
f2345(k, chal_rand, res, ck, ik, ak, op);
/* Compute sequence number SQN */
for (i=0; i<PJSIP_AKA_SQNLEN; ++i)
sqn[i] = (pj_uint8_t) (chal_sqnxoraka[i] ^ ak[i]);
/* Verify MAC in the challenge */
/* Compute XMAC */
f1(k, chal_rand, sqn, amf, xmac, op);
if (pj_memcmp(chal_mac, xmac, PJSIP_AKA_MACLEN) != 0) {
return PJSIP_EAUTHINNONCE;
}
/* Build a temporary credential info to create MD5 digest, using
* "res" as the password.
*/
pj_memcpy(&aka_cred, cred, sizeof(aka_cred));
aka_cred.data_type = PJSIP_CRED_DATA_PLAIN_PASSWD;
/* Create a response */
if (aka_version == 1) {
/*
* For AKAv1, the password is RES
*/
aka_cred.data.ptr = (char*)res;
aka_cred.data.slen = PJSIP_AKA_RESLEN;
pjsip_auth_create_digest(&auth->response, &chal->nonce,
&auth->nc, &auth->cnonce, &auth->qop,
&auth->uri, &chal->realm, &aka_cred, method);
} else if (aka_version == 2) {
/*
* For AKAv2, password is base64 encoded [1] parameters:
* PRF(RES||IK||CK,"http-digest-akav2-password")
*
* The pseudo-random function (PRF) is HMAC-MD5 in this case.
*/
pj_str_t resikck;
const pj_str_t AKAv2_Passwd = { "http-digest-akav2-password", 26 };
pj_uint8_t hmac_digest[16];
char tmp_buf[48];
int hmac64_len;
resikck.slen = PJSIP_AKA_RESLEN + PJSIP_AKA_IKLEN + PJSIP_AKA_CKLEN;
pj_assert(resikck.slen <= PJ_ARRAY_SIZE(tmp_buf));
resikck.ptr = tmp_buf;
pj_memcpy(resikck.ptr + 0, res, PJSIP_AKA_RESLEN);
pj_memcpy(resikck.ptr + PJSIP_AKA_RESLEN, ik, PJSIP_AKA_IKLEN);
pj_memcpy(resikck.ptr + PJSIP_AKA_RESLEN + PJSIP_AKA_IKLEN,
ck, PJSIP_AKA_CKLEN);
pj_hmac_md5((const pj_uint8_t*)AKAv2_Passwd.ptr, AKAv2_Passwd.slen,
(const pj_uint8_t*)resikck.ptr, resikck.slen,
hmac_digest);
aka_cred.data.slen = hmac64_len =
PJ_BASE256_TO_BASE64_LEN(PJ_ARRAY_SIZE(hmac_digest));
pj_assert(aka_cred.data.slen+1 <= PJ_ARRAY_SIZE(tmp_buf));
aka_cred.data.ptr = tmp_buf;
pj_base64_encode(hmac_digest, PJ_ARRAY_SIZE(hmac_digest),
aka_cred.data.ptr, &len);
aka_cred.data.slen = hmac64_len;
pjsip_auth_create_digest(&auth->response, &chal->nonce,
&auth->nc, &auth->cnonce, &auth->qop,
&auth->uri, &chal->realm, &aka_cred, method);
} else {
pj_assert(!"Bug!");
return PJ_EBUG;
}
/* Done */
return PJ_SUCCESS;
} | 947 | True | 1 |
CVE-2022-24754 | False | False | False | False | AV:N/AC:L/Au:N/C:P/I:P/A:P | NETWORK | LOW | NONE | PARTIAL | PARTIAL | PARTIAL | 7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | HIGH | HIGH | HIGH | 9.8 | CRITICAL | 3.9 | 5.9 | False | [{'url': 'https://github.com/pjsip/pjproject/commit/d27f79da11df7bc8bb56c2f291d71e54df8d2c47', 'name': 'https://github.com/pjsip/pjproject/commit/d27f79da11df7bc8bb56c2f291d71e54df8d2c47', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-73f7-48m9-w662', 'name': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-73f7-48m9-w662', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2022/03/msg00035.html', 'name': '[debian-lts-announce] 20220328 [SECURITY] [DLA 2962-1] pjproject security update', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-120'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:teluu:pjsip:*:*:*:*:*:*:*:*', 'versionEndIncluding': '2.12', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:debian:debian_linux:9.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'PJSIP is a free and open source multimedia communication library written in C language. In versions prior to and including 2.12 PJSIP there is a stack-buffer overflow vulnerability which only impacts PJSIP users who accept hashed digest credentials (credentials with data_type `PJSIP_CRED_DATA_DIGEST`). This issue has been patched in the master branch of the PJSIP repository and will be included with the next release. Users unable to upgrade need to check that the hashed digest data length must be equal to `PJSIP_MD5STRLEN` before passing to PJSIP.'}] | 2022-06-05T02:46Z | 2022-03-11T20:15Z | Buffer Copy without Checking Size of Input ('Classic Buffer Overflow') | The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow. | A buffer overflow condition exists when a program attempts to put more data in a buffer than it can hold, or when a program attempts to put data in a memory area outside of the boundaries of a buffer. The simplest type of error, and the most common cause of buffer overflows, is the "classic" case in which the program copies the buffer without restricting how much is copied. Other variants exist, but the existence of a classic overflow strongly suggests that the programmer is not considering even the most basic of security protections.
| https://cwe.mitre.org/data/definitions/120.html | 0 | Riza Sulistyo | 2022-03-08 22:20:39+07:00 | Use PJ_ASSERT_RETURN() on pjsip_auth_create_digest() and pjsua_init_tpselector() (#3009)
* Use PJ_ASSERT_RETURN on pjsip_auth_create_digest
* Use PJ_ASSERT_RETURN on pjsua_init_tpselector()
* Fix incorrect check.
* Add return value to pjsip_auth_create_digest() and pjsip_auth_create_digestSHA256()
* Modification based on comments. | d27f79da11df7bc8bb56c2f291d71e54df8d2c47 | False | pjsip/pjproject | PJSIP project | 2016-01-24 05:00:33 | 2022-08-26 15:35:55 | http://www.pjsip.org | pjsip | 1248.0 | 567.0 | pjsip_auth_create_digest | pjsip_auth_create_digest( pj_str_t * result , const pj_str_t * nonce , const pj_str_t * nc , const pj_str_t * cnonce , const pj_str_t * qop , const pj_str_t * uri , const pj_str_t * realm , const pjsip_cred_info * cred_info , const pj_str_t * method) | ['result', 'nonce', 'nc', 'cnonce', 'qop', 'uri', 'realm', 'cred_info', 'method'] | PJ_DEF(void) pjsip_auth_create_digest( pj_str_t *result,
const pj_str_t *nonce,
const pj_str_t *nc,
const pj_str_t *cnonce,
const pj_str_t *qop,
const pj_str_t *uri,
const pj_str_t *realm,
const pjsip_cred_info *cred_info,
const pj_str_t *method)
{
char ha1[PJSIP_MD5STRLEN];
char ha2[PJSIP_MD5STRLEN];
unsigned char digest[16];
pj_md5_context pms;
pj_assert(result->slen >= PJSIP_MD5STRLEN);
AUTH_TRACE_((THIS_FILE, "Begin creating digest"));
if ((cred_info->data_type & PASSWD_MASK) == PJSIP_CRED_DATA_PLAIN_PASSWD) {
/***
*** ha1 = MD5(username ":" realm ":" password)
***/
pj_md5_init(&pms);
MD5_APPEND( &pms, cred_info->username.ptr, cred_info->username.slen);
MD5_APPEND( &pms, ":", 1);
MD5_APPEND( &pms, realm->ptr, realm->slen);
MD5_APPEND( &pms, ":", 1);
MD5_APPEND( &pms, cred_info->data.ptr, cred_info->data.slen);
pj_md5_final(&pms, digest);
digestNtoStr(digest, 16, ha1);
} else if ((cred_info->data_type & PASSWD_MASK) == PJSIP_CRED_DATA_DIGEST) {
pj_assert(cred_info->data.slen == 32);
pj_memcpy( ha1, cred_info->data.ptr, cred_info->data.slen );
} else {
pj_assert(!"Invalid data_type");
}
AUTH_TRACE_((THIS_FILE, " ha1=%.32s", ha1));
/***
*** ha2 = MD5(method ":" req_uri)
***/
pj_md5_init(&pms);
MD5_APPEND( &pms, method->ptr, method->slen);
MD5_APPEND( &pms, ":", 1);
MD5_APPEND( &pms, uri->ptr, uri->slen);
pj_md5_final(&pms, digest);
digestNtoStr(digest, 16, ha2);
AUTH_TRACE_((THIS_FILE, " ha2=%.32s", ha2));
/***
*** When qop is not used:
*** response = MD5(ha1 ":" nonce ":" ha2)
***
*** When qop=auth is used:
*** response = MD5(ha1 ":" nonce ":" nc ":" cnonce ":" qop ":" ha2)
***/
pj_md5_init(&pms);
MD5_APPEND( &pms, ha1, PJSIP_MD5STRLEN);
MD5_APPEND( &pms, ":", 1);
MD5_APPEND( &pms, nonce->ptr, nonce->slen);
if (qop && qop->slen != 0) {
MD5_APPEND( &pms, ":", 1);
MD5_APPEND( &pms, nc->ptr, nc->slen);
MD5_APPEND( &pms, ":", 1);
MD5_APPEND( &pms, cnonce->ptr, cnonce->slen);
MD5_APPEND( &pms, ":", 1);
MD5_APPEND( &pms, qop->ptr, qop->slen);
}
MD5_APPEND( &pms, ":", 1);
MD5_APPEND( &pms, ha2, PJSIP_MD5STRLEN);
/* This is the final response digest. */
pj_md5_final(&pms, digest);
/* Convert digest to string and store in chal->response. */
result->slen = PJSIP_MD5STRLEN;
digestNtoStr(digest, 16, result->ptr);
AUTH_TRACE_((THIS_FILE, " digest=%.32s", result->ptr));
AUTH_TRACE_((THIS_FILE, "Digest created"));
} | 520 | True | 1 |
CVE-2022-24754 | False | False | False | False | AV:N/AC:L/Au:N/C:P/I:P/A:P | NETWORK | LOW | NONE | PARTIAL | PARTIAL | PARTIAL | 7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | HIGH | HIGH | HIGH | 9.8 | CRITICAL | 3.9 | 5.9 | False | [{'url': 'https://github.com/pjsip/pjproject/commit/d27f79da11df7bc8bb56c2f291d71e54df8d2c47', 'name': 'https://github.com/pjsip/pjproject/commit/d27f79da11df7bc8bb56c2f291d71e54df8d2c47', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-73f7-48m9-w662', 'name': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-73f7-48m9-w662', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2022/03/msg00035.html', 'name': '[debian-lts-announce] 20220328 [SECURITY] [DLA 2962-1] pjproject security update', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-120'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:teluu:pjsip:*:*:*:*:*:*:*:*', 'versionEndIncluding': '2.12', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:debian:debian_linux:9.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'PJSIP is a free and open source multimedia communication library written in C language. In versions prior to and including 2.12 PJSIP there is a stack-buffer overflow vulnerability which only impacts PJSIP users who accept hashed digest credentials (credentials with data_type `PJSIP_CRED_DATA_DIGEST`). This issue has been patched in the master branch of the PJSIP repository and will be included with the next release. Users unable to upgrade need to check that the hashed digest data length must be equal to `PJSIP_MD5STRLEN` before passing to PJSIP.'}] | 2022-06-05T02:46Z | 2022-03-11T20:15Z | Buffer Copy without Checking Size of Input ('Classic Buffer Overflow') | The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow. | A buffer overflow condition exists when a program attempts to put more data in a buffer than it can hold, or when a program attempts to put data in a memory area outside of the boundaries of a buffer. The simplest type of error, and the most common cause of buffer overflows, is the "classic" case in which the program copies the buffer without restricting how much is copied. Other variants exist, but the existence of a classic overflow strongly suggests that the programmer is not considering even the most basic of security protections.
| https://cwe.mitre.org/data/definitions/120.html | 0 | Riza Sulistyo | 2022-03-08 22:20:39+07:00 | Use PJ_ASSERT_RETURN() on pjsip_auth_create_digest() and pjsua_init_tpselector() (#3009)
* Use PJ_ASSERT_RETURN on pjsip_auth_create_digest
* Use PJ_ASSERT_RETURN on pjsua_init_tpselector()
* Fix incorrect check.
* Add return value to pjsip_auth_create_digest() and pjsip_auth_create_digestSHA256()
* Modification based on comments. | d27f79da11df7bc8bb56c2f291d71e54df8d2c47 | False | pjsip/pjproject | PJSIP project | 2016-01-24 05:00:33 | 2022-08-26 15:35:55 | http://www.pjsip.org | pjsip | 1248.0 | 567.0 | pjsip_auth_create_digestSHA256 | pjsip_auth_create_digestSHA256( pj_str_t * result , const pj_str_t * nonce , const pj_str_t * nc , const pj_str_t * cnonce , const pj_str_t * qop , const pj_str_t * uri , const pj_str_t * realm , const pjsip_cred_info * cred_info , const pj_str_t * method) | ['result', 'nonce', 'nc', 'cnonce', 'qop', 'uri', 'realm', 'cred_info', 'method'] | PJ_DEF(void) pjsip_auth_create_digestSHA256(pj_str_t *result,
const pj_str_t *nonce,
const pj_str_t *nc,
const pj_str_t *cnonce,
const pj_str_t *qop,
const pj_str_t *uri,
const pj_str_t *realm,
const pjsip_cred_info *cred_info,
const pj_str_t *method)
{
#if PJSIP_AUTH_HAS_DIGEST_SHA256
char ha1[PJSIP_SHA256STRLEN];
char ha2[PJSIP_SHA256STRLEN];
unsigned char digest[32];
SHA256_CTX pms;
pj_assert(result->slen >= PJSIP_SHA256STRLEN);
AUTH_TRACE_((THIS_FILE, "Begin creating digest"));
if ((cred_info->data_type & PASSWD_MASK) == PJSIP_CRED_DATA_PLAIN_PASSWD)
{
/***
*** ha1 = SHA256(username ":" realm ":" password)
***/
SHA256_Init(&pms);
SHA256_Update( &pms, cred_info->username.ptr,
cred_info->username.slen);
SHA256_Update( &pms, ":", 1);
SHA256_Update( &pms, realm->ptr, realm->slen);
SHA256_Update( &pms, ":", 1);
SHA256_Update( &pms, cred_info->data.ptr, cred_info->data.slen);
SHA256_Final(digest, &pms);
digestNtoStr(digest, 32, ha1);
} else if ((cred_info->data_type & PASSWD_MASK) == PJSIP_CRED_DATA_DIGEST)
{
pj_assert(cred_info->data.slen == 32);
pj_memcpy( ha1, cred_info->data.ptr, cred_info->data.slen );
} else {
pj_assert(!"Invalid data_type");
}
AUTH_TRACE_((THIS_FILE, " ha1=%.64s", ha1));
/***
*** ha2 = SHA256(method ":" req_uri)
***/
SHA256_Init(&pms);
SHA256_Update( &pms, method->ptr, method->slen);
SHA256_Update( &pms, ":", 1);
SHA256_Update( &pms, uri->ptr, uri->slen);
SHA256_Final( digest, &pms);
digestNtoStr(digest, 32, ha2);
AUTH_TRACE_((THIS_FILE, " ha2=%.64s", ha2));
/***
*** When qop is not used:
*** response = SHA256(ha1 ":" nonce ":" ha2)
***
*** When qop=auth is used:
*** response = SHA256(ha1 ":" nonce ":" nc ":" cnonce ":" qop ":" ha2)
***/
SHA256_Init(&pms);
SHA256_Update( &pms, ha1, PJSIP_SHA256STRLEN);
SHA256_Update( &pms, ":", 1);
SHA256_Update( &pms, nonce->ptr, nonce->slen);
if (qop && qop->slen != 0) {
SHA256_Update( &pms, ":", 1);
SHA256_Update( &pms, nc->ptr, nc->slen);
SHA256_Update( &pms, ":", 1);
SHA256_Update( &pms, cnonce->ptr, cnonce->slen);
SHA256_Update( &pms, ":", 1);
SHA256_Update( &pms, qop->ptr, qop->slen);
}
SHA256_Update( &pms, ":", 1);
SHA256_Update( &pms, ha2, PJSIP_SHA256STRLEN);
/* This is the final response digest. */
SHA256_Final(digest, &pms);
/* Convert digest to string and store in chal->response. */
result->slen = PJSIP_SHA256STRLEN;
digestNtoStr(digest, 32, result->ptr);
AUTH_TRACE_((THIS_FILE, " digest=%.64s", result->ptr));
AUTH_TRACE_((THIS_FILE, "Digest created"));
#else
PJ_UNUSED_ARG(result);
PJ_UNUSED_ARG(nonce);
PJ_UNUSED_ARG(nc);
PJ_UNUSED_ARG(cnonce);
PJ_UNUSED_ARG(qop);
PJ_UNUSED_ARG(uri);
PJ_UNUSED_ARG(realm);
PJ_UNUSED_ARG(cred_info);
PJ_UNUSED_ARG(method);
#endif
} | 565 | True | 1 |
CVE-2022-24754 | False | False | False | False | AV:N/AC:L/Au:N/C:P/I:P/A:P | NETWORK | LOW | NONE | PARTIAL | PARTIAL | PARTIAL | 7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | HIGH | HIGH | HIGH | 9.8 | CRITICAL | 3.9 | 5.9 | False | [{'url': 'https://github.com/pjsip/pjproject/commit/d27f79da11df7bc8bb56c2f291d71e54df8d2c47', 'name': 'https://github.com/pjsip/pjproject/commit/d27f79da11df7bc8bb56c2f291d71e54df8d2c47', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-73f7-48m9-w662', 'name': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-73f7-48m9-w662', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2022/03/msg00035.html', 'name': '[debian-lts-announce] 20220328 [SECURITY] [DLA 2962-1] pjproject security update', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-120'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:teluu:pjsip:*:*:*:*:*:*:*:*', 'versionEndIncluding': '2.12', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:debian:debian_linux:9.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'PJSIP is a free and open source multimedia communication library written in C language. In versions prior to and including 2.12 PJSIP there is a stack-buffer overflow vulnerability which only impacts PJSIP users who accept hashed digest credentials (credentials with data_type `PJSIP_CRED_DATA_DIGEST`). This issue has been patched in the master branch of the PJSIP repository and will be included with the next release. Users unable to upgrade need to check that the hashed digest data length must be equal to `PJSIP_MD5STRLEN` before passing to PJSIP.'}] | 2022-06-05T02:46Z | 2022-03-11T20:15Z | Buffer Copy without Checking Size of Input ('Classic Buffer Overflow') | The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow. | A buffer overflow condition exists when a program attempts to put more data in a buffer than it can hold, or when a program attempts to put data in a memory area outside of the boundaries of a buffer. The simplest type of error, and the most common cause of buffer overflows, is the "classic" case in which the program copies the buffer without restricting how much is copied. Other variants exist, but the existence of a classic overflow strongly suggests that the programmer is not considering even the most basic of security protections.
| https://cwe.mitre.org/data/definitions/120.html | 0 | Riza Sulistyo | 2022-03-08 22:20:39+07:00 | Use PJ_ASSERT_RETURN() on pjsip_auth_create_digest() and pjsua_init_tpselector() (#3009)
* Use PJ_ASSERT_RETURN on pjsip_auth_create_digest
* Use PJ_ASSERT_RETURN on pjsua_init_tpselector()
* Fix incorrect check.
* Add return value to pjsip_auth_create_digest() and pjsip_auth_create_digestSHA256()
* Modification based on comments. | d27f79da11df7bc8bb56c2f291d71e54df8d2c47 | False | pjsip/pjproject | PJSIP project | 2016-01-24 05:00:33 | 2022-08-26 15:35:55 | http://www.pjsip.org | pjsip | 1248.0 | 567.0 | respond_digest | respond_digest( pj_pool_t * pool , pjsip_digest_credential * cred , const pjsip_digest_challenge * chal , const pj_str_t * uri , const pjsip_cred_info * cred_info , const pj_str_t * cnonce , pj_uint32_t nc , const pj_str_t * method) | ['pool', 'cred', 'chal', 'uri', 'cred_info', 'cnonce', 'nc', 'method'] | static pj_status_t respond_digest( pj_pool_t *pool,
pjsip_digest_credential *cred,
const pjsip_digest_challenge *chal,
const pj_str_t *uri,
const pjsip_cred_info *cred_info,
const pj_str_t *cnonce,
pj_uint32_t nc,
const pj_str_t *method)
{
const pj_str_t pjsip_AKAv1_MD5_STR = { "AKAv1-MD5", 9 };
pj_bool_t algo_sha256 = PJ_FALSE;
/* Check if algo is sha256 */
#if PJSIP_AUTH_HAS_DIGEST_SHA256
algo_sha256 = (pj_stricmp(&chal->algorithm, &pjsip_SHA256_STR)==0);
#endif
/* Check algorithm is supported. We support MD5, AKAv1-MD5, and SHA256. */
if (chal->algorithm.slen==0 ||
(algo_sha256 ||
pj_stricmp(&chal->algorithm, &pjsip_MD5_STR)==0 ||
pj_stricmp(&chal->algorithm, &pjsip_AKAv1_MD5_STR)==0))
{
PJ_LOG(4,(THIS_FILE, "Digest algorithm is \"%.*s\"",
chal->algorithm.slen, chal->algorithm.ptr));
}
else {
PJ_LOG(4,(THIS_FILE, "Unsupported digest algorithm \"%.*s\"",
chal->algorithm.slen, chal->algorithm.ptr));
return PJSIP_EINVALIDALGORITHM;
}
/* Build digest credential from arguments. */
pj_strdup(pool, &cred->username, &cred_info->username);
pj_strdup(pool, &cred->realm, &chal->realm);
pj_strdup(pool, &cred->nonce, &chal->nonce);
pj_strdup(pool, &cred->uri, uri);
pj_strdup(pool, &cred->algorithm, &chal->algorithm);
pj_strdup(pool, &cred->opaque, &chal->opaque);
/* Allocate memory. */
cred->response.slen = algo_sha256? PJSIP_SHA256STRLEN : PJSIP_MD5STRLEN;
cred->response.ptr = (char*) pj_pool_alloc(pool, cred->response.slen);
if (chal->qop.slen == 0) {
/* Server doesn't require quality of protection. */
if ((cred_info->data_type & EXT_MASK) == PJSIP_CRED_DATA_EXT_AKA) {
/* Call application callback to create the response digest */
return (*cred_info->ext.aka.cb)(pool, chal, cred_info,
method, cred);
}
else {
/* Convert digest to string and store in chal->response. */
if (algo_sha256) {
pjsip_auth_create_digestSHA256(
&cred->response, &cred->nonce, NULL,
NULL, NULL, uri, &chal->realm,
cred_info, method);
} else {
pjsip_auth_create_digest( &cred->response, &cred->nonce, NULL,
NULL, NULL, uri, &chal->realm,
cred_info, method);
}
}
} else if (has_auth_qop(pool, &chal->qop)) {
/* Server requires quality of protection.
* We respond with selecting "qop=auth" protection.
*/
cred->qop = pjsip_AUTH_STR;
cred->nc.ptr = (char*) pj_pool_alloc(pool, 16);
cred->nc.slen = pj_ansi_snprintf(cred->nc.ptr, 16, "%08u", nc);
if (cnonce && cnonce->slen) {
pj_strdup(pool, &cred->cnonce, cnonce);
} else {
pj_str_t dummy_cnonce = { "b39971", 6};
pj_strdup(pool, &cred->cnonce, &dummy_cnonce);
}
if ((cred_info->data_type & EXT_MASK) == PJSIP_CRED_DATA_EXT_AKA) {
/* Call application callback to create the response digest */
return (*cred_info->ext.aka.cb)(pool, chal, cred_info,
method, cred);
}
else {
/* Convert digest to string and store in chal->response. */
if (algo_sha256) {
pjsip_auth_create_digestSHA256(
&cred->response, &cred->nonce,
&cred->nc, &cred->cnonce,
&pjsip_AUTH_STR, uri,
&chal->realm, cred_info,
method);
} else {
pjsip_auth_create_digest( &cred->response, &cred->nonce,
&cred->nc, &cred->cnonce,
&pjsip_AUTH_STR, uri,
&chal->realm, cred_info,
method);
}
}
} else {
/* Server requires quality protection that we don't support. */
PJ_LOG(4,(THIS_FILE, "Unsupported qop offer %.*s",
chal->qop.slen, chal->qop.ptr));
return PJSIP_EINVALIDQOP;
}
return PJ_SUCCESS;
} | 668 | True | 1 |
CVE-2022-24754 | False | False | False | False | AV:N/AC:L/Au:N/C:P/I:P/A:P | NETWORK | LOW | NONE | PARTIAL | PARTIAL | PARTIAL | 7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | HIGH | HIGH | HIGH | 9.8 | CRITICAL | 3.9 | 5.9 | False | [{'url': 'https://github.com/pjsip/pjproject/commit/d27f79da11df7bc8bb56c2f291d71e54df8d2c47', 'name': 'https://github.com/pjsip/pjproject/commit/d27f79da11df7bc8bb56c2f291d71e54df8d2c47', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-73f7-48m9-w662', 'name': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-73f7-48m9-w662', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2022/03/msg00035.html', 'name': '[debian-lts-announce] 20220328 [SECURITY] [DLA 2962-1] pjproject security update', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-120'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:teluu:pjsip:*:*:*:*:*:*:*:*', 'versionEndIncluding': '2.12', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:debian:debian_linux:9.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'PJSIP is a free and open source multimedia communication library written in C language. In versions prior to and including 2.12 PJSIP there is a stack-buffer overflow vulnerability which only impacts PJSIP users who accept hashed digest credentials (credentials with data_type `PJSIP_CRED_DATA_DIGEST`). This issue has been patched in the master branch of the PJSIP repository and will be included with the next release. Users unable to upgrade need to check that the hashed digest data length must be equal to `PJSIP_MD5STRLEN` before passing to PJSIP.'}] | 2022-06-05T02:46Z | 2022-03-11T20:15Z | Buffer Copy without Checking Size of Input ('Classic Buffer Overflow') | The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow. | A buffer overflow condition exists when a program attempts to put more data in a buffer than it can hold, or when a program attempts to put data in a memory area outside of the boundaries of a buffer. The simplest type of error, and the most common cause of buffer overflows, is the "classic" case in which the program copies the buffer without restricting how much is copied. Other variants exist, but the existence of a classic overflow strongly suggests that the programmer is not considering even the most basic of security protections.
| https://cwe.mitre.org/data/definitions/120.html | 0 | Riza Sulistyo | 2022-03-08 22:20:39+07:00 | Use PJ_ASSERT_RETURN() on pjsip_auth_create_digest() and pjsua_init_tpselector() (#3009)
* Use PJ_ASSERT_RETURN on pjsip_auth_create_digest
* Use PJ_ASSERT_RETURN on pjsua_init_tpselector()
* Fix incorrect check.
* Add return value to pjsip_auth_create_digest() and pjsip_auth_create_digestSHA256()
* Modification based on comments. | d27f79da11df7bc8bb56c2f291d71e54df8d2c47 | False | pjsip/pjproject | PJSIP project | 2016-01-24 05:00:33 | 2022-08-26 15:35:55 | http://www.pjsip.org | pjsip | 1248.0 | 567.0 | pjsip_auth_verify | pjsip_auth_verify( const pjsip_authorization_hdr * hdr , const pj_str_t * method , const pjsip_cred_info * cred_info) | ['hdr', 'method', 'cred_info'] | static pj_status_t pjsip_auth_verify( const pjsip_authorization_hdr *hdr,
const pj_str_t *method,
const pjsip_cred_info *cred_info )
{
if (pj_stricmp(&hdr->scheme, &pjsip_DIGEST_STR) == 0) {
char digest_buf[PJSIP_MD5STRLEN];
pj_str_t digest;
const pjsip_digest_credential *dig = &hdr->credential.digest;
/* Check that username and realm match.
* These checks should have been performed before entering this
* function.
*/
PJ_ASSERT_RETURN(pj_strcmp(&dig->username, &cred_info->username) == 0,
PJ_EINVALIDOP);
PJ_ASSERT_RETURN(pj_strcmp(&dig->realm, &cred_info->realm) == 0,
PJ_EINVALIDOP);
/* Prepare for our digest calculation. */
digest.ptr = digest_buf;
digest.slen = PJSIP_MD5STRLEN;
/* Create digest for comparison. */
pjsip_auth_create_digest(&digest,
&hdr->credential.digest.nonce,
&hdr->credential.digest.nc,
&hdr->credential.digest.cnonce,
&hdr->credential.digest.qop,
&hdr->credential.digest.uri,
&cred_info->realm,
cred_info,
method );
/* Compare digest. */
return (pj_stricmp(&digest, &hdr->credential.digest.response) == 0) ?
PJ_SUCCESS : PJSIP_EAUTHINVALIDDIGEST;
} else {
pj_assert(!"Unsupported authentication scheme");
return PJSIP_EINVALIDAUTHSCHEME;
}
} | 205 | True | 1 |
CVE-2022-24754 | False | False | False | False | AV:N/AC:L/Au:N/C:P/I:P/A:P | NETWORK | LOW | NONE | PARTIAL | PARTIAL | PARTIAL | 7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | HIGH | HIGH | HIGH | 9.8 | CRITICAL | 3.9 | 5.9 | False | [{'url': 'https://github.com/pjsip/pjproject/commit/d27f79da11df7bc8bb56c2f291d71e54df8d2c47', 'name': 'https://github.com/pjsip/pjproject/commit/d27f79da11df7bc8bb56c2f291d71e54df8d2c47', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-73f7-48m9-w662', 'name': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-73f7-48m9-w662', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2022/03/msg00035.html', 'name': '[debian-lts-announce] 20220328 [SECURITY] [DLA 2962-1] pjproject security update', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-120'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:teluu:pjsip:*:*:*:*:*:*:*:*', 'versionEndIncluding': '2.12', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:debian:debian_linux:9.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'PJSIP is a free and open source multimedia communication library written in C language. In versions prior to and including 2.12 PJSIP there is a stack-buffer overflow vulnerability which only impacts PJSIP users who accept hashed digest credentials (credentials with data_type `PJSIP_CRED_DATA_DIGEST`). This issue has been patched in the master branch of the PJSIP repository and will be included with the next release. Users unable to upgrade need to check that the hashed digest data length must be equal to `PJSIP_MD5STRLEN` before passing to PJSIP.'}] | 2022-06-05T02:46Z | 2022-03-11T20:15Z | Buffer Copy without Checking Size of Input ('Classic Buffer Overflow') | The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow. | A buffer overflow condition exists when a program attempts to put more data in a buffer than it can hold, or when a program attempts to put data in a memory area outside of the boundaries of a buffer. The simplest type of error, and the most common cause of buffer overflows, is the "classic" case in which the program copies the buffer without restricting how much is copied. Other variants exist, but the existence of a classic overflow strongly suggests that the programmer is not considering even the most basic of security protections.
| https://cwe.mitre.org/data/definitions/120.html | 0 | Riza Sulistyo | 2022-03-08 22:20:39+07:00 | Use PJ_ASSERT_RETURN() on pjsip_auth_create_digest() and pjsua_init_tpselector() (#3009)
* Use PJ_ASSERT_RETURN on pjsip_auth_create_digest
* Use PJ_ASSERT_RETURN on pjsua_init_tpselector()
* Fix incorrect check.
* Add return value to pjsip_auth_create_digest() and pjsip_auth_create_digestSHA256()
* Modification based on comments. | d27f79da11df7bc8bb56c2f291d71e54df8d2c47 | False | pjsip/pjproject | PJSIP project | 2016-01-24 05:00:33 | 2022-08-26 15:35:55 | http://www.pjsip.org | pjsip | 1248.0 | 567.0 | pjsua_init_tpselector | pjsua_init_tpselector( pjsua_transport_id tp_id , pjsip_tpselector * sel) | ['tp_id', 'sel'] | void pjsua_init_tpselector(pjsua_transport_id tp_id,
pjsip_tpselector *sel)
{
pjsua_transport_data *tpdata;
unsigned flag;
pj_bzero(sel, sizeof(*sel));
if (tp_id == PJSUA_INVALID_ID)
return;
pj_assert(tp_id >= 0 && tp_id < (int)PJ_ARRAY_SIZE(pjsua_var.tpdata));
tpdata = &pjsua_var.tpdata[tp_id];
flag = pjsip_transport_get_flag_from_type(tpdata->type);
if (flag & PJSIP_TRANSPORT_DATAGRAM) {
sel->type = PJSIP_TPSELECTOR_TRANSPORT;
sel->u.transport = tpdata->data.tp;
} else {
sel->type = PJSIP_TPSELECTOR_LISTENER;
sel->u.listener = tpdata->data.factory;
}
} | 122 | True | 1 |
CVE-2022-24764 | False | False | False | False | AV:N/AC:L/Au:N/C:N/I:N/A:P | NETWORK | LOW | NONE | NONE | NONE | PARTIAL | 5.0 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | NONE | NONE | HIGH | 7.5 | HIGH | 3.9 | 3.6 | False | [{'url': 'https://github.com/pjsip/pjproject/commit/560a1346f87aabe126509bb24930106dea292b00', 'name': 'https://github.com/pjsip/pjproject/commit/560a1346f87aabe126509bb24930106dea292b00', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-f5qg-pqcg-765m', 'name': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-f5qg-pqcg-765m', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2022/03/msg00035.html', 'name': '[debian-lts-announce] 20220328 [SECURITY] [DLA 2962-1] pjproject security update', 'refsource': 'MLIST', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-120'}, {'lang': 'en', 'value': 'CWE-121'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:teluu:pjsip:*:*:*:*:*:*:*:*', 'versionEndIncluding': '2.12', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'PJSIP is a free and open source multimedia communication library written in C. Versions 2.12 and prior contain a stack buffer overflow vulnerability that affects PJSUA2 users or users that call the API `pjmedia_sdp_print(), pjmedia_sdp_media_print()`. Applications that do not use PJSUA2 and do not directly call `pjmedia_sdp_print()` or `pjmedia_sdp_media_print()` should not be affected. A patch is available on the `master` branch of the `pjsip/pjproject` GitHub repository. There are currently no known workarounds.'}] | 2022-03-28T21:00Z | 2022-03-22T17:15Z | Buffer Copy without Checking Size of Input ('Classic Buffer Overflow') | The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow. | A buffer overflow condition exists when a program attempts to put more data in a buffer than it can hold, or when a program attempts to put data in a memory area outside of the boundaries of a buffer. The simplest type of error, and the most common cause of buffer overflows, is the "classic" case in which the program copies the buffer without restricting how much is copied. Other variants exist, but the existence of a classic overflow strongly suggests that the programmer is not considering even the most basic of security protections.
| https://cwe.mitre.org/data/definitions/120.html | 0 | Nanang Izzuddin | 2022-03-22 15:30:47+07:00 | Merge pull request from GHSA-f5qg-pqcg-765m | 560a1346f87aabe126509bb24930106dea292b00 | False | pjsip/pjproject | PJSIP project | 2016-01-24 05:00:33 | 2022-08-26 15:35:55 | http://www.pjsip.org | pjsip | 1248.0 | 567.0 | print_media_desc | print_media_desc( const pjmedia_sdp_media * m , char * buf , pj_size_t len) | ['m', 'buf', 'len'] | static int print_media_desc(const pjmedia_sdp_media *m, char *buf, pj_size_t len)
{
char *p = buf;
char *end = buf+len;
unsigned i;
int printed;
/* check length for the "m=" line. */
if (len < (pj_size_t)m->desc.media.slen+m->desc.transport.slen+12+24) {
return -1;
}
*p++ = 'm'; /* m= */
*p++ = '=';
pj_memcpy(p, m->desc.media.ptr, m->desc.media.slen);
p += m->desc.media.slen;
*p++ = ' ';
printed = pj_utoa(m->desc.port, p);
p += printed;
if (m->desc.port_count > 1) {
*p++ = '/';
printed = pj_utoa(m->desc.port_count, p);
p += printed;
}
*p++ = ' ';
pj_memcpy(p, m->desc.transport.ptr, m->desc.transport.slen);
p += m->desc.transport.slen;
for (i=0; i<m->desc.fmt_count; ++i) {
*p++ = ' ';
pj_memcpy(p, m->desc.fmt[i].ptr, m->desc.fmt[i].slen);
p += m->desc.fmt[i].slen;
}
*p++ = '\r';
*p++ = '\n';
/* print connection info, if present. */
if (m->conn) {
printed = print_connection_info(m->conn, p, (int)(end-p));
if (printed < 0) {
return -1;
}
p += printed;
}
/* print optional bandwidth info. */
for (i=0; i<m->bandw_count; ++i) {
printed = (int)print_bandw(m->bandw[i], p, end-p);
if (printed < 0) {
return -1;
}
p += printed;
}
/* print attributes. */
for (i=0; i<m->attr_count; ++i) {
printed = (int)print_attr(m->attr[i], p, end-p);
if (printed < 0) {
return -1;
}
p += printed;
}
return (int)(p-buf);
} | 446 | True | 1 |
CVE-2022-24764 | False | False | False | False | AV:N/AC:L/Au:N/C:N/I:N/A:P | NETWORK | LOW | NONE | NONE | NONE | PARTIAL | 5.0 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | NONE | NONE | HIGH | 7.5 | HIGH | 3.9 | 3.6 | False | [{'url': 'https://github.com/pjsip/pjproject/commit/560a1346f87aabe126509bb24930106dea292b00', 'name': 'https://github.com/pjsip/pjproject/commit/560a1346f87aabe126509bb24930106dea292b00', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-f5qg-pqcg-765m', 'name': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-f5qg-pqcg-765m', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2022/03/msg00035.html', 'name': '[debian-lts-announce] 20220328 [SECURITY] [DLA 2962-1] pjproject security update', 'refsource': 'MLIST', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-120'}, {'lang': 'en', 'value': 'CWE-121'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:teluu:pjsip:*:*:*:*:*:*:*:*', 'versionEndIncluding': '2.12', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'PJSIP is a free and open source multimedia communication library written in C. Versions 2.12 and prior contain a stack buffer overflow vulnerability that affects PJSUA2 users or users that call the API `pjmedia_sdp_print(), pjmedia_sdp_media_print()`. Applications that do not use PJSUA2 and do not directly call `pjmedia_sdp_print()` or `pjmedia_sdp_media_print()` should not be affected. A patch is available on the `master` branch of the `pjsip/pjproject` GitHub repository. There are currently no known workarounds.'}] | 2022-03-28T21:00Z | 2022-03-22T17:15Z | Stack-based Buffer Overflow | A stack-based buffer overflow condition is a condition where the buffer being overwritten is allocated on the stack (i.e., is a local variable or, rarely, a parameter to a function). | https://cwe.mitre.org/data/definitions/121.html | 0 | Nanang Izzuddin | 2022-03-22 15:30:47+07:00 | Merge pull request from GHSA-f5qg-pqcg-765m | 560a1346f87aabe126509bb24930106dea292b00 | False | pjsip/pjproject | PJSIP project | 2016-01-24 05:00:33 | 2022-08-26 15:35:55 | http://www.pjsip.org | pjsip | 1248.0 | 567.0 | print_media_desc | print_media_desc( const pjmedia_sdp_media * m , char * buf , pj_size_t len) | ['m', 'buf', 'len'] | static int print_media_desc(const pjmedia_sdp_media *m, char *buf, pj_size_t len)
{
char *p = buf;
char *end = buf+len;
unsigned i;
int printed;
/* check length for the "m=" line. */
if (len < (pj_size_t)m->desc.media.slen+m->desc.transport.slen+12+24) {
return -1;
}
*p++ = 'm'; /* m= */
*p++ = '=';
pj_memcpy(p, m->desc.media.ptr, m->desc.media.slen);
p += m->desc.media.slen;
*p++ = ' ';
printed = pj_utoa(m->desc.port, p);
p += printed;
if (m->desc.port_count > 1) {
*p++ = '/';
printed = pj_utoa(m->desc.port_count, p);
p += printed;
}
*p++ = ' ';
pj_memcpy(p, m->desc.transport.ptr, m->desc.transport.slen);
p += m->desc.transport.slen;
for (i=0; i<m->desc.fmt_count; ++i) {
*p++ = ' ';
pj_memcpy(p, m->desc.fmt[i].ptr, m->desc.fmt[i].slen);
p += m->desc.fmt[i].slen;
}
*p++ = '\r';
*p++ = '\n';
/* print connection info, if present. */
if (m->conn) {
printed = print_connection_info(m->conn, p, (int)(end-p));
if (printed < 0) {
return -1;
}
p += printed;
}
/* print optional bandwidth info. */
for (i=0; i<m->bandw_count; ++i) {
printed = (int)print_bandw(m->bandw[i], p, end-p);
if (printed < 0) {
return -1;
}
p += printed;
}
/* print attributes. */
for (i=0; i<m->attr_count; ++i) {
printed = (int)print_attr(m->attr[i], p, end-p);
if (printed < 0) {
return -1;
}
p += printed;
}
return (int)(p-buf);
} | 446 | True | 1 |
|
CVE-2022-24786 | False | False | False | False | AV:N/AC:L/Au:N/C:P/I:P/A:P | NETWORK | LOW | NONE | PARTIAL | PARTIAL | PARTIAL | 7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | HIGH | HIGH | HIGH | 9.8 | CRITICAL | 3.9 | 5.9 | False | [{'url': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-vhxv-phmx-g52q', 'name': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-vhxv-phmx-g52q', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'https://github.com/pjsip/pjproject/commit/11559e49e65bdf00922ad5ae28913ec6a198d508', 'name': 'https://github.com/pjsip/pjproject/commit/11559e49e65bdf00922ad5ae28913ec6a198d508', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}, {'lang': 'en', 'value': 'CWE-787'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:pjsip:pjsip:*:*:*:*:*:*:*:*', 'versionEndIncluding': '2.12', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'PJSIP is a free and open source multimedia communication library written in C. PJSIP versions 2.12 and prior do not parse incoming RTCP feedback RPSI (Reference Picture Selection Indication) packet, but any app that directly uses pjmedia_rtcp_fb_parse_rpsi() will be affected. A patch is available in the `master` branch of the `pjsip/pjproject` GitHub repository. There are currently no known workarounds.'}] | 2022-04-13T18:35Z | 2022-04-06T14:15Z | Out-of-bounds Read | The software reads data past the end, or before the beginning, of the intended buffer. | Typically, this can allow attackers to read sensitive information from other memory locations or cause a crash. A crash can occur when the code reads a variable amount of data and assumes that a sentinel exists to stop the read operation, such as a NUL in a string. The expected sentinel might not be located in the out-of-bounds memory, causing excessive data to be read, leading to a segmentation fault or a buffer overflow. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent read operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/125.html | 0 | Riza Sulistyo | 2022-04-06 10:40:09+07:00 | Merge pull request from GHSA-vhxv-phmx-g52q
* Prevent OOB read/write when parsing RTCP FB RPSI
* Add log information
* Modification based on comments. | 11559e49e65bdf00922ad5ae28913ec6a198d508 | False | pjsip/pjproject | PJSIP project | 2016-01-24 05:00:33 | 2022-08-26 15:35:55 | http://www.pjsip.org | pjsip | 1248.0 | 567.0 | pjmedia_rtcp_fb_build_nack | pjmedia_rtcp_fb_build_nack( pjmedia_rtcp_session * session , void * buf , pj_size_t * length , unsigned nack_cnt , const pjmedia_rtcp_fb_nack nack [ ]) | ['session', 'buf', 'length', 'nack_cnt'] | PJ_DEF(pj_status_t) pjmedia_rtcp_fb_build_nack(
pjmedia_rtcp_session *session,
void *buf,
pj_size_t *length,
unsigned nack_cnt,
const pjmedia_rtcp_fb_nack nack[])
{
pjmedia_rtcp_common *hdr;
pj_uint8_t *p;
unsigned len, i;
PJ_ASSERT_RETURN(session && buf && length && nack_cnt && nack, PJ_EINVAL);
len = (3 + nack_cnt) * 4;
if (len > *length)
return PJ_ETOOSMALL;
/* Build RTCP-FB NACK header */
hdr = (pjmedia_rtcp_common*)buf;
pj_memcpy(hdr, &session->rtcp_rr_pkt.common, sizeof(*hdr));
hdr->pt = RTCP_RTPFB;
hdr->count = 1; /* FMT = 1 */
hdr->length = pj_htons((pj_uint16_t)(len/4 - 1));
/* Build RTCP-FB NACK FCI */
p = (pj_uint8_t*)hdr + sizeof(*hdr);
for (i = 0; i < nack_cnt; ++i) {
pj_uint16_t val;
val = pj_htons((pj_uint16_t)nack[i].pid);
pj_memcpy(p, &val, 2);
val = pj_htons(nack[i].blp);
pj_memcpy(p+2, &val, 2);
p += 4;
}
/* Finally */
*length = len;
return PJ_SUCCESS;
} | 221 | True | 1 |
CVE-2022-24786 | False | False | False | False | AV:N/AC:L/Au:N/C:P/I:P/A:P | NETWORK | LOW | NONE | PARTIAL | PARTIAL | PARTIAL | 7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | HIGH | HIGH | HIGH | 9.8 | CRITICAL | 3.9 | 5.9 | False | [{'url': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-vhxv-phmx-g52q', 'name': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-vhxv-phmx-g52q', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'https://github.com/pjsip/pjproject/commit/11559e49e65bdf00922ad5ae28913ec6a198d508', 'name': 'https://github.com/pjsip/pjproject/commit/11559e49e65bdf00922ad5ae28913ec6a198d508', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}, {'lang': 'en', 'value': 'CWE-787'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:pjsip:pjsip:*:*:*:*:*:*:*:*', 'versionEndIncluding': '2.12', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'PJSIP is a free and open source multimedia communication library written in C. PJSIP versions 2.12 and prior do not parse incoming RTCP feedback RPSI (Reference Picture Selection Indication) packet, but any app that directly uses pjmedia_rtcp_fb_parse_rpsi() will be affected. A patch is available in the `master` branch of the `pjsip/pjproject` GitHub repository. There are currently no known workarounds.'}] | 2022-04-13T18:35Z | 2022-04-06T14:15Z | Out-of-bounds Write | The software writes data past the end, or before the beginning, of the intended buffer. | Typically, this can result in corruption of data, a crash, or code execution. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent write operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/787.html | 0 | Riza Sulistyo | 2022-04-06 10:40:09+07:00 | Merge pull request from GHSA-vhxv-phmx-g52q
* Prevent OOB read/write when parsing RTCP FB RPSI
* Add log information
* Modification based on comments. | 11559e49e65bdf00922ad5ae28913ec6a198d508 | False | pjsip/pjproject | PJSIP project | 2016-01-24 05:00:33 | 2022-08-26 15:35:55 | http://www.pjsip.org | pjsip | 1248.0 | 567.0 | pjmedia_rtcp_fb_build_nack | pjmedia_rtcp_fb_build_nack( pjmedia_rtcp_session * session , void * buf , pj_size_t * length , unsigned nack_cnt , const pjmedia_rtcp_fb_nack nack [ ]) | ['session', 'buf', 'length', 'nack_cnt'] | PJ_DEF(pj_status_t) pjmedia_rtcp_fb_build_nack(
pjmedia_rtcp_session *session,
void *buf,
pj_size_t *length,
unsigned nack_cnt,
const pjmedia_rtcp_fb_nack nack[])
{
pjmedia_rtcp_common *hdr;
pj_uint8_t *p;
unsigned len, i;
PJ_ASSERT_RETURN(session && buf && length && nack_cnt && nack, PJ_EINVAL);
len = (3 + nack_cnt) * 4;
if (len > *length)
return PJ_ETOOSMALL;
/* Build RTCP-FB NACK header */
hdr = (pjmedia_rtcp_common*)buf;
pj_memcpy(hdr, &session->rtcp_rr_pkt.common, sizeof(*hdr));
hdr->pt = RTCP_RTPFB;
hdr->count = 1; /* FMT = 1 */
hdr->length = pj_htons((pj_uint16_t)(len/4 - 1));
/* Build RTCP-FB NACK FCI */
p = (pj_uint8_t*)hdr + sizeof(*hdr);
for (i = 0; i < nack_cnt; ++i) {
pj_uint16_t val;
val = pj_htons((pj_uint16_t)nack[i].pid);
pj_memcpy(p, &val, 2);
val = pj_htons(nack[i].blp);
pj_memcpy(p+2, &val, 2);
p += 4;
}
/* Finally */
*length = len;
return PJ_SUCCESS;
} | 221 | True | 1 |
CVE-2022-24786 | False | False | False | False | AV:N/AC:L/Au:N/C:P/I:P/A:P | NETWORK | LOW | NONE | PARTIAL | PARTIAL | PARTIAL | 7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | HIGH | HIGH | HIGH | 9.8 | CRITICAL | 3.9 | 5.9 | False | [{'url': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-vhxv-phmx-g52q', 'name': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-vhxv-phmx-g52q', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'https://github.com/pjsip/pjproject/commit/11559e49e65bdf00922ad5ae28913ec6a198d508', 'name': 'https://github.com/pjsip/pjproject/commit/11559e49e65bdf00922ad5ae28913ec6a198d508', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}, {'lang': 'en', 'value': 'CWE-787'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:pjsip:pjsip:*:*:*:*:*:*:*:*', 'versionEndIncluding': '2.12', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'PJSIP is a free and open source multimedia communication library written in C. PJSIP versions 2.12 and prior do not parse incoming RTCP feedback RPSI (Reference Picture Selection Indication) packet, but any app that directly uses pjmedia_rtcp_fb_parse_rpsi() will be affected. A patch is available in the `master` branch of the `pjsip/pjproject` GitHub repository. There are currently no known workarounds.'}] | 2022-04-13T18:35Z | 2022-04-06T14:15Z | Out-of-bounds Read | The software reads data past the end, or before the beginning, of the intended buffer. | Typically, this can allow attackers to read sensitive information from other memory locations or cause a crash. A crash can occur when the code reads a variable amount of data and assumes that a sentinel exists to stop the read operation, such as a NUL in a string. The expected sentinel might not be located in the out-of-bounds memory, causing excessive data to be read, leading to a segmentation fault or a buffer overflow. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent read operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/125.html | 0 | Riza Sulistyo | 2022-04-06 10:40:09+07:00 | Merge pull request from GHSA-vhxv-phmx-g52q
* Prevent OOB read/write when parsing RTCP FB RPSI
* Add log information
* Modification based on comments. | 11559e49e65bdf00922ad5ae28913ec6a198d508 | False | pjsip/pjproject | PJSIP project | 2016-01-24 05:00:33 | 2022-08-26 15:35:55 | http://www.pjsip.org | pjsip | 1248.0 | 567.0 | pjmedia_rtcp_fb_build_pli | pjmedia_rtcp_fb_build_pli( pjmedia_rtcp_session * session , void * buf , pj_size_t * length) | ['session', 'buf', 'length'] | PJ_DEF(pj_status_t) pjmedia_rtcp_fb_build_pli(
pjmedia_rtcp_session *session,
void *buf,
pj_size_t *length)
{
pjmedia_rtcp_common *hdr;
unsigned len;
PJ_ASSERT_RETURN(session && buf && length, PJ_EINVAL);
len = 12;
if (len > *length)
return PJ_ETOOSMALL;
/* Build RTCP-FB PLI header */
hdr = (pjmedia_rtcp_common*)buf;
pj_memcpy(hdr, &session->rtcp_rr_pkt.common, sizeof(*hdr));
hdr->pt = RTCP_PSFB;
hdr->count = 1; /* FMT = 1 */
hdr->length = pj_htons((pj_uint16_t)(len/4 - 1));
/* Finally */
*length = len;
return PJ_SUCCESS;
} | 111 | True | 1 |
CVE-2022-24786 | False | False | False | False | AV:N/AC:L/Au:N/C:P/I:P/A:P | NETWORK | LOW | NONE | PARTIAL | PARTIAL | PARTIAL | 7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | HIGH | HIGH | HIGH | 9.8 | CRITICAL | 3.9 | 5.9 | False | [{'url': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-vhxv-phmx-g52q', 'name': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-vhxv-phmx-g52q', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'https://github.com/pjsip/pjproject/commit/11559e49e65bdf00922ad5ae28913ec6a198d508', 'name': 'https://github.com/pjsip/pjproject/commit/11559e49e65bdf00922ad5ae28913ec6a198d508', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}, {'lang': 'en', 'value': 'CWE-787'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:pjsip:pjsip:*:*:*:*:*:*:*:*', 'versionEndIncluding': '2.12', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'PJSIP is a free and open source multimedia communication library written in C. PJSIP versions 2.12 and prior do not parse incoming RTCP feedback RPSI (Reference Picture Selection Indication) packet, but any app that directly uses pjmedia_rtcp_fb_parse_rpsi() will be affected. A patch is available in the `master` branch of the `pjsip/pjproject` GitHub repository. There are currently no known workarounds.'}] | 2022-04-13T18:35Z | 2022-04-06T14:15Z | Out-of-bounds Write | The software writes data past the end, or before the beginning, of the intended buffer. | Typically, this can result in corruption of data, a crash, or code execution. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent write operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/787.html | 0 | Riza Sulistyo | 2022-04-06 10:40:09+07:00 | Merge pull request from GHSA-vhxv-phmx-g52q
* Prevent OOB read/write when parsing RTCP FB RPSI
* Add log information
* Modification based on comments. | 11559e49e65bdf00922ad5ae28913ec6a198d508 | False | pjsip/pjproject | PJSIP project | 2016-01-24 05:00:33 | 2022-08-26 15:35:55 | http://www.pjsip.org | pjsip | 1248.0 | 567.0 | pjmedia_rtcp_fb_build_pli | pjmedia_rtcp_fb_build_pli( pjmedia_rtcp_session * session , void * buf , pj_size_t * length) | ['session', 'buf', 'length'] | PJ_DEF(pj_status_t) pjmedia_rtcp_fb_build_pli(
pjmedia_rtcp_session *session,
void *buf,
pj_size_t *length)
{
pjmedia_rtcp_common *hdr;
unsigned len;
PJ_ASSERT_RETURN(session && buf && length, PJ_EINVAL);
len = 12;
if (len > *length)
return PJ_ETOOSMALL;
/* Build RTCP-FB PLI header */
hdr = (pjmedia_rtcp_common*)buf;
pj_memcpy(hdr, &session->rtcp_rr_pkt.common, sizeof(*hdr));
hdr->pt = RTCP_PSFB;
hdr->count = 1; /* FMT = 1 */
hdr->length = pj_htons((pj_uint16_t)(len/4 - 1));
/* Finally */
*length = len;
return PJ_SUCCESS;
} | 111 | True | 1 |
CVE-2022-24786 | False | False | False | False | AV:N/AC:L/Au:N/C:P/I:P/A:P | NETWORK | LOW | NONE | PARTIAL | PARTIAL | PARTIAL | 7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | HIGH | HIGH | HIGH | 9.8 | CRITICAL | 3.9 | 5.9 | False | [{'url': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-vhxv-phmx-g52q', 'name': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-vhxv-phmx-g52q', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'https://github.com/pjsip/pjproject/commit/11559e49e65bdf00922ad5ae28913ec6a198d508', 'name': 'https://github.com/pjsip/pjproject/commit/11559e49e65bdf00922ad5ae28913ec6a198d508', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}, {'lang': 'en', 'value': 'CWE-787'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:pjsip:pjsip:*:*:*:*:*:*:*:*', 'versionEndIncluding': '2.12', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'PJSIP is a free and open source multimedia communication library written in C. PJSIP versions 2.12 and prior do not parse incoming RTCP feedback RPSI (Reference Picture Selection Indication) packet, but any app that directly uses pjmedia_rtcp_fb_parse_rpsi() will be affected. A patch is available in the `master` branch of the `pjsip/pjproject` GitHub repository. There are currently no known workarounds.'}] | 2022-04-13T18:35Z | 2022-04-06T14:15Z | Out-of-bounds Read | The software reads data past the end, or before the beginning, of the intended buffer. | Typically, this can allow attackers to read sensitive information from other memory locations or cause a crash. A crash can occur when the code reads a variable amount of data and assumes that a sentinel exists to stop the read operation, such as a NUL in a string. The expected sentinel might not be located in the out-of-bounds memory, causing excessive data to be read, leading to a segmentation fault or a buffer overflow. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent read operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/125.html | 0 | Riza Sulistyo | 2022-04-06 10:40:09+07:00 | Merge pull request from GHSA-vhxv-phmx-g52q
* Prevent OOB read/write when parsing RTCP FB RPSI
* Add log information
* Modification based on comments. | 11559e49e65bdf00922ad5ae28913ec6a198d508 | False | pjsip/pjproject | PJSIP project | 2016-01-24 05:00:33 | 2022-08-26 15:35:55 | http://www.pjsip.org | pjsip | 1248.0 | 567.0 | pjmedia_rtcp_fb_build_rpsi | pjmedia_rtcp_fb_build_rpsi( pjmedia_rtcp_session * session , void * buf , pj_size_t * length , const pjmedia_rtcp_fb_rpsi * rpsi) | ['session', 'buf', 'length', 'rpsi'] | PJ_DEF(pj_status_t) pjmedia_rtcp_fb_build_rpsi(
pjmedia_rtcp_session *session,
void *buf,
pj_size_t *length,
const pjmedia_rtcp_fb_rpsi *rpsi)
{
pjmedia_rtcp_common *hdr;
pj_uint8_t *p;
unsigned bitlen, padlen, len;
PJ_ASSERT_RETURN(session && buf && length && rpsi, PJ_EINVAL);
bitlen = (unsigned)rpsi->rpsi_bit_len + 16;
padlen = (32 - (bitlen % 32)) % 32;
len = (3 + (bitlen+padlen)/32) * 4;
if (len > *length)
return PJ_ETOOSMALL;
/* Build RTCP-FB RPSI header */
hdr = (pjmedia_rtcp_common*)buf;
pj_memcpy(hdr, &session->rtcp_rr_pkt.common, sizeof(*hdr));
hdr->pt = RTCP_PSFB;
hdr->count = 3; /* FMT = 3 */
hdr->length = pj_htons((pj_uint16_t)(len/4 - 1));
/* Build RTCP-FB RPSI FCI */
p = (pj_uint8_t*)hdr + sizeof(*hdr);
/* PB (number of padding bits) */
*p++ = (pj_uint8_t)padlen;
/* Payload type */
*p++ = rpsi->pt & 0x7F;
/* RPSI bit string */
pj_memcpy(p, rpsi->rpsi.ptr, rpsi->rpsi_bit_len/8);
p += rpsi->rpsi_bit_len/8;
if (rpsi->rpsi_bit_len % 8) {
*p++ = *(rpsi->rpsi.ptr + rpsi->rpsi_bit_len/8);
}
/* Zero padding */
if (padlen >= 8)
pj_bzero(p, padlen/8);
/* Finally */
*length = len;
return PJ_SUCCESS;
} | 265 | True | 1 |
CVE-2022-24786 | False | False | False | False | AV:N/AC:L/Au:N/C:P/I:P/A:P | NETWORK | LOW | NONE | PARTIAL | PARTIAL | PARTIAL | 7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | HIGH | HIGH | HIGH | 9.8 | CRITICAL | 3.9 | 5.9 | False | [{'url': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-vhxv-phmx-g52q', 'name': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-vhxv-phmx-g52q', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'https://github.com/pjsip/pjproject/commit/11559e49e65bdf00922ad5ae28913ec6a198d508', 'name': 'https://github.com/pjsip/pjproject/commit/11559e49e65bdf00922ad5ae28913ec6a198d508', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}, {'lang': 'en', 'value': 'CWE-787'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:pjsip:pjsip:*:*:*:*:*:*:*:*', 'versionEndIncluding': '2.12', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'PJSIP is a free and open source multimedia communication library written in C. PJSIP versions 2.12 and prior do not parse incoming RTCP feedback RPSI (Reference Picture Selection Indication) packet, but any app that directly uses pjmedia_rtcp_fb_parse_rpsi() will be affected. A patch is available in the `master` branch of the `pjsip/pjproject` GitHub repository. There are currently no known workarounds.'}] | 2022-04-13T18:35Z | 2022-04-06T14:15Z | Out-of-bounds Write | The software writes data past the end, or before the beginning, of the intended buffer. | Typically, this can result in corruption of data, a crash, or code execution. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent write operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/787.html | 0 | Riza Sulistyo | 2022-04-06 10:40:09+07:00 | Merge pull request from GHSA-vhxv-phmx-g52q
* Prevent OOB read/write when parsing RTCP FB RPSI
* Add log information
* Modification based on comments. | 11559e49e65bdf00922ad5ae28913ec6a198d508 | False | pjsip/pjproject | PJSIP project | 2016-01-24 05:00:33 | 2022-08-26 15:35:55 | http://www.pjsip.org | pjsip | 1248.0 | 567.0 | pjmedia_rtcp_fb_build_rpsi | pjmedia_rtcp_fb_build_rpsi( pjmedia_rtcp_session * session , void * buf , pj_size_t * length , const pjmedia_rtcp_fb_rpsi * rpsi) | ['session', 'buf', 'length', 'rpsi'] | PJ_DEF(pj_status_t) pjmedia_rtcp_fb_build_rpsi(
pjmedia_rtcp_session *session,
void *buf,
pj_size_t *length,
const pjmedia_rtcp_fb_rpsi *rpsi)
{
pjmedia_rtcp_common *hdr;
pj_uint8_t *p;
unsigned bitlen, padlen, len;
PJ_ASSERT_RETURN(session && buf && length && rpsi, PJ_EINVAL);
bitlen = (unsigned)rpsi->rpsi_bit_len + 16;
padlen = (32 - (bitlen % 32)) % 32;
len = (3 + (bitlen+padlen)/32) * 4;
if (len > *length)
return PJ_ETOOSMALL;
/* Build RTCP-FB RPSI header */
hdr = (pjmedia_rtcp_common*)buf;
pj_memcpy(hdr, &session->rtcp_rr_pkt.common, sizeof(*hdr));
hdr->pt = RTCP_PSFB;
hdr->count = 3; /* FMT = 3 */
hdr->length = pj_htons((pj_uint16_t)(len/4 - 1));
/* Build RTCP-FB RPSI FCI */
p = (pj_uint8_t*)hdr + sizeof(*hdr);
/* PB (number of padding bits) */
*p++ = (pj_uint8_t)padlen;
/* Payload type */
*p++ = rpsi->pt & 0x7F;
/* RPSI bit string */
pj_memcpy(p, rpsi->rpsi.ptr, rpsi->rpsi_bit_len/8);
p += rpsi->rpsi_bit_len/8;
if (rpsi->rpsi_bit_len % 8) {
*p++ = *(rpsi->rpsi.ptr + rpsi->rpsi_bit_len/8);
}
/* Zero padding */
if (padlen >= 8)
pj_bzero(p, padlen/8);
/* Finally */
*length = len;
return PJ_SUCCESS;
} | 265 | True | 1 |
CVE-2022-24786 | False | False | False | False | AV:N/AC:L/Au:N/C:P/I:P/A:P | NETWORK | LOW | NONE | PARTIAL | PARTIAL | PARTIAL | 7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | HIGH | HIGH | HIGH | 9.8 | CRITICAL | 3.9 | 5.9 | False | [{'url': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-vhxv-phmx-g52q', 'name': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-vhxv-phmx-g52q', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'https://github.com/pjsip/pjproject/commit/11559e49e65bdf00922ad5ae28913ec6a198d508', 'name': 'https://github.com/pjsip/pjproject/commit/11559e49e65bdf00922ad5ae28913ec6a198d508', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}, {'lang': 'en', 'value': 'CWE-787'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:pjsip:pjsip:*:*:*:*:*:*:*:*', 'versionEndIncluding': '2.12', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'PJSIP is a free and open source multimedia communication library written in C. PJSIP versions 2.12 and prior do not parse incoming RTCP feedback RPSI (Reference Picture Selection Indication) packet, but any app that directly uses pjmedia_rtcp_fb_parse_rpsi() will be affected. A patch is available in the `master` branch of the `pjsip/pjproject` GitHub repository. There are currently no known workarounds.'}] | 2022-04-13T18:35Z | 2022-04-06T14:15Z | Out-of-bounds Read | The software reads data past the end, or before the beginning, of the intended buffer. | Typically, this can allow attackers to read sensitive information from other memory locations or cause a crash. A crash can occur when the code reads a variable amount of data and assumes that a sentinel exists to stop the read operation, such as a NUL in a string. The expected sentinel might not be located in the out-of-bounds memory, causing excessive data to be read, leading to a segmentation fault or a buffer overflow. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent read operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/125.html | 0 | Riza Sulistyo | 2022-04-06 10:40:09+07:00 | Merge pull request from GHSA-vhxv-phmx-g52q
* Prevent OOB read/write when parsing RTCP FB RPSI
* Add log information
* Modification based on comments. | 11559e49e65bdf00922ad5ae28913ec6a198d508 | False | pjsip/pjproject | PJSIP project | 2016-01-24 05:00:33 | 2022-08-26 15:35:55 | http://www.pjsip.org | pjsip | 1248.0 | 567.0 | pjmedia_rtcp_fb_build_sli | pjmedia_rtcp_fb_build_sli( pjmedia_rtcp_session * session , void * buf , pj_size_t * length , unsigned sli_cnt , const pjmedia_rtcp_fb_sli sli [ ]) | ['session', 'buf', 'length', 'sli_cnt'] | PJ_DEF(pj_status_t) pjmedia_rtcp_fb_build_sli(
pjmedia_rtcp_session *session,
void *buf,
pj_size_t *length,
unsigned sli_cnt,
const pjmedia_rtcp_fb_sli sli[])
{
pjmedia_rtcp_common *hdr;
pj_uint8_t *p;
unsigned len, i;
PJ_ASSERT_RETURN(session && buf && length && sli_cnt && sli, PJ_EINVAL);
len = (3 + sli_cnt) * 4;
if (len > *length)
return PJ_ETOOSMALL;
/* Build RTCP-FB SLI header */
hdr = (pjmedia_rtcp_common*)buf;
pj_memcpy(hdr, &session->rtcp_rr_pkt.common, sizeof(*hdr));
hdr->pt = RTCP_PSFB;
hdr->count = 2; /* FMT = 2 */
hdr->length = pj_htons((pj_uint16_t)(len/4 - 1));
/* Build RTCP-FB SLI FCI */
p = (pj_uint8_t*)hdr + sizeof(*hdr);
for (i = 0; i < sli_cnt; ++i) {
/* 'first' takes 13 bit */
*p++ = (pj_uint8_t)((sli[i].first >> 5) & 0xFF); /* 8 MSB bits */
*p = (pj_uint8_t)((sli[i].first & 31) << 3); /* 5 LSB bits */
/* 'number' takes 13 bit */
*p++ |= (pj_uint8_t)((sli[i].number >> 10) & 7); /* 3 MSB bits */
*p++ = (pj_uint8_t)((sli[i].number >> 2) & 0xFF); /* 8 mid bits */
*p = (pj_uint8_t)((sli[i].number & 3) << 6); /* 2 LSB bits */
/* 'pict_id' takes 6 bit */
*p++ |= (sli[i].pict_id & 63);
}
/* Finally */
*length = len;
return PJ_SUCCESS;
} | 293 | True | 1 |
CVE-2022-24786 | False | False | False | False | AV:N/AC:L/Au:N/C:P/I:P/A:P | NETWORK | LOW | NONE | PARTIAL | PARTIAL | PARTIAL | 7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | HIGH | HIGH | HIGH | 9.8 | CRITICAL | 3.9 | 5.9 | False | [{'url': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-vhxv-phmx-g52q', 'name': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-vhxv-phmx-g52q', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'https://github.com/pjsip/pjproject/commit/11559e49e65bdf00922ad5ae28913ec6a198d508', 'name': 'https://github.com/pjsip/pjproject/commit/11559e49e65bdf00922ad5ae28913ec6a198d508', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}, {'lang': 'en', 'value': 'CWE-787'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:pjsip:pjsip:*:*:*:*:*:*:*:*', 'versionEndIncluding': '2.12', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'PJSIP is a free and open source multimedia communication library written in C. PJSIP versions 2.12 and prior do not parse incoming RTCP feedback RPSI (Reference Picture Selection Indication) packet, but any app that directly uses pjmedia_rtcp_fb_parse_rpsi() will be affected. A patch is available in the `master` branch of the `pjsip/pjproject` GitHub repository. There are currently no known workarounds.'}] | 2022-04-13T18:35Z | 2022-04-06T14:15Z | Out-of-bounds Write | The software writes data past the end, or before the beginning, of the intended buffer. | Typically, this can result in corruption of data, a crash, or code execution. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent write operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/787.html | 0 | Riza Sulistyo | 2022-04-06 10:40:09+07:00 | Merge pull request from GHSA-vhxv-phmx-g52q
* Prevent OOB read/write when parsing RTCP FB RPSI
* Add log information
* Modification based on comments. | 11559e49e65bdf00922ad5ae28913ec6a198d508 | False | pjsip/pjproject | PJSIP project | 2016-01-24 05:00:33 | 2022-08-26 15:35:55 | http://www.pjsip.org | pjsip | 1248.0 | 567.0 | pjmedia_rtcp_fb_build_sli | pjmedia_rtcp_fb_build_sli( pjmedia_rtcp_session * session , void * buf , pj_size_t * length , unsigned sli_cnt , const pjmedia_rtcp_fb_sli sli [ ]) | ['session', 'buf', 'length', 'sli_cnt'] | PJ_DEF(pj_status_t) pjmedia_rtcp_fb_build_sli(
pjmedia_rtcp_session *session,
void *buf,
pj_size_t *length,
unsigned sli_cnt,
const pjmedia_rtcp_fb_sli sli[])
{
pjmedia_rtcp_common *hdr;
pj_uint8_t *p;
unsigned len, i;
PJ_ASSERT_RETURN(session && buf && length && sli_cnt && sli, PJ_EINVAL);
len = (3 + sli_cnt) * 4;
if (len > *length)
return PJ_ETOOSMALL;
/* Build RTCP-FB SLI header */
hdr = (pjmedia_rtcp_common*)buf;
pj_memcpy(hdr, &session->rtcp_rr_pkt.common, sizeof(*hdr));
hdr->pt = RTCP_PSFB;
hdr->count = 2; /* FMT = 2 */
hdr->length = pj_htons((pj_uint16_t)(len/4 - 1));
/* Build RTCP-FB SLI FCI */
p = (pj_uint8_t*)hdr + sizeof(*hdr);
for (i = 0; i < sli_cnt; ++i) {
/* 'first' takes 13 bit */
*p++ = (pj_uint8_t)((sli[i].first >> 5) & 0xFF); /* 8 MSB bits */
*p = (pj_uint8_t)((sli[i].first & 31) << 3); /* 5 LSB bits */
/* 'number' takes 13 bit */
*p++ |= (pj_uint8_t)((sli[i].number >> 10) & 7); /* 3 MSB bits */
*p++ = (pj_uint8_t)((sli[i].number >> 2) & 0xFF); /* 8 mid bits */
*p = (pj_uint8_t)((sli[i].number & 3) << 6); /* 2 LSB bits */
/* 'pict_id' takes 6 bit */
*p++ |= (sli[i].pict_id & 63);
}
/* Finally */
*length = len;
return PJ_SUCCESS;
} | 293 | True | 1 |
CVE-2022-24786 | False | False | False | False | AV:N/AC:L/Au:N/C:P/I:P/A:P | NETWORK | LOW | NONE | PARTIAL | PARTIAL | PARTIAL | 7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | HIGH | HIGH | HIGH | 9.8 | CRITICAL | 3.9 | 5.9 | False | [{'url': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-vhxv-phmx-g52q', 'name': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-vhxv-phmx-g52q', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'https://github.com/pjsip/pjproject/commit/11559e49e65bdf00922ad5ae28913ec6a198d508', 'name': 'https://github.com/pjsip/pjproject/commit/11559e49e65bdf00922ad5ae28913ec6a198d508', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}, {'lang': 'en', 'value': 'CWE-787'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:pjsip:pjsip:*:*:*:*:*:*:*:*', 'versionEndIncluding': '2.12', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'PJSIP is a free and open source multimedia communication library written in C. PJSIP versions 2.12 and prior do not parse incoming RTCP feedback RPSI (Reference Picture Selection Indication) packet, but any app that directly uses pjmedia_rtcp_fb_parse_rpsi() will be affected. A patch is available in the `master` branch of the `pjsip/pjproject` GitHub repository. There are currently no known workarounds.'}] | 2022-04-13T18:35Z | 2022-04-06T14:15Z | Out-of-bounds Read | The software reads data past the end, or before the beginning, of the intended buffer. | Typically, this can allow attackers to read sensitive information from other memory locations or cause a crash. A crash can occur when the code reads a variable amount of data and assumes that a sentinel exists to stop the read operation, such as a NUL in a string. The expected sentinel might not be located in the out-of-bounds memory, causing excessive data to be read, leading to a segmentation fault or a buffer overflow. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent read operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/125.html | 0 | Riza Sulistyo | 2022-04-06 10:40:09+07:00 | Merge pull request from GHSA-vhxv-phmx-g52q
* Prevent OOB read/write when parsing RTCP FB RPSI
* Add log information
* Modification based on comments. | 11559e49e65bdf00922ad5ae28913ec6a198d508 | False | pjsip/pjproject | PJSIP project | 2016-01-24 05:00:33 | 2022-08-26 15:35:55 | http://www.pjsip.org | pjsip | 1248.0 | 567.0 | pjmedia_rtcp_fb_parse_nack | pjmedia_rtcp_fb_parse_nack( const void * buf , pj_size_t length , unsigned * nack_cnt , pjmedia_rtcp_fb_nack nack [ ]) | ['buf', 'length', 'nack_cnt'] | PJ_DEF(pj_status_t) pjmedia_rtcp_fb_parse_nack(
const void *buf,
pj_size_t length,
unsigned *nack_cnt,
pjmedia_rtcp_fb_nack nack[])
{
pjmedia_rtcp_common *hdr = (pjmedia_rtcp_common*) buf;
pj_uint8_t *p;
unsigned cnt, i;
PJ_ASSERT_RETURN(buf && nack_cnt && nack, PJ_EINVAL);
PJ_ASSERT_RETURN(length >= sizeof(pjmedia_rtcp_common), PJ_ETOOSMALL);
/* Generic NACK uses pt==RTCP_RTPFB and FMT==1 */
if (hdr->pt != RTCP_RTPFB || hdr->count != 1)
return PJ_ENOTFOUND;
cnt = pj_ntohs((pj_uint16_t)hdr->length);
if (cnt > 2) cnt -= 2; else cnt = 0;
if (length < (cnt+3)*4)
return PJ_ETOOSMALL;
*nack_cnt = PJ_MIN(*nack_cnt, cnt);
p = (pj_uint8_t*)hdr + sizeof(*hdr);
for (i = 0; i < *nack_cnt; ++i) {
pj_uint16_t val;
pj_memcpy(&val, p, 2);
nack[i].pid = pj_ntohs(val);
pj_memcpy(&val, p+2, 2);
nack[i].blp = pj_ntohs(val);
p += 4;
}
return PJ_SUCCESS;
} | 218 | True | 1 |
CVE-2022-24786 | False | False | False | False | AV:N/AC:L/Au:N/C:P/I:P/A:P | NETWORK | LOW | NONE | PARTIAL | PARTIAL | PARTIAL | 7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | HIGH | HIGH | HIGH | 9.8 | CRITICAL | 3.9 | 5.9 | False | [{'url': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-vhxv-phmx-g52q', 'name': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-vhxv-phmx-g52q', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'https://github.com/pjsip/pjproject/commit/11559e49e65bdf00922ad5ae28913ec6a198d508', 'name': 'https://github.com/pjsip/pjproject/commit/11559e49e65bdf00922ad5ae28913ec6a198d508', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}, {'lang': 'en', 'value': 'CWE-787'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:pjsip:pjsip:*:*:*:*:*:*:*:*', 'versionEndIncluding': '2.12', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'PJSIP is a free and open source multimedia communication library written in C. PJSIP versions 2.12 and prior do not parse incoming RTCP feedback RPSI (Reference Picture Selection Indication) packet, but any app that directly uses pjmedia_rtcp_fb_parse_rpsi() will be affected. A patch is available in the `master` branch of the `pjsip/pjproject` GitHub repository. There are currently no known workarounds.'}] | 2022-04-13T18:35Z | 2022-04-06T14:15Z | Out-of-bounds Write | The software writes data past the end, or before the beginning, of the intended buffer. | Typically, this can result in corruption of data, a crash, or code execution. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent write operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/787.html | 0 | Riza Sulistyo | 2022-04-06 10:40:09+07:00 | Merge pull request from GHSA-vhxv-phmx-g52q
* Prevent OOB read/write when parsing RTCP FB RPSI
* Add log information
* Modification based on comments. | 11559e49e65bdf00922ad5ae28913ec6a198d508 | False | pjsip/pjproject | PJSIP project | 2016-01-24 05:00:33 | 2022-08-26 15:35:55 | http://www.pjsip.org | pjsip | 1248.0 | 567.0 | pjmedia_rtcp_fb_parse_nack | pjmedia_rtcp_fb_parse_nack( const void * buf , pj_size_t length , unsigned * nack_cnt , pjmedia_rtcp_fb_nack nack [ ]) | ['buf', 'length', 'nack_cnt'] | PJ_DEF(pj_status_t) pjmedia_rtcp_fb_parse_nack(
const void *buf,
pj_size_t length,
unsigned *nack_cnt,
pjmedia_rtcp_fb_nack nack[])
{
pjmedia_rtcp_common *hdr = (pjmedia_rtcp_common*) buf;
pj_uint8_t *p;
unsigned cnt, i;
PJ_ASSERT_RETURN(buf && nack_cnt && nack, PJ_EINVAL);
PJ_ASSERT_RETURN(length >= sizeof(pjmedia_rtcp_common), PJ_ETOOSMALL);
/* Generic NACK uses pt==RTCP_RTPFB and FMT==1 */
if (hdr->pt != RTCP_RTPFB || hdr->count != 1)
return PJ_ENOTFOUND;
cnt = pj_ntohs((pj_uint16_t)hdr->length);
if (cnt > 2) cnt -= 2; else cnt = 0;
if (length < (cnt+3)*4)
return PJ_ETOOSMALL;
*nack_cnt = PJ_MIN(*nack_cnt, cnt);
p = (pj_uint8_t*)hdr + sizeof(*hdr);
for (i = 0; i < *nack_cnt; ++i) {
pj_uint16_t val;
pj_memcpy(&val, p, 2);
nack[i].pid = pj_ntohs(val);
pj_memcpy(&val, p+2, 2);
nack[i].blp = pj_ntohs(val);
p += 4;
}
return PJ_SUCCESS;
} | 218 | True | 1 |
CVE-2022-24786 | False | False | False | False | AV:N/AC:L/Au:N/C:P/I:P/A:P | NETWORK | LOW | NONE | PARTIAL | PARTIAL | PARTIAL | 7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | HIGH | HIGH | HIGH | 9.8 | CRITICAL | 3.9 | 5.9 | False | [{'url': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-vhxv-phmx-g52q', 'name': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-vhxv-phmx-g52q', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'https://github.com/pjsip/pjproject/commit/11559e49e65bdf00922ad5ae28913ec6a198d508', 'name': 'https://github.com/pjsip/pjproject/commit/11559e49e65bdf00922ad5ae28913ec6a198d508', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}, {'lang': 'en', 'value': 'CWE-787'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:pjsip:pjsip:*:*:*:*:*:*:*:*', 'versionEndIncluding': '2.12', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'PJSIP is a free and open source multimedia communication library written in C. PJSIP versions 2.12 and prior do not parse incoming RTCP feedback RPSI (Reference Picture Selection Indication) packet, but any app that directly uses pjmedia_rtcp_fb_parse_rpsi() will be affected. A patch is available in the `master` branch of the `pjsip/pjproject` GitHub repository. There are currently no known workarounds.'}] | 2022-04-13T18:35Z | 2022-04-06T14:15Z | Out-of-bounds Read | The software reads data past the end, or before the beginning, of the intended buffer. | Typically, this can allow attackers to read sensitive information from other memory locations or cause a crash. A crash can occur when the code reads a variable amount of data and assumes that a sentinel exists to stop the read operation, such as a NUL in a string. The expected sentinel might not be located in the out-of-bounds memory, causing excessive data to be read, leading to a segmentation fault or a buffer overflow. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent read operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/125.html | 0 | Riza Sulistyo | 2022-04-06 10:40:09+07:00 | Merge pull request from GHSA-vhxv-phmx-g52q
* Prevent OOB read/write when parsing RTCP FB RPSI
* Add log information
* Modification based on comments. | 11559e49e65bdf00922ad5ae28913ec6a198d508 | False | pjsip/pjproject | PJSIP project | 2016-01-24 05:00:33 | 2022-08-26 15:35:55 | http://www.pjsip.org | pjsip | 1248.0 | 567.0 | pjmedia_rtcp_fb_parse_pli | pjmedia_rtcp_fb_parse_pli( const void * buf , pj_size_t length) | ['buf', 'length'] | PJ_DEF(pj_status_t) pjmedia_rtcp_fb_parse_pli(
const void *buf,
pj_size_t length)
{
pjmedia_rtcp_common *hdr = (pjmedia_rtcp_common*) buf;
PJ_ASSERT_RETURN(buf, PJ_EINVAL);
if (length < 12)
return PJ_ETOOSMALL;
/* PLI uses pt==RTCP_PSFB and FMT==1 */
if (hdr->pt != RTCP_PSFB || hdr->count != 1)
return PJ_ENOTFOUND;
return PJ_SUCCESS;
} | 57 | True | 1 |
CVE-2022-24786 | False | False | False | False | AV:N/AC:L/Au:N/C:P/I:P/A:P | NETWORK | LOW | NONE | PARTIAL | PARTIAL | PARTIAL | 7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | HIGH | HIGH | HIGH | 9.8 | CRITICAL | 3.9 | 5.9 | False | [{'url': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-vhxv-phmx-g52q', 'name': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-vhxv-phmx-g52q', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'https://github.com/pjsip/pjproject/commit/11559e49e65bdf00922ad5ae28913ec6a198d508', 'name': 'https://github.com/pjsip/pjproject/commit/11559e49e65bdf00922ad5ae28913ec6a198d508', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}, {'lang': 'en', 'value': 'CWE-787'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:pjsip:pjsip:*:*:*:*:*:*:*:*', 'versionEndIncluding': '2.12', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'PJSIP is a free and open source multimedia communication library written in C. PJSIP versions 2.12 and prior do not parse incoming RTCP feedback RPSI (Reference Picture Selection Indication) packet, but any app that directly uses pjmedia_rtcp_fb_parse_rpsi() will be affected. A patch is available in the `master` branch of the `pjsip/pjproject` GitHub repository. There are currently no known workarounds.'}] | 2022-04-13T18:35Z | 2022-04-06T14:15Z | Out-of-bounds Write | The software writes data past the end, or before the beginning, of the intended buffer. | Typically, this can result in corruption of data, a crash, or code execution. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent write operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/787.html | 0 | Riza Sulistyo | 2022-04-06 10:40:09+07:00 | Merge pull request from GHSA-vhxv-phmx-g52q
* Prevent OOB read/write when parsing RTCP FB RPSI
* Add log information
* Modification based on comments. | 11559e49e65bdf00922ad5ae28913ec6a198d508 | False | pjsip/pjproject | PJSIP project | 2016-01-24 05:00:33 | 2022-08-26 15:35:55 | http://www.pjsip.org | pjsip | 1248.0 | 567.0 | pjmedia_rtcp_fb_parse_pli | pjmedia_rtcp_fb_parse_pli( const void * buf , pj_size_t length) | ['buf', 'length'] | PJ_DEF(pj_status_t) pjmedia_rtcp_fb_parse_pli(
const void *buf,
pj_size_t length)
{
pjmedia_rtcp_common *hdr = (pjmedia_rtcp_common*) buf;
PJ_ASSERT_RETURN(buf, PJ_EINVAL);
if (length < 12)
return PJ_ETOOSMALL;
/* PLI uses pt==RTCP_PSFB and FMT==1 */
if (hdr->pt != RTCP_PSFB || hdr->count != 1)
return PJ_ENOTFOUND;
return PJ_SUCCESS;
} | 57 | True | 1 |
CVE-2022-24786 | False | False | False | False | AV:N/AC:L/Au:N/C:P/I:P/A:P | NETWORK | LOW | NONE | PARTIAL | PARTIAL | PARTIAL | 7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | HIGH | HIGH | HIGH | 9.8 | CRITICAL | 3.9 | 5.9 | False | [{'url': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-vhxv-phmx-g52q', 'name': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-vhxv-phmx-g52q', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'https://github.com/pjsip/pjproject/commit/11559e49e65bdf00922ad5ae28913ec6a198d508', 'name': 'https://github.com/pjsip/pjproject/commit/11559e49e65bdf00922ad5ae28913ec6a198d508', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}, {'lang': 'en', 'value': 'CWE-787'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:pjsip:pjsip:*:*:*:*:*:*:*:*', 'versionEndIncluding': '2.12', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'PJSIP is a free and open source multimedia communication library written in C. PJSIP versions 2.12 and prior do not parse incoming RTCP feedback RPSI (Reference Picture Selection Indication) packet, but any app that directly uses pjmedia_rtcp_fb_parse_rpsi() will be affected. A patch is available in the `master` branch of the `pjsip/pjproject` GitHub repository. There are currently no known workarounds.'}] | 2022-04-13T18:35Z | 2022-04-06T14:15Z | Out-of-bounds Read | The software reads data past the end, or before the beginning, of the intended buffer. | Typically, this can allow attackers to read sensitive information from other memory locations or cause a crash. A crash can occur when the code reads a variable amount of data and assumes that a sentinel exists to stop the read operation, such as a NUL in a string. The expected sentinel might not be located in the out-of-bounds memory, causing excessive data to be read, leading to a segmentation fault or a buffer overflow. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent read operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/125.html | 0 | Riza Sulistyo | 2022-04-06 10:40:09+07:00 | Merge pull request from GHSA-vhxv-phmx-g52q
* Prevent OOB read/write when parsing RTCP FB RPSI
* Add log information
* Modification based on comments. | 11559e49e65bdf00922ad5ae28913ec6a198d508 | False | pjsip/pjproject | PJSIP project | 2016-01-24 05:00:33 | 2022-08-26 15:35:55 | http://www.pjsip.org | pjsip | 1248.0 | 567.0 | pjmedia_rtcp_fb_parse_rpsi | pjmedia_rtcp_fb_parse_rpsi( const void * buf , pj_size_t length , pjmedia_rtcp_fb_rpsi * rpsi) | ['buf', 'length', 'rpsi'] | PJ_DEF(pj_status_t) pjmedia_rtcp_fb_parse_rpsi(
const void *buf,
pj_size_t length,
pjmedia_rtcp_fb_rpsi *rpsi)
{
pjmedia_rtcp_common *hdr = (pjmedia_rtcp_common*) buf;
pj_uint8_t *p;
pj_uint8_t padlen;
pj_size_t rpsi_len;
PJ_ASSERT_RETURN(buf && rpsi, PJ_EINVAL);
PJ_ASSERT_RETURN(length >= sizeof(pjmedia_rtcp_common), PJ_ETOOSMALL);
/* RPSI uses pt==RTCP_PSFB and FMT==3 */
if (hdr->pt != RTCP_PSFB || hdr->count != 3)
return PJ_ENOTFOUND;
rpsi_len = (pj_ntohs((pj_uint16_t)hdr->length)-2) * 4;
if (length < rpsi_len + 12)
return PJ_ETOOSMALL;
p = (pj_uint8_t*)hdr + sizeof(*hdr);
padlen = *p++;
rpsi->pt = (*p++ & 0x7F);
rpsi->rpsi_bit_len = rpsi_len*8 - 16 - padlen;
pj_strset(&rpsi->rpsi, (char*)p, (rpsi->rpsi_bit_len + 7)/8);
return PJ_SUCCESS;
} | 173 | True | 1 |
CVE-2022-24786 | False | False | False | False | AV:N/AC:L/Au:N/C:P/I:P/A:P | NETWORK | LOW | NONE | PARTIAL | PARTIAL | PARTIAL | 7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | HIGH | HIGH | HIGH | 9.8 | CRITICAL | 3.9 | 5.9 | False | [{'url': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-vhxv-phmx-g52q', 'name': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-vhxv-phmx-g52q', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'https://github.com/pjsip/pjproject/commit/11559e49e65bdf00922ad5ae28913ec6a198d508', 'name': 'https://github.com/pjsip/pjproject/commit/11559e49e65bdf00922ad5ae28913ec6a198d508', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}, {'lang': 'en', 'value': 'CWE-787'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:pjsip:pjsip:*:*:*:*:*:*:*:*', 'versionEndIncluding': '2.12', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'PJSIP is a free and open source multimedia communication library written in C. PJSIP versions 2.12 and prior do not parse incoming RTCP feedback RPSI (Reference Picture Selection Indication) packet, but any app that directly uses pjmedia_rtcp_fb_parse_rpsi() will be affected. A patch is available in the `master` branch of the `pjsip/pjproject` GitHub repository. There are currently no known workarounds.'}] | 2022-04-13T18:35Z | 2022-04-06T14:15Z | Out-of-bounds Write | The software writes data past the end, or before the beginning, of the intended buffer. | Typically, this can result in corruption of data, a crash, or code execution. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent write operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/787.html | 0 | Riza Sulistyo | 2022-04-06 10:40:09+07:00 | Merge pull request from GHSA-vhxv-phmx-g52q
* Prevent OOB read/write when parsing RTCP FB RPSI
* Add log information
* Modification based on comments. | 11559e49e65bdf00922ad5ae28913ec6a198d508 | False | pjsip/pjproject | PJSIP project | 2016-01-24 05:00:33 | 2022-08-26 15:35:55 | http://www.pjsip.org | pjsip | 1248.0 | 567.0 | pjmedia_rtcp_fb_parse_rpsi | pjmedia_rtcp_fb_parse_rpsi( const void * buf , pj_size_t length , pjmedia_rtcp_fb_rpsi * rpsi) | ['buf', 'length', 'rpsi'] | PJ_DEF(pj_status_t) pjmedia_rtcp_fb_parse_rpsi(
const void *buf,
pj_size_t length,
pjmedia_rtcp_fb_rpsi *rpsi)
{
pjmedia_rtcp_common *hdr = (pjmedia_rtcp_common*) buf;
pj_uint8_t *p;
pj_uint8_t padlen;
pj_size_t rpsi_len;
PJ_ASSERT_RETURN(buf && rpsi, PJ_EINVAL);
PJ_ASSERT_RETURN(length >= sizeof(pjmedia_rtcp_common), PJ_ETOOSMALL);
/* RPSI uses pt==RTCP_PSFB and FMT==3 */
if (hdr->pt != RTCP_PSFB || hdr->count != 3)
return PJ_ENOTFOUND;
rpsi_len = (pj_ntohs((pj_uint16_t)hdr->length)-2) * 4;
if (length < rpsi_len + 12)
return PJ_ETOOSMALL;
p = (pj_uint8_t*)hdr + sizeof(*hdr);
padlen = *p++;
rpsi->pt = (*p++ & 0x7F);
rpsi->rpsi_bit_len = rpsi_len*8 - 16 - padlen;
pj_strset(&rpsi->rpsi, (char*)p, (rpsi->rpsi_bit_len + 7)/8);
return PJ_SUCCESS;
} | 173 | True | 1 |
CVE-2022-24786 | False | False | False | False | AV:N/AC:L/Au:N/C:P/I:P/A:P | NETWORK | LOW | NONE | PARTIAL | PARTIAL | PARTIAL | 7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | HIGH | HIGH | HIGH | 9.8 | CRITICAL | 3.9 | 5.9 | False | [{'url': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-vhxv-phmx-g52q', 'name': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-vhxv-phmx-g52q', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'https://github.com/pjsip/pjproject/commit/11559e49e65bdf00922ad5ae28913ec6a198d508', 'name': 'https://github.com/pjsip/pjproject/commit/11559e49e65bdf00922ad5ae28913ec6a198d508', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}, {'lang': 'en', 'value': 'CWE-787'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:pjsip:pjsip:*:*:*:*:*:*:*:*', 'versionEndIncluding': '2.12', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'PJSIP is a free and open source multimedia communication library written in C. PJSIP versions 2.12 and prior do not parse incoming RTCP feedback RPSI (Reference Picture Selection Indication) packet, but any app that directly uses pjmedia_rtcp_fb_parse_rpsi() will be affected. A patch is available in the `master` branch of the `pjsip/pjproject` GitHub repository. There are currently no known workarounds.'}] | 2022-04-13T18:35Z | 2022-04-06T14:15Z | Out-of-bounds Read | The software reads data past the end, or before the beginning, of the intended buffer. | Typically, this can allow attackers to read sensitive information from other memory locations or cause a crash. A crash can occur when the code reads a variable amount of data and assumes that a sentinel exists to stop the read operation, such as a NUL in a string. The expected sentinel might not be located in the out-of-bounds memory, causing excessive data to be read, leading to a segmentation fault or a buffer overflow. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent read operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/125.html | 0 | Riza Sulistyo | 2022-04-06 10:40:09+07:00 | Merge pull request from GHSA-vhxv-phmx-g52q
* Prevent OOB read/write when parsing RTCP FB RPSI
* Add log information
* Modification based on comments. | 11559e49e65bdf00922ad5ae28913ec6a198d508 | False | pjsip/pjproject | PJSIP project | 2016-01-24 05:00:33 | 2022-08-26 15:35:55 | http://www.pjsip.org | pjsip | 1248.0 | 567.0 | pjmedia_rtcp_fb_parse_sli | pjmedia_rtcp_fb_parse_sli( const void * buf , pj_size_t length , unsigned * sli_cnt , pjmedia_rtcp_fb_sli sli [ ]) | ['buf', 'length', 'sli_cnt'] | PJ_DEF(pj_status_t) pjmedia_rtcp_fb_parse_sli(
const void *buf,
pj_size_t length,
unsigned *sli_cnt,
pjmedia_rtcp_fb_sli sli[])
{
pjmedia_rtcp_common *hdr = (pjmedia_rtcp_common*) buf;
pj_uint8_t *p;
unsigned cnt, i;
PJ_ASSERT_RETURN(buf && sli_cnt && sli, PJ_EINVAL);
PJ_ASSERT_RETURN(length >= sizeof(pjmedia_rtcp_common), PJ_ETOOSMALL);
/* PLI uses pt==RTCP_PSFB and FMT==2 */
if (hdr->pt != RTCP_PSFB || hdr->count != 2)
return PJ_ENOTFOUND;
cnt = pj_ntohs((pj_uint16_t)hdr->length) - 2;
if (length < (cnt+3)*4)
return PJ_ETOOSMALL;
*sli_cnt = PJ_MIN(*sli_cnt, cnt);
p = (pj_uint8_t*)hdr + sizeof(*hdr);
for (i = 0; i < *sli_cnt; ++i) {
/* 'first' takes 13 bit */
sli[i].first = (p[0] << 5) + ((p[1] & 0xF8) >> 3);
/* 'number' takes 13 bit */
sli[i].number = ((p[1] & 0x07) << 10) +
(p[2] << 2) +
((p[3] & 0xC0) >> 6);
/* 'pict_id' takes 6 bit */
sli[i].pict_id = (p[3] & 0x3F);
p += 4;
}
return PJ_SUCCESS;
} | 248 | True | 1 |
CVE-2022-24786 | False | False | False | False | AV:N/AC:L/Au:N/C:P/I:P/A:P | NETWORK | LOW | NONE | PARTIAL | PARTIAL | PARTIAL | 7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | HIGH | HIGH | HIGH | 9.8 | CRITICAL | 3.9 | 5.9 | False | [{'url': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-vhxv-phmx-g52q', 'name': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-vhxv-phmx-g52q', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'https://github.com/pjsip/pjproject/commit/11559e49e65bdf00922ad5ae28913ec6a198d508', 'name': 'https://github.com/pjsip/pjproject/commit/11559e49e65bdf00922ad5ae28913ec6a198d508', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}, {'lang': 'en', 'value': 'CWE-787'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:pjsip:pjsip:*:*:*:*:*:*:*:*', 'versionEndIncluding': '2.12', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'PJSIP is a free and open source multimedia communication library written in C. PJSIP versions 2.12 and prior do not parse incoming RTCP feedback RPSI (Reference Picture Selection Indication) packet, but any app that directly uses pjmedia_rtcp_fb_parse_rpsi() will be affected. A patch is available in the `master` branch of the `pjsip/pjproject` GitHub repository. There are currently no known workarounds.'}] | 2022-04-13T18:35Z | 2022-04-06T14:15Z | Out-of-bounds Write | The software writes data past the end, or before the beginning, of the intended buffer. | Typically, this can result in corruption of data, a crash, or code execution. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent write operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/787.html | 0 | Riza Sulistyo | 2022-04-06 10:40:09+07:00 | Merge pull request from GHSA-vhxv-phmx-g52q
* Prevent OOB read/write when parsing RTCP FB RPSI
* Add log information
* Modification based on comments. | 11559e49e65bdf00922ad5ae28913ec6a198d508 | False | pjsip/pjproject | PJSIP project | 2016-01-24 05:00:33 | 2022-08-26 15:35:55 | http://www.pjsip.org | pjsip | 1248.0 | 567.0 | pjmedia_rtcp_fb_parse_sli | pjmedia_rtcp_fb_parse_sli( const void * buf , pj_size_t length , unsigned * sli_cnt , pjmedia_rtcp_fb_sli sli [ ]) | ['buf', 'length', 'sli_cnt'] | PJ_DEF(pj_status_t) pjmedia_rtcp_fb_parse_sli(
const void *buf,
pj_size_t length,
unsigned *sli_cnt,
pjmedia_rtcp_fb_sli sli[])
{
pjmedia_rtcp_common *hdr = (pjmedia_rtcp_common*) buf;
pj_uint8_t *p;
unsigned cnt, i;
PJ_ASSERT_RETURN(buf && sli_cnt && sli, PJ_EINVAL);
PJ_ASSERT_RETURN(length >= sizeof(pjmedia_rtcp_common), PJ_ETOOSMALL);
/* PLI uses pt==RTCP_PSFB and FMT==2 */
if (hdr->pt != RTCP_PSFB || hdr->count != 2)
return PJ_ENOTFOUND;
cnt = pj_ntohs((pj_uint16_t)hdr->length) - 2;
if (length < (cnt+3)*4)
return PJ_ETOOSMALL;
*sli_cnt = PJ_MIN(*sli_cnt, cnt);
p = (pj_uint8_t*)hdr + sizeof(*hdr);
for (i = 0; i < *sli_cnt; ++i) {
/* 'first' takes 13 bit */
sli[i].first = (p[0] << 5) + ((p[1] & 0xF8) >> 3);
/* 'number' takes 13 bit */
sli[i].number = ((p[1] & 0x07) << 10) +
(p[2] << 2) +
((p[3] & 0xC0) >> 6);
/* 'pict_id' takes 6 bit */
sli[i].pict_id = (p[3] & 0x3F);
p += 4;
}
return PJ_SUCCESS;
} | 248 | True | 1 |
CVE-2022-24793 | False | False | False | False | AV:N/AC:M/Au:N/C:N/I:N/A:P | NETWORK | MEDIUM | NONE | NONE | NONE | PARTIAL | 4.3 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | NONE | NONE | HIGH | 7.5 | HIGH | 3.9 | 3.6 | False | [{'url': 'https://github.com/pjsip/pjproject/commit/9fae8f43accef8ea65d4a8ae9cdf297c46cfe29a', 'name': 'https://github.com/pjsip/pjproject/commit/9fae8f43accef8ea65d4a8ae9cdf297c46cfe29a', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-p6g5-v97c-w5q4', 'name': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-p6g5-v97c-w5q4', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2022/05/msg00047.html', 'name': '[debian-lts-announce] 20220531 [SECURITY] [DLA 3036-1] pjproject security update', 'refsource': 'MLIST', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-120'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:pjsip:pjsip:*:*:*:*:*:*:*:*', 'versionEndIncluding': '2.12', 'cpe_name': []}]}] | [{'lang': 'en', 'value': "PJSIP is a free and open source multimedia communication library written in C. A buffer overflow vulnerability in versions 2.12 and prior affects applications that uses PJSIP DNS resolution. It doesn't affect PJSIP users who utilize an external resolver. A patch is available in the `master` branch of the `pjsip/pjproject` GitHub repository. A workaround is to disable DNS resolution in PJSIP config (by setting `nameserver_count` to zero) or use an external resolver instead."}] | 2022-06-02T14:15Z | 2022-04-06T14:15Z | Buffer Copy without Checking Size of Input ('Classic Buffer Overflow') | The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow. | A buffer overflow condition exists when a program attempts to put more data in a buffer than it can hold, or when a program attempts to put data in a memory area outside of the boundaries of a buffer. The simplest type of error, and the most common cause of buffer overflows, is the "classic" case in which the program copies the buffer without restricting how much is copied. Other variants exist, but the existence of a classic overflow strongly suggests that the programmer is not considering even the most basic of security protections.
| https://cwe.mitre.org/data/definitions/120.html | 0 | Riza Sulistyo | 2022-04-06 10:49:47+07:00 | Merge pull request from GHSA-p6g5-v97c-w5q4
* Prevent heap buffer overflow when parsing DNS packets
* Make sure packet parsing doesn't advance beyond max/end
* Update checks
* Remove check
Co-authored-by: sauwming <ming@teluu.com> | 9fae8f43accef8ea65d4a8ae9cdf297c46cfe29a | False | pjsip/pjproject | PJSIP project | 2016-01-24 05:00:33 | 2022-08-26 15:35:55 | http://www.pjsip.org | pjsip | 1248.0 | 567.0 | get_name | get_name( int rec_counter , const pj_uint8_t * pkt , const pj_uint8_t * start , const pj_uint8_t * max , pj_str_t * name) | ['rec_counter', 'pkt', 'start', 'max', 'name'] | static pj_status_t get_name(int rec_counter, const pj_uint8_t *pkt,
const pj_uint8_t *start, const pj_uint8_t *max,
pj_str_t *name)
{
const pj_uint8_t *p;
pj_status_t status;
/* Limit the number of recursion */
if (rec_counter > 10) {
/* Too many name recursion */
return PJLIB_UTIL_EDNSINNAMEPTR;
}
p = start;
while (*p) {
if ((*p & 0xc0) == 0xc0) {
/* Compression is found! */
pj_uint16_t offset;
/* Get the 14bit offset */
pj_memcpy(&offset, p, 2);
offset ^= pj_htons((pj_uint16_t)(0xc0 << 8));
offset = pj_ntohs(offset);
/* Check that offset is valid */
if (offset >= max - pkt)
return PJLIB_UTIL_EDNSINNAMEPTR;
/* Retrieve the name from that offset. */
status = get_name(rec_counter+1, pkt, pkt + offset, max, name);
if (status != PJ_SUCCESS)
return status;
return PJ_SUCCESS;
} else {
unsigned label_len = *p;
/* Check that label length is valid */
if (pkt+label_len > max)
return PJLIB_UTIL_EDNSINNAMEPTR;
pj_memcpy(name->ptr + name->slen, p+1, label_len);
name->slen += label_len;
p += label_len + 1;
if (*p != 0) {
*(name->ptr + name->slen) = '.';
++name->slen;
}
if (p >= max)
return PJLIB_UTIL_EDNSINSIZE;
}
}
return PJ_SUCCESS;
} | 234 | True | 1 |
CVE-2022-24793 | False | False | False | False | AV:N/AC:M/Au:N/C:N/I:N/A:P | NETWORK | MEDIUM | NONE | NONE | NONE | PARTIAL | 4.3 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | NONE | NONE | HIGH | 7.5 | HIGH | 3.9 | 3.6 | False | [{'url': 'https://github.com/pjsip/pjproject/commit/9fae8f43accef8ea65d4a8ae9cdf297c46cfe29a', 'name': 'https://github.com/pjsip/pjproject/commit/9fae8f43accef8ea65d4a8ae9cdf297c46cfe29a', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-p6g5-v97c-w5q4', 'name': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-p6g5-v97c-w5q4', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2022/05/msg00047.html', 'name': '[debian-lts-announce] 20220531 [SECURITY] [DLA 3036-1] pjproject security update', 'refsource': 'MLIST', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-120'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:pjsip:pjsip:*:*:*:*:*:*:*:*', 'versionEndIncluding': '2.12', 'cpe_name': []}]}] | [{'lang': 'en', 'value': "PJSIP is a free and open source multimedia communication library written in C. A buffer overflow vulnerability in versions 2.12 and prior affects applications that uses PJSIP DNS resolution. It doesn't affect PJSIP users who utilize an external resolver. A patch is available in the `master` branch of the `pjsip/pjproject` GitHub repository. A workaround is to disable DNS resolution in PJSIP config (by setting `nameserver_count` to zero) or use an external resolver instead."}] | 2022-06-02T14:15Z | 2022-04-06T14:15Z | Buffer Copy without Checking Size of Input ('Classic Buffer Overflow') | The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow. | A buffer overflow condition exists when a program attempts to put more data in a buffer than it can hold, or when a program attempts to put data in a memory area outside of the boundaries of a buffer. The simplest type of error, and the most common cause of buffer overflows, is the "classic" case in which the program copies the buffer without restricting how much is copied. Other variants exist, but the existence of a classic overflow strongly suggests that the programmer is not considering even the most basic of security protections.
| https://cwe.mitre.org/data/definitions/120.html | 0 | Riza Sulistyo | 2022-04-06 10:49:47+07:00 | Merge pull request from GHSA-p6g5-v97c-w5q4
* Prevent heap buffer overflow when parsing DNS packets
* Make sure packet parsing doesn't advance beyond max/end
* Update checks
* Remove check
Co-authored-by: sauwming <ming@teluu.com> | 9fae8f43accef8ea65d4a8ae9cdf297c46cfe29a | False | pjsip/pjproject | PJSIP project | 2016-01-24 05:00:33 | 2022-08-26 15:35:55 | http://www.pjsip.org | pjsip | 1248.0 | 567.0 | get_name_len | get_name_len( int rec_counter , const pj_uint8_t * pkt , const pj_uint8_t * start , const pj_uint8_t * max , int * parsed_len , int * name_len) | ['rec_counter', 'pkt', 'start', 'max', 'parsed_len', 'name_len'] | static pj_status_t get_name_len(int rec_counter, const pj_uint8_t *pkt,
const pj_uint8_t *start, const pj_uint8_t *max,
int *parsed_len, int *name_len)
{
const pj_uint8_t *p;
pj_status_t status;
/* Limit the number of recursion */
if (rec_counter > 10) {
/* Too many name recursion */
return PJLIB_UTIL_EDNSINNAMEPTR;
}
*name_len = *parsed_len = 0;
p = start;
while (*p) {
if ((*p & 0xc0) == 0xc0) {
/* Compression is found! */
int ptr_len = 0;
int dummy;
pj_uint16_t offset;
/* Get the 14bit offset */
pj_memcpy(&offset, p, 2);
offset ^= pj_htons((pj_uint16_t)(0xc0 << 8));
offset = pj_ntohs(offset);
/* Check that offset is valid */
if (offset >= max - pkt)
return PJLIB_UTIL_EDNSINNAMEPTR;
/* Get the name length from that offset. */
status = get_name_len(rec_counter+1, pkt, pkt + offset, max,
&dummy, &ptr_len);
if (status != PJ_SUCCESS)
return status;
*parsed_len += 2;
*name_len += ptr_len;
return PJ_SUCCESS;
} else {
unsigned label_len = *p;
/* Check that label length is valid */
if (pkt+label_len > max)
return PJLIB_UTIL_EDNSINNAMEPTR;
p += (label_len + 1);
*parsed_len += (label_len + 1);
if (*p != 0)
++label_len;
*name_len += label_len;
if (p >= max)
return PJLIB_UTIL_EDNSINSIZE;
}
}
++p;
(*parsed_len)++;
return PJ_SUCCESS;
} | 253 | True | 1 |
CVE-2022-24792 | False | False | False | False | AV:N/AC:M/Au:N/C:N/I:N/A:P | NETWORK | MEDIUM | NONE | NONE | NONE | PARTIAL | 4.3 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | NONE | NONE | HIGH | 7.5 | HIGH | 3.9 | 3.6 | False | [{'url': 'https://github.com/pjsip/pjproject/commit/947bc1ee6d05be10204b918df75a503415fd3213', 'name': 'https://github.com/pjsip/pjproject/commit/947bc1ee6d05be10204b918df75a503415fd3213', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-rwgw-vwxg-q799', 'name': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-rwgw-vwxg-q799', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2022/05/msg00047.html', 'name': '[debian-lts-announce] 20220531 [SECURITY] [DLA 3036-1] pjproject security update', 'refsource': 'MLIST', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-835'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:teluu:pjsip:*:*:*:*:*:*:x86:*', 'versionEndIncluding': '2.12', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'PJSIP is a free and open source multimedia communication library written in C. A denial-of-service vulnerability affects applications on a 32-bit systems that use PJSIP versions 2.12 and prior to play/read invalid WAV files. The vulnerability occurs when reading WAV file data chunks with length greater than 31-bit integers. The vulnerability does not affect 64-bit apps and should not affect apps that only plays trusted WAV files. A patch is available on the `master` branch of the `pjsip/project` GitHub repository. As a workaround, apps can reject a WAV file received from an unknown source or validate the file first.'}] | 2022-06-02T14:15Z | 2022-04-25T16:16Z | Loop with Unreachable Exit Condition ('Infinite Loop') | The program contains an iteration or loop with an exit condition that cannot be reached, i.e., an infinite loop. | If the loop can be influenced by an attacker, this weakness could allow attackers to consume excessive resources such as CPU or memory.
| https://cwe.mitre.org/data/definitions/835.html | 0 | Riza Sulistyo | 2022-04-25 11:54:19+07:00 | Merge pull request from GHSA-rwgw-vwxg-q799
* Prevent potential infinite loop when parsing WAV format file
* Check if subchunk is negative.
* Fix and add checks
* Change data type from pj_ssize_t to long.
* Modify check
* Fix leak file descriptor and modify check on wav_playlist
* Move overflow/underflow check to pj_file_setpos()
* Use macro to simplify check
* modification based on comments
* Remove unnecessary casting
* Modification based on comments | 947bc1ee6d05be10204b918df75a503415fd3213 | False | pjsip/pjproject | PJSIP project | 2016-01-24 05:00:33 | 2022-08-26 15:35:55 | http://www.pjsip.org | pjsip | 1248.0 | 567.0 | avi_get_frame | avi_get_frame( pjmedia_port * this_port , pjmedia_frame * frame) | ['this_port', 'frame'] | static pj_status_t avi_get_frame(pjmedia_port *this_port,
pjmedia_frame *frame)
{
struct avi_reader_port *fport = (struct avi_reader_port*)this_port;
pj_status_t status = PJ_SUCCESS;
pj_ssize_t size_read = 0, size_to_read = 0;
pj_assert(fport->base.info.signature == SIGNATURE);
/* We encountered end of file */
if (fport->eof) {
PJ_LOG(5,(THIS_FILE, "File port %.*s EOF",
(int)fport->base.info.name.slen,
fport->base.info.name.ptr));
/* Call callback, if any */
if (fport->cb2) {
pj_bool_t no_loop = (fport->options & PJMEDIA_AVI_FILE_NO_LOOP);
if (!fport->subscribed) {
status = pjmedia_event_subscribe(NULL, &file_on_event,
fport, fport);
fport->subscribed = (status == PJ_SUCCESS)? PJ_TRUE:
PJ_FALSE;
}
if (fport->subscribed && fport->eof != 2) {
pjmedia_event event;
if (no_loop) {
/* To prevent the callback from being called repeatedly */
fport->eof = 2;
} else {
fport->eof = PJ_FALSE;
pj_file_setpos(fport->fd, fport->start_data, PJ_SEEK_SET);
}
pjmedia_event_init(&event, PJMEDIA_EVENT_CALLBACK,
NULL, fport);
pjmedia_event_publish(NULL, fport, &event,
PJMEDIA_EVENT_PUBLISH_POST_EVENT);
}
/* Should not access player port after this since
* it might have been destroyed by the callback.
*/
frame->type = PJMEDIA_FRAME_TYPE_NONE;
frame->size = 0;
return (no_loop? PJ_EEOF: PJ_SUCCESS);
} else if (fport->cb) {
status = (*fport->cb)(this_port, fport->base.port_data.pdata);
}
/* If callback returns non PJ_SUCCESS or 'no loop' is specified,
* return immediately (and don't try to access player port since
* it might have been destroyed by the callback).
*/
if ((status != PJ_SUCCESS) ||
(fport->options & PJMEDIA_AVI_FILE_NO_LOOP))
{
frame->type = PJMEDIA_FRAME_TYPE_NONE;
frame->size = 0;
return PJ_EEOF;
}
/* Rewind file */
PJ_LOG(5,(THIS_FILE, "File port %.*s rewinding..",
(int)fport->base.info.name.slen,
fport->base.info.name.ptr));
fport->eof = PJ_FALSE;
pj_file_setpos(fport->fd, fport->start_data, PJ_SEEK_SET);
}
/* For PCMU/A audio stream, reduce frame size to half (temporarily). */
if (fport->base.info.fmt.type == PJMEDIA_TYPE_AUDIO &&
(fport->fmt_id == PJMEDIA_FORMAT_PCMA ||
fport->fmt_id == PJMEDIA_FORMAT_PCMU))
{
frame->size >>= 1;
}
/* Fill frame buffer. */
size_to_read = frame->size;
do {
pjmedia_avi_subchunk ch = {0, 0};
char *cid;
unsigned stream_id;
/* We need to read data from the file past the chunk boundary */
if (fport->size_left > 0 && fport->size_left < size_to_read) {
status = file_read3(fport->fd, frame->buf, fport->size_left,
fport->bits_per_sample, &size_read);
if (status != PJ_SUCCESS)
goto on_error2;
size_to_read -= fport->size_left;
fport->size_left = 0;
}
/* Read new chunk data */
if (fport->size_left == 0) {
pj_off_t pos;
pj_file_getpos(fport->fd, &pos);
/* Data is padded to the nearest WORD boundary */
if (fport->pad) {
status = pj_file_setpos(fport->fd, fport->pad, PJ_SEEK_CUR);
fport->pad = 0;
}
status = file_read(fport->fd, &ch, sizeof(pjmedia_avi_subchunk));
if (status != PJ_SUCCESS) {
size_read = 0;
goto on_error2;
}
cid = (char *)&ch.id;
if (cid[0] >= '0' && cid[0] <= '9' &&
cid[1] >= '0' && cid[1] <= '9')
{
stream_id = (cid[0] - '0') * 10 + (cid[1] - '0');
} else
stream_id = 100;
fport->pad = (pj_uint8_t)ch.len & 1;
TRACE_((THIS_FILE, "Reading movi data at pos %u (%x), id: %.*s, "
"length: %u", (unsigned long)pos,
(unsigned long)pos, 4, cid, ch.len));
/* We are only interested in data with our stream id */
if (stream_id != fport->stream_id) {
if (COMPARE_TAG(ch.id, PJMEDIA_AVI_LIST_TAG))
PJ_LOG(5, (THIS_FILE, "Unsupported LIST tag found in "
"the movi data."));
else if (COMPARE_TAG(ch.id, PJMEDIA_AVI_RIFF_TAG)) {
PJ_LOG(3, (THIS_FILE, "Unsupported format: multiple "
"AVIs in a single file."));
status = AVI_EOF;
goto on_error2;
}
status = pj_file_setpos(fport->fd, ch.len,
PJ_SEEK_CUR);
continue;
}
fport->size_left = ch.len;
}
frame->type = (fport->base.info.fmt.type == PJMEDIA_TYPE_VIDEO ?
PJMEDIA_FRAME_TYPE_VIDEO : PJMEDIA_FRAME_TYPE_AUDIO);
if (frame->type == PJMEDIA_FRAME_TYPE_AUDIO) {
if (size_to_read > fport->size_left)
size_to_read = fport->size_left;
status = file_read3(fport->fd, (char *)frame->buf + frame->size -
size_to_read, size_to_read,
fport->bits_per_sample, &size_read);
if (status != PJ_SUCCESS)
goto on_error2;
fport->size_left -= size_to_read;
} else {
pj_assert(frame->size >= ch.len);
status = file_read3(fport->fd, frame->buf, ch.len,
0, &size_read);
if (status != PJ_SUCCESS)
goto on_error2;
frame->size = ch.len;
fport->size_left = 0;
}
break;
} while(1);
frame->timestamp.u64 = fport->next_ts.u64;
if (frame->type == PJMEDIA_FRAME_TYPE_AUDIO) {
/* Decode PCMU/A frame */
if (fport->fmt_id == PJMEDIA_FORMAT_PCMA ||
fport->fmt_id == PJMEDIA_FORMAT_PCMU)
{
unsigned i;
pj_uint16_t *dst;
pj_uint8_t *src;
dst = (pj_uint16_t*)frame->buf + frame->size - 1;
src = (pj_uint8_t*)frame->buf + frame->size - 1;
if (fport->fmt_id == PJMEDIA_FORMAT_PCMU) {
for (i = 0; i < frame->size; ++i) {
*dst-- = (pj_uint16_t) pjmedia_ulaw2linear(*src--);
}
} else {
for (i = 0; i < frame->size; ++i) {
*dst-- = (pj_uint16_t) pjmedia_alaw2linear(*src--);
}
}
/* Return back the frame size */
frame->size <<= 1;
}
if (fport->usec_per_frame) {
fport->next_ts.u64 += (fport->usec_per_frame *
fport->base.info.fmt.det.aud.clock_rate /
1000000);
} else {
fport->next_ts.u64 += (frame->size *
fport->base.info.fmt.det.aud.clock_rate /
(fport->base.info.fmt.det.aud.avg_bps / 8));
}
} else {
if (fport->usec_per_frame) {
fport->next_ts.u64 += (fport->usec_per_frame * VIDEO_CLOCK_RATE /
1000000);
} else {
fport->next_ts.u64 += (frame->size * VIDEO_CLOCK_RATE /
(fport->base.info.fmt.det.vid.avg_bps / 8));
}
}
return PJ_SUCCESS;
on_error2:
if (status == AVI_EOF) {
fport->eof = PJ_TRUE;
size_to_read -= size_read;
if (size_to_read == (pj_ssize_t)frame->size) {
/* Frame is empty */
frame->type = PJMEDIA_FRAME_TYPE_NONE;
frame->size = 0;
return PJ_EEOF;
}
pj_bzero((char *)frame->buf + frame->size - size_to_read,
size_to_read);
return PJ_SUCCESS;
}
return status;
} | 1312 | True | 1 |
CVE-2022-24792 | False | False | False | False | AV:N/AC:M/Au:N/C:N/I:N/A:P | NETWORK | MEDIUM | NONE | NONE | NONE | PARTIAL | 4.3 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | NONE | NONE | HIGH | 7.5 | HIGH | 3.9 | 3.6 | False | [{'url': 'https://github.com/pjsip/pjproject/commit/947bc1ee6d05be10204b918df75a503415fd3213', 'name': 'https://github.com/pjsip/pjproject/commit/947bc1ee6d05be10204b918df75a503415fd3213', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-rwgw-vwxg-q799', 'name': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-rwgw-vwxg-q799', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2022/05/msg00047.html', 'name': '[debian-lts-announce] 20220531 [SECURITY] [DLA 3036-1] pjproject security update', 'refsource': 'MLIST', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-835'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:teluu:pjsip:*:*:*:*:*:*:x86:*', 'versionEndIncluding': '2.12', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'PJSIP is a free and open source multimedia communication library written in C. A denial-of-service vulnerability affects applications on a 32-bit systems that use PJSIP versions 2.12 and prior to play/read invalid WAV files. The vulnerability occurs when reading WAV file data chunks with length greater than 31-bit integers. The vulnerability does not affect 64-bit apps and should not affect apps that only plays trusted WAV files. A patch is available on the `master` branch of the `pjsip/project` GitHub repository. As a workaround, apps can reject a WAV file received from an unknown source or validate the file first.'}] | 2022-06-02T14:15Z | 2022-04-25T16:16Z | Loop with Unreachable Exit Condition ('Infinite Loop') | The program contains an iteration or loop with an exit condition that cannot be reached, i.e., an infinite loop. | If the loop can be influenced by an attacker, this weakness could allow attackers to consume excessive resources such as CPU or memory.
| https://cwe.mitre.org/data/definitions/835.html | 0 | Riza Sulistyo | 2022-04-25 11:54:19+07:00 | Merge pull request from GHSA-rwgw-vwxg-q799
* Prevent potential infinite loop when parsing WAV format file
* Check if subchunk is negative.
* Fix and add checks
* Change data type from pj_ssize_t to long.
* Modify check
* Fix leak file descriptor and modify check on wav_playlist
* Move overflow/underflow check to pj_file_setpos()
* Use macro to simplify check
* modification based on comments
* Remove unnecessary casting
* Modification based on comments | 947bc1ee6d05be10204b918df75a503415fd3213 | False | pjsip/pjproject | PJSIP project | 2016-01-24 05:00:33 | 2022-08-26 15:35:55 | http://www.pjsip.org | pjsip | 1248.0 | 567.0 | pjmedia_avi_player_create_streams | pjmedia_avi_player_create_streams( pj_pool_t * pool , const char * filename , unsigned options , pjmedia_avi_streams ** p_streams) | ['pool', 'filename', 'options', 'p_streams'] | pjmedia_avi_player_create_streams(pj_pool_t *pool,
const char *filename,
unsigned options,
pjmedia_avi_streams **p_streams)
{
pjmedia_avi_hdr avi_hdr;
struct avi_reader_port *fport[PJMEDIA_AVI_MAX_NUM_STREAMS];
pj_off_t pos;
unsigned i, nstr = 0;
pj_status_t status = PJ_SUCCESS;
/* Check arguments. */
PJ_ASSERT_RETURN(pool && filename && p_streams, PJ_EINVAL);
/* Check the file really exists. */
if (!pj_file_exists(filename)) {
return PJ_ENOTFOUND;
}
/* Create fport instance. */
fport[0] = create_avi_port(pool);
if (!fport[0]) {
return PJ_ENOMEM;
}
/* Get the file size. */
fport[0]->fsize = pj_file_size(filename);
/* Size must be more than AVI header size */
if (fport[0]->fsize <= sizeof(riff_hdr_t) + sizeof(avih_hdr_t) +
sizeof(strl_hdr_t))
{
return PJMEDIA_EINVALIMEDIATYPE;
}
/* Open file. */
status = pj_file_open(pool, filename, PJ_O_RDONLY, &fport[0]->fd);
if (status != PJ_SUCCESS)
return status;
/* Read the RIFF + AVIH header. */
status = file_read(fport[0]->fd, &avi_hdr,
sizeof(riff_hdr_t) + sizeof(avih_hdr_t));
if (status != PJ_SUCCESS)
goto on_error;
/* Validate AVI file. */
if (!COMPARE_TAG(avi_hdr.riff_hdr.riff, PJMEDIA_AVI_RIFF_TAG) ||
!COMPARE_TAG(avi_hdr.riff_hdr.avi, PJMEDIA_AVI_AVI_TAG) ||
!COMPARE_TAG(avi_hdr.avih_hdr.list_tag, PJMEDIA_AVI_LIST_TAG) ||
!COMPARE_TAG(avi_hdr.avih_hdr.hdrl_tag, PJMEDIA_AVI_HDRL_TAG) ||
!COMPARE_TAG(avi_hdr.avih_hdr.avih, PJMEDIA_AVI_AVIH_TAG))
{
status = PJMEDIA_EINVALIMEDIATYPE;
goto on_error;
}
PJ_LOG(5, (THIS_FILE, "The AVI file has %d streams.",
avi_hdr.avih_hdr.num_streams));
/* Unsupported AVI format. */
if (avi_hdr.avih_hdr.num_streams > PJMEDIA_AVI_MAX_NUM_STREAMS) {
status = PJMEDIA_EAVIUNSUPP;
goto on_error;
}
/**
* TODO: Possibly unsupported AVI format.
* If you encounter this warning, verify whether the avi player
* is working properly.
*/
if (avi_hdr.avih_hdr.flags & AVIF_MUSTUSEINDEX ||
avi_hdr.avih_hdr.pad > 1)
{
PJ_LOG(3, (THIS_FILE, "Warning!!! Possibly unsupported AVI format: "
"flags:%d, pad:%d", avi_hdr.avih_hdr.flags,
avi_hdr.avih_hdr.pad));
}
/* Read the headers of each stream. */
for (i = 0; i < avi_hdr.avih_hdr.num_streams; i++) {
pj_size_t elem = 0;
pj_ssize_t size_to_read;
/* Read strl header */
status = file_read(fport[0]->fd, &avi_hdr.strl_hdr[i],
sizeof(strl_hdr_t));
if (status != PJ_SUCCESS)
goto on_error;
elem = COMPARE_TAG(avi_hdr.strl_hdr[i].data_type,
PJMEDIA_AVI_VIDS_TAG) ?
sizeof(strf_video_hdr_t) :
COMPARE_TAG(avi_hdr.strl_hdr[i].data_type,
PJMEDIA_AVI_AUDS_TAG) ?
sizeof(strf_audio_hdr_t) : 0;
/* Read strf header */
status = file_read2(fport[0]->fd, &avi_hdr.strf_hdr[i],
elem, 0);
if (status != PJ_SUCCESS)
goto on_error;
/* Normalize the endian */
if (elem == sizeof(strf_video_hdr_t))
data_to_host2(&avi_hdr.strf_hdr[i],
sizeof(strf_video_hdr_sizes)/
sizeof(strf_video_hdr_sizes[0]),
strf_video_hdr_sizes);
else if (elem == sizeof(strf_audio_hdr_t))
data_to_host2(&avi_hdr.strf_hdr[i],
sizeof(strf_audio_hdr_sizes)/
sizeof(strf_audio_hdr_sizes[0]),
strf_audio_hdr_sizes);
/* Skip the remainder of the header */
size_to_read = avi_hdr.strl_hdr[i].list_sz - (sizeof(strl_hdr_t) -
8) - elem;
status = pj_file_setpos(fport[0]->fd, size_to_read, PJ_SEEK_CUR);
if (status != PJ_SUCCESS) {
goto on_error;
}
}
/* Finish reading the AVIH header */
status = pj_file_setpos(fport[0]->fd, avi_hdr.avih_hdr.list_sz +
sizeof(riff_hdr_t) + 8, PJ_SEEK_SET);
if (status != PJ_SUCCESS) {
goto on_error;
}
/* Skip any JUNK or LIST INFO until we get MOVI tag */
do {
pjmedia_avi_subchunk ch;
int read = 0;
status = file_read(fport[0]->fd, &ch, sizeof(pjmedia_avi_subchunk));
if (status != PJ_SUCCESS) {
goto on_error;
}
if (COMPARE_TAG(ch.id, PJMEDIA_AVI_LIST_TAG))
{
read = 4;
status = file_read(fport[0]->fd, &ch, read);
if (COMPARE_TAG(ch.id, PJMEDIA_AVI_MOVI_TAG))
break;
}
status = pj_file_setpos(fport[0]->fd, ch.len-read, PJ_SEEK_CUR);
if (status != PJ_SUCCESS) {
goto on_error;
}
} while(1);
status = pj_file_getpos(fport[0]->fd, &pos);
if (status != PJ_SUCCESS)
goto on_error;
for (i = 0, nstr = 0; i < avi_hdr.avih_hdr.num_streams; i++) {
pjmedia_format_id fmt_id;
/* Skip non-audio, non-video, or disabled streams) */
if ((!COMPARE_TAG(avi_hdr.strl_hdr[i].data_type,
PJMEDIA_AVI_VIDS_TAG) &&
!COMPARE_TAG(avi_hdr.strl_hdr[i].data_type,
PJMEDIA_AVI_AUDS_TAG)) ||
avi_hdr.strl_hdr[i].flags & AVISF_DISABLED)
{
continue;
}
if (COMPARE_TAG(avi_hdr.strl_hdr[i].data_type,
PJMEDIA_AVI_VIDS_TAG))
{
int j;
if (avi_hdr.strl_hdr[i].flags & AVISF_VIDEO_PALCHANGES) {
PJ_LOG(4, (THIS_FILE, "Unsupported video stream"));
continue;
}
fmt_id = avi_hdr.strl_hdr[i].codec;
for (j = sizeof(avi_fmts)/sizeof(avi_fmts[0])-1; j >= 0; j--) {
/* Check supported video formats here */
if (fmt_id == avi_fmts[j].fmt_id) {
if (avi_fmts[j].eff_fmt_id)
fmt_id = avi_fmts[j].eff_fmt_id;
break;
}
}
if (j < 0) {
PJ_LOG(4, (THIS_FILE, "Unsupported video stream"));
continue;
}
} else {
/* Check supported audio formats here */
strf_audio_hdr_t *hdr = (strf_audio_hdr_t*)
&avi_hdr.strf_hdr[i].strf_audio_hdr;
if (hdr->fmt_tag == PJMEDIA_WAVE_FMT_TAG_PCM &&
hdr->bits_per_sample == 16)
{
fmt_id = PJMEDIA_FORMAT_PCM;
}
else if (hdr->fmt_tag == PJMEDIA_WAVE_FMT_TAG_ALAW)
{
fmt_id = PJMEDIA_FORMAT_PCMA;
}
else if (hdr->fmt_tag == PJMEDIA_WAVE_FMT_TAG_ULAW)
{
fmt_id = PJMEDIA_FORMAT_PCMU;
}
else
{
PJ_LOG(4, (THIS_FILE, "Unsupported audio stream"));
continue;
}
}
if (nstr > 0) {
/* Create fport instance. */
fport[nstr] = create_avi_port(pool);
if (!fport[nstr]) {
status = PJ_ENOMEM;
goto on_error;
}
/* Open file. */
status = pj_file_open(pool, filename, PJ_O_RDONLY,
&fport[nstr]->fd);
if (status != PJ_SUCCESS)
goto on_error;
/* Set the file position */
status = pj_file_setpos(fport[nstr]->fd, pos, PJ_SEEK_SET);
if (status != PJ_SUCCESS) {
goto on_error;
}
}
fport[nstr]->stream_id = i;
fport[nstr]->fmt_id = fmt_id;
nstr++;
}
if (nstr == 0) {
status = PJMEDIA_EAVIUNSUPP;
goto on_error;
}
for (i = 0; i < nstr; i++) {
strl_hdr_t *strl_hdr = &avi_hdr.strl_hdr[fport[i]->stream_id];
/* Initialize */
fport[i]->options = options;
fport[i]->fsize = fport[0]->fsize;
/* Current file position now points to start of data */
fport[i]->start_data = pos;
if (COMPARE_TAG(strl_hdr->data_type, PJMEDIA_AVI_VIDS_TAG)) {
strf_video_hdr_t *strf_hdr =
&avi_hdr.strf_hdr[fport[i]->stream_id].strf_video_hdr;
const pjmedia_video_format_info *vfi;
vfi = pjmedia_get_video_format_info(
pjmedia_video_format_mgr_instance(),
strl_hdr->codec);
fport[i]->bits_per_sample = (vfi ? vfi->bpp : 0);
fport[i]->usec_per_frame = avi_hdr.avih_hdr.usec_per_frame;
pjmedia_format_init_video(&fport[i]->base.info.fmt,
fport[i]->fmt_id,
strf_hdr->biWidth,
strf_hdr->biHeight,
strl_hdr->rate,
strl_hdr->scale);
#if 0
/* The calculation below is wrong. strf_hdr->biSizeImage shows
* uncompressed size. Looks like we need to go the ugly way to
* get the bitrage:
* http://www.virtualdub.org/blog/pivot/entry.php?id=159
*/
bps = strf_hdr->biSizeImage * 8 * strl_hdr->rate / strl_hdr->scale;
if (bps==0) {
/* strf_hdr->biSizeImage may be zero for uncompressed RGB */
bps = strf_hdr->biWidth * strf_hdr->biHeight *
strf_hdr->biBitCount *
strl_hdr->rate / strl_hdr->scale;
}
fport[i]->base.info.fmt.det.vid.avg_bps = bps;
fport[i]->base.info.fmt.det.vid.max_bps = bps;
#endif
} else {
strf_audio_hdr_t *strf_hdr =
&avi_hdr.strf_hdr[fport[i]->stream_id].strf_audio_hdr;
fport[i]->bits_per_sample = strf_hdr->bits_per_sample;
fport[i]->usec_per_frame = avi_hdr.avih_hdr.usec_per_frame;
pjmedia_format_init_audio(&fport[i]->base.info.fmt,
fport[i]->fmt_id,
strf_hdr->sample_rate,
strf_hdr->nchannels,
strf_hdr->bits_per_sample,
20000 /* fport[i]->usec_per_frame */,
strf_hdr->bytes_per_sec * 8,
strf_hdr->bytes_per_sec * 8);
/* Set format to PCM (we will decode PCMA/U) */
if (fport[i]->fmt_id == PJMEDIA_FORMAT_PCMA ||
fport[i]->fmt_id == PJMEDIA_FORMAT_PCMU)
{
fport[i]->base.info.fmt.id = PJMEDIA_FORMAT_PCM;
fport[i]->base.info.fmt.det.aud.bits_per_sample = 16;
}
}
pj_strdup2(pool, &fport[i]->base.info.name, filename);
}
/* Done. */
*p_streams = pj_pool_alloc(pool, sizeof(pjmedia_avi_streams));
(*p_streams)->num_streams = nstr;
(*p_streams)->streams = pj_pool_calloc(pool, (*p_streams)->num_streams,
sizeof(pjmedia_port *));
for (i = 0; i < nstr; i++)
(*p_streams)->streams[i] = &fport[i]->base;
PJ_LOG(4,(THIS_FILE,
"AVI file player '%.*s' created with "
"%d media ports",
(int)fport[0]->base.info.name.slen,
fport[0]->base.info.name.ptr,
(*p_streams)->num_streams));
return PJ_SUCCESS;
on_error:
fport[0]->base.on_destroy(&fport[0]->base);
for (i = 1; i < nstr; i++)
fport[i]->base.on_destroy(&fport[i]->base);
if (status == AVI_EOF)
return PJMEDIA_EINVALIMEDIATYPE;
return status;
} | 1846 | True | 1 |
CVE-2022-24792 | False | False | False | False | AV:N/AC:M/Au:N/C:N/I:N/A:P | NETWORK | MEDIUM | NONE | NONE | NONE | PARTIAL | 4.3 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | NONE | NONE | HIGH | 7.5 | HIGH | 3.9 | 3.6 | False | [{'url': 'https://github.com/pjsip/pjproject/commit/947bc1ee6d05be10204b918df75a503415fd3213', 'name': 'https://github.com/pjsip/pjproject/commit/947bc1ee6d05be10204b918df75a503415fd3213', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-rwgw-vwxg-q799', 'name': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-rwgw-vwxg-q799', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2022/05/msg00047.html', 'name': '[debian-lts-announce] 20220531 [SECURITY] [DLA 3036-1] pjproject security update', 'refsource': 'MLIST', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-835'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:teluu:pjsip:*:*:*:*:*:*:x86:*', 'versionEndIncluding': '2.12', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'PJSIP is a free and open source multimedia communication library written in C. A denial-of-service vulnerability affects applications on a 32-bit systems that use PJSIP versions 2.12 and prior to play/read invalid WAV files. The vulnerability occurs when reading WAV file data chunks with length greater than 31-bit integers. The vulnerability does not affect 64-bit apps and should not affect apps that only plays trusted WAV files. A patch is available on the `master` branch of the `pjsip/project` GitHub repository. As a workaround, apps can reject a WAV file received from an unknown source or validate the file first.'}] | 2022-06-02T14:15Z | 2022-04-25T16:16Z | Loop with Unreachable Exit Condition ('Infinite Loop') | The program contains an iteration or loop with an exit condition that cannot be reached, i.e., an infinite loop. | If the loop can be influenced by an attacker, this weakness could allow attackers to consume excessive resources such as CPU or memory.
| https://cwe.mitre.org/data/definitions/835.html | 0 | Riza Sulistyo | 2022-04-25 11:54:19+07:00 | Merge pull request from GHSA-rwgw-vwxg-q799
* Prevent potential infinite loop when parsing WAV format file
* Check if subchunk is negative.
* Fix and add checks
* Change data type from pj_ssize_t to long.
* Modify check
* Fix leak file descriptor and modify check on wav_playlist
* Move overflow/underflow check to pj_file_setpos()
* Use macro to simplify check
* modification based on comments
* Remove unnecessary casting
* Modification based on comments | 947bc1ee6d05be10204b918df75a503415fd3213 | False | pjsip/pjproject | PJSIP project | 2016-01-24 05:00:33 | 2022-08-26 15:35:55 | http://www.pjsip.org | pjsip | 1248.0 | 567.0 | pjmedia_wav_player_port_create | pjmedia_wav_player_port_create( pj_pool_t * pool , const char * filename , unsigned ptime , unsigned options , pj_ssize_t buff_size , pjmedia_port ** p_port) | ['pool', 'filename', 'ptime', 'options', 'buff_size', 'p_port'] | PJ_DEF(pj_status_t) pjmedia_wav_player_port_create( pj_pool_t *pool,
const char *filename,
unsigned ptime,
unsigned options,
pj_ssize_t buff_size,
pjmedia_port **p_port )
{
pjmedia_wave_hdr wave_hdr;
pj_ssize_t size_to_read, size_read;
struct file_reader_port *fport;
pjmedia_audio_format_detail *ad;
pj_off_t pos;
pj_str_t name;
unsigned samples_per_frame;
pj_status_t status = PJ_SUCCESS;
/* Check arguments. */
PJ_ASSERT_RETURN(pool && filename && p_port, PJ_EINVAL);
/* Check the file really exists. */
if (!pj_file_exists(filename)) {
return PJ_ENOTFOUND;
}
/* Normalize ptime */
if (ptime == 0)
ptime = 20;
/* Normalize buff_size */
if (buff_size < 1) buff_size = PJMEDIA_FILE_PORT_BUFSIZE;
/* Create fport instance. */
fport = create_file_port(pool);
if (!fport) {
return PJ_ENOMEM;
}
/* Get the file size. */
fport->fsize = pj_file_size(filename);
/* Size must be more than WAVE header size */
if (fport->fsize <= sizeof(pjmedia_wave_hdr)) {
return PJMEDIA_ENOTVALIDWAVE;
}
/* Open file. */
status = pj_file_open( pool, filename, PJ_O_RDONLY, &fport->fd);
if (status != PJ_SUCCESS)
return status;
/* Read the file header plus fmt header only. */
size_read = size_to_read = sizeof(wave_hdr) - 8;
status = pj_file_read( fport->fd, &wave_hdr, &size_read);
if (status != PJ_SUCCESS) {
pj_file_close(fport->fd);
return status;
}
if (size_read != size_to_read) {
pj_file_close(fport->fd);
return PJMEDIA_ENOTVALIDWAVE;
}
/* Normalize WAVE header fields values from little-endian to host
* byte order.
*/
pjmedia_wave_hdr_file_to_host(&wave_hdr);
/* Validate WAVE file. */
if (wave_hdr.riff_hdr.riff != PJMEDIA_RIFF_TAG ||
wave_hdr.riff_hdr.wave != PJMEDIA_WAVE_TAG ||
wave_hdr.fmt_hdr.fmt != PJMEDIA_FMT_TAG)
{
pj_file_close(fport->fd);
TRACE_((THIS_FILE,
"actual value|expected riff=%x|%x, wave=%x|%x fmt=%x|%x",
wave_hdr.riff_hdr.riff, PJMEDIA_RIFF_TAG,
wave_hdr.riff_hdr.wave, PJMEDIA_WAVE_TAG,
wave_hdr.fmt_hdr.fmt, PJMEDIA_FMT_TAG));
return PJMEDIA_ENOTVALIDWAVE;
}
/* Validate format and its attributes (i.e: bits per sample, block align) */
switch (wave_hdr.fmt_hdr.fmt_tag) {
case PJMEDIA_WAVE_FMT_TAG_PCM:
if (wave_hdr.fmt_hdr.bits_per_sample != 16 ||
wave_hdr.fmt_hdr.block_align != 2 * wave_hdr.fmt_hdr.nchan)
status = PJMEDIA_EWAVEUNSUPP;
break;
case PJMEDIA_WAVE_FMT_TAG_ALAW:
case PJMEDIA_WAVE_FMT_TAG_ULAW:
if (wave_hdr.fmt_hdr.bits_per_sample != 8 ||
wave_hdr.fmt_hdr.block_align != wave_hdr.fmt_hdr.nchan)
status = PJMEDIA_ENOTVALIDWAVE;
break;
default:
status = PJMEDIA_EWAVEUNSUPP;
break;
}
if (status != PJ_SUCCESS) {
pj_file_close(fport->fd);
return status;
}
fport->fmt_tag = (pjmedia_wave_fmt_tag)wave_hdr.fmt_hdr.fmt_tag;
fport->bytes_per_sample = (pj_uint16_t)
(wave_hdr.fmt_hdr.bits_per_sample / 8);
/* If length of fmt_header is greater than 16, skip the remaining
* fmt header data.
*/
if (wave_hdr.fmt_hdr.len > 16) {
size_to_read = wave_hdr.fmt_hdr.len - 16;
status = pj_file_setpos(fport->fd, size_to_read, PJ_SEEK_CUR);
if (status != PJ_SUCCESS) {
pj_file_close(fport->fd);
return status;
}
}
/* Repeat reading the WAVE file until we have 'data' chunk */
for (;;) {
pjmedia_wave_subchunk subchunk;
size_read = 8;
status = pj_file_read(fport->fd, &subchunk, &size_read);
if (status != PJ_SUCCESS || size_read != 8) {
pj_file_close(fport->fd);
return PJMEDIA_EWAVETOOSHORT;
}
/* Normalize endianness */
PJMEDIA_WAVE_NORMALIZE_SUBCHUNK(&subchunk);
/* Break if this is "data" chunk */
if (subchunk.id == PJMEDIA_DATA_TAG) {
wave_hdr.data_hdr.data = PJMEDIA_DATA_TAG;
wave_hdr.data_hdr.len = subchunk.len;
break;
}
/* Otherwise skip the chunk contents */
size_to_read = subchunk.len;
status = pj_file_setpos(fport->fd, size_to_read, PJ_SEEK_CUR);
if (status != PJ_SUCCESS) {
pj_file_close(fport->fd);
return status;
}
}
/* Current file position now points to start of data */
status = pj_file_getpos(fport->fd, &pos);
fport->start_data = (unsigned)pos;
fport->data_len = wave_hdr.data_hdr.len;
fport->data_left = wave_hdr.data_hdr.len;
/* Validate length. */
if (wave_hdr.data_hdr.len > fport->fsize - fport->start_data) {
/* Actual data length may be shorter than declared. We should still
* try to play whatever data is there instead of immediately returning
* error.
*/
wave_hdr.data_hdr.len = (pj_uint32_t)fport->fsize - fport->start_data;
// pj_file_close(fport->fd);
// return PJMEDIA_EWAVEUNSUPP;
}
if (wave_hdr.data_hdr.len < ptime * wave_hdr.fmt_hdr.sample_rate *
wave_hdr.fmt_hdr.nchan / 1000)
{
pj_file_close(fport->fd);
return PJMEDIA_EWAVETOOSHORT;
}
/* It seems like we have a valid WAVE file. */
/* Initialize */
fport->options = options;
/* Update port info. */
ad = pjmedia_format_get_audio_format_detail(&fport->base.info.fmt, 1);
pj_strdup2(pool, &name, filename);
samples_per_frame = ptime * wave_hdr.fmt_hdr.sample_rate *
wave_hdr.fmt_hdr.nchan / 1000;
pjmedia_port_info_init(&fport->base.info, &name, SIGNATURE,
wave_hdr.fmt_hdr.sample_rate,
wave_hdr.fmt_hdr.nchan,
BITS_PER_SAMPLE,
samples_per_frame);
/* If file is shorter than buffer size, adjust buffer size to file
* size. Otherwise EOF callback will be called multiple times when
* fill_buffer() is called.
*/
if (wave_hdr.data_hdr.len < (unsigned)buff_size)
buff_size = wave_hdr.data_hdr.len;
/* Create file buffer.
*/
fport->bufsize = (pj_uint32_t)buff_size;
/* samples_per_frame must be smaller than bufsize (because get_frame()
* doesn't handle this case).
*/
if (samples_per_frame * fport->bytes_per_sample >= fport->bufsize) {
pj_file_close(fport->fd);
return PJ_EINVAL;
}
/* Create buffer. */
fport->buf = (char*) pj_pool_alloc(pool, fport->bufsize);
if (!fport->buf) {
pj_file_close(fport->fd);
return PJ_ENOMEM;
}
fport->readpos = fport->buf;
/* Set initial position of the file. */
fport->fpos = fport->start_data;
/* Fill up the buffer. */
status = fill_buffer(fport);
if (status != PJ_SUCCESS) {
pj_file_close(fport->fd);
return status;
}
/* Done. */
*p_port = &fport->base;
PJ_LOG(4,(THIS_FILE,
"File player '%.*s' created: samp.rate=%d, ch=%d, bufsize=%uKB, "
"filesize=%luKB",
(int)fport->base.info.name.slen,
fport->base.info.name.ptr,
ad->clock_rate,
ad->channel_count,
fport->bufsize / 1000,
(unsigned long)(fport->fsize / 1000)));
return PJ_SUCCESS;
} | 1012 | True | 1 |
CVE-2022-24792 | False | False | False | False | AV:N/AC:M/Au:N/C:N/I:N/A:P | NETWORK | MEDIUM | NONE | NONE | NONE | PARTIAL | 4.3 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | NONE | NONE | HIGH | 7.5 | HIGH | 3.9 | 3.6 | False | [{'url': 'https://github.com/pjsip/pjproject/commit/947bc1ee6d05be10204b918df75a503415fd3213', 'name': 'https://github.com/pjsip/pjproject/commit/947bc1ee6d05be10204b918df75a503415fd3213', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-rwgw-vwxg-q799', 'name': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-rwgw-vwxg-q799', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2022/05/msg00047.html', 'name': '[debian-lts-announce] 20220531 [SECURITY] [DLA 3036-1] pjproject security update', 'refsource': 'MLIST', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-835'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:teluu:pjsip:*:*:*:*:*:*:x86:*', 'versionEndIncluding': '2.12', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'PJSIP is a free and open source multimedia communication library written in C. A denial-of-service vulnerability affects applications on a 32-bit systems that use PJSIP versions 2.12 and prior to play/read invalid WAV files. The vulnerability occurs when reading WAV file data chunks with length greater than 31-bit integers. The vulnerability does not affect 64-bit apps and should not affect apps that only plays trusted WAV files. A patch is available on the `master` branch of the `pjsip/project` GitHub repository. As a workaround, apps can reject a WAV file received from an unknown source or validate the file first.'}] | 2022-06-02T14:15Z | 2022-04-25T16:16Z | Loop with Unreachable Exit Condition ('Infinite Loop') | The program contains an iteration or loop with an exit condition that cannot be reached, i.e., an infinite loop. | If the loop can be influenced by an attacker, this weakness could allow attackers to consume excessive resources such as CPU or memory.
| https://cwe.mitre.org/data/definitions/835.html | 0 | Riza Sulistyo | 2022-04-25 11:54:19+07:00 | Merge pull request from GHSA-rwgw-vwxg-q799
* Prevent potential infinite loop when parsing WAV format file
* Check if subchunk is negative.
* Fix and add checks
* Change data type from pj_ssize_t to long.
* Modify check
* Fix leak file descriptor and modify check on wav_playlist
* Move overflow/underflow check to pj_file_setpos()
* Use macro to simplify check
* modification based on comments
* Remove unnecessary casting
* Modification based on comments | 947bc1ee6d05be10204b918df75a503415fd3213 | False | pjsip/pjproject | PJSIP project | 2016-01-24 05:00:33 | 2022-08-26 15:35:55 | http://www.pjsip.org | pjsip | 1248.0 | 567.0 | pjmedia_wav_playlist_create | pjmedia_wav_playlist_create( pj_pool_t * pool , const pj_str_t * port_label , const pj_str_t file_list [ ] , int file_count , unsigned ptime , unsigned options , pj_ssize_t buff_size , pjmedia_port ** p_port) | ['pool', 'port_label', 'file_count', 'ptime', 'options', 'buff_size', 'p_port'] | PJ_DEF(pj_status_t) pjmedia_wav_playlist_create(pj_pool_t *pool,
const pj_str_t *port_label,
const pj_str_t file_list[],
int file_count,
unsigned ptime,
unsigned options,
pj_ssize_t buff_size,
pjmedia_port **p_port)
{
struct playlist_port *fport;
pjmedia_audio_format_detail *afd;
pj_off_t pos;
pj_status_t status;
int index;
pj_bool_t has_wave_info = PJ_FALSE;
pj_str_t tmp_port_label;
char filename[PJ_MAXPATH]; /* filename for open operations. */
/* Check arguments. */
PJ_ASSERT_RETURN(pool && file_list && file_count && p_port, PJ_EINVAL);
/* Normalize port_label */
if (port_label == NULL || port_label->slen == 0) {
tmp_port_label = pj_str("WAV playlist");
port_label = &tmp_port_label;
}
/* Be sure all files exist */
for (index=0; index<file_count; index++) {
PJ_ASSERT_RETURN(file_list[index].slen >= 0, PJ_ETOOSMALL);
if (file_list[index].slen >= PJ_MAXPATH)
return PJ_ENAMETOOLONG;
pj_memcpy(filename, file_list[index].ptr, file_list[index].slen);
filename[file_list[index].slen] = '\0';
/* Check the file really exists. */
if (!pj_file_exists(filename)) {
PJ_LOG(4,(THIS_FILE,
"WAV playlist error: file '%s' not found",
filename));
return PJ_ENOTFOUND;
}
}
/* Normalize ptime */
if (ptime == 0)
ptime = 20;
/* Create fport instance. */
fport = create_file_list_port(pool, port_label);
if (!fport) {
return PJ_ENOMEM;
}
afd = pjmedia_format_get_audio_format_detail(&fport->base.info.fmt, 1);
/* start with the first file. */
fport->current_file = 0;
fport->max_file = file_count;
/* Create file descriptor list */
fport->fd_list = (pj_oshandle_t*)
pj_pool_zalloc(pool, sizeof(pj_oshandle_t)*file_count);
if (!fport->fd_list) {
return PJ_ENOMEM;
}
/* Create file size list */
fport->fsize_list = (pj_off_t*)
pj_pool_alloc(pool, sizeof(pj_off_t)*file_count);
if (!fport->fsize_list) {
return PJ_ENOMEM;
}
/* Create start of WAVE data list */
fport->start_data_list = (unsigned*)
pj_pool_alloc(pool, sizeof(unsigned)*file_count);
if (!fport->start_data_list) {
return PJ_ENOMEM;
}
/* Create data len list */
fport->data_len_list = (unsigned*)
pj_pool_alloc(pool, sizeof(unsigned)*file_count);
if (!fport->data_len_list) {
return PJ_ENOMEM;
}
/* Create data left list */
fport->data_left_list = (unsigned*)
pj_pool_alloc(pool, sizeof(unsigned)*file_count);
if (!fport->data_left_list) {
return PJ_ENOMEM;
}
/* Create file position list */
fport->fpos_list = (pj_off_t*)
pj_pool_alloc(pool, sizeof(pj_off_t)*file_count);
if (!fport->fpos_list) {
return PJ_ENOMEM;
}
/* Create file buffer once for this operation.
*/
if (buff_size < 1) buff_size = PJMEDIA_FILE_PORT_BUFSIZE;
fport->bufsize = (pj_uint32_t)buff_size;
/* Create buffer. */
fport->buf = (char*) pj_pool_alloc(pool, fport->bufsize);
if (!fport->buf) {
return PJ_ENOMEM;
}
/* Initialize port */
fport->options = options;
fport->readpos = fport->buf;
/* ok run this for all files to be sure all are good for playback. */
for (index=file_count-1; index>=0; index--) {
pjmedia_wave_hdr wavehdr;
pj_ssize_t size_to_read, size_read;
/* we end with the last one so we are good to go if still in function*/
pj_memcpy(filename, file_list[index].ptr, file_list[index].slen);
filename[file_list[index].slen] = '\0';
/* Get the file size. */
fport->current_file = index;
fport->fsize_list[index] = pj_file_size(filename);
/* Size must be more than WAVE header size */
if (fport->fsize_list[index] <= sizeof(pjmedia_wave_hdr)) {
status = PJMEDIA_ENOTVALIDWAVE;
goto on_error;
}
/* Open file. */
status = pj_file_open( pool, filename, PJ_O_RDONLY,
&fport->fd_list[index]);
if (status != PJ_SUCCESS)
goto on_error;
/* Read the file header plus fmt header only. */
size_read = size_to_read = sizeof(wavehdr) - 8;
status = pj_file_read( fport->fd_list[index], &wavehdr, &size_read);
if (status != PJ_SUCCESS) {
goto on_error;
}
if (size_read != size_to_read) {
status = PJMEDIA_ENOTVALIDWAVE;
goto on_error;
}
/* Normalize WAVE header fields values from little-endian to host
* byte order.
*/
pjmedia_wave_hdr_file_to_host(&wavehdr);
/* Validate WAVE file. */
if (wavehdr.riff_hdr.riff != PJMEDIA_RIFF_TAG ||
wavehdr.riff_hdr.wave != PJMEDIA_WAVE_TAG ||
wavehdr.fmt_hdr.fmt != PJMEDIA_FMT_TAG)
{
TRACE_((THIS_FILE,
"actual value|expected riff=%x|%x, wave=%x|%x fmt=%x|%x",
wavehdr.riff_hdr.riff, PJMEDIA_RIFF_TAG,
wavehdr.riff_hdr.wave, PJMEDIA_WAVE_TAG,
wavehdr.fmt_hdr.fmt, PJMEDIA_FMT_TAG));
status = PJMEDIA_ENOTVALIDWAVE;
goto on_error;
}
/* Must be PCM with 16bits per sample */
if (wavehdr.fmt_hdr.fmt_tag != 1 ||
wavehdr.fmt_hdr.bits_per_sample != 16)
{
status = PJMEDIA_EWAVEUNSUPP;
goto on_error;
}
/* Block align must be 2*nchannels */
if (wavehdr.fmt_hdr.block_align !=
wavehdr.fmt_hdr.nchan * BYTES_PER_SAMPLE)
{
status = PJMEDIA_EWAVEUNSUPP;
goto on_error;
}
/* If length of fmt_header is greater than 16, skip the remaining
* fmt header data.
*/
if (wavehdr.fmt_hdr.len > 16) {
size_to_read = wavehdr.fmt_hdr.len - 16;
status = pj_file_setpos(fport->fd_list[index], size_to_read,
PJ_SEEK_CUR);
if (status != PJ_SUCCESS) {
goto on_error;
}
}
/* Repeat reading the WAVE file until we have 'data' chunk */
for (;;) {
pjmedia_wave_subchunk subchunk;
size_read = 8;
status = pj_file_read(fport->fd_list[index], &subchunk,
&size_read);
if (status != PJ_SUCCESS || size_read != 8) {
status = PJMEDIA_EWAVETOOSHORT;
goto on_error;
}
/* Normalize endianness */
PJMEDIA_WAVE_NORMALIZE_SUBCHUNK(&subchunk);
/* Break if this is "data" chunk */
if (subchunk.id == PJMEDIA_DATA_TAG) {
wavehdr.data_hdr.data = PJMEDIA_DATA_TAG;
wavehdr.data_hdr.len = subchunk.len;
break;
}
/* Otherwise skip the chunk contents */
size_to_read = subchunk.len;
status = pj_file_setpos(fport->fd_list[index], size_to_read,
PJ_SEEK_CUR);
if (status != PJ_SUCCESS) {
goto on_error;
}
}
/* Current file position now points to start of data */
status = pj_file_getpos(fport->fd_list[index], &pos);
fport->start_data_list[index] = (unsigned)pos;
fport->data_len_list[index] = wavehdr.data_hdr.len;
fport->data_left_list[index] = wavehdr.data_hdr.len;
/* Validate length. */
if (wavehdr.data_hdr.len > fport->fsize_list[index] -
fport->start_data_list[index])
{
status = PJMEDIA_EWAVEUNSUPP;
goto on_error;
}
if (wavehdr.data_hdr.len < ptime * wavehdr.fmt_hdr.sample_rate *
wavehdr.fmt_hdr.nchan / 1000)
{
status = PJMEDIA_EWAVETOOSHORT;
goto on_error;
}
/* It seems like we have a valid WAVE file. */
/* Update port info if we don't have one, otherwise check
* that the WAV file has the same attributes as previous files.
*/
if (!has_wave_info) {
afd->channel_count = wavehdr.fmt_hdr.nchan;
afd->clock_rate = wavehdr.fmt_hdr.sample_rate;
afd->bits_per_sample = wavehdr.fmt_hdr.bits_per_sample;
afd->frame_time_usec = ptime * 1000;
afd->avg_bps = afd->max_bps = afd->clock_rate *
afd->channel_count *
afd->bits_per_sample;
has_wave_info = PJ_TRUE;
} else {
/* Check that this file has the same characteristics as the other
* files.
*/
if (wavehdr.fmt_hdr.nchan != afd->channel_count ||
wavehdr.fmt_hdr.sample_rate != afd->clock_rate ||
wavehdr.fmt_hdr.bits_per_sample != afd->bits_per_sample)
{
/* This file has different characteristics than the other
* files.
*/
PJ_LOG(4,(THIS_FILE,
"WAV playlist error: file '%s' has differrent number"
" of channels, sample rate, or bits per sample",
filename));
status = PJMEDIA_EWAVEUNSUPP;
goto on_error;
}
}
/* If file is shorter than buffer size, adjust buffer size to file
* size. Otherwise EOF callback will be called multiple times when
* file_fill_buffer() is called.
*/
if (wavehdr.data_hdr.len < (unsigned)buff_size)
buff_size = wavehdr.data_hdr.len;
/* Create file buffer.
*/
fport->bufsize = (pj_uint32_t)buff_size;
/* Set initial position of the file. */
fport->fpos_list[index] = fport->start_data_list[index];
}
/* Fill up the buffer. */
status = file_fill_buffer(fport);
if (status != PJ_SUCCESS) {
goto on_error;
}
/* Done. */
*p_port = &fport->base;
PJ_LOG(4,(THIS_FILE,
"WAV playlist '%.*s' created: samp.rate=%d, ch=%d, bufsize=%uKB",
(int)port_label->slen,
port_label->ptr,
afd->clock_rate,
afd->channel_count,
fport->bufsize / 1000));
return PJ_SUCCESS;
on_error:
for (index=0; index<file_count; ++index) {
if (fport->fd_list[index] != 0)
pj_file_close(fport->fd_list[index]);
}
return status;
} | 1385 | True | 1 |
CVE-2022-31031 | False | False | False | False | AV:N/AC:M/Au:N/C:P/I:P/A:P | NETWORK | MEDIUM | NONE | PARTIAL | PARTIAL | PARTIAL | 6.8 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | HIGH | HIGH | HIGH | 9.8 | CRITICAL | 3.9 | 5.9 | False | [{'url': 'https://github.com/pjsip/pjproject/commit/450baca94f475345542c6953832650c390889202', 'name': 'https://github.com/pjsip/pjproject/commit/450baca94f475345542c6953832650c390889202', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-26j7-ww69-c4qj', 'name': 'https://github.com/pjsip/pjproject/security/advisories/GHSA-26j7-ww69-c4qj', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-120'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:teluu:pjsip:*:*:*:*:*:*:*:*', 'versionEndIncluding': '2.12.1', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'PJSIP is a free and open source multimedia communication library written in C language implementing standard based protocols such as SIP, SDP, RTP, STUN, TURN, and ICE. In versions prior to and including 2.12.1 a stack buffer overflow vulnerability affects PJSIP users that use STUN in their applications, either by: setting a STUN server in their account/media config in PJSUA/PJSUA2 level, or directly using `pjlib-util/stun_simple` API. A patch is available in commit 450baca which should be included in the next release. There are no known workarounds for this issue.'}] | 2022-06-17T20:05Z | 2022-06-09T16:15Z | Buffer Copy without Checking Size of Input ('Classic Buffer Overflow') | The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow. | A buffer overflow condition exists when a program attempts to put more data in a buffer than it can hold, or when a program attempts to put data in a memory area outside of the boundaries of a buffer. The simplest type of error, and the most common cause of buffer overflows, is the "classic" case in which the program copies the buffer without restricting how much is copied. Other variants exist, but the existence of a classic overflow strongly suggests that the programmer is not considering even the most basic of security protections.
| https://cwe.mitre.org/data/definitions/120.html | 0 | sauwming | 2022-06-07 12:00:13+08:00 | Merge pull request from GHSA-26j7-ww69-c4qj | 450baca94f475345542c6953832650c390889202 | False | pjsip/pjproject | PJSIP project | 2016-01-24 05:00:33 | 2022-08-26 15:35:55 | http://www.pjsip.org | pjsip | 1248.0 | 567.0 | pjstun_parse_msg | pjstun_parse_msg( void * buf , pj_size_t buf_len , pjstun_msg * msg) | ['buf', 'buf_len', 'msg'] | PJ_DEF(pj_status_t) pjstun_parse_msg( void *buf, pj_size_t buf_len,
pjstun_msg *msg)
{
pj_uint16_t msg_type, msg_len;
char *p_attr;
PJ_CHECK_STACK();
msg->hdr = (pjstun_msg_hdr*)buf;
msg_type = pj_ntohs(msg->hdr->type);
switch (msg_type) {
case PJSTUN_BINDING_REQUEST:
case PJSTUN_BINDING_RESPONSE:
case PJSTUN_BINDING_ERROR_RESPONSE:
case PJSTUN_SHARED_SECRET_REQUEST:
case PJSTUN_SHARED_SECRET_RESPONSE:
case PJSTUN_SHARED_SECRET_ERROR_RESPONSE:
break;
default:
PJ_LOG(4,(THIS_FILE, "Error: unknown msg type %d", msg_type));
return PJLIB_UTIL_ESTUNINMSGTYPE;
}
msg_len = pj_ntohs(msg->hdr->length);
if (msg_len != buf_len - sizeof(pjstun_msg_hdr)) {
PJ_LOG(4,(THIS_FILE, "Error: invalid msg_len %d (expecting %d)",
msg_len, buf_len - sizeof(pjstun_msg_hdr)));
return PJLIB_UTIL_ESTUNINMSGLEN;
}
msg->attr_count = 0;
p_attr = (char*)buf + sizeof(pjstun_msg_hdr);
while (msg_len > 0) {
pjstun_attr_hdr **attr = &msg->attr[msg->attr_count];
pj_uint32_t len;
pj_uint16_t attr_type;
*attr = (pjstun_attr_hdr*)p_attr;
len = pj_ntohs((pj_uint16_t) ((*attr)->length)) + sizeof(pjstun_attr_hdr);
len = (len + 3) & ~3;
if (msg_len < len) {
PJ_LOG(4,(THIS_FILE, "Error: length mismatch in attr %d",
msg->attr_count));
return PJLIB_UTIL_ESTUNINATTRLEN;
}
attr_type = pj_ntohs((*attr)->type);
if (attr_type > PJSTUN_ATTR_REFLECTED_FROM &&
attr_type != PJSTUN_ATTR_XOR_MAPPED_ADDR)
{
PJ_LOG(5,(THIS_FILE, "Warning: unknown attr type %x in attr %d. "
"Attribute was ignored.",
attr_type, msg->attr_count));
}
msg_len = (pj_uint16_t)(msg_len - len);
p_attr += len;
++msg->attr_count;
}
return PJ_SUCCESS;
} | 318 | True | 1 |
CVE-2020-15261 | False | False | False | False | AV:L/AC:L/Au:N/C:P/I:P/A:P | LOCAL | LOW | NONE | PARTIAL | PARTIAL | PARTIAL | 4.6 | CVSS:3.1/AV:L/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H | LOCAL | LOW | HIGH | NONE | UNCHANGED | HIGH | HIGH | HIGH | 6.7 | MEDIUM | 0.8 | 5.9 | False | [{'url': 'https://github.com/veyon/veyon/commit/f231ec511b9a09f43f49b2c7bb7c60b8046276b1', 'name': 'https://github.com/veyon/veyon/commit/f231ec511b9a09f43f49b2c7bb7c60b8046276b1', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/veyon/veyon/security/advisories/GHSA-c8cc-x786-hqqp', 'name': 'https://github.com/veyon/veyon/security/advisories/GHSA-c8cc-x786-hqqp', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'https://github.com/veyon/veyon/issues/657', 'name': 'https://github.com/veyon/veyon/issues/657', 'refsource': 'MISC', 'tags': ['Issue Tracking', 'Third Party Advisory']}, {'url': 'http://packetstormsecurity.com/files/162873/Veyon-4.4.1-Unquoted-Service-Path.html', 'name': 'http://packetstormsecurity.com/files/162873/Veyon-4.4.1-Unquoted-Service-Path.html', 'refsource': 'MISC', 'tags': []}, {'url': 'https://www.exploit-db.com/exploits/49925', 'name': 'https://www.exploit-db.com/exploits/49925', 'refsource': 'MISC', 'tags': []}, {'url': 'https://www.exploit-db.com/exploits/48246', 'name': 'https://www.exploit-db.com/exploits/48246', 'refsource': 'MISC', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-428'}]}] | MEDIUM | [{'operator': 'AND', 'children': [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:veyon:veyon:*:*:*:*:*:*:*:*', 'versionEndExcluding': '4.4.2', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': False, 'cpe23Uri': 'cpe:2.3:o:microsoft:windows:-:*:*:*:*:*:*:*', 'cpe_name': []}]}], 'cpe_match': []}] | [{'lang': 'en', 'value': "On Windows the Veyon Service before version 4.4.2 contains an unquoted service path vulnerability, allowing locally authenticated users with administrative privileges to run malicious executables with LocalSystem privileges. Since Veyon users (both students and teachers) usually don't have administrative privileges, this vulnerability is only dangerous in anyway unsafe setups. The problem has been fixed in version 4.4.2. As a workaround, the exploitation of the vulnerability can be prevented by revoking administrative privileges from all potentially untrustworthy users."}] | 2021-06-18T12:15Z | 2020-10-19T22:15Z | Unquoted Search Path or Element | The product uses a search path that contains an unquoted element, in which the element contains whitespace or other separators. This can cause the product to access resources in a parent path. | If a malicious individual has access to the file system, it is possible to elevate privileges by inserting such a file as "C:\Program.exe" to be run by a privileged program making use of WinExec.
| https://cwe.mitre.org/data/definitions/428.html | 0 | Tobias Junghans | 2020-09-01 10:09:31+02:00 | WindowsServiceControl: quote service binary path
Fix unquoted service path vulnerability.
Closes #657. | f231ec511b9a09f43f49b2c7bb7c60b8046276b1 | False | veyon/veyon | Cross-platform computer monitoring and classroom management | 2017-04-11 05:22:24 | 2022-08-25 09:06:18 | https://veyon.io | veyon | 846.0 | 223.0 | WindowsServiceControl::install | WindowsServiceControl::install( const QString & filePath , const QString & displayName) | ['filePath', 'displayName'] | bool WindowsServiceControl::install( const QString& filePath, const QString& displayName )
{
m_serviceHandle = CreateService(
m_serviceManager, // SCManager database
WindowsCoreFunctions::toConstWCharArray( m_name ), // name of service
WindowsCoreFunctions::toConstWCharArray( displayName ),// name to display
SERVICE_ALL_ACCESS, // desired access
SERVICE_WIN32_OWN_PROCESS,
// service type
SERVICE_AUTO_START, // start type
SERVICE_ERROR_NORMAL, // error control type
WindowsCoreFunctions::toConstWCharArray( filePath ), // service's binary
nullptr, // no load ordering group
nullptr, // no tag identifier
L"Tcpip\0RpcSs\0\0", // dependencies
nullptr, // LocalSystem account
nullptr ); // no password
if( m_serviceHandle == nullptr )
{
const auto error = GetLastError();
if( error == ERROR_SERVICE_EXISTS )
{
vCritical() << qUtf8Printable( tr( "The service \"%1\" is already installed." ).arg( m_name ) );
}
else
{
vCritical() << qUtf8Printable( tr( "The service \"%1\" could not be installed." ).arg( m_name ) );
}
return false;
}
SC_ACTION serviceActions;
serviceActions.Delay = 10000;
serviceActions.Type = SC_ACTION_RESTART;
SERVICE_FAILURE_ACTIONS serviceFailureActions;
serviceFailureActions.dwResetPeriod = 0;
serviceFailureActions.lpRebootMsg = nullptr;
serviceFailureActions.lpCommand = nullptr;
serviceFailureActions.lpsaActions = &serviceActions;
serviceFailureActions.cActions = 1;
ChangeServiceConfig2( m_serviceHandle, SERVICE_CONFIG_FAILURE_ACTIONS, &serviceFailureActions );
// Everything went fine
vInfo() << qUtf8Printable( tr( "The service \"%1\" has been installed successfully." ).arg( m_name ) );
return true;
} | 209 | True | 1 |
CVE-2020-15569 | False | False | False | True | AV:N/AC:M/Au:N/C:N/I:N/A:P | NETWORK | MEDIUM | NONE | NONE | NONE | PARTIAL | 4.3 | CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H | LOCAL | LOW | NONE | REQUIRED | UNCHANGED | NONE | NONE | HIGH | 5.5 | MEDIUM | 1.8 | 3.6 | False | [{'url': 'https://github.com/milkytracker/MilkyTracker/commit/7afd55c42ad80d01a339197a2d8b5461d214edaf', 'name': 'https://github.com/milkytracker/MilkyTracker/commit/7afd55c42ad80d01a339197a2d8b5461d214edaf', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2020/07/msg00023.html', 'name': '[debian-lts-announce] 20200727 [SECURITY] [DLA 2292-1] milkytracker security update', 'refsource': 'MLIST', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-416'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:milkytracker_project:milkytracker:*:*:*:*:*:*:*:*', 'versionEndIncluding': '1.02.00', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'PlayerGeneric.cpp in MilkyTracker through 1.02.00 has a use-after-free in the PlayerGeneric destructor.'}] | 2020-07-27T17:15Z | 2020-07-06T14:15Z | Use After Free | Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code. |
The use of previously-freed memory can have any number of adverse consequences, ranging from the corruption of valid data to the execution of arbitrary code, depending on the instantiation and timing of the flaw. The simplest way data corruption may occur involves the system's reuse of the freed memory. Use-after-free errors have two common and sometimes overlapping causes:
Error conditions and other exceptional circumstances.
Confusion over which part of the program is responsible for freeing the memory.
In this scenario, the memory in question is allocated to another pointer validly at some point after it has been freed. The original pointer to the freed memory is used again and points to somewhere within the new allocation. As the data is changed, it corrupts the validly used memory; this induces undefined behavior in the process.
If the newly allocated data chances to hold a class, in C++ for example, various function pointers may be scattered within the heap data. If one of these function pointers is overwritten with an address to valid shellcode, execution of arbitrary code can be achieved.
| https://cwe.mitre.org/data/definitions/416.html | 0 | Jeremy Clarke | 2020-04-13 23:53:51+01:00 | Fix use-after-free in PlayerGeneric destructor | 7afd55c42ad80d01a339197a2d8b5461d214edaf | False | milkytracker/MilkyTracker | An FT2 compatible music tracker | 2013-10-20 10:16:11 | 2022-08-27 12:40:00 | http://milkytracker.github.io/ | milkytracker | 1276.0 | 131.0 | PlayerGeneric::~PlayerGeneric | PlayerGeneric::~PlayerGeneric() | [] | PlayerGeneric::~PlayerGeneric()
{
if (mixer)
delete mixer;
if (player)
{
if (mixer->isActive() && !mixer->isDeviceRemoved(player))
mixer->removeDevice(player);
delete player;
}
delete[] audioDriverName;
delete listener;
} | 54 | True | 1 |
CVE-2022-34927 | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H | LOCAL | LOW | NONE | REQUIRED | UNCHANGED | HIGH | HIGH | HIGH | 7.8 | HIGH | 1.8 | 5.9 | nan | [{'url': 'https://github.com/milkytracker/MilkyTracker/commit/3a5474f9102cbdc10fbd9e7b1b2c8d3f3f45d91b', 'name': 'https://github.com/milkytracker/MilkyTracker/commit/3a5474f9102cbdc10fbd9e7b1b2c8d3f3f45d91b', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/milkytracker/MilkyTracker/issues/275', 'name': 'https://github.com/milkytracker/MilkyTracker/issues/275', 'refsource': 'MISC', 'tags': ['Exploit', 'Issue Tracking', 'Mitigation', 'Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-787'}]}] | nan | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:milkytracker_project:milkytracker:1.03.00:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'MilkyTracker v1.03.00 was discovered to contain a stack overflow via the component LoaderXM::load. This vulnerability is triggered when the program is supplied a crafted XM module file.'}] | 2022-08-09T18:23Z | 2022-08-03T01:15Z | Out-of-bounds Write | The software writes data past the end, or before the beginning, of the intended buffer. | Typically, this can result in corruption of data, a crash, or code execution. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent write operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/787.html | 0 | Johannes Schultz | 2022-06-26 17:53:59+02:00 | Fix possible stack corruption with XM instrument headers claiming a size of less than 4
Closes #275 | 3a5474f9102cbdc10fbd9e7b1b2c8d3f3f45d91b | False | milkytracker/MilkyTracker | An FT2 compatible music tracker | 2013-10-20 10:16:11 | 2022-08-27 12:40:00 | http://milkytracker.github.io/ | milkytracker | 1276.0 | 131.0 | LoaderXM::load | LoaderXM::load( XMFileBase & f , XModule * module) | ['f', 'module'] | mp_sint32 LoaderXM::load(XMFileBase& f, XModule* module)
{
mp_ubyte insData[230];
mp_sint32 smpReloc[MP_MAXINSSAMPS];
mp_ubyte nbu[MP_MAXINSSAMPS];
mp_uint32 fileSize = 0;
module->cleanUp();
// this will make code much easier to read
TXMHeader* header = &module->header;
TXMInstrument* instr = module->instr;
TXMSample* smp = module->smp;
TXMPattern* phead = module->phead;
// we're already out of memory here
if (!phead || !instr || !smp)
return MP_OUT_OF_MEMORY;
fileSize = f.sizeWithBaseOffset();
f.read(&header->sig,1,17);
f.read(&header->name,1,20);
f.read(&header->whythis1a,1,1);
header->whythis1a=0;
f.read(&header->tracker,1,20);
f.readWords(&header->ver,1);
if (header->ver != 0x102 &&
header->ver != 0x103 && // untested
header->ver != 0x104)
return MP_LOADER_FAILED;
f.readDwords(&header->hdrsize,1);
header->hdrsize-=4;
mp_uint32 hdrSize = 0x110;
if (header->hdrsize > hdrSize)
hdrSize = header->hdrsize;
mp_ubyte* hdrBuff = new mp_ubyte[hdrSize];
memset(hdrBuff, 0, hdrSize);
f.read(hdrBuff, 1, header->hdrsize);
header->ordnum = LittleEndian::GET_WORD(hdrBuff);
header->restart = LittleEndian::GET_WORD(hdrBuff+2);
header->channum = LittleEndian::GET_WORD(hdrBuff+4);
header->patnum = LittleEndian::GET_WORD(hdrBuff+6);
header->insnum = LittleEndian::GET_WORD(hdrBuff+8);
header->freqtab = LittleEndian::GET_WORD(hdrBuff+10);
header->tempo = LittleEndian::GET_WORD(hdrBuff+12);
header->speed = LittleEndian::GET_WORD(hdrBuff+14);
memcpy(header->ord, hdrBuff+16, 256);
if(header->ordnum > MP_MAXORDERS)
header->ordnum = MP_MAXORDERS;
if(header->insnum > MP_MAXINS)
return MP_LOADER_FAILED;
delete[] hdrBuff;
header->mainvol=255;
header->flags = XModule::MODULE_XMNOTECLIPPING |
XModule::MODULE_XMARPEGGIO |
XModule::MODULE_XMPORTANOTEBUFFER |
XModule::MODULE_XMVOLCOLUMNVIBRATO;
header->uppernotebound = 119;
mp_sint32 i,y,sc;
for (i=0;i<32;i++) header->pan[i]=0x80;
// old version?
if (header->ver == 0x102 || header->ver == 0x103)
{
mp_sint32 s = 0;
mp_sint32 e = 0;
for (y=0;y<header->insnum;y++) {
f.readDwords(&instr[y].size,1);
f.read(&instr[y].name,1,22);
f.read(&instr[y].type,1,1);
mp_uword numSamples = 0;
f.readWords(&numSamples,1);
if(numSamples > MP_MAXINSSAMPS)
return MP_LOADER_FAILED;
instr[y].samp = numSamples;
if (instr[y].size == 29)
{
#ifdef MILKYTRACKER
s+=16;
#endif
for (mp_sint32 i = 0; i < 120; i++)
instr[y].snum[i] = -1;
continue;
}
f.readDwords(&instr[y].shsize,1);
memset(insData, 0, 230);
if (instr[y].size - 33 > 230)
return MP_OUT_OF_MEMORY;
f.read(insData, 1, instr[y].size - 33);
if (instr[y].samp) {
mp_ubyte* insDataPtr = insData;
memcpy(nbu, insDataPtr, MP_MAXINSSAMPS);
insDataPtr+=MP_MAXINSSAMPS;
TEnvelope venv;
TEnvelope penv;
memset(&venv,0,sizeof(venv));
memset(&penv,0,sizeof(penv));
mp_sint32 k;
for (k = 0; k < XM_ENVELOPENUMPOINTS; k++)
{
venv.env[k][0] = LittleEndian::GET_WORD(insDataPtr);
venv.env[k][1] = LittleEndian::GET_WORD(insDataPtr+2);
insDataPtr+=4;
}
for (k = 0; k < XM_ENVELOPENUMPOINTS; k++)
{
penv.env[k][0] = LittleEndian::GET_WORD(insDataPtr);
penv.env[k][1] = LittleEndian::GET_WORD(insDataPtr+2);
insDataPtr+=4;
}
venv.num = *insDataPtr++;
if (venv.num > XM_ENVELOPENUMPOINTS) venv.num = XM_ENVELOPENUMPOINTS;
penv.num = *insDataPtr++;
if (penv.num > XM_ENVELOPENUMPOINTS) penv.num = XM_ENVELOPENUMPOINTS;
venv.sustain = *insDataPtr++;
venv.loops = *insDataPtr++;
venv.loope = *insDataPtr++;
penv.sustain = *insDataPtr++;
penv.loops = *insDataPtr++;
penv.loope = *insDataPtr++;
venv.type = *insDataPtr++;
penv.type = *insDataPtr++;
mp_ubyte vibtype, vibsweep, vibdepth, vibrate;
mp_uword volfade;
vibtype = *insDataPtr++;
vibsweep = *insDataPtr++;
vibdepth = *insDataPtr++;
vibrate = *insDataPtr++;
vibdepth<<=1;
volfade = LittleEndian::GET_WORD(insDataPtr);
insDataPtr+=2;
volfade<<=1;
//instr[y].res = LittleEndian::GET_WORD(insDataPtr);
insDataPtr+=2;
for (mp_sint32 l=0;l<XM_ENVELOPENUMPOINTS;l++) {
venv.env[l][1]<<=2;
penv.env[l][1]<<=2;
}
if (!module->addVolumeEnvelope(venv))
return MP_OUT_OF_MEMORY;
if (!module->addPanningEnvelope(penv))
return MP_OUT_OF_MEMORY;
mp_sint32 g=0, sc;
for (sc=0;sc<instr[y].samp;sc++) {
smp[g+s].flags=3;
smp[g+s].venvnum=e+1;
smp[g+s].penvnum=e+1;
smp[g+s].vibtype=vibtype;
smp[g+s].vibsweep=vibsweep;
smp[g+s].vibdepth=vibdepth;
smp[g+s].vibrate=vibrate;
smp[g+s].volfade=volfade;
// not sure why I did that, actually doesn't make sense
//if (!(venv.type&1)) smp[g+s].volfade=0;
f.readDwords(&smp[g+s].samplen,1);
f.readDwords(&smp[g+s].loopstart,1);
f.readDwords(&smp[g+s].looplen,1);
smp[g+s].vol=XModule::vol64to255(f.readByte());
//f.read(&smp[g+s].vol,1,1);
f.read(&smp[g+s].finetune,1,1);
f.read(&smp[g+s].type,1,1);
#ifdef VERBOSE
printf("Before: %i, After: %i\n", smp[g+s].type, smp[g+s].type & (3+16));
#endif
f.read(&smp[g+s].pan,1,1);
f.read(&smp[g+s].relnote,1,1);
f.read(&smp[g+s].res,1,1);
f.read(&smp[g+s].name,1,22);
char line[30];
memset(line, 0, sizeof(line));
XModule::convertStr(line, smp[g+s].name, 23, false);
if (line[0])
module->addSongMessageLine(line);
// ignore empty samples
#ifndef MILKYTRACKER
// ignore empty samples when not being a tracker
if (smp[g+s].samplen) {
smpReloc[sc] = g;
g++;
}
else
smpReloc[sc] = -1;
#else
smpReloc[sc] = g;
g++;
#endif
}
instr[y].samp = g;
for (sc = 0; sc < MP_MAXINSSAMPS; sc++) {
if (smpReloc[nbu[sc]] == -1)
instr[y].snum[sc] = -1;
else
instr[y].snum[sc] = smpReloc[nbu[sc]]+s;
}
e++;
}
else
{
for (mp_sint32 i = 0; i < 120; i++)
instr[y].snum[i] = -1;
}
#ifdef MILKYTRACKER
s+=16;
#else
s+=instr[y].samp;
#endif
}
header->smpnum=s;
header->volenvnum=e;
header->panenvnum=e;
}
for (y=0;y<header->patnum;y++) {
if (header->ver == 0x104 || header->ver == 0x103)
{
f.readDwords(&phead[y].len,1);
f.read(&phead[y].ptype,1,1);
f.readWords(&phead[y].rows,1);
f.readWords(&phead[y].patdata,1);
}
else
{
f.readDwords(&phead[y].len,1);
f.read(&phead[y].ptype,1,1);
phead[y].rows = (mp_uword)f.readByte()+1;
f.readWords(&phead[y].patdata,1);
}
phead[y].effnum=2;
phead[y].channum=(mp_ubyte)header->channum;
phead[y].patternData = new mp_ubyte[phead[y].rows*header->channum*6];
// out of memory?
if (phead[y].patternData == NULL)
{
return MP_OUT_OF_MEMORY;
}
memset(phead[y].patternData,0,phead[y].rows*header->channum*6);
if (phead[y].patdata) {
mp_ubyte *buffer = new mp_ubyte[phead[y].patdata];
// out of memory?
if (buffer == NULL)
{
return MP_OUT_OF_MEMORY;
}
f.read(buffer,1,phead[y].patdata);
//printf("%i\n", phead[y].patdata);
mp_sint32 pc = 0, bc = 0;
for (mp_sint32 r=0;r<phead[y].rows;r++) {
for (mp_sint32 c=0;c<header->channum;c++) {
mp_ubyte slot[5];
memset(slot,0,5);
if ((buffer[pc]&128)) {
mp_ubyte pb = buffer[pc];
pc++;
if ((pb&1)) {
//phead[y].patternData[bc]=buffer[pc];
slot[0]=buffer[pc];
pc++;
}
if ((pb&2)) {
//phead[y].patternData[bc+1]=buffer[pc];
slot[1]=buffer[pc];
pc++;
}
if ((pb&4)) {
//phead[y].patternData[bc+2]=buffer[pc];
slot[2]=buffer[pc];
pc++;
}
if ((pb&8)) {
//phead[y].patternData[bc+3]=buffer[pc];
slot[3]=buffer[pc];
pc++;
}
if ((pb&16)) {
//phead[y].patternData[bc+4]=buffer[pc];
slot[4]=buffer[pc];
pc++;
}
}
else {
//memcpy(phead[y].patternData+bc,buffer+pc,5);
memcpy(slot,buffer+pc,5);
pc+=5;
}
char gl=0;
for (mp_sint32 i=0;i<XModule::numValidXMEffects;i++)
if (slot[3]==XModule::validXMEffects[i]) gl=1;
if (!gl) slot[3]=slot[4]=0;
if ((slot[3]==0xC)||(slot[3]==0x10)) {
slot[4] = XModule::vol64to255(slot[4]);
/*mp_sint32 bl = slot[4];
if (bl>64) bl=64;
slot[4]=(bl*261120)>>16;*/
}
if ((!slot[3])&&(slot[4])) slot[3]=0x20;
if (slot[3]==0xE) {
slot[3]=(slot[4]>>4)+0x30;
slot[4]=slot[4]&0xf;
}
if (slot[3]==0x21) {
slot[3]=(slot[4]>>4)+0x40;
slot[4]=slot[4]&0xf;
}
if (slot[0]==97) slot[0]=XModule::NOTE_OFF;
phead[y].patternData[bc]=slot[0];
phead[y].patternData[bc+1]=slot[1];
XModule::convertXMVolumeEffects(slot[2], phead[y].patternData[bc+2], phead[y].patternData[bc+3]);
phead[y].patternData[bc+4]=slot[3];
phead[y].patternData[bc+5]=slot[4];
/*if ((y==3)&&(c==2)) {
for (mp_sint32 bl=0;bl<6;bl++) cprintf("%x ",phead[y].patternData[bc+bl]);
cprintf("\r\n");
getch();
};*/
/*printf("Note : %i\r\n",phead[y].patternData[bc]);
printf("Ins : %i\r\n",phead[y].patternData[bc+1]);
printf("Vol : %i\r\n",phead[y].patternData[bc+2]);
printf("Eff : %i\r\n",phead[y].patternData[bc+3]);
printf("Effop: %i\r\n",phead[y].patternData[bc+4]);
getch();*/
bc+=6;
} // for c
} // for r
delete[] buffer;
}
}
if (header->ver == 0x104)
{
mp_sint32 s = 0;
mp_sint32 e = 0;
for (y=0;y<header->insnum;y++) {
// fixes MOOH.XM loading problems
// seems to store more instruments in the header than in the actual file
if (f.posWithBaseOffset() >= fileSize)
break;
//TXMInstrument* ins = &instr[y];
f.readDwords(&instr[y].size,1);
if (instr[y].size < 29)
{
mp_ubyte buffer[29];
memset(buffer, 0, sizeof(buffer));
f.read(buffer, 1, instr[y].size - 4);
memcpy(instr[y].name, buffer, 22);
instr[y].type = buffer[22];
instr[y].samp = LittleEndian::GET_WORD(buffer + 23);
}
else
{
f.read(&instr[y].name,1,22);
f.read(&instr[y].type,1,1);
f.readWords(&instr[y].samp,1);
}
if (instr[y].samp > MP_MAXINSSAMPS)
return MP_LOADER_FAILED;
//printf("%i, %i\n", instr[y].size, instr[y].samp);
if (instr[y].size <= 29)
{
#ifdef MILKYTRACKER
s+=16;
#endif
for (mp_sint32 i = 0; i < 120; i++)
instr[y].snum[i] = -1;
continue;
}
f.readDwords(&instr[y].shsize,1);
#ifdef VERBOSE
printf("%i/%i: %i, %i, %i, %s\n",y,header->insnum-1,instr[y].size,instr[y].shsize,instr[y].samp,instr[y].name);
#endif
memset(insData, 0, 230);
if (instr[y].size - 33 > 230)
{
//return -7;
break;
}
f.read(insData, 1, instr[y].size - 33);
/*printf("%i\r\n",instr[y].size);
printf("%s\r\n",instr[y].name);
printf("%i\r\n",instr[y].type);
printf("%i\r\n",instr[y].samp);
printf("%i\r\n",instr[y].shsize);*/
//getch();
memset(smpReloc, 0, sizeof(smpReloc));
if (instr[y].samp) {
mp_ubyte* insDataPtr = insData;
//f.read(&nbu,1,96);
memcpy(nbu, insDataPtr, MP_MAXINSSAMPS);
insDataPtr+=MP_MAXINSSAMPS;
TEnvelope venv;
TEnvelope penv;
memset(&venv,0,sizeof(venv));
memset(&penv,0,sizeof(penv));
mp_sint32 k;
for (k = 0; k < XM_ENVELOPENUMPOINTS; k++)
{
venv.env[k][0] = LittleEndian::GET_WORD(insDataPtr);
venv.env[k][1] = LittleEndian::GET_WORD(insDataPtr+2);
insDataPtr+=4;
}
for (k = 0; k < XM_ENVELOPENUMPOINTS; k++)
{
penv.env[k][0] = LittleEndian::GET_WORD(insDataPtr);
penv.env[k][1] = LittleEndian::GET_WORD(insDataPtr+2);
insDataPtr+=4;
}
venv.num = *insDataPtr++;
if (venv.num > XM_ENVELOPENUMPOINTS) venv.num = XM_ENVELOPENUMPOINTS;
penv.num = *insDataPtr++;
if (penv.num > XM_ENVELOPENUMPOINTS) penv.num = XM_ENVELOPENUMPOINTS;
venv.sustain = *insDataPtr++;
venv.loops = *insDataPtr++;
venv.loope = *insDataPtr++;
penv.sustain = *insDataPtr++;
penv.loops = *insDataPtr++;
penv.loope = *insDataPtr++;
venv.type = *insDataPtr++;
penv.type = *insDataPtr++;
mp_ubyte vibtype, vibsweep, vibdepth, vibrate;
mp_uword volfade;
vibtype = *insDataPtr++;
vibsweep = *insDataPtr++;
vibdepth = *insDataPtr++;
vibrate = *insDataPtr++;
vibdepth<<=1;
//f.readWords(&volfade,1);
volfade = LittleEndian::GET_WORD(insDataPtr);
insDataPtr+=2;
volfade<<=1;
//instr[y].res = LittleEndian::GET_WORD(insDataPtr);
insDataPtr+=2;
for (mp_sint32 l=0;l<XM_ENVELOPENUMPOINTS;l++) {
venv.env[l][1]<<=2;
penv.env[l][1]<<=2;
}
if (!module->addVolumeEnvelope(venv))
return MP_OUT_OF_MEMORY;
if (!module->addPanningEnvelope(penv))
return MP_OUT_OF_MEMORY;
mp_sint32 g=0, sc;
for (sc=0;sc<instr[y].samp;sc++) {
//TXMSample* smpl = &smp[g+s];
smp[g+s].flags=3;
smp[g+s].venvnum=e+1;
smp[g+s].penvnum=e+1;
smp[g+s].vibtype=vibtype;
smp[g+s].vibsweep=vibsweep;
smp[g+s].vibdepth=vibdepth;
smp[g+s].vibrate=vibrate;
smp[g+s].volfade=volfade;
// not sure why I did that, actually doesn't make sense
//if (!(venv.type&1)) smp[g+s].volfade=0;
f.readDwords(&smp[g+s].samplen,1);
f.readDwords(&smp[g+s].loopstart,1);
f.readDwords(&smp[g+s].looplen,1);
smp[g+s].vol=XModule::vol64to255(f.readByte());
//f.read(&smp[g+s].vol,1,1);
f.read(&smp[g+s].finetune,1,1);
f.read(&smp[g+s].type,1,1);
#ifdef VERBOSE
printf("Before: %i, After: %i\n", smp[g+s].type, smp[g+s].type & (3+16));
#endif
f.read(&smp[g+s].pan,1,1);
f.read(&smp[g+s].relnote,1,1);
f.read(&smp[g+s].res,1,1);
f.read(&smp[g+s].name,1,22);
char line[30];
memset(line, 0, sizeof(line));
XModule::convertStr(line, smp[g+s].name, 23, false);
if (line[0])
module->addSongMessageLine(line);
#ifndef MILKYTRACKER
// ignore empty samples when not being a tracker
if (smp[g+s].samplen) {
smpReloc[sc] = g;
g++;
}
else
smpReloc[sc] = -1;
#else
smpReloc[sc] = g;
g++;
#endif
}
instr[y].samp = g;
for (sc = 0; sc < MP_MAXINSSAMPS; sc++) {
if (smpReloc[nbu[sc]] == -1)
instr[y].snum[sc] = -1;
else
instr[y].snum[sc] = smpReloc[nbu[sc]]+s;
}
for (sc=0;sc<instr[y].samp;sc++) {
if (smp[s].samplen)
{
bool adpcm = (smp[s].res == 0xAD);
mp_uint32 oldSize = smp[s].samplen;
if (smp[s].type&16)
{
smp[s].samplen>>=1;
smp[s].loopstart>>=1;
smp[s].looplen>>=1;
}
mp_sint32 result = module->loadModuleSample(f, s,
adpcm ? XModule::ST_PACKING_ADPCM : XModule::ST_DELTA,
adpcm ? (XModule::ST_PACKING_ADPCM | XModule::ST_16BIT) : (XModule::ST_DELTA | XModule::ST_16BIT),
oldSize);
if (result != MP_OK)
return result;
if (adpcm)
smp[s].res = 0;
}
s++;
if (s>=MP_MAXSAMPLES)
return MP_OUT_OF_MEMORY;
}
e++;
}
else
{
for (mp_sint32 i = 0; i < 120; i++)
instr[y].snum[i] = -1;
}
#ifdef MILKYTRACKER
s+=16 - instr[y].samp;
#endif
}
header->smpnum=s;
header->volenvnum=e;
header->panenvnum=e;
}
else
{
mp_sint32 s = 0;
for (y=0;y<header->insnum;y++) {
for (sc=0;sc<instr[y].samp;sc++) {
if (smp[s].samplen)
{
mp_uint32 oldSize = smp[s].samplen;
if (smp[s].type&16)
{
smp[s].samplen>>=1;
smp[s].loopstart>>=1;
smp[s].looplen>>=1;
}
mp_sint32 result = module->loadModuleSample(f, s, XModule::ST_DELTA, XModule::ST_DELTA | XModule::ST_16BIT, oldSize);
if (result != MP_OK)
return result;
}
s++;
if (s>=MP_MAXSAMPLES)
return MP_OUT_OF_MEMORY;
}
#ifdef MILKYTRACKER
s+=16 - instr[y].samp;
#endif
}
}
// convert modplug stereo samples
for (mp_sint32 s = 0; s < header->smpnum; s++)
{
if (smp[s].type & 32)
{
// that's what's allowed, stupid modplug tracker
smp[s].type &= 3+16;
if (smp[s].sample == NULL)
continue;
if (!(smp[s].type&16)) {
smp[s].samplen>>=1;
smp[s].loopstart>>=1;
smp[s].looplen>>=1;
mp_sbyte* sample = (mp_sbyte*)smp[s].sample;
mp_sint32 samplen = smp[s].samplen;
for (mp_sint32 i = 0; i < samplen; i++)
{
mp_sint32 s = ((mp_sint32)sample[i] + (mp_sint32)sample[i + samplen]) >> 1;
if (s < -128) s = -128;
if (s > 127) s = 127;
sample[i] = (mp_sbyte)s;
}
}
else
{
smp[s].samplen>>=1;
smp[s].loopstart>>=1;
smp[s].looplen>>=1;
mp_sword* sample = (mp_sword*)smp[s].sample;
mp_sint32 samplen = smp[s].samplen;
for (mp_sint32 i = 0; i < samplen; i++)
{
mp_sint32 s = ((mp_sint32)sample[i] + (mp_sint32)sample[i + samplen]) >> 1;
if (s < -32768) s = -32768;
if (s > 32767) s = 32767;
sample[i] = (mp_sword)s;
}
}
}
// correct loop type 0x03 (undefined)
// will become ping pong loop
// note that FT2 will refuse to load XM files with such a loop type
if ((smp[s].type & 0x3) == 0x3)
smp[s].type&=~1;
}
// correct number of patterns if necessary, otherwise the post processing will remove
// the "invalid" patterns from the order list
bool addPatterns = false;
for (i = 0; i < header->ordnum; i++)
if (header->ord[i]+1 > header->patnum)
{
header->patnum = header->ord[i]+1;
addPatterns = true;
}
// if the pattern number has been adjusted, add some empty patterns
if (addPatterns)
{
for (i = 0; i < header->patnum; i++)
if (phead[i].patternData == NULL)
{
phead[i].rows = 64;
phead[i].effnum = 2;
phead[i].channum = (mp_ubyte)header->channum;
phead[i].patternData = new mp_ubyte[phead[i].rows*header->channum*6];
// out of memory?
if (phead[i].patternData == NULL)
{
return MP_OUT_OF_MEMORY;
}
memset(phead[i].patternData,0,phead[i].rows*header->channum*6);
}
}
// check for MODPLUG extensions
if (f.posWithBaseOffset() + 8 <= fileSize)
{
char buffer[4];
f.read(buffer, 1, 4);
if (memcmp(buffer, "text", 4) == 0)
{
mp_uint32 len = f.readDword();
module->allocateSongMessage(len+1);
memset(module->message, 0, len+1);
f.read(module->message, 1, len);
}
}
module->postProcessSamples();
return MP_OK;
} | 4841 | True | 1 |
CVE-2020-15888 | False | False | False | True | AV:N/AC:M/Au:N/C:P/I:P/A:P | NETWORK | MEDIUM | NONE | PARTIAL | PARTIAL | PARTIAL | 6.8 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | REQUIRED | UNCHANGED | HIGH | HIGH | HIGH | 8.8 | HIGH | 2.8 | 5.9 | False | [{'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00054.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00054.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'https://github.com/lua/lua/commit/6298903e35217ab69c279056f925fb72900ce0b7', 'name': 'https://github.com/lua/lua/commit/6298903e35217ab69c279056f925fb72900ce0b7', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00079.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00079.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'https://github.com/lua/lua/commit/eb41999461b6f428186c55abd95f4ce1a76217d5', 'name': 'https://github.com/lua/lua/commit/eb41999461b6f428186c55abd95f4ce1a76217d5', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00071.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00071.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00053.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00053.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}, {'lang': 'en', 'value': 'CWE-787'}, {'lang': 'en', 'value': 'CWE-416'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:lua:lua:*:*:*:*:*:*:*:*', 'versionEndIncluding': '5.4.0', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Lua through 5.4.0 mishandles the interaction between stack resizes and garbage collection, leading to a heap-based buffer overflow, heap-based buffer over-read, or use-after-free.'}] | 2021-07-21T11:39Z | 2020-07-21T22:15Z | Out-of-bounds Read | The software reads data past the end, or before the beginning, of the intended buffer. | Typically, this can allow attackers to read sensitive information from other memory locations or cause a crash. A crash can occur when the code reads a variable amount of data and assumes that a sentinel exists to stop the read operation, such as a NUL in a string. The expected sentinel might not be located in the out-of-bounds memory, causing excessive data to be read, leading to a segmentation fault or a buffer overflow. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent read operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/125.html | 0 | Roberto Ierusalimschy | 2020-07-06 12:11:54-03:00 | Keep minimum size when shrinking a stack
When shrinking a stack (during GC), do not make it smaller than the
initial stack size. | 6298903e35217ab69c279056f925fb72900ce0b7 | False | lua/lua | The Lua development repository, as seen by the Lua team. Mirrored irregularly. Please DO NOT send pull requests. Report issues in the Lua mailing list https://www.lua.org/lua-l.html | 2012-09-14 05:55:07 | 2022-08-24 20:40:26 | https://www.lua.org/ | lua | 5964.0 | 1279.0 | luaD_shrinkstack | luaD_shrinkstack( lua_State * L) | ['L'] | void luaD_shrinkstack (lua_State *L) {
int inuse = stackinuse(L);
int goodsize = inuse + (inuse / 8) + 2*EXTRA_STACK;
if (goodsize > LUAI_MAXSTACK)
goodsize = LUAI_MAXSTACK; /* respect stack limit */
/* if thread is currently not handling a stack overflow and its
good size is smaller than current size, shrink its stack */
if (inuse <= (LUAI_MAXSTACK - EXTRA_STACK) &&
goodsize < L->stacksize)
luaD_reallocstack(L, goodsize, 0); /* ok if that fails */
else /* don't change stack */
condmovestack(L,{},{}); /* (change only for debugging) */
luaE_shrinkCI(L); /* shrink CI list */
} | 83 | True | 1 |
CVE-2020-15888 | False | False | False | True | AV:N/AC:M/Au:N/C:P/I:P/A:P | NETWORK | MEDIUM | NONE | PARTIAL | PARTIAL | PARTIAL | 6.8 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | REQUIRED | UNCHANGED | HIGH | HIGH | HIGH | 8.8 | HIGH | 2.8 | 5.9 | False | [{'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00054.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00054.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'https://github.com/lua/lua/commit/6298903e35217ab69c279056f925fb72900ce0b7', 'name': 'https://github.com/lua/lua/commit/6298903e35217ab69c279056f925fb72900ce0b7', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00079.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00079.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'https://github.com/lua/lua/commit/eb41999461b6f428186c55abd95f4ce1a76217d5', 'name': 'https://github.com/lua/lua/commit/eb41999461b6f428186c55abd95f4ce1a76217d5', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00071.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00071.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00053.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00053.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}, {'lang': 'en', 'value': 'CWE-787'}, {'lang': 'en', 'value': 'CWE-416'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:lua:lua:*:*:*:*:*:*:*:*', 'versionEndIncluding': '5.4.0', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Lua through 5.4.0 mishandles the interaction between stack resizes and garbage collection, leading to a heap-based buffer overflow, heap-based buffer over-read, or use-after-free.'}] | 2021-07-21T11:39Z | 2020-07-21T22:15Z | Use After Free | Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code. |
The use of previously-freed memory can have any number of adverse consequences, ranging from the corruption of valid data to the execution of arbitrary code, depending on the instantiation and timing of the flaw. The simplest way data corruption may occur involves the system's reuse of the freed memory. Use-after-free errors have two common and sometimes overlapping causes:
Error conditions and other exceptional circumstances.
Confusion over which part of the program is responsible for freeing the memory.
In this scenario, the memory in question is allocated to another pointer validly at some point after it has been freed. The original pointer to the freed memory is used again and points to somewhere within the new allocation. As the data is changed, it corrupts the validly used memory; this induces undefined behavior in the process.
If the newly allocated data chances to hold a class, in C++ for example, various function pointers may be scattered within the heap data. If one of these function pointers is overwritten with an address to valid shellcode, execution of arbitrary code can be achieved.
| https://cwe.mitre.org/data/definitions/416.html | 0 | Roberto Ierusalimschy | 2020-07-06 12:11:54-03:00 | Keep minimum size when shrinking a stack
When shrinking a stack (during GC), do not make it smaller than the
initial stack size. | 6298903e35217ab69c279056f925fb72900ce0b7 | False | lua/lua | The Lua development repository, as seen by the Lua team. Mirrored irregularly. Please DO NOT send pull requests. Report issues in the Lua mailing list https://www.lua.org/lua-l.html | 2012-09-14 05:55:07 | 2022-08-24 20:40:26 | https://www.lua.org/ | lua | 5964.0 | 1279.0 | luaD_shrinkstack | luaD_shrinkstack( lua_State * L) | ['L'] | void luaD_shrinkstack (lua_State *L) {
int inuse = stackinuse(L);
int goodsize = inuse + (inuse / 8) + 2*EXTRA_STACK;
if (goodsize > LUAI_MAXSTACK)
goodsize = LUAI_MAXSTACK; /* respect stack limit */
/* if thread is currently not handling a stack overflow and its
good size is smaller than current size, shrink its stack */
if (inuse <= (LUAI_MAXSTACK - EXTRA_STACK) &&
goodsize < L->stacksize)
luaD_reallocstack(L, goodsize, 0); /* ok if that fails */
else /* don't change stack */
condmovestack(L,{},{}); /* (change only for debugging) */
luaE_shrinkCI(L); /* shrink CI list */
} | 83 | True | 1 |
CVE-2020-15888 | False | False | False | True | AV:N/AC:M/Au:N/C:P/I:P/A:P | NETWORK | MEDIUM | NONE | PARTIAL | PARTIAL | PARTIAL | 6.8 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | REQUIRED | UNCHANGED | HIGH | HIGH | HIGH | 8.8 | HIGH | 2.8 | 5.9 | False | [{'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00054.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00054.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'https://github.com/lua/lua/commit/6298903e35217ab69c279056f925fb72900ce0b7', 'name': 'https://github.com/lua/lua/commit/6298903e35217ab69c279056f925fb72900ce0b7', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00079.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00079.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'https://github.com/lua/lua/commit/eb41999461b6f428186c55abd95f4ce1a76217d5', 'name': 'https://github.com/lua/lua/commit/eb41999461b6f428186c55abd95f4ce1a76217d5', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00071.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00071.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00053.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00053.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}, {'lang': 'en', 'value': 'CWE-787'}, {'lang': 'en', 'value': 'CWE-416'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:lua:lua:*:*:*:*:*:*:*:*', 'versionEndIncluding': '5.4.0', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Lua through 5.4.0 mishandles the interaction between stack resizes and garbage collection, leading to a heap-based buffer overflow, heap-based buffer over-read, or use-after-free.'}] | 2021-07-21T11:39Z | 2020-07-21T22:15Z | Out-of-bounds Write | The software writes data past the end, or before the beginning, of the intended buffer. | Typically, this can result in corruption of data, a crash, or code execution. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent write operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/787.html | 0 | Roberto Ierusalimschy | 2020-07-06 12:11:54-03:00 | Keep minimum size when shrinking a stack
When shrinking a stack (during GC), do not make it smaller than the
initial stack size. | 6298903e35217ab69c279056f925fb72900ce0b7 | False | lua/lua | The Lua development repository, as seen by the Lua team. Mirrored irregularly. Please DO NOT send pull requests. Report issues in the Lua mailing list https://www.lua.org/lua-l.html | 2012-09-14 05:55:07 | 2022-08-24 20:40:26 | https://www.lua.org/ | lua | 5964.0 | 1279.0 | luaD_shrinkstack | luaD_shrinkstack( lua_State * L) | ['L'] | void luaD_shrinkstack (lua_State *L) {
int inuse = stackinuse(L);
int goodsize = inuse + (inuse / 8) + 2*EXTRA_STACK;
if (goodsize > LUAI_MAXSTACK)
goodsize = LUAI_MAXSTACK; /* respect stack limit */
/* if thread is currently not handling a stack overflow and its
good size is smaller than current size, shrink its stack */
if (inuse <= (LUAI_MAXSTACK - EXTRA_STACK) &&
goodsize < L->stacksize)
luaD_reallocstack(L, goodsize, 0); /* ok if that fails */
else /* don't change stack */
condmovestack(L,{},{}); /* (change only for debugging) */
luaE_shrinkCI(L); /* shrink CI list */
} | 83 | True | 1 |
CVE-2020-15888 | False | False | False | True | AV:N/AC:M/Au:N/C:P/I:P/A:P | NETWORK | MEDIUM | NONE | PARTIAL | PARTIAL | PARTIAL | 6.8 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | REQUIRED | UNCHANGED | HIGH | HIGH | HIGH | 8.8 | HIGH | 2.8 | 5.9 | False | [{'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00054.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00054.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'https://github.com/lua/lua/commit/6298903e35217ab69c279056f925fb72900ce0b7', 'name': 'https://github.com/lua/lua/commit/6298903e35217ab69c279056f925fb72900ce0b7', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00079.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00079.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'https://github.com/lua/lua/commit/eb41999461b6f428186c55abd95f4ce1a76217d5', 'name': 'https://github.com/lua/lua/commit/eb41999461b6f428186c55abd95f4ce1a76217d5', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00071.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00071.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00053.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00053.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}, {'lang': 'en', 'value': 'CWE-787'}, {'lang': 'en', 'value': 'CWE-416'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:lua:lua:*:*:*:*:*:*:*:*', 'versionEndIncluding': '5.4.0', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Lua through 5.4.0 mishandles the interaction between stack resizes and garbage collection, leading to a heap-based buffer overflow, heap-based buffer over-read, or use-after-free.'}] | 2021-07-21T11:39Z | 2020-07-21T22:15Z | Out-of-bounds Read | The software reads data past the end, or before the beginning, of the intended buffer. | Typically, this can allow attackers to read sensitive information from other memory locations or cause a crash. A crash can occur when the code reads a variable amount of data and assumes that a sentinel exists to stop the read operation, such as a NUL in a string. The expected sentinel might not be located in the out-of-bounds memory, causing excessive data to be read, leading to a segmentation fault or a buffer overflow. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent read operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/125.html | 0 | Roberto Ierusalimschy | 2020-07-07 18:03:48-03:00 | Fixed bugs of stack reallocation x GC
Macro 'checkstackGC' was doing a GC step after resizing the stack;
the GC could shrink the stack and undo the resize. Moreover, macro
'checkstackp' also does a GC step, which could remove the preallocated
CallInfo when calling a function. (Its name has been changed to
'checkstackGCp' to emphasize that it calls the GC.) | eb41999461b6f428186c55abd95f4ce1a76217d5 | False | lua/lua | The Lua development repository, as seen by the Lua team. Mirrored irregularly. Please DO NOT send pull requests. Report issues in the Lua mailing list https://www.lua.org/lua-l.html | 2012-09-14 05:55:07 | 2022-08-24 20:40:26 | https://www.lua.org/ | lua | 5964.0 | 1279.0 | luaD_call | luaD_call( lua_State * L , StkId func , int nresults) | ['L', 'func', 'nresults'] | void luaD_call (lua_State *L, StkId func, int nresults) {
lua_CFunction f;
retry:
switch (ttypetag(s2v(func))) {
case LUA_VCCL: /* C closure */
f = clCvalue(s2v(func))->f;
goto Cfunc;
case LUA_VLCF: /* light C function */
f = fvalue(s2v(func));
Cfunc: {
int n; /* number of returns */
CallInfo *ci = next_ci(L);
checkstackp(L, LUA_MINSTACK, func); /* ensure minimum stack size */
ci->nresults = nresults;
ci->callstatus = CIST_C;
ci->top = L->top + LUA_MINSTACK;
ci->func = func;
L->ci = ci;
lua_assert(ci->top <= L->stack_last);
if (L->hookmask & LUA_MASKCALL) {
int narg = cast_int(L->top - func) - 1;
luaD_hook(L, LUA_HOOKCALL, -1, 1, narg);
}
lua_unlock(L);
n = (*f)(L); /* do the actual call */
lua_lock(L);
api_checknelems(L, n);
luaD_poscall(L, ci, n);
break;
}
case LUA_VLCL: { /* Lua function */
CallInfo *ci = next_ci(L);
Proto *p = clLvalue(s2v(func))->p;
int narg = cast_int(L->top - func) - 1; /* number of real arguments */
int nfixparams = p->numparams;
int fsize = p->maxstacksize; /* frame size */
checkstackp(L, fsize, func);
ci->nresults = nresults;
ci->u.l.savedpc = p->code; /* starting point */
ci->callstatus = 0;
ci->top = func + 1 + fsize;
ci->func = func;
L->ci = ci;
for (; narg < nfixparams; narg++)
setnilvalue(s2v(L->top++)); /* complete missing arguments */
lua_assert(ci->top <= L->stack_last);
luaV_execute(L, ci); /* run the function */
break;
}
default: { /* not a function */
checkstackp(L, 1, func); /* space for metamethod */
luaD_tryfuncTM(L, func); /* try to get '__call' metamethod */
goto retry; /* try again with metamethod */
}
}
} | 383 | True | 1 |
CVE-2020-15888 | False | False | False | True | AV:N/AC:M/Au:N/C:P/I:P/A:P | NETWORK | MEDIUM | NONE | PARTIAL | PARTIAL | PARTIAL | 6.8 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | REQUIRED | UNCHANGED | HIGH | HIGH | HIGH | 8.8 | HIGH | 2.8 | 5.9 | False | [{'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00054.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00054.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'https://github.com/lua/lua/commit/6298903e35217ab69c279056f925fb72900ce0b7', 'name': 'https://github.com/lua/lua/commit/6298903e35217ab69c279056f925fb72900ce0b7', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00079.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00079.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'https://github.com/lua/lua/commit/eb41999461b6f428186c55abd95f4ce1a76217d5', 'name': 'https://github.com/lua/lua/commit/eb41999461b6f428186c55abd95f4ce1a76217d5', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00071.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00071.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00053.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00053.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}, {'lang': 'en', 'value': 'CWE-787'}, {'lang': 'en', 'value': 'CWE-416'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:lua:lua:*:*:*:*:*:*:*:*', 'versionEndIncluding': '5.4.0', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Lua through 5.4.0 mishandles the interaction between stack resizes and garbage collection, leading to a heap-based buffer overflow, heap-based buffer over-read, or use-after-free.'}] | 2021-07-21T11:39Z | 2020-07-21T22:15Z | Use After Free | Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code. |
The use of previously-freed memory can have any number of adverse consequences, ranging from the corruption of valid data to the execution of arbitrary code, depending on the instantiation and timing of the flaw. The simplest way data corruption may occur involves the system's reuse of the freed memory. Use-after-free errors have two common and sometimes overlapping causes:
Error conditions and other exceptional circumstances.
Confusion over which part of the program is responsible for freeing the memory.
In this scenario, the memory in question is allocated to another pointer validly at some point after it has been freed. The original pointer to the freed memory is used again and points to somewhere within the new allocation. As the data is changed, it corrupts the validly used memory; this induces undefined behavior in the process.
If the newly allocated data chances to hold a class, in C++ for example, various function pointers may be scattered within the heap data. If one of these function pointers is overwritten with an address to valid shellcode, execution of arbitrary code can be achieved.
| https://cwe.mitre.org/data/definitions/416.html | 0 | Roberto Ierusalimschy | 2020-07-07 18:03:48-03:00 | Fixed bugs of stack reallocation x GC
Macro 'checkstackGC' was doing a GC step after resizing the stack;
the GC could shrink the stack and undo the resize. Moreover, macro
'checkstackp' also does a GC step, which could remove the preallocated
CallInfo when calling a function. (Its name has been changed to
'checkstackGCp' to emphasize that it calls the GC.) | eb41999461b6f428186c55abd95f4ce1a76217d5 | False | lua/lua | The Lua development repository, as seen by the Lua team. Mirrored irregularly. Please DO NOT send pull requests. Report issues in the Lua mailing list https://www.lua.org/lua-l.html | 2012-09-14 05:55:07 | 2022-08-24 20:40:26 | https://www.lua.org/ | lua | 5964.0 | 1279.0 | luaD_call | luaD_call( lua_State * L , StkId func , int nresults) | ['L', 'func', 'nresults'] | void luaD_call (lua_State *L, StkId func, int nresults) {
lua_CFunction f;
retry:
switch (ttypetag(s2v(func))) {
case LUA_VCCL: /* C closure */
f = clCvalue(s2v(func))->f;
goto Cfunc;
case LUA_VLCF: /* light C function */
f = fvalue(s2v(func));
Cfunc: {
int n; /* number of returns */
CallInfo *ci = next_ci(L);
checkstackp(L, LUA_MINSTACK, func); /* ensure minimum stack size */
ci->nresults = nresults;
ci->callstatus = CIST_C;
ci->top = L->top + LUA_MINSTACK;
ci->func = func;
L->ci = ci;
lua_assert(ci->top <= L->stack_last);
if (L->hookmask & LUA_MASKCALL) {
int narg = cast_int(L->top - func) - 1;
luaD_hook(L, LUA_HOOKCALL, -1, 1, narg);
}
lua_unlock(L);
n = (*f)(L); /* do the actual call */
lua_lock(L);
api_checknelems(L, n);
luaD_poscall(L, ci, n);
break;
}
case LUA_VLCL: { /* Lua function */
CallInfo *ci = next_ci(L);
Proto *p = clLvalue(s2v(func))->p;
int narg = cast_int(L->top - func) - 1; /* number of real arguments */
int nfixparams = p->numparams;
int fsize = p->maxstacksize; /* frame size */
checkstackp(L, fsize, func);
ci->nresults = nresults;
ci->u.l.savedpc = p->code; /* starting point */
ci->callstatus = 0;
ci->top = func + 1 + fsize;
ci->func = func;
L->ci = ci;
for (; narg < nfixparams; narg++)
setnilvalue(s2v(L->top++)); /* complete missing arguments */
lua_assert(ci->top <= L->stack_last);
luaV_execute(L, ci); /* run the function */
break;
}
default: { /* not a function */
checkstackp(L, 1, func); /* space for metamethod */
luaD_tryfuncTM(L, func); /* try to get '__call' metamethod */
goto retry; /* try again with metamethod */
}
}
} | 383 | True | 1 |
CVE-2020-15888 | False | False | False | True | AV:N/AC:M/Au:N/C:P/I:P/A:P | NETWORK | MEDIUM | NONE | PARTIAL | PARTIAL | PARTIAL | 6.8 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | REQUIRED | UNCHANGED | HIGH | HIGH | HIGH | 8.8 | HIGH | 2.8 | 5.9 | False | [{'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00054.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00054.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'https://github.com/lua/lua/commit/6298903e35217ab69c279056f925fb72900ce0b7', 'name': 'https://github.com/lua/lua/commit/6298903e35217ab69c279056f925fb72900ce0b7', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00079.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00079.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'https://github.com/lua/lua/commit/eb41999461b6f428186c55abd95f4ce1a76217d5', 'name': 'https://github.com/lua/lua/commit/eb41999461b6f428186c55abd95f4ce1a76217d5', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00071.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00071.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00053.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00053.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}, {'lang': 'en', 'value': 'CWE-787'}, {'lang': 'en', 'value': 'CWE-416'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:lua:lua:*:*:*:*:*:*:*:*', 'versionEndIncluding': '5.4.0', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Lua through 5.4.0 mishandles the interaction between stack resizes and garbage collection, leading to a heap-based buffer overflow, heap-based buffer over-read, or use-after-free.'}] | 2021-07-21T11:39Z | 2020-07-21T22:15Z | Out-of-bounds Write | The software writes data past the end, or before the beginning, of the intended buffer. | Typically, this can result in corruption of data, a crash, or code execution. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent write operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/787.html | 0 | Roberto Ierusalimschy | 2020-07-07 18:03:48-03:00 | Fixed bugs of stack reallocation x GC
Macro 'checkstackGC' was doing a GC step after resizing the stack;
the GC could shrink the stack and undo the resize. Moreover, macro
'checkstackp' also does a GC step, which could remove the preallocated
CallInfo when calling a function. (Its name has been changed to
'checkstackGCp' to emphasize that it calls the GC.) | eb41999461b6f428186c55abd95f4ce1a76217d5 | False | lua/lua | The Lua development repository, as seen by the Lua team. Mirrored irregularly. Please DO NOT send pull requests. Report issues in the Lua mailing list https://www.lua.org/lua-l.html | 2012-09-14 05:55:07 | 2022-08-24 20:40:26 | https://www.lua.org/ | lua | 5964.0 | 1279.0 | luaD_call | luaD_call( lua_State * L , StkId func , int nresults) | ['L', 'func', 'nresults'] | void luaD_call (lua_State *L, StkId func, int nresults) {
lua_CFunction f;
retry:
switch (ttypetag(s2v(func))) {
case LUA_VCCL: /* C closure */
f = clCvalue(s2v(func))->f;
goto Cfunc;
case LUA_VLCF: /* light C function */
f = fvalue(s2v(func));
Cfunc: {
int n; /* number of returns */
CallInfo *ci = next_ci(L);
checkstackp(L, LUA_MINSTACK, func); /* ensure minimum stack size */
ci->nresults = nresults;
ci->callstatus = CIST_C;
ci->top = L->top + LUA_MINSTACK;
ci->func = func;
L->ci = ci;
lua_assert(ci->top <= L->stack_last);
if (L->hookmask & LUA_MASKCALL) {
int narg = cast_int(L->top - func) - 1;
luaD_hook(L, LUA_HOOKCALL, -1, 1, narg);
}
lua_unlock(L);
n = (*f)(L); /* do the actual call */
lua_lock(L);
api_checknelems(L, n);
luaD_poscall(L, ci, n);
break;
}
case LUA_VLCL: { /* Lua function */
CallInfo *ci = next_ci(L);
Proto *p = clLvalue(s2v(func))->p;
int narg = cast_int(L->top - func) - 1; /* number of real arguments */
int nfixparams = p->numparams;
int fsize = p->maxstacksize; /* frame size */
checkstackp(L, fsize, func);
ci->nresults = nresults;
ci->u.l.savedpc = p->code; /* starting point */
ci->callstatus = 0;
ci->top = func + 1 + fsize;
ci->func = func;
L->ci = ci;
for (; narg < nfixparams; narg++)
setnilvalue(s2v(L->top++)); /* complete missing arguments */
lua_assert(ci->top <= L->stack_last);
luaV_execute(L, ci); /* run the function */
break;
}
default: { /* not a function */
checkstackp(L, 1, func); /* space for metamethod */
luaD_tryfuncTM(L, func); /* try to get '__call' metamethod */
goto retry; /* try again with metamethod */
}
}
} | 383 | True | 1 |
CVE-2020-15888 | False | False | False | True | AV:N/AC:M/Au:N/C:P/I:P/A:P | NETWORK | MEDIUM | NONE | PARTIAL | PARTIAL | PARTIAL | 6.8 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | REQUIRED | UNCHANGED | HIGH | HIGH | HIGH | 8.8 | HIGH | 2.8 | 5.9 | False | [{'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00054.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00054.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'https://github.com/lua/lua/commit/6298903e35217ab69c279056f925fb72900ce0b7', 'name': 'https://github.com/lua/lua/commit/6298903e35217ab69c279056f925fb72900ce0b7', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00079.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00079.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'https://github.com/lua/lua/commit/eb41999461b6f428186c55abd95f4ce1a76217d5', 'name': 'https://github.com/lua/lua/commit/eb41999461b6f428186c55abd95f4ce1a76217d5', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00071.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00071.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00053.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00053.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}, {'lang': 'en', 'value': 'CWE-787'}, {'lang': 'en', 'value': 'CWE-416'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:lua:lua:*:*:*:*:*:*:*:*', 'versionEndIncluding': '5.4.0', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Lua through 5.4.0 mishandles the interaction between stack resizes and garbage collection, leading to a heap-based buffer overflow, heap-based buffer over-read, or use-after-free.'}] | 2021-07-21T11:39Z | 2020-07-21T22:15Z | Out-of-bounds Read | The software reads data past the end, or before the beginning, of the intended buffer. | Typically, this can allow attackers to read sensitive information from other memory locations or cause a crash. A crash can occur when the code reads a variable amount of data and assumes that a sentinel exists to stop the read operation, such as a NUL in a string. The expected sentinel might not be located in the out-of-bounds memory, causing excessive data to be read, leading to a segmentation fault or a buffer overflow. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent read operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/125.html | 0 | Roberto Ierusalimschy | 2020-07-07 18:03:48-03:00 | Fixed bugs of stack reallocation x GC
Macro 'checkstackGC' was doing a GC step after resizing the stack;
the GC could shrink the stack and undo the resize. Moreover, macro
'checkstackp' also does a GC step, which could remove the preallocated
CallInfo when calling a function. (Its name has been changed to
'checkstackGCp' to emphasize that it calls the GC.) | eb41999461b6f428186c55abd95f4ce1a76217d5 | False | lua/lua | The Lua development repository, as seen by the Lua team. Mirrored irregularly. Please DO NOT send pull requests. Report issues in the Lua mailing list https://www.lua.org/lua-l.html | 2012-09-14 05:55:07 | 2022-08-24 20:40:26 | https://www.lua.org/ | lua | 5964.0 | 1279.0 | luaT_adjustvarargs | luaT_adjustvarargs( lua_State * L , int nfixparams , CallInfo * ci , const Proto * p) | ['L', 'nfixparams', 'ci', 'p'] | void luaT_adjustvarargs (lua_State *L, int nfixparams, CallInfo *ci,
const Proto *p) {
int i;
int actual = cast_int(L->top - ci->func) - 1; /* number of arguments */
int nextra = actual - nfixparams; /* number of extra arguments */
ci->u.l.nextraargs = nextra;
checkstackGC(L, p->maxstacksize + 1);
/* copy function to the top of the stack */
setobjs2s(L, L->top++, ci->func);
/* move fixed parameters to the top of the stack */
for (i = 1; i <= nfixparams; i++) {
setobjs2s(L, L->top++, ci->func + i);
setnilvalue(s2v(ci->func + i)); /* erase original parameter (for GC) */
}
ci->func += actual + 1;
ci->top += actual + 1;
lua_assert(L->top <= ci->top && ci->top <= L->stack_last);
} | 159 | True | 1 |
CVE-2020-15888 | False | False | False | True | AV:N/AC:M/Au:N/C:P/I:P/A:P | NETWORK | MEDIUM | NONE | PARTIAL | PARTIAL | PARTIAL | 6.8 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | REQUIRED | UNCHANGED | HIGH | HIGH | HIGH | 8.8 | HIGH | 2.8 | 5.9 | False | [{'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00054.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00054.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'https://github.com/lua/lua/commit/6298903e35217ab69c279056f925fb72900ce0b7', 'name': 'https://github.com/lua/lua/commit/6298903e35217ab69c279056f925fb72900ce0b7', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00079.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00079.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'https://github.com/lua/lua/commit/eb41999461b6f428186c55abd95f4ce1a76217d5', 'name': 'https://github.com/lua/lua/commit/eb41999461b6f428186c55abd95f4ce1a76217d5', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00071.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00071.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00053.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00053.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}, {'lang': 'en', 'value': 'CWE-787'}, {'lang': 'en', 'value': 'CWE-416'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:lua:lua:*:*:*:*:*:*:*:*', 'versionEndIncluding': '5.4.0', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Lua through 5.4.0 mishandles the interaction between stack resizes and garbage collection, leading to a heap-based buffer overflow, heap-based buffer over-read, or use-after-free.'}] | 2021-07-21T11:39Z | 2020-07-21T22:15Z | Use After Free | Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code. |
The use of previously-freed memory can have any number of adverse consequences, ranging from the corruption of valid data to the execution of arbitrary code, depending on the instantiation and timing of the flaw. The simplest way data corruption may occur involves the system's reuse of the freed memory. Use-after-free errors have two common and sometimes overlapping causes:
Error conditions and other exceptional circumstances.
Confusion over which part of the program is responsible for freeing the memory.
In this scenario, the memory in question is allocated to another pointer validly at some point after it has been freed. The original pointer to the freed memory is used again and points to somewhere within the new allocation. As the data is changed, it corrupts the validly used memory; this induces undefined behavior in the process.
If the newly allocated data chances to hold a class, in C++ for example, various function pointers may be scattered within the heap data. If one of these function pointers is overwritten with an address to valid shellcode, execution of arbitrary code can be achieved.
| https://cwe.mitre.org/data/definitions/416.html | 0 | Roberto Ierusalimschy | 2020-07-07 18:03:48-03:00 | Fixed bugs of stack reallocation x GC
Macro 'checkstackGC' was doing a GC step after resizing the stack;
the GC could shrink the stack and undo the resize. Moreover, macro
'checkstackp' also does a GC step, which could remove the preallocated
CallInfo when calling a function. (Its name has been changed to
'checkstackGCp' to emphasize that it calls the GC.) | eb41999461b6f428186c55abd95f4ce1a76217d5 | False | lua/lua | The Lua development repository, as seen by the Lua team. Mirrored irregularly. Please DO NOT send pull requests. Report issues in the Lua mailing list https://www.lua.org/lua-l.html | 2012-09-14 05:55:07 | 2022-08-24 20:40:26 | https://www.lua.org/ | lua | 5964.0 | 1279.0 | luaT_adjustvarargs | luaT_adjustvarargs( lua_State * L , int nfixparams , CallInfo * ci , const Proto * p) | ['L', 'nfixparams', 'ci', 'p'] | void luaT_adjustvarargs (lua_State *L, int nfixparams, CallInfo *ci,
const Proto *p) {
int i;
int actual = cast_int(L->top - ci->func) - 1; /* number of arguments */
int nextra = actual - nfixparams; /* number of extra arguments */
ci->u.l.nextraargs = nextra;
checkstackGC(L, p->maxstacksize + 1);
/* copy function to the top of the stack */
setobjs2s(L, L->top++, ci->func);
/* move fixed parameters to the top of the stack */
for (i = 1; i <= nfixparams; i++) {
setobjs2s(L, L->top++, ci->func + i);
setnilvalue(s2v(ci->func + i)); /* erase original parameter (for GC) */
}
ci->func += actual + 1;
ci->top += actual + 1;
lua_assert(L->top <= ci->top && ci->top <= L->stack_last);
} | 159 | True | 1 |
CVE-2020-15888 | False | False | False | True | AV:N/AC:M/Au:N/C:P/I:P/A:P | NETWORK | MEDIUM | NONE | PARTIAL | PARTIAL | PARTIAL | 6.8 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | REQUIRED | UNCHANGED | HIGH | HIGH | HIGH | 8.8 | HIGH | 2.8 | 5.9 | False | [{'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00054.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00054.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'https://github.com/lua/lua/commit/6298903e35217ab69c279056f925fb72900ce0b7', 'name': 'https://github.com/lua/lua/commit/6298903e35217ab69c279056f925fb72900ce0b7', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00079.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00079.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'https://github.com/lua/lua/commit/eb41999461b6f428186c55abd95f4ce1a76217d5', 'name': 'https://github.com/lua/lua/commit/eb41999461b6f428186c55abd95f4ce1a76217d5', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00071.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00071.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00053.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00053.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}, {'lang': 'en', 'value': 'CWE-787'}, {'lang': 'en', 'value': 'CWE-416'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:lua:lua:*:*:*:*:*:*:*:*', 'versionEndIncluding': '5.4.0', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Lua through 5.4.0 mishandles the interaction between stack resizes and garbage collection, leading to a heap-based buffer overflow, heap-based buffer over-read, or use-after-free.'}] | 2021-07-21T11:39Z | 2020-07-21T22:15Z | Out-of-bounds Write | The software writes data past the end, or before the beginning, of the intended buffer. | Typically, this can result in corruption of data, a crash, or code execution. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent write operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/787.html | 0 | Roberto Ierusalimschy | 2020-07-07 18:03:48-03:00 | Fixed bugs of stack reallocation x GC
Macro 'checkstackGC' was doing a GC step after resizing the stack;
the GC could shrink the stack and undo the resize. Moreover, macro
'checkstackp' also does a GC step, which could remove the preallocated
CallInfo when calling a function. (Its name has been changed to
'checkstackGCp' to emphasize that it calls the GC.) | eb41999461b6f428186c55abd95f4ce1a76217d5 | False | lua/lua | The Lua development repository, as seen by the Lua team. Mirrored irregularly. Please DO NOT send pull requests. Report issues in the Lua mailing list https://www.lua.org/lua-l.html | 2012-09-14 05:55:07 | 2022-08-24 20:40:26 | https://www.lua.org/ | lua | 5964.0 | 1279.0 | luaT_adjustvarargs | luaT_adjustvarargs( lua_State * L , int nfixparams , CallInfo * ci , const Proto * p) | ['L', 'nfixparams', 'ci', 'p'] | void luaT_adjustvarargs (lua_State *L, int nfixparams, CallInfo *ci,
const Proto *p) {
int i;
int actual = cast_int(L->top - ci->func) - 1; /* number of arguments */
int nextra = actual - nfixparams; /* number of extra arguments */
ci->u.l.nextraargs = nextra;
checkstackGC(L, p->maxstacksize + 1);
/* copy function to the top of the stack */
setobjs2s(L, L->top++, ci->func);
/* move fixed parameters to the top of the stack */
for (i = 1; i <= nfixparams; i++) {
setobjs2s(L, L->top++, ci->func + i);
setnilvalue(s2v(ci->func + i)); /* erase original parameter (for GC) */
}
ci->func += actual + 1;
ci->top += actual + 1;
lua_assert(L->top <= ci->top && ci->top <= L->stack_last);
} | 159 | True | 1 |
CVE-2020-15888 | False | False | False | True | AV:N/AC:M/Au:N/C:P/I:P/A:P | NETWORK | MEDIUM | NONE | PARTIAL | PARTIAL | PARTIAL | 6.8 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | REQUIRED | UNCHANGED | HIGH | HIGH | HIGH | 8.8 | HIGH | 2.8 | 5.9 | False | [{'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00054.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00054.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'https://github.com/lua/lua/commit/6298903e35217ab69c279056f925fb72900ce0b7', 'name': 'https://github.com/lua/lua/commit/6298903e35217ab69c279056f925fb72900ce0b7', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00079.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00079.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'https://github.com/lua/lua/commit/eb41999461b6f428186c55abd95f4ce1a76217d5', 'name': 'https://github.com/lua/lua/commit/eb41999461b6f428186c55abd95f4ce1a76217d5', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00071.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00071.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00053.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00053.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}, {'lang': 'en', 'value': 'CWE-787'}, {'lang': 'en', 'value': 'CWE-416'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:lua:lua:*:*:*:*:*:*:*:*', 'versionEndIncluding': '5.4.0', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Lua through 5.4.0 mishandles the interaction between stack resizes and garbage collection, leading to a heap-based buffer overflow, heap-based buffer over-read, or use-after-free.'}] | 2021-07-21T11:39Z | 2020-07-21T22:15Z | Out-of-bounds Read | The software reads data past the end, or before the beginning, of the intended buffer. | Typically, this can allow attackers to read sensitive information from other memory locations or cause a crash. A crash can occur when the code reads a variable amount of data and assumes that a sentinel exists to stop the read operation, such as a NUL in a string. The expected sentinel might not be located in the out-of-bounds memory, causing excessive data to be read, leading to a segmentation fault or a buffer overflow. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent read operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/125.html | 0 | Roberto Ierusalimschy | 2020-07-07 18:03:48-03:00 | Fixed bugs of stack reallocation x GC
Macro 'checkstackGC' was doing a GC step after resizing the stack;
the GC could shrink the stack and undo the resize. Moreover, macro
'checkstackp' also does a GC step, which could remove the preallocated
CallInfo when calling a function. (Its name has been changed to
'checkstackGCp' to emphasize that it calls the GC.) | eb41999461b6f428186c55abd95f4ce1a76217d5 | False | lua/lua | The Lua development repository, as seen by the Lua team. Mirrored irregularly. Please DO NOT send pull requests. Report issues in the Lua mailing list https://www.lua.org/lua-l.html | 2012-09-14 05:55:07 | 2022-08-24 20:40:26 | https://www.lua.org/ | lua | 5964.0 | 1279.0 | luaT_getvarargs | luaT_getvarargs( lua_State * L , CallInfo * ci , StkId where , int wanted) | ['L', 'ci', 'where', 'wanted'] | void luaT_getvarargs (lua_State *L, CallInfo *ci, StkId where, int wanted) {
int i;
int nextra = ci->u.l.nextraargs;
if (wanted < 0) {
wanted = nextra; /* get all extra arguments available */
checkstackp(L, nextra, where); /* ensure stack space */
L->top = where + nextra; /* next instruction will need top */
}
for (i = 0; i < wanted && i < nextra; i++)
setobjs2s(L, where + i, ci->func - nextra + i);
for (; i < wanted; i++) /* complete required results with nil */
setnilvalue(s2v(where + i));
} | 115 | True | 1 |
CVE-2020-15888 | False | False | False | True | AV:N/AC:M/Au:N/C:P/I:P/A:P | NETWORK | MEDIUM | NONE | PARTIAL | PARTIAL | PARTIAL | 6.8 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | REQUIRED | UNCHANGED | HIGH | HIGH | HIGH | 8.8 | HIGH | 2.8 | 5.9 | False | [{'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00054.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00054.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'https://github.com/lua/lua/commit/6298903e35217ab69c279056f925fb72900ce0b7', 'name': 'https://github.com/lua/lua/commit/6298903e35217ab69c279056f925fb72900ce0b7', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00079.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00079.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'https://github.com/lua/lua/commit/eb41999461b6f428186c55abd95f4ce1a76217d5', 'name': 'https://github.com/lua/lua/commit/eb41999461b6f428186c55abd95f4ce1a76217d5', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00071.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00071.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00053.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00053.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}, {'lang': 'en', 'value': 'CWE-787'}, {'lang': 'en', 'value': 'CWE-416'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:lua:lua:*:*:*:*:*:*:*:*', 'versionEndIncluding': '5.4.0', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Lua through 5.4.0 mishandles the interaction between stack resizes and garbage collection, leading to a heap-based buffer overflow, heap-based buffer over-read, or use-after-free.'}] | 2021-07-21T11:39Z | 2020-07-21T22:15Z | Use After Free | Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code. |
The use of previously-freed memory can have any number of adverse consequences, ranging from the corruption of valid data to the execution of arbitrary code, depending on the instantiation and timing of the flaw. The simplest way data corruption may occur involves the system's reuse of the freed memory. Use-after-free errors have two common and sometimes overlapping causes:
Error conditions and other exceptional circumstances.
Confusion over which part of the program is responsible for freeing the memory.
In this scenario, the memory in question is allocated to another pointer validly at some point after it has been freed. The original pointer to the freed memory is used again and points to somewhere within the new allocation. As the data is changed, it corrupts the validly used memory; this induces undefined behavior in the process.
If the newly allocated data chances to hold a class, in C++ for example, various function pointers may be scattered within the heap data. If one of these function pointers is overwritten with an address to valid shellcode, execution of arbitrary code can be achieved.
| https://cwe.mitre.org/data/definitions/416.html | 0 | Roberto Ierusalimschy | 2020-07-07 18:03:48-03:00 | Fixed bugs of stack reallocation x GC
Macro 'checkstackGC' was doing a GC step after resizing the stack;
the GC could shrink the stack and undo the resize. Moreover, macro
'checkstackp' also does a GC step, which could remove the preallocated
CallInfo when calling a function. (Its name has been changed to
'checkstackGCp' to emphasize that it calls the GC.) | eb41999461b6f428186c55abd95f4ce1a76217d5 | False | lua/lua | The Lua development repository, as seen by the Lua team. Mirrored irregularly. Please DO NOT send pull requests. Report issues in the Lua mailing list https://www.lua.org/lua-l.html | 2012-09-14 05:55:07 | 2022-08-24 20:40:26 | https://www.lua.org/ | lua | 5964.0 | 1279.0 | luaT_getvarargs | luaT_getvarargs( lua_State * L , CallInfo * ci , StkId where , int wanted) | ['L', 'ci', 'where', 'wanted'] | void luaT_getvarargs (lua_State *L, CallInfo *ci, StkId where, int wanted) {
int i;
int nextra = ci->u.l.nextraargs;
if (wanted < 0) {
wanted = nextra; /* get all extra arguments available */
checkstackp(L, nextra, where); /* ensure stack space */
L->top = where + nextra; /* next instruction will need top */
}
for (i = 0; i < wanted && i < nextra; i++)
setobjs2s(L, where + i, ci->func - nextra + i);
for (; i < wanted; i++) /* complete required results with nil */
setnilvalue(s2v(where + i));
} | 115 | True | 1 |
CVE-2020-15888 | False | False | False | True | AV:N/AC:M/Au:N/C:P/I:P/A:P | NETWORK | MEDIUM | NONE | PARTIAL | PARTIAL | PARTIAL | 6.8 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | REQUIRED | UNCHANGED | HIGH | HIGH | HIGH | 8.8 | HIGH | 2.8 | 5.9 | False | [{'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00054.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00054.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'https://github.com/lua/lua/commit/6298903e35217ab69c279056f925fb72900ce0b7', 'name': 'https://github.com/lua/lua/commit/6298903e35217ab69c279056f925fb72900ce0b7', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00079.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00079.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'https://github.com/lua/lua/commit/eb41999461b6f428186c55abd95f4ce1a76217d5', 'name': 'https://github.com/lua/lua/commit/eb41999461b6f428186c55abd95f4ce1a76217d5', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00071.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00071.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00053.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00053.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}, {'lang': 'en', 'value': 'CWE-787'}, {'lang': 'en', 'value': 'CWE-416'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:lua:lua:*:*:*:*:*:*:*:*', 'versionEndIncluding': '5.4.0', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Lua through 5.4.0 mishandles the interaction between stack resizes and garbage collection, leading to a heap-based buffer overflow, heap-based buffer over-read, or use-after-free.'}] | 2021-07-21T11:39Z | 2020-07-21T22:15Z | Out-of-bounds Write | The software writes data past the end, or before the beginning, of the intended buffer. | Typically, this can result in corruption of data, a crash, or code execution. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent write operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/787.html | 0 | Roberto Ierusalimschy | 2020-07-07 18:03:48-03:00 | Fixed bugs of stack reallocation x GC
Macro 'checkstackGC' was doing a GC step after resizing the stack;
the GC could shrink the stack and undo the resize. Moreover, macro
'checkstackp' also does a GC step, which could remove the preallocated
CallInfo when calling a function. (Its name has been changed to
'checkstackGCp' to emphasize that it calls the GC.) | eb41999461b6f428186c55abd95f4ce1a76217d5 | False | lua/lua | The Lua development repository, as seen by the Lua team. Mirrored irregularly. Please DO NOT send pull requests. Report issues in the Lua mailing list https://www.lua.org/lua-l.html | 2012-09-14 05:55:07 | 2022-08-24 20:40:26 | https://www.lua.org/ | lua | 5964.0 | 1279.0 | luaT_getvarargs | luaT_getvarargs( lua_State * L , CallInfo * ci , StkId where , int wanted) | ['L', 'ci', 'where', 'wanted'] | void luaT_getvarargs (lua_State *L, CallInfo *ci, StkId where, int wanted) {
int i;
int nextra = ci->u.l.nextraargs;
if (wanted < 0) {
wanted = nextra; /* get all extra arguments available */
checkstackp(L, nextra, where); /* ensure stack space */
L->top = where + nextra; /* next instruction will need top */
}
for (i = 0; i < wanted && i < nextra; i++)
setobjs2s(L, where + i, ci->func - nextra + i);
for (; i < wanted; i++) /* complete required results with nil */
setnilvalue(s2v(where + i));
} | 115 | True | 1 |
CVE-2020-15888 | False | False | False | True | AV:N/AC:M/Au:N/C:P/I:P/A:P | NETWORK | MEDIUM | NONE | PARTIAL | PARTIAL | PARTIAL | 6.8 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | REQUIRED | UNCHANGED | HIGH | HIGH | HIGH | 8.8 | HIGH | 2.8 | 5.9 | False | [{'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00054.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00054.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'https://github.com/lua/lua/commit/6298903e35217ab69c279056f925fb72900ce0b7', 'name': 'https://github.com/lua/lua/commit/6298903e35217ab69c279056f925fb72900ce0b7', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00079.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00079.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'https://github.com/lua/lua/commit/eb41999461b6f428186c55abd95f4ce1a76217d5', 'name': 'https://github.com/lua/lua/commit/eb41999461b6f428186c55abd95f4ce1a76217d5', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00071.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00071.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00053.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00053.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}, {'lang': 'en', 'value': 'CWE-787'}, {'lang': 'en', 'value': 'CWE-416'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:lua:lua:*:*:*:*:*:*:*:*', 'versionEndIncluding': '5.4.0', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Lua through 5.4.0 mishandles the interaction between stack resizes and garbage collection, leading to a heap-based buffer overflow, heap-based buffer over-read, or use-after-free.'}] | 2021-07-21T11:39Z | 2020-07-21T22:15Z | Out-of-bounds Read | The software reads data past the end, or before the beginning, of the intended buffer. | Typically, this can allow attackers to read sensitive information from other memory locations or cause a crash. A crash can occur when the code reads a variable amount of data and assumes that a sentinel exists to stop the read operation, such as a NUL in a string. The expected sentinel might not be located in the out-of-bounds memory, causing excessive data to be read, leading to a segmentation fault or a buffer overflow. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent read operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/125.html | 0 | Roberto Ierusalimschy | 2020-07-07 18:03:48-03:00 | Fixed bugs of stack reallocation x GC
Macro 'checkstackGC' was doing a GC step after resizing the stack;
the GC could shrink the stack and undo the resize. Moreover, macro
'checkstackp' also does a GC step, which could remove the preallocated
CallInfo when calling a function. (Its name has been changed to
'checkstackGCp' to emphasize that it calls the GC.) | eb41999461b6f428186c55abd95f4ce1a76217d5 | False | lua/lua | The Lua development repository, as seen by the Lua team. Mirrored irregularly. Please DO NOT send pull requests. Report issues in the Lua mailing list https://www.lua.org/lua-l.html | 2012-09-14 05:55:07 | 2022-08-24 20:40:26 | https://www.lua.org/ | lua | 5964.0 | 1279.0 | luaV_execute | luaV_execute( lua_State * L , CallInfo * ci) | ['L', 'ci'] | void luaV_execute (lua_State *L, CallInfo *ci) {
LClosure *cl;
TValue *k;
StkId base;
const Instruction *pc;
int trap;
#if LUA_USE_JUMPTABLE
#include "ljumptab.h"
#endif
tailcall:
trap = L->hookmask;
cl = clLvalue(s2v(ci->func));
k = cl->p->k;
pc = ci->u.l.savedpc;
if (trap) {
if (cl->p->is_vararg)
trap = 0; /* hooks will start after VARARGPREP instruction */
else if (pc == cl->p->code) /* first instruction (not resuming)? */
luaD_hookcall(L, ci);
ci->u.l.trap = 1; /* there may be other hooks */
}
base = ci->func + 1;
/* main loop of interpreter */
for (;;) {
Instruction i; /* instruction being executed */
StkId ra; /* instruction's A register */
vmfetch();
lua_assert(base == ci->func + 1);
lua_assert(base <= L->top && L->top < L->stack + L->stacksize);
/* invalidate top for instructions not expecting it */
lua_assert(isIT(i) || (cast_void(L->top = base), 1));
vmdispatch (GET_OPCODE(i)) {
vmcase(OP_MOVE) {
setobjs2s(L, ra, RB(i));
vmbreak;
}
vmcase(OP_LOADI) {
lua_Integer b = GETARG_sBx(i);
setivalue(s2v(ra), b);
vmbreak;
}
vmcase(OP_LOADF) {
int b = GETARG_sBx(i);
setfltvalue(s2v(ra), cast_num(b));
vmbreak;
}
vmcase(OP_LOADK) {
TValue *rb = k + GETARG_Bx(i);
setobj2s(L, ra, rb);
vmbreak;
}
vmcase(OP_LOADKX) {
TValue *rb;
rb = k + GETARG_Ax(*pc); pc++;
setobj2s(L, ra, rb);
vmbreak;
}
vmcase(OP_LOADFALSE) {
setbfvalue(s2v(ra));
vmbreak;
}
vmcase(OP_LFALSESKIP) {
setbfvalue(s2v(ra));
pc++; /* skip next instruction */
vmbreak;
}
vmcase(OP_LOADTRUE) {
setbtvalue(s2v(ra));
vmbreak;
}
vmcase(OP_LOADNIL) {
int b = GETARG_B(i);
do {
setnilvalue(s2v(ra++));
} while (b--);
vmbreak;
}
vmcase(OP_GETUPVAL) {
int b = GETARG_B(i);
setobj2s(L, ra, cl->upvals[b]->v);
vmbreak;
}
vmcase(OP_SETUPVAL) {
UpVal *uv = cl->upvals[GETARG_B(i)];
setobj(L, uv->v, s2v(ra));
luaC_barrier(L, uv, s2v(ra));
vmbreak;
}
vmcase(OP_GETTABUP) {
const TValue *slot;
TValue *upval = cl->upvals[GETARG_B(i)]->v;
TValue *rc = KC(i);
TString *key = tsvalue(rc); /* key must be a string */
if (luaV_fastget(L, upval, key, slot, luaH_getshortstr)) {
setobj2s(L, ra, slot);
}
else
Protect(luaV_finishget(L, upval, rc, ra, slot));
vmbreak;
}
vmcase(OP_GETTABLE) {
const TValue *slot;
TValue *rb = vRB(i);
TValue *rc = vRC(i);
lua_Unsigned n;
if (ttisinteger(rc) /* fast track for integers? */
? (cast_void(n = ivalue(rc)), luaV_fastgeti(L, rb, n, slot))
: luaV_fastget(L, rb, rc, slot, luaH_get)) {
setobj2s(L, ra, slot);
}
else
Protect(luaV_finishget(L, rb, rc, ra, slot));
vmbreak;
}
vmcase(OP_GETI) {
const TValue *slot;
TValue *rb = vRB(i);
int c = GETARG_C(i);
if (luaV_fastgeti(L, rb, c, slot)) {
setobj2s(L, ra, slot);
}
else {
TValue key;
setivalue(&key, c);
Protect(luaV_finishget(L, rb, &key, ra, slot));
}
vmbreak;
}
vmcase(OP_GETFIELD) {
const TValue *slot;
TValue *rb = vRB(i);
TValue *rc = KC(i);
TString *key = tsvalue(rc); /* key must be a string */
if (luaV_fastget(L, rb, key, slot, luaH_getshortstr)) {
setobj2s(L, ra, slot);
}
else
Protect(luaV_finishget(L, rb, rc, ra, slot));
vmbreak;
}
vmcase(OP_SETTABUP) {
const TValue *slot;
TValue *upval = cl->upvals[GETARG_A(i)]->v;
TValue *rb = KB(i);
TValue *rc = RKC(i);
TString *key = tsvalue(rb); /* key must be a string */
if (luaV_fastget(L, upval, key, slot, luaH_getshortstr)) {
luaV_finishfastset(L, upval, slot, rc);
}
else
Protect(luaV_finishset(L, upval, rb, rc, slot));
vmbreak;
}
vmcase(OP_SETTABLE) {
const TValue *slot;
TValue *rb = vRB(i); /* key (table is in 'ra') */
TValue *rc = RKC(i); /* value */
lua_Unsigned n;
if (ttisinteger(rb) /* fast track for integers? */
? (cast_void(n = ivalue(rb)), luaV_fastgeti(L, s2v(ra), n, slot))
: luaV_fastget(L, s2v(ra), rb, slot, luaH_get)) {
luaV_finishfastset(L, s2v(ra), slot, rc);
}
else
Protect(luaV_finishset(L, s2v(ra), rb, rc, slot));
vmbreak;
}
vmcase(OP_SETI) {
const TValue *slot;
int c = GETARG_B(i);
TValue *rc = RKC(i);
if (luaV_fastgeti(L, s2v(ra), c, slot)) {
luaV_finishfastset(L, s2v(ra), slot, rc);
}
else {
TValue key;
setivalue(&key, c);
Protect(luaV_finishset(L, s2v(ra), &key, rc, slot));
}
vmbreak;
}
vmcase(OP_SETFIELD) {
const TValue *slot;
TValue *rb = KB(i);
TValue *rc = RKC(i);
TString *key = tsvalue(rb); /* key must be a string */
if (luaV_fastget(L, s2v(ra), key, slot, luaH_getshortstr)) {
luaV_finishfastset(L, s2v(ra), slot, rc);
}
else
Protect(luaV_finishset(L, s2v(ra), rb, rc, slot));
vmbreak;
}
vmcase(OP_NEWTABLE) {
int b = GETARG_B(i); /* log2(hash size) + 1 */
int c = GETARG_C(i); /* array size */
Table *t;
if (b > 0)
b = 1 << (b - 1); /* size is 2^(b - 1) */
lua_assert((!TESTARG_k(i)) == (GETARG_Ax(*pc) == 0));
if (TESTARG_k(i)) /* non-zero extra argument? */
c += GETARG_Ax(*pc) * (MAXARG_C + 1); /* add it to size */
pc++; /* skip extra argument */
L->top = ra + 1; /* correct top in case of emergency GC */
t = luaH_new(L); /* memory allocation */
sethvalue2s(L, ra, t);
if (b != 0 || c != 0)
luaH_resize(L, t, c, b); /* idem */
checkGC(L, ra + 1);
vmbreak;
}
vmcase(OP_SELF) {
const TValue *slot;
TValue *rb = vRB(i);
TValue *rc = RKC(i);
TString *key = tsvalue(rc); /* key must be a string */
setobj2s(L, ra + 1, rb);
if (luaV_fastget(L, rb, key, slot, luaH_getstr)) {
setobj2s(L, ra, slot);
}
else
Protect(luaV_finishget(L, rb, rc, ra, slot));
vmbreak;
}
vmcase(OP_ADDI) {
op_arithI(L, l_addi, luai_numadd);
vmbreak;
}
vmcase(OP_ADDK) {
op_arithK(L, l_addi, luai_numadd);
vmbreak;
}
vmcase(OP_SUBK) {
op_arithK(L, l_subi, luai_numsub);
vmbreak;
}
vmcase(OP_MULK) {
op_arithK(L, l_muli, luai_nummul);
vmbreak;
}
vmcase(OP_MODK) {
op_arithK(L, luaV_mod, luaV_modf);
vmbreak;
}
vmcase(OP_POWK) {
op_arithfK(L, luai_numpow);
vmbreak;
}
vmcase(OP_DIVK) {
op_arithfK(L, luai_numdiv);
vmbreak;
}
vmcase(OP_IDIVK) {
op_arithK(L, luaV_idiv, luai_numidiv);
vmbreak;
}
vmcase(OP_BANDK) {
op_bitwiseK(L, l_band);
vmbreak;
}
vmcase(OP_BORK) {
op_bitwiseK(L, l_bor);
vmbreak;
}
vmcase(OP_BXORK) {
op_bitwiseK(L, l_bxor);
vmbreak;
}
vmcase(OP_SHRI) {
TValue *rb = vRB(i);
int ic = GETARG_sC(i);
lua_Integer ib;
if (tointegerns(rb, &ib)) {
pc++; setivalue(s2v(ra), luaV_shiftl(ib, -ic));
}
vmbreak;
}
vmcase(OP_SHLI) {
TValue *rb = vRB(i);
int ic = GETARG_sC(i);
lua_Integer ib;
if (tointegerns(rb, &ib)) {
pc++; setivalue(s2v(ra), luaV_shiftl(ic, ib));
}
vmbreak;
}
vmcase(OP_ADD) {
op_arith(L, l_addi, luai_numadd);
vmbreak;
}
vmcase(OP_SUB) {
op_arith(L, l_subi, luai_numsub);
vmbreak;
}
vmcase(OP_MUL) {
op_arith(L, l_muli, luai_nummul);
vmbreak;
}
vmcase(OP_MOD) {
op_arith(L, luaV_mod, luaV_modf);
vmbreak;
}
vmcase(OP_POW) {
op_arithf(L, luai_numpow);
vmbreak;
}
vmcase(OP_DIV) { /* float division (always with floats) */
op_arithf(L, luai_numdiv);
vmbreak;
}
vmcase(OP_IDIV) { /* floor division */
op_arith(L, luaV_idiv, luai_numidiv);
vmbreak;
}
vmcase(OP_BAND) {
op_bitwise(L, l_band);
vmbreak;
}
vmcase(OP_BOR) {
op_bitwise(L, l_bor);
vmbreak;
}
vmcase(OP_BXOR) {
op_bitwise(L, l_bxor);
vmbreak;
}
vmcase(OP_SHR) {
op_bitwise(L, luaV_shiftr);
vmbreak;
}
vmcase(OP_SHL) {
op_bitwise(L, luaV_shiftl);
vmbreak;
}
vmcase(OP_MMBIN) {
Instruction pi = *(pc - 2); /* original arith. expression */
TValue *rb = vRB(i);
TMS tm = (TMS)GETARG_C(i);
StkId result = RA(pi);
lua_assert(OP_ADD <= GET_OPCODE(pi) && GET_OPCODE(pi) <= OP_SHR);
Protect(luaT_trybinTM(L, s2v(ra), rb, result, tm));
vmbreak;
}
vmcase(OP_MMBINI) {
Instruction pi = *(pc - 2); /* original arith. expression */
int imm = GETARG_sB(i);
TMS tm = (TMS)GETARG_C(i);
int flip = GETARG_k(i);
StkId result = RA(pi);
Protect(luaT_trybiniTM(L, s2v(ra), imm, flip, result, tm));
vmbreak;
}
vmcase(OP_MMBINK) {
Instruction pi = *(pc - 2); /* original arith. expression */
TValue *imm = KB(i);
TMS tm = (TMS)GETARG_C(i);
int flip = GETARG_k(i);
StkId result = RA(pi);
Protect(luaT_trybinassocTM(L, s2v(ra), imm, flip, result, tm));
vmbreak;
}
vmcase(OP_UNM) {
TValue *rb = vRB(i);
lua_Number nb;
if (ttisinteger(rb)) {
lua_Integer ib = ivalue(rb);
setivalue(s2v(ra), intop(-, 0, ib));
}
else if (tonumberns(rb, nb)) {
setfltvalue(s2v(ra), luai_numunm(L, nb));
}
else
Protect(luaT_trybinTM(L, rb, rb, ra, TM_UNM));
vmbreak;
}
vmcase(OP_BNOT) {
TValue *rb = vRB(i);
lua_Integer ib;
if (tointegerns(rb, &ib)) {
setivalue(s2v(ra), intop(^, ~l_castS2U(0), ib));
}
else
Protect(luaT_trybinTM(L, rb, rb, ra, TM_BNOT));
vmbreak;
}
vmcase(OP_NOT) {
TValue *rb = vRB(i);
if (l_isfalse(rb))
setbtvalue(s2v(ra));
else
setbfvalue(s2v(ra));
vmbreak;
}
vmcase(OP_LEN) {
Protect(luaV_objlen(L, ra, vRB(i)));
vmbreak;
}
vmcase(OP_CONCAT) {
int n = GETARG_B(i); /* number of elements to concatenate */
L->top = ra + n; /* mark the end of concat operands */
ProtectNT(luaV_concat(L, n));
checkGC(L, L->top); /* 'luaV_concat' ensures correct top */
vmbreak;
}
vmcase(OP_CLOSE) {
Protect(luaF_close(L, ra, LUA_OK));
vmbreak;
}
vmcase(OP_TBC) {
/* create new to-be-closed upvalue */
halfProtect(luaF_newtbcupval(L, ra));
vmbreak;
}
vmcase(OP_JMP) {
dojump(ci, i, 0);
vmbreak;
}
vmcase(OP_EQ) {
int cond;
TValue *rb = vRB(i);
Protect(cond = luaV_equalobj(L, s2v(ra), rb));
docondjump();
vmbreak;
}
vmcase(OP_LT) {
op_order(L, l_lti, LTnum, lessthanothers);
vmbreak;
}
vmcase(OP_LE) {
op_order(L, l_lei, LEnum, lessequalothers);
vmbreak;
}
vmcase(OP_EQK) {
TValue *rb = KB(i);
/* basic types do not use '__eq'; we can use raw equality */
int cond = luaV_rawequalobj(s2v(ra), rb);
docondjump();
vmbreak;
}
vmcase(OP_EQI) {
int cond;
int im = GETARG_sB(i);
if (ttisinteger(s2v(ra)))
cond = (ivalue(s2v(ra)) == im);
else if (ttisfloat(s2v(ra)))
cond = luai_numeq(fltvalue(s2v(ra)), cast_num(im));
else
cond = 0; /* other types cannot be equal to a number */
docondjump();
vmbreak;
}
vmcase(OP_LTI) {
op_orderI(L, l_lti, luai_numlt, 0, TM_LT);
vmbreak;
}
vmcase(OP_LEI) {
op_orderI(L, l_lei, luai_numle, 0, TM_LE);
vmbreak;
}
vmcase(OP_GTI) {
op_orderI(L, l_gti, luai_numgt, 1, TM_LT);
vmbreak;
}
vmcase(OP_GEI) {
op_orderI(L, l_gei, luai_numge, 1, TM_LE);
vmbreak;
}
vmcase(OP_TEST) {
int cond = !l_isfalse(s2v(ra));
docondjump();
vmbreak;
}
vmcase(OP_TESTSET) {
TValue *rb = vRB(i);
if (l_isfalse(rb) == GETARG_k(i))
pc++;
else {
setobj2s(L, ra, rb);
donextjump(ci);
}
vmbreak;
}
vmcase(OP_CALL) {
int b = GETARG_B(i);
int nresults = GETARG_C(i) - 1;
if (b != 0) /* fixed number of arguments? */
L->top = ra + b; /* top signals number of arguments */
/* else previous instruction set top */
ProtectNT(luaD_call(L, ra, nresults));
vmbreak;
}
vmcase(OP_TAILCALL) {
int b = GETARG_B(i); /* number of arguments + 1 (function) */
int nparams1 = GETARG_C(i);
/* delat is virtual 'func' - real 'func' (vararg functions) */
int delta = (nparams1) ? ci->u.l.nextraargs + nparams1 : 0;
if (b != 0)
L->top = ra + b;
else /* previous instruction set top */
b = cast_int(L->top - ra);
savepc(ci); /* some calls here can raise errors */
if (TESTARG_k(i)) {
/* close upvalues from current call; the compiler ensures
that there are no to-be-closed variables here, so this
call cannot change the stack */
luaF_close(L, base, NOCLOSINGMETH);
lua_assert(base == ci->func + 1);
}
while (!ttisfunction(s2v(ra))) { /* not a function? */
luaD_tryfuncTM(L, ra); /* try '__call' metamethod */
b++; /* there is now one extra argument */
checkstackp(L, 1, ra);
}
if (!ttisLclosure(s2v(ra))) { /* C function? */
luaD_call(L, ra, LUA_MULTRET); /* call it */
updatetrap(ci);
updatestack(ci); /* stack may have been relocated */
ci->func -= delta;
luaD_poscall(L, ci, cast_int(L->top - ra));
return;
}
ci->func -= delta;
luaD_pretailcall(L, ci, ra, b); /* prepare call frame */
goto tailcall;
}
vmcase(OP_RETURN) {
int n = GETARG_B(i) - 1; /* number of results */
int nparams1 = GETARG_C(i);
if (n < 0) /* not fixed? */
n = cast_int(L->top - ra); /* get what is available */
savepc(ci);
if (TESTARG_k(i)) { /* may there be open upvalues? */
if (L->top < ci->top)
L->top = ci->top;
luaF_close(L, base, LUA_OK);
updatetrap(ci);
updatestack(ci);
}
if (nparams1) /* vararg function? */
ci->func -= ci->u.l.nextraargs + nparams1;
L->top = ra + n; /* set call for 'luaD_poscall' */
luaD_poscall(L, ci, n);
return;
}
vmcase(OP_RETURN0) {
if (L->hookmask) {
L->top = ra;
halfProtectNT(luaD_poscall(L, ci, 0)); /* no hurry... */
}
else { /* do the 'poscall' here */
int nres = ci->nresults;
L->ci = ci->previous; /* back to caller */
L->top = base - 1;
while (nres-- > 0)
setnilvalue(s2v(L->top++)); /* all results are nil */
}
return;
}
vmcase(OP_RETURN1) {
if (L->hookmask) {
L->top = ra + 1;
halfProtectNT(luaD_poscall(L, ci, 1)); /* no hurry... */
}
else { /* do the 'poscall' here */
int nres = ci->nresults;
L->ci = ci->previous; /* back to caller */
if (nres == 0)
L->top = base - 1; /* asked for no results */
else {
setobjs2s(L, base - 1, ra); /* at least this result */
L->top = base;
while (--nres > 0) /* complete missing results */
setnilvalue(s2v(L->top++));
}
}
return;
}
vmcase(OP_FORLOOP) {
if (ttisinteger(s2v(ra + 2))) { /* integer loop? */
lua_Unsigned count = l_castS2U(ivalue(s2v(ra + 1)));
if (count > 0) { /* still more iterations? */
lua_Integer step = ivalue(s2v(ra + 2));
lua_Integer idx = ivalue(s2v(ra)); /* internal index */
chgivalue(s2v(ra + 1), count - 1); /* update counter */
idx = intop(+, idx, step); /* add step to index */
chgivalue(s2v(ra), idx); /* update internal index */
setivalue(s2v(ra + 3), idx); /* and control variable */
pc -= GETARG_Bx(i); /* jump back */
}
}
else if (floatforloop(ra)) /* float loop */
pc -= GETARG_Bx(i); /* jump back */
updatetrap(ci); /* allows a signal to break the loop */
vmbreak;
}
vmcase(OP_FORPREP) {
savestate(L, ci); /* in case of errors */
if (forprep(L, ra))
pc += GETARG_Bx(i) + 1; /* skip the loop */
vmbreak;
}
vmcase(OP_TFORPREP) {
/* create to-be-closed upvalue (if needed) */
halfProtect(luaF_newtbcupval(L, ra + 3));
pc += GETARG_Bx(i);
i = *(pc++); /* go to next instruction */
lua_assert(GET_OPCODE(i) == OP_TFORCALL && ra == RA(i));
goto l_tforcall;
}
vmcase(OP_TFORCALL) {
l_tforcall:
/* 'ra' has the iterator function, 'ra + 1' has the state,
'ra + 2' has the control variable, and 'ra + 3' has the
to-be-closed variable. The call will use the stack after
these values (starting at 'ra + 4')
*/
/* push function, state, and control variable */
memcpy(ra + 4, ra, 3 * sizeof(*ra));
L->top = ra + 4 + 3;
ProtectNT(luaD_call(L, ra + 4, GETARG_C(i))); /* do the call */
updatestack(ci); /* stack may have changed */
i = *(pc++); /* go to next instruction */
lua_assert(GET_OPCODE(i) == OP_TFORLOOP && ra == RA(i));
goto l_tforloop;
}
vmcase(OP_TFORLOOP) {
l_tforloop:
if (!ttisnil(s2v(ra + 4))) { /* continue loop? */
setobjs2s(L, ra + 2, ra + 4); /* save control variable */
pc -= GETARG_Bx(i); /* jump back */
}
vmbreak;
}
vmcase(OP_SETLIST) {
int n = GETARG_B(i);
unsigned int last = GETARG_C(i);
Table *h = hvalue(s2v(ra));
if (n == 0)
n = cast_int(L->top - ra) - 1; /* get up to the top */
else
L->top = ci->top; /* correct top in case of emergency GC */
last += n;
if (TESTARG_k(i)) {
last += GETARG_Ax(*pc) * (MAXARG_C + 1);
pc++;
}
if (last > luaH_realasize(h)) /* needs more space? */
luaH_resizearray(L, h, last); /* preallocate it at once */
for (; n > 0; n--) {
TValue *val = s2v(ra + n);
setobj2t(L, &h->array[last - 1], val);
last--;
luaC_barrierback(L, obj2gco(h), val);
}
vmbreak;
}
vmcase(OP_CLOSURE) {
Proto *p = cl->p->p[GETARG_Bx(i)];
halfProtect(pushclosure(L, p, cl->upvals, base, ra));
checkGC(L, ra + 1);
vmbreak;
}
vmcase(OP_VARARG) {
int n = GETARG_C(i) - 1; /* required results */
Protect(luaT_getvarargs(L, ci, ra, n));
vmbreak;
}
vmcase(OP_VARARGPREP) {
luaT_adjustvarargs(L, GETARG_A(i), ci, cl->p);
updatetrap(ci);
if (trap) {
luaD_hookcall(L, ci);
L->oldpc = pc + 1; /* next opcode will be seen as a "new" line */
}
updatebase(ci); /* function has new base after adjustment */
vmbreak;
}
vmcase(OP_EXTRAARG) {
lua_assert(0);
vmbreak;
}
}
}
} | 4165 | True | 1 |
CVE-2020-15888 | False | False | False | True | AV:N/AC:M/Au:N/C:P/I:P/A:P | NETWORK | MEDIUM | NONE | PARTIAL | PARTIAL | PARTIAL | 6.8 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | REQUIRED | UNCHANGED | HIGH | HIGH | HIGH | 8.8 | HIGH | 2.8 | 5.9 | False | [{'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00054.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00054.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'https://github.com/lua/lua/commit/6298903e35217ab69c279056f925fb72900ce0b7', 'name': 'https://github.com/lua/lua/commit/6298903e35217ab69c279056f925fb72900ce0b7', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00079.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00079.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'https://github.com/lua/lua/commit/eb41999461b6f428186c55abd95f4ce1a76217d5', 'name': 'https://github.com/lua/lua/commit/eb41999461b6f428186c55abd95f4ce1a76217d5', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00071.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00071.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00053.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00053.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}, {'lang': 'en', 'value': 'CWE-787'}, {'lang': 'en', 'value': 'CWE-416'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:lua:lua:*:*:*:*:*:*:*:*', 'versionEndIncluding': '5.4.0', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Lua through 5.4.0 mishandles the interaction between stack resizes and garbage collection, leading to a heap-based buffer overflow, heap-based buffer over-read, or use-after-free.'}] | 2021-07-21T11:39Z | 2020-07-21T22:15Z | Use After Free | Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code. |
The use of previously-freed memory can have any number of adverse consequences, ranging from the corruption of valid data to the execution of arbitrary code, depending on the instantiation and timing of the flaw. The simplest way data corruption may occur involves the system's reuse of the freed memory. Use-after-free errors have two common and sometimes overlapping causes:
Error conditions and other exceptional circumstances.
Confusion over which part of the program is responsible for freeing the memory.
In this scenario, the memory in question is allocated to another pointer validly at some point after it has been freed. The original pointer to the freed memory is used again and points to somewhere within the new allocation. As the data is changed, it corrupts the validly used memory; this induces undefined behavior in the process.
If the newly allocated data chances to hold a class, in C++ for example, various function pointers may be scattered within the heap data. If one of these function pointers is overwritten with an address to valid shellcode, execution of arbitrary code can be achieved.
| https://cwe.mitre.org/data/definitions/416.html | 0 | Roberto Ierusalimschy | 2020-07-07 18:03:48-03:00 | Fixed bugs of stack reallocation x GC
Macro 'checkstackGC' was doing a GC step after resizing the stack;
the GC could shrink the stack and undo the resize. Moreover, macro
'checkstackp' also does a GC step, which could remove the preallocated
CallInfo when calling a function. (Its name has been changed to
'checkstackGCp' to emphasize that it calls the GC.) | eb41999461b6f428186c55abd95f4ce1a76217d5 | False | lua/lua | The Lua development repository, as seen by the Lua team. Mirrored irregularly. Please DO NOT send pull requests. Report issues in the Lua mailing list https://www.lua.org/lua-l.html | 2012-09-14 05:55:07 | 2022-08-24 20:40:26 | https://www.lua.org/ | lua | 5964.0 | 1279.0 | luaV_execute | luaV_execute( lua_State * L , CallInfo * ci) | ['L', 'ci'] | void luaV_execute (lua_State *L, CallInfo *ci) {
LClosure *cl;
TValue *k;
StkId base;
const Instruction *pc;
int trap;
#if LUA_USE_JUMPTABLE
#include "ljumptab.h"
#endif
tailcall:
trap = L->hookmask;
cl = clLvalue(s2v(ci->func));
k = cl->p->k;
pc = ci->u.l.savedpc;
if (trap) {
if (cl->p->is_vararg)
trap = 0; /* hooks will start after VARARGPREP instruction */
else if (pc == cl->p->code) /* first instruction (not resuming)? */
luaD_hookcall(L, ci);
ci->u.l.trap = 1; /* there may be other hooks */
}
base = ci->func + 1;
/* main loop of interpreter */
for (;;) {
Instruction i; /* instruction being executed */
StkId ra; /* instruction's A register */
vmfetch();
lua_assert(base == ci->func + 1);
lua_assert(base <= L->top && L->top < L->stack + L->stacksize);
/* invalidate top for instructions not expecting it */
lua_assert(isIT(i) || (cast_void(L->top = base), 1));
vmdispatch (GET_OPCODE(i)) {
vmcase(OP_MOVE) {
setobjs2s(L, ra, RB(i));
vmbreak;
}
vmcase(OP_LOADI) {
lua_Integer b = GETARG_sBx(i);
setivalue(s2v(ra), b);
vmbreak;
}
vmcase(OP_LOADF) {
int b = GETARG_sBx(i);
setfltvalue(s2v(ra), cast_num(b));
vmbreak;
}
vmcase(OP_LOADK) {
TValue *rb = k + GETARG_Bx(i);
setobj2s(L, ra, rb);
vmbreak;
}
vmcase(OP_LOADKX) {
TValue *rb;
rb = k + GETARG_Ax(*pc); pc++;
setobj2s(L, ra, rb);
vmbreak;
}
vmcase(OP_LOADFALSE) {
setbfvalue(s2v(ra));
vmbreak;
}
vmcase(OP_LFALSESKIP) {
setbfvalue(s2v(ra));
pc++; /* skip next instruction */
vmbreak;
}
vmcase(OP_LOADTRUE) {
setbtvalue(s2v(ra));
vmbreak;
}
vmcase(OP_LOADNIL) {
int b = GETARG_B(i);
do {
setnilvalue(s2v(ra++));
} while (b--);
vmbreak;
}
vmcase(OP_GETUPVAL) {
int b = GETARG_B(i);
setobj2s(L, ra, cl->upvals[b]->v);
vmbreak;
}
vmcase(OP_SETUPVAL) {
UpVal *uv = cl->upvals[GETARG_B(i)];
setobj(L, uv->v, s2v(ra));
luaC_barrier(L, uv, s2v(ra));
vmbreak;
}
vmcase(OP_GETTABUP) {
const TValue *slot;
TValue *upval = cl->upvals[GETARG_B(i)]->v;
TValue *rc = KC(i);
TString *key = tsvalue(rc); /* key must be a string */
if (luaV_fastget(L, upval, key, slot, luaH_getshortstr)) {
setobj2s(L, ra, slot);
}
else
Protect(luaV_finishget(L, upval, rc, ra, slot));
vmbreak;
}
vmcase(OP_GETTABLE) {
const TValue *slot;
TValue *rb = vRB(i);
TValue *rc = vRC(i);
lua_Unsigned n;
if (ttisinteger(rc) /* fast track for integers? */
? (cast_void(n = ivalue(rc)), luaV_fastgeti(L, rb, n, slot))
: luaV_fastget(L, rb, rc, slot, luaH_get)) {
setobj2s(L, ra, slot);
}
else
Protect(luaV_finishget(L, rb, rc, ra, slot));
vmbreak;
}
vmcase(OP_GETI) {
const TValue *slot;
TValue *rb = vRB(i);
int c = GETARG_C(i);
if (luaV_fastgeti(L, rb, c, slot)) {
setobj2s(L, ra, slot);
}
else {
TValue key;
setivalue(&key, c);
Protect(luaV_finishget(L, rb, &key, ra, slot));
}
vmbreak;
}
vmcase(OP_GETFIELD) {
const TValue *slot;
TValue *rb = vRB(i);
TValue *rc = KC(i);
TString *key = tsvalue(rc); /* key must be a string */
if (luaV_fastget(L, rb, key, slot, luaH_getshortstr)) {
setobj2s(L, ra, slot);
}
else
Protect(luaV_finishget(L, rb, rc, ra, slot));
vmbreak;
}
vmcase(OP_SETTABUP) {
const TValue *slot;
TValue *upval = cl->upvals[GETARG_A(i)]->v;
TValue *rb = KB(i);
TValue *rc = RKC(i);
TString *key = tsvalue(rb); /* key must be a string */
if (luaV_fastget(L, upval, key, slot, luaH_getshortstr)) {
luaV_finishfastset(L, upval, slot, rc);
}
else
Protect(luaV_finishset(L, upval, rb, rc, slot));
vmbreak;
}
vmcase(OP_SETTABLE) {
const TValue *slot;
TValue *rb = vRB(i); /* key (table is in 'ra') */
TValue *rc = RKC(i); /* value */
lua_Unsigned n;
if (ttisinteger(rb) /* fast track for integers? */
? (cast_void(n = ivalue(rb)), luaV_fastgeti(L, s2v(ra), n, slot))
: luaV_fastget(L, s2v(ra), rb, slot, luaH_get)) {
luaV_finishfastset(L, s2v(ra), slot, rc);
}
else
Protect(luaV_finishset(L, s2v(ra), rb, rc, slot));
vmbreak;
}
vmcase(OP_SETI) {
const TValue *slot;
int c = GETARG_B(i);
TValue *rc = RKC(i);
if (luaV_fastgeti(L, s2v(ra), c, slot)) {
luaV_finishfastset(L, s2v(ra), slot, rc);
}
else {
TValue key;
setivalue(&key, c);
Protect(luaV_finishset(L, s2v(ra), &key, rc, slot));
}
vmbreak;
}
vmcase(OP_SETFIELD) {
const TValue *slot;
TValue *rb = KB(i);
TValue *rc = RKC(i);
TString *key = tsvalue(rb); /* key must be a string */
if (luaV_fastget(L, s2v(ra), key, slot, luaH_getshortstr)) {
luaV_finishfastset(L, s2v(ra), slot, rc);
}
else
Protect(luaV_finishset(L, s2v(ra), rb, rc, slot));
vmbreak;
}
vmcase(OP_NEWTABLE) {
int b = GETARG_B(i); /* log2(hash size) + 1 */
int c = GETARG_C(i); /* array size */
Table *t;
if (b > 0)
b = 1 << (b - 1); /* size is 2^(b - 1) */
lua_assert((!TESTARG_k(i)) == (GETARG_Ax(*pc) == 0));
if (TESTARG_k(i)) /* non-zero extra argument? */
c += GETARG_Ax(*pc) * (MAXARG_C + 1); /* add it to size */
pc++; /* skip extra argument */
L->top = ra + 1; /* correct top in case of emergency GC */
t = luaH_new(L); /* memory allocation */
sethvalue2s(L, ra, t);
if (b != 0 || c != 0)
luaH_resize(L, t, c, b); /* idem */
checkGC(L, ra + 1);
vmbreak;
}
vmcase(OP_SELF) {
const TValue *slot;
TValue *rb = vRB(i);
TValue *rc = RKC(i);
TString *key = tsvalue(rc); /* key must be a string */
setobj2s(L, ra + 1, rb);
if (luaV_fastget(L, rb, key, slot, luaH_getstr)) {
setobj2s(L, ra, slot);
}
else
Protect(luaV_finishget(L, rb, rc, ra, slot));
vmbreak;
}
vmcase(OP_ADDI) {
op_arithI(L, l_addi, luai_numadd);
vmbreak;
}
vmcase(OP_ADDK) {
op_arithK(L, l_addi, luai_numadd);
vmbreak;
}
vmcase(OP_SUBK) {
op_arithK(L, l_subi, luai_numsub);
vmbreak;
}
vmcase(OP_MULK) {
op_arithK(L, l_muli, luai_nummul);
vmbreak;
}
vmcase(OP_MODK) {
op_arithK(L, luaV_mod, luaV_modf);
vmbreak;
}
vmcase(OP_POWK) {
op_arithfK(L, luai_numpow);
vmbreak;
}
vmcase(OP_DIVK) {
op_arithfK(L, luai_numdiv);
vmbreak;
}
vmcase(OP_IDIVK) {
op_arithK(L, luaV_idiv, luai_numidiv);
vmbreak;
}
vmcase(OP_BANDK) {
op_bitwiseK(L, l_band);
vmbreak;
}
vmcase(OP_BORK) {
op_bitwiseK(L, l_bor);
vmbreak;
}
vmcase(OP_BXORK) {
op_bitwiseK(L, l_bxor);
vmbreak;
}
vmcase(OP_SHRI) {
TValue *rb = vRB(i);
int ic = GETARG_sC(i);
lua_Integer ib;
if (tointegerns(rb, &ib)) {
pc++; setivalue(s2v(ra), luaV_shiftl(ib, -ic));
}
vmbreak;
}
vmcase(OP_SHLI) {
TValue *rb = vRB(i);
int ic = GETARG_sC(i);
lua_Integer ib;
if (tointegerns(rb, &ib)) {
pc++; setivalue(s2v(ra), luaV_shiftl(ic, ib));
}
vmbreak;
}
vmcase(OP_ADD) {
op_arith(L, l_addi, luai_numadd);
vmbreak;
}
vmcase(OP_SUB) {
op_arith(L, l_subi, luai_numsub);
vmbreak;
}
vmcase(OP_MUL) {
op_arith(L, l_muli, luai_nummul);
vmbreak;
}
vmcase(OP_MOD) {
op_arith(L, luaV_mod, luaV_modf);
vmbreak;
}
vmcase(OP_POW) {
op_arithf(L, luai_numpow);
vmbreak;
}
vmcase(OP_DIV) { /* float division (always with floats) */
op_arithf(L, luai_numdiv);
vmbreak;
}
vmcase(OP_IDIV) { /* floor division */
op_arith(L, luaV_idiv, luai_numidiv);
vmbreak;
}
vmcase(OP_BAND) {
op_bitwise(L, l_band);
vmbreak;
}
vmcase(OP_BOR) {
op_bitwise(L, l_bor);
vmbreak;
}
vmcase(OP_BXOR) {
op_bitwise(L, l_bxor);
vmbreak;
}
vmcase(OP_SHR) {
op_bitwise(L, luaV_shiftr);
vmbreak;
}
vmcase(OP_SHL) {
op_bitwise(L, luaV_shiftl);
vmbreak;
}
vmcase(OP_MMBIN) {
Instruction pi = *(pc - 2); /* original arith. expression */
TValue *rb = vRB(i);
TMS tm = (TMS)GETARG_C(i);
StkId result = RA(pi);
lua_assert(OP_ADD <= GET_OPCODE(pi) && GET_OPCODE(pi) <= OP_SHR);
Protect(luaT_trybinTM(L, s2v(ra), rb, result, tm));
vmbreak;
}
vmcase(OP_MMBINI) {
Instruction pi = *(pc - 2); /* original arith. expression */
int imm = GETARG_sB(i);
TMS tm = (TMS)GETARG_C(i);
int flip = GETARG_k(i);
StkId result = RA(pi);
Protect(luaT_trybiniTM(L, s2v(ra), imm, flip, result, tm));
vmbreak;
}
vmcase(OP_MMBINK) {
Instruction pi = *(pc - 2); /* original arith. expression */
TValue *imm = KB(i);
TMS tm = (TMS)GETARG_C(i);
int flip = GETARG_k(i);
StkId result = RA(pi);
Protect(luaT_trybinassocTM(L, s2v(ra), imm, flip, result, tm));
vmbreak;
}
vmcase(OP_UNM) {
TValue *rb = vRB(i);
lua_Number nb;
if (ttisinteger(rb)) {
lua_Integer ib = ivalue(rb);
setivalue(s2v(ra), intop(-, 0, ib));
}
else if (tonumberns(rb, nb)) {
setfltvalue(s2v(ra), luai_numunm(L, nb));
}
else
Protect(luaT_trybinTM(L, rb, rb, ra, TM_UNM));
vmbreak;
}
vmcase(OP_BNOT) {
TValue *rb = vRB(i);
lua_Integer ib;
if (tointegerns(rb, &ib)) {
setivalue(s2v(ra), intop(^, ~l_castS2U(0), ib));
}
else
Protect(luaT_trybinTM(L, rb, rb, ra, TM_BNOT));
vmbreak;
}
vmcase(OP_NOT) {
TValue *rb = vRB(i);
if (l_isfalse(rb))
setbtvalue(s2v(ra));
else
setbfvalue(s2v(ra));
vmbreak;
}
vmcase(OP_LEN) {
Protect(luaV_objlen(L, ra, vRB(i)));
vmbreak;
}
vmcase(OP_CONCAT) {
int n = GETARG_B(i); /* number of elements to concatenate */
L->top = ra + n; /* mark the end of concat operands */
ProtectNT(luaV_concat(L, n));
checkGC(L, L->top); /* 'luaV_concat' ensures correct top */
vmbreak;
}
vmcase(OP_CLOSE) {
Protect(luaF_close(L, ra, LUA_OK));
vmbreak;
}
vmcase(OP_TBC) {
/* create new to-be-closed upvalue */
halfProtect(luaF_newtbcupval(L, ra));
vmbreak;
}
vmcase(OP_JMP) {
dojump(ci, i, 0);
vmbreak;
}
vmcase(OP_EQ) {
int cond;
TValue *rb = vRB(i);
Protect(cond = luaV_equalobj(L, s2v(ra), rb));
docondjump();
vmbreak;
}
vmcase(OP_LT) {
op_order(L, l_lti, LTnum, lessthanothers);
vmbreak;
}
vmcase(OP_LE) {
op_order(L, l_lei, LEnum, lessequalothers);
vmbreak;
}
vmcase(OP_EQK) {
TValue *rb = KB(i);
/* basic types do not use '__eq'; we can use raw equality */
int cond = luaV_rawequalobj(s2v(ra), rb);
docondjump();
vmbreak;
}
vmcase(OP_EQI) {
int cond;
int im = GETARG_sB(i);
if (ttisinteger(s2v(ra)))
cond = (ivalue(s2v(ra)) == im);
else if (ttisfloat(s2v(ra)))
cond = luai_numeq(fltvalue(s2v(ra)), cast_num(im));
else
cond = 0; /* other types cannot be equal to a number */
docondjump();
vmbreak;
}
vmcase(OP_LTI) {
op_orderI(L, l_lti, luai_numlt, 0, TM_LT);
vmbreak;
}
vmcase(OP_LEI) {
op_orderI(L, l_lei, luai_numle, 0, TM_LE);
vmbreak;
}
vmcase(OP_GTI) {
op_orderI(L, l_gti, luai_numgt, 1, TM_LT);
vmbreak;
}
vmcase(OP_GEI) {
op_orderI(L, l_gei, luai_numge, 1, TM_LE);
vmbreak;
}
vmcase(OP_TEST) {
int cond = !l_isfalse(s2v(ra));
docondjump();
vmbreak;
}
vmcase(OP_TESTSET) {
TValue *rb = vRB(i);
if (l_isfalse(rb) == GETARG_k(i))
pc++;
else {
setobj2s(L, ra, rb);
donextjump(ci);
}
vmbreak;
}
vmcase(OP_CALL) {
int b = GETARG_B(i);
int nresults = GETARG_C(i) - 1;
if (b != 0) /* fixed number of arguments? */
L->top = ra + b; /* top signals number of arguments */
/* else previous instruction set top */
ProtectNT(luaD_call(L, ra, nresults));
vmbreak;
}
vmcase(OP_TAILCALL) {
int b = GETARG_B(i); /* number of arguments + 1 (function) */
int nparams1 = GETARG_C(i);
/* delat is virtual 'func' - real 'func' (vararg functions) */
int delta = (nparams1) ? ci->u.l.nextraargs + nparams1 : 0;
if (b != 0)
L->top = ra + b;
else /* previous instruction set top */
b = cast_int(L->top - ra);
savepc(ci); /* some calls here can raise errors */
if (TESTARG_k(i)) {
/* close upvalues from current call; the compiler ensures
that there are no to-be-closed variables here, so this
call cannot change the stack */
luaF_close(L, base, NOCLOSINGMETH);
lua_assert(base == ci->func + 1);
}
while (!ttisfunction(s2v(ra))) { /* not a function? */
luaD_tryfuncTM(L, ra); /* try '__call' metamethod */
b++; /* there is now one extra argument */
checkstackp(L, 1, ra);
}
if (!ttisLclosure(s2v(ra))) { /* C function? */
luaD_call(L, ra, LUA_MULTRET); /* call it */
updatetrap(ci);
updatestack(ci); /* stack may have been relocated */
ci->func -= delta;
luaD_poscall(L, ci, cast_int(L->top - ra));
return;
}
ci->func -= delta;
luaD_pretailcall(L, ci, ra, b); /* prepare call frame */
goto tailcall;
}
vmcase(OP_RETURN) {
int n = GETARG_B(i) - 1; /* number of results */
int nparams1 = GETARG_C(i);
if (n < 0) /* not fixed? */
n = cast_int(L->top - ra); /* get what is available */
savepc(ci);
if (TESTARG_k(i)) { /* may there be open upvalues? */
if (L->top < ci->top)
L->top = ci->top;
luaF_close(L, base, LUA_OK);
updatetrap(ci);
updatestack(ci);
}
if (nparams1) /* vararg function? */
ci->func -= ci->u.l.nextraargs + nparams1;
L->top = ra + n; /* set call for 'luaD_poscall' */
luaD_poscall(L, ci, n);
return;
}
vmcase(OP_RETURN0) {
if (L->hookmask) {
L->top = ra;
halfProtectNT(luaD_poscall(L, ci, 0)); /* no hurry... */
}
else { /* do the 'poscall' here */
int nres = ci->nresults;
L->ci = ci->previous; /* back to caller */
L->top = base - 1;
while (nres-- > 0)
setnilvalue(s2v(L->top++)); /* all results are nil */
}
return;
}
vmcase(OP_RETURN1) {
if (L->hookmask) {
L->top = ra + 1;
halfProtectNT(luaD_poscall(L, ci, 1)); /* no hurry... */
}
else { /* do the 'poscall' here */
int nres = ci->nresults;
L->ci = ci->previous; /* back to caller */
if (nres == 0)
L->top = base - 1; /* asked for no results */
else {
setobjs2s(L, base - 1, ra); /* at least this result */
L->top = base;
while (--nres > 0) /* complete missing results */
setnilvalue(s2v(L->top++));
}
}
return;
}
vmcase(OP_FORLOOP) {
if (ttisinteger(s2v(ra + 2))) { /* integer loop? */
lua_Unsigned count = l_castS2U(ivalue(s2v(ra + 1)));
if (count > 0) { /* still more iterations? */
lua_Integer step = ivalue(s2v(ra + 2));
lua_Integer idx = ivalue(s2v(ra)); /* internal index */
chgivalue(s2v(ra + 1), count - 1); /* update counter */
idx = intop(+, idx, step); /* add step to index */
chgivalue(s2v(ra), idx); /* update internal index */
setivalue(s2v(ra + 3), idx); /* and control variable */
pc -= GETARG_Bx(i); /* jump back */
}
}
else if (floatforloop(ra)) /* float loop */
pc -= GETARG_Bx(i); /* jump back */
updatetrap(ci); /* allows a signal to break the loop */
vmbreak;
}
vmcase(OP_FORPREP) {
savestate(L, ci); /* in case of errors */
if (forprep(L, ra))
pc += GETARG_Bx(i) + 1; /* skip the loop */
vmbreak;
}
vmcase(OP_TFORPREP) {
/* create to-be-closed upvalue (if needed) */
halfProtect(luaF_newtbcupval(L, ra + 3));
pc += GETARG_Bx(i);
i = *(pc++); /* go to next instruction */
lua_assert(GET_OPCODE(i) == OP_TFORCALL && ra == RA(i));
goto l_tforcall;
}
vmcase(OP_TFORCALL) {
l_tforcall:
/* 'ra' has the iterator function, 'ra + 1' has the state,
'ra + 2' has the control variable, and 'ra + 3' has the
to-be-closed variable. The call will use the stack after
these values (starting at 'ra + 4')
*/
/* push function, state, and control variable */
memcpy(ra + 4, ra, 3 * sizeof(*ra));
L->top = ra + 4 + 3;
ProtectNT(luaD_call(L, ra + 4, GETARG_C(i))); /* do the call */
updatestack(ci); /* stack may have changed */
i = *(pc++); /* go to next instruction */
lua_assert(GET_OPCODE(i) == OP_TFORLOOP && ra == RA(i));
goto l_tforloop;
}
vmcase(OP_TFORLOOP) {
l_tforloop:
if (!ttisnil(s2v(ra + 4))) { /* continue loop? */
setobjs2s(L, ra + 2, ra + 4); /* save control variable */
pc -= GETARG_Bx(i); /* jump back */
}
vmbreak;
}
vmcase(OP_SETLIST) {
int n = GETARG_B(i);
unsigned int last = GETARG_C(i);
Table *h = hvalue(s2v(ra));
if (n == 0)
n = cast_int(L->top - ra) - 1; /* get up to the top */
else
L->top = ci->top; /* correct top in case of emergency GC */
last += n;
if (TESTARG_k(i)) {
last += GETARG_Ax(*pc) * (MAXARG_C + 1);
pc++;
}
if (last > luaH_realasize(h)) /* needs more space? */
luaH_resizearray(L, h, last); /* preallocate it at once */
for (; n > 0; n--) {
TValue *val = s2v(ra + n);
setobj2t(L, &h->array[last - 1], val);
last--;
luaC_barrierback(L, obj2gco(h), val);
}
vmbreak;
}
vmcase(OP_CLOSURE) {
Proto *p = cl->p->p[GETARG_Bx(i)];
halfProtect(pushclosure(L, p, cl->upvals, base, ra));
checkGC(L, ra + 1);
vmbreak;
}
vmcase(OP_VARARG) {
int n = GETARG_C(i) - 1; /* required results */
Protect(luaT_getvarargs(L, ci, ra, n));
vmbreak;
}
vmcase(OP_VARARGPREP) {
luaT_adjustvarargs(L, GETARG_A(i), ci, cl->p);
updatetrap(ci);
if (trap) {
luaD_hookcall(L, ci);
L->oldpc = pc + 1; /* next opcode will be seen as a "new" line */
}
updatebase(ci); /* function has new base after adjustment */
vmbreak;
}
vmcase(OP_EXTRAARG) {
lua_assert(0);
vmbreak;
}
}
}
} | 4165 | True | 1 |
CVE-2020-15888 | False | False | False | True | AV:N/AC:M/Au:N/C:P/I:P/A:P | NETWORK | MEDIUM | NONE | PARTIAL | PARTIAL | PARTIAL | 6.8 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | REQUIRED | UNCHANGED | HIGH | HIGH | HIGH | 8.8 | HIGH | 2.8 | 5.9 | False | [{'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00054.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00054.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'https://github.com/lua/lua/commit/6298903e35217ab69c279056f925fb72900ce0b7', 'name': 'https://github.com/lua/lua/commit/6298903e35217ab69c279056f925fb72900ce0b7', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00079.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00079.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'https://github.com/lua/lua/commit/eb41999461b6f428186c55abd95f4ce1a76217d5', 'name': 'https://github.com/lua/lua/commit/eb41999461b6f428186c55abd95f4ce1a76217d5', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00071.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00071.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00053.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00053.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}, {'lang': 'en', 'value': 'CWE-787'}, {'lang': 'en', 'value': 'CWE-416'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:lua:lua:*:*:*:*:*:*:*:*', 'versionEndIncluding': '5.4.0', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Lua through 5.4.0 mishandles the interaction between stack resizes and garbage collection, leading to a heap-based buffer overflow, heap-based buffer over-read, or use-after-free.'}] | 2021-07-21T11:39Z | 2020-07-21T22:15Z | Out-of-bounds Write | The software writes data past the end, or before the beginning, of the intended buffer. | Typically, this can result in corruption of data, a crash, or code execution. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent write operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/787.html | 0 | Roberto Ierusalimschy | 2020-07-07 18:03:48-03:00 | Fixed bugs of stack reallocation x GC
Macro 'checkstackGC' was doing a GC step after resizing the stack;
the GC could shrink the stack and undo the resize. Moreover, macro
'checkstackp' also does a GC step, which could remove the preallocated
CallInfo when calling a function. (Its name has been changed to
'checkstackGCp' to emphasize that it calls the GC.) | eb41999461b6f428186c55abd95f4ce1a76217d5 | False | lua/lua | The Lua development repository, as seen by the Lua team. Mirrored irregularly. Please DO NOT send pull requests. Report issues in the Lua mailing list https://www.lua.org/lua-l.html | 2012-09-14 05:55:07 | 2022-08-24 20:40:26 | https://www.lua.org/ | lua | 5964.0 | 1279.0 | luaV_execute | luaV_execute( lua_State * L , CallInfo * ci) | ['L', 'ci'] | void luaV_execute (lua_State *L, CallInfo *ci) {
LClosure *cl;
TValue *k;
StkId base;
const Instruction *pc;
int trap;
#if LUA_USE_JUMPTABLE
#include "ljumptab.h"
#endif
tailcall:
trap = L->hookmask;
cl = clLvalue(s2v(ci->func));
k = cl->p->k;
pc = ci->u.l.savedpc;
if (trap) {
if (cl->p->is_vararg)
trap = 0; /* hooks will start after VARARGPREP instruction */
else if (pc == cl->p->code) /* first instruction (not resuming)? */
luaD_hookcall(L, ci);
ci->u.l.trap = 1; /* there may be other hooks */
}
base = ci->func + 1;
/* main loop of interpreter */
for (;;) {
Instruction i; /* instruction being executed */
StkId ra; /* instruction's A register */
vmfetch();
lua_assert(base == ci->func + 1);
lua_assert(base <= L->top && L->top < L->stack + L->stacksize);
/* invalidate top for instructions not expecting it */
lua_assert(isIT(i) || (cast_void(L->top = base), 1));
vmdispatch (GET_OPCODE(i)) {
vmcase(OP_MOVE) {
setobjs2s(L, ra, RB(i));
vmbreak;
}
vmcase(OP_LOADI) {
lua_Integer b = GETARG_sBx(i);
setivalue(s2v(ra), b);
vmbreak;
}
vmcase(OP_LOADF) {
int b = GETARG_sBx(i);
setfltvalue(s2v(ra), cast_num(b));
vmbreak;
}
vmcase(OP_LOADK) {
TValue *rb = k + GETARG_Bx(i);
setobj2s(L, ra, rb);
vmbreak;
}
vmcase(OP_LOADKX) {
TValue *rb;
rb = k + GETARG_Ax(*pc); pc++;
setobj2s(L, ra, rb);
vmbreak;
}
vmcase(OP_LOADFALSE) {
setbfvalue(s2v(ra));
vmbreak;
}
vmcase(OP_LFALSESKIP) {
setbfvalue(s2v(ra));
pc++; /* skip next instruction */
vmbreak;
}
vmcase(OP_LOADTRUE) {
setbtvalue(s2v(ra));
vmbreak;
}
vmcase(OP_LOADNIL) {
int b = GETARG_B(i);
do {
setnilvalue(s2v(ra++));
} while (b--);
vmbreak;
}
vmcase(OP_GETUPVAL) {
int b = GETARG_B(i);
setobj2s(L, ra, cl->upvals[b]->v);
vmbreak;
}
vmcase(OP_SETUPVAL) {
UpVal *uv = cl->upvals[GETARG_B(i)];
setobj(L, uv->v, s2v(ra));
luaC_barrier(L, uv, s2v(ra));
vmbreak;
}
vmcase(OP_GETTABUP) {
const TValue *slot;
TValue *upval = cl->upvals[GETARG_B(i)]->v;
TValue *rc = KC(i);
TString *key = tsvalue(rc); /* key must be a string */
if (luaV_fastget(L, upval, key, slot, luaH_getshortstr)) {
setobj2s(L, ra, slot);
}
else
Protect(luaV_finishget(L, upval, rc, ra, slot));
vmbreak;
}
vmcase(OP_GETTABLE) {
const TValue *slot;
TValue *rb = vRB(i);
TValue *rc = vRC(i);
lua_Unsigned n;
if (ttisinteger(rc) /* fast track for integers? */
? (cast_void(n = ivalue(rc)), luaV_fastgeti(L, rb, n, slot))
: luaV_fastget(L, rb, rc, slot, luaH_get)) {
setobj2s(L, ra, slot);
}
else
Protect(luaV_finishget(L, rb, rc, ra, slot));
vmbreak;
}
vmcase(OP_GETI) {
const TValue *slot;
TValue *rb = vRB(i);
int c = GETARG_C(i);
if (luaV_fastgeti(L, rb, c, slot)) {
setobj2s(L, ra, slot);
}
else {
TValue key;
setivalue(&key, c);
Protect(luaV_finishget(L, rb, &key, ra, slot));
}
vmbreak;
}
vmcase(OP_GETFIELD) {
const TValue *slot;
TValue *rb = vRB(i);
TValue *rc = KC(i);
TString *key = tsvalue(rc); /* key must be a string */
if (luaV_fastget(L, rb, key, slot, luaH_getshortstr)) {
setobj2s(L, ra, slot);
}
else
Protect(luaV_finishget(L, rb, rc, ra, slot));
vmbreak;
}
vmcase(OP_SETTABUP) {
const TValue *slot;
TValue *upval = cl->upvals[GETARG_A(i)]->v;
TValue *rb = KB(i);
TValue *rc = RKC(i);
TString *key = tsvalue(rb); /* key must be a string */
if (luaV_fastget(L, upval, key, slot, luaH_getshortstr)) {
luaV_finishfastset(L, upval, slot, rc);
}
else
Protect(luaV_finishset(L, upval, rb, rc, slot));
vmbreak;
}
vmcase(OP_SETTABLE) {
const TValue *slot;
TValue *rb = vRB(i); /* key (table is in 'ra') */
TValue *rc = RKC(i); /* value */
lua_Unsigned n;
if (ttisinteger(rb) /* fast track for integers? */
? (cast_void(n = ivalue(rb)), luaV_fastgeti(L, s2v(ra), n, slot))
: luaV_fastget(L, s2v(ra), rb, slot, luaH_get)) {
luaV_finishfastset(L, s2v(ra), slot, rc);
}
else
Protect(luaV_finishset(L, s2v(ra), rb, rc, slot));
vmbreak;
}
vmcase(OP_SETI) {
const TValue *slot;
int c = GETARG_B(i);
TValue *rc = RKC(i);
if (luaV_fastgeti(L, s2v(ra), c, slot)) {
luaV_finishfastset(L, s2v(ra), slot, rc);
}
else {
TValue key;
setivalue(&key, c);
Protect(luaV_finishset(L, s2v(ra), &key, rc, slot));
}
vmbreak;
}
vmcase(OP_SETFIELD) {
const TValue *slot;
TValue *rb = KB(i);
TValue *rc = RKC(i);
TString *key = tsvalue(rb); /* key must be a string */
if (luaV_fastget(L, s2v(ra), key, slot, luaH_getshortstr)) {
luaV_finishfastset(L, s2v(ra), slot, rc);
}
else
Protect(luaV_finishset(L, s2v(ra), rb, rc, slot));
vmbreak;
}
vmcase(OP_NEWTABLE) {
int b = GETARG_B(i); /* log2(hash size) + 1 */
int c = GETARG_C(i); /* array size */
Table *t;
if (b > 0)
b = 1 << (b - 1); /* size is 2^(b - 1) */
lua_assert((!TESTARG_k(i)) == (GETARG_Ax(*pc) == 0));
if (TESTARG_k(i)) /* non-zero extra argument? */
c += GETARG_Ax(*pc) * (MAXARG_C + 1); /* add it to size */
pc++; /* skip extra argument */
L->top = ra + 1; /* correct top in case of emergency GC */
t = luaH_new(L); /* memory allocation */
sethvalue2s(L, ra, t);
if (b != 0 || c != 0)
luaH_resize(L, t, c, b); /* idem */
checkGC(L, ra + 1);
vmbreak;
}
vmcase(OP_SELF) {
const TValue *slot;
TValue *rb = vRB(i);
TValue *rc = RKC(i);
TString *key = tsvalue(rc); /* key must be a string */
setobj2s(L, ra + 1, rb);
if (luaV_fastget(L, rb, key, slot, luaH_getstr)) {
setobj2s(L, ra, slot);
}
else
Protect(luaV_finishget(L, rb, rc, ra, slot));
vmbreak;
}
vmcase(OP_ADDI) {
op_arithI(L, l_addi, luai_numadd);
vmbreak;
}
vmcase(OP_ADDK) {
op_arithK(L, l_addi, luai_numadd);
vmbreak;
}
vmcase(OP_SUBK) {
op_arithK(L, l_subi, luai_numsub);
vmbreak;
}
vmcase(OP_MULK) {
op_arithK(L, l_muli, luai_nummul);
vmbreak;
}
vmcase(OP_MODK) {
op_arithK(L, luaV_mod, luaV_modf);
vmbreak;
}
vmcase(OP_POWK) {
op_arithfK(L, luai_numpow);
vmbreak;
}
vmcase(OP_DIVK) {
op_arithfK(L, luai_numdiv);
vmbreak;
}
vmcase(OP_IDIVK) {
op_arithK(L, luaV_idiv, luai_numidiv);
vmbreak;
}
vmcase(OP_BANDK) {
op_bitwiseK(L, l_band);
vmbreak;
}
vmcase(OP_BORK) {
op_bitwiseK(L, l_bor);
vmbreak;
}
vmcase(OP_BXORK) {
op_bitwiseK(L, l_bxor);
vmbreak;
}
vmcase(OP_SHRI) {
TValue *rb = vRB(i);
int ic = GETARG_sC(i);
lua_Integer ib;
if (tointegerns(rb, &ib)) {
pc++; setivalue(s2v(ra), luaV_shiftl(ib, -ic));
}
vmbreak;
}
vmcase(OP_SHLI) {
TValue *rb = vRB(i);
int ic = GETARG_sC(i);
lua_Integer ib;
if (tointegerns(rb, &ib)) {
pc++; setivalue(s2v(ra), luaV_shiftl(ic, ib));
}
vmbreak;
}
vmcase(OP_ADD) {
op_arith(L, l_addi, luai_numadd);
vmbreak;
}
vmcase(OP_SUB) {
op_arith(L, l_subi, luai_numsub);
vmbreak;
}
vmcase(OP_MUL) {
op_arith(L, l_muli, luai_nummul);
vmbreak;
}
vmcase(OP_MOD) {
op_arith(L, luaV_mod, luaV_modf);
vmbreak;
}
vmcase(OP_POW) {
op_arithf(L, luai_numpow);
vmbreak;
}
vmcase(OP_DIV) { /* float division (always with floats) */
op_arithf(L, luai_numdiv);
vmbreak;
}
vmcase(OP_IDIV) { /* floor division */
op_arith(L, luaV_idiv, luai_numidiv);
vmbreak;
}
vmcase(OP_BAND) {
op_bitwise(L, l_band);
vmbreak;
}
vmcase(OP_BOR) {
op_bitwise(L, l_bor);
vmbreak;
}
vmcase(OP_BXOR) {
op_bitwise(L, l_bxor);
vmbreak;
}
vmcase(OP_SHR) {
op_bitwise(L, luaV_shiftr);
vmbreak;
}
vmcase(OP_SHL) {
op_bitwise(L, luaV_shiftl);
vmbreak;
}
vmcase(OP_MMBIN) {
Instruction pi = *(pc - 2); /* original arith. expression */
TValue *rb = vRB(i);
TMS tm = (TMS)GETARG_C(i);
StkId result = RA(pi);
lua_assert(OP_ADD <= GET_OPCODE(pi) && GET_OPCODE(pi) <= OP_SHR);
Protect(luaT_trybinTM(L, s2v(ra), rb, result, tm));
vmbreak;
}
vmcase(OP_MMBINI) {
Instruction pi = *(pc - 2); /* original arith. expression */
int imm = GETARG_sB(i);
TMS tm = (TMS)GETARG_C(i);
int flip = GETARG_k(i);
StkId result = RA(pi);
Protect(luaT_trybiniTM(L, s2v(ra), imm, flip, result, tm));
vmbreak;
}
vmcase(OP_MMBINK) {
Instruction pi = *(pc - 2); /* original arith. expression */
TValue *imm = KB(i);
TMS tm = (TMS)GETARG_C(i);
int flip = GETARG_k(i);
StkId result = RA(pi);
Protect(luaT_trybinassocTM(L, s2v(ra), imm, flip, result, tm));
vmbreak;
}
vmcase(OP_UNM) {
TValue *rb = vRB(i);
lua_Number nb;
if (ttisinteger(rb)) {
lua_Integer ib = ivalue(rb);
setivalue(s2v(ra), intop(-, 0, ib));
}
else if (tonumberns(rb, nb)) {
setfltvalue(s2v(ra), luai_numunm(L, nb));
}
else
Protect(luaT_trybinTM(L, rb, rb, ra, TM_UNM));
vmbreak;
}
vmcase(OP_BNOT) {
TValue *rb = vRB(i);
lua_Integer ib;
if (tointegerns(rb, &ib)) {
setivalue(s2v(ra), intop(^, ~l_castS2U(0), ib));
}
else
Protect(luaT_trybinTM(L, rb, rb, ra, TM_BNOT));
vmbreak;
}
vmcase(OP_NOT) {
TValue *rb = vRB(i);
if (l_isfalse(rb))
setbtvalue(s2v(ra));
else
setbfvalue(s2v(ra));
vmbreak;
}
vmcase(OP_LEN) {
Protect(luaV_objlen(L, ra, vRB(i)));
vmbreak;
}
vmcase(OP_CONCAT) {
int n = GETARG_B(i); /* number of elements to concatenate */
L->top = ra + n; /* mark the end of concat operands */
ProtectNT(luaV_concat(L, n));
checkGC(L, L->top); /* 'luaV_concat' ensures correct top */
vmbreak;
}
vmcase(OP_CLOSE) {
Protect(luaF_close(L, ra, LUA_OK));
vmbreak;
}
vmcase(OP_TBC) {
/* create new to-be-closed upvalue */
halfProtect(luaF_newtbcupval(L, ra));
vmbreak;
}
vmcase(OP_JMP) {
dojump(ci, i, 0);
vmbreak;
}
vmcase(OP_EQ) {
int cond;
TValue *rb = vRB(i);
Protect(cond = luaV_equalobj(L, s2v(ra), rb));
docondjump();
vmbreak;
}
vmcase(OP_LT) {
op_order(L, l_lti, LTnum, lessthanothers);
vmbreak;
}
vmcase(OP_LE) {
op_order(L, l_lei, LEnum, lessequalothers);
vmbreak;
}
vmcase(OP_EQK) {
TValue *rb = KB(i);
/* basic types do not use '__eq'; we can use raw equality */
int cond = luaV_rawequalobj(s2v(ra), rb);
docondjump();
vmbreak;
}
vmcase(OP_EQI) {
int cond;
int im = GETARG_sB(i);
if (ttisinteger(s2v(ra)))
cond = (ivalue(s2v(ra)) == im);
else if (ttisfloat(s2v(ra)))
cond = luai_numeq(fltvalue(s2v(ra)), cast_num(im));
else
cond = 0; /* other types cannot be equal to a number */
docondjump();
vmbreak;
}
vmcase(OP_LTI) {
op_orderI(L, l_lti, luai_numlt, 0, TM_LT);
vmbreak;
}
vmcase(OP_LEI) {
op_orderI(L, l_lei, luai_numle, 0, TM_LE);
vmbreak;
}
vmcase(OP_GTI) {
op_orderI(L, l_gti, luai_numgt, 1, TM_LT);
vmbreak;
}
vmcase(OP_GEI) {
op_orderI(L, l_gei, luai_numge, 1, TM_LE);
vmbreak;
}
vmcase(OP_TEST) {
int cond = !l_isfalse(s2v(ra));
docondjump();
vmbreak;
}
vmcase(OP_TESTSET) {
TValue *rb = vRB(i);
if (l_isfalse(rb) == GETARG_k(i))
pc++;
else {
setobj2s(L, ra, rb);
donextjump(ci);
}
vmbreak;
}
vmcase(OP_CALL) {
int b = GETARG_B(i);
int nresults = GETARG_C(i) - 1;
if (b != 0) /* fixed number of arguments? */
L->top = ra + b; /* top signals number of arguments */
/* else previous instruction set top */
ProtectNT(luaD_call(L, ra, nresults));
vmbreak;
}
vmcase(OP_TAILCALL) {
int b = GETARG_B(i); /* number of arguments + 1 (function) */
int nparams1 = GETARG_C(i);
/* delat is virtual 'func' - real 'func' (vararg functions) */
int delta = (nparams1) ? ci->u.l.nextraargs + nparams1 : 0;
if (b != 0)
L->top = ra + b;
else /* previous instruction set top */
b = cast_int(L->top - ra);
savepc(ci); /* some calls here can raise errors */
if (TESTARG_k(i)) {
/* close upvalues from current call; the compiler ensures
that there are no to-be-closed variables here, so this
call cannot change the stack */
luaF_close(L, base, NOCLOSINGMETH);
lua_assert(base == ci->func + 1);
}
while (!ttisfunction(s2v(ra))) { /* not a function? */
luaD_tryfuncTM(L, ra); /* try '__call' metamethod */
b++; /* there is now one extra argument */
checkstackp(L, 1, ra);
}
if (!ttisLclosure(s2v(ra))) { /* C function? */
luaD_call(L, ra, LUA_MULTRET); /* call it */
updatetrap(ci);
updatestack(ci); /* stack may have been relocated */
ci->func -= delta;
luaD_poscall(L, ci, cast_int(L->top - ra));
return;
}
ci->func -= delta;
luaD_pretailcall(L, ci, ra, b); /* prepare call frame */
goto tailcall;
}
vmcase(OP_RETURN) {
int n = GETARG_B(i) - 1; /* number of results */
int nparams1 = GETARG_C(i);
if (n < 0) /* not fixed? */
n = cast_int(L->top - ra); /* get what is available */
savepc(ci);
if (TESTARG_k(i)) { /* may there be open upvalues? */
if (L->top < ci->top)
L->top = ci->top;
luaF_close(L, base, LUA_OK);
updatetrap(ci);
updatestack(ci);
}
if (nparams1) /* vararg function? */
ci->func -= ci->u.l.nextraargs + nparams1;
L->top = ra + n; /* set call for 'luaD_poscall' */
luaD_poscall(L, ci, n);
return;
}
vmcase(OP_RETURN0) {
if (L->hookmask) {
L->top = ra;
halfProtectNT(luaD_poscall(L, ci, 0)); /* no hurry... */
}
else { /* do the 'poscall' here */
int nres = ci->nresults;
L->ci = ci->previous; /* back to caller */
L->top = base - 1;
while (nres-- > 0)
setnilvalue(s2v(L->top++)); /* all results are nil */
}
return;
}
vmcase(OP_RETURN1) {
if (L->hookmask) {
L->top = ra + 1;
halfProtectNT(luaD_poscall(L, ci, 1)); /* no hurry... */
}
else { /* do the 'poscall' here */
int nres = ci->nresults;
L->ci = ci->previous; /* back to caller */
if (nres == 0)
L->top = base - 1; /* asked for no results */
else {
setobjs2s(L, base - 1, ra); /* at least this result */
L->top = base;
while (--nres > 0) /* complete missing results */
setnilvalue(s2v(L->top++));
}
}
return;
}
vmcase(OP_FORLOOP) {
if (ttisinteger(s2v(ra + 2))) { /* integer loop? */
lua_Unsigned count = l_castS2U(ivalue(s2v(ra + 1)));
if (count > 0) { /* still more iterations? */
lua_Integer step = ivalue(s2v(ra + 2));
lua_Integer idx = ivalue(s2v(ra)); /* internal index */
chgivalue(s2v(ra + 1), count - 1); /* update counter */
idx = intop(+, idx, step); /* add step to index */
chgivalue(s2v(ra), idx); /* update internal index */
setivalue(s2v(ra + 3), idx); /* and control variable */
pc -= GETARG_Bx(i); /* jump back */
}
}
else if (floatforloop(ra)) /* float loop */
pc -= GETARG_Bx(i); /* jump back */
updatetrap(ci); /* allows a signal to break the loop */
vmbreak;
}
vmcase(OP_FORPREP) {
savestate(L, ci); /* in case of errors */
if (forprep(L, ra))
pc += GETARG_Bx(i) + 1; /* skip the loop */
vmbreak;
}
vmcase(OP_TFORPREP) {
/* create to-be-closed upvalue (if needed) */
halfProtect(luaF_newtbcupval(L, ra + 3));
pc += GETARG_Bx(i);
i = *(pc++); /* go to next instruction */
lua_assert(GET_OPCODE(i) == OP_TFORCALL && ra == RA(i));
goto l_tforcall;
}
vmcase(OP_TFORCALL) {
l_tforcall:
/* 'ra' has the iterator function, 'ra + 1' has the state,
'ra + 2' has the control variable, and 'ra + 3' has the
to-be-closed variable. The call will use the stack after
these values (starting at 'ra + 4')
*/
/* push function, state, and control variable */
memcpy(ra + 4, ra, 3 * sizeof(*ra));
L->top = ra + 4 + 3;
ProtectNT(luaD_call(L, ra + 4, GETARG_C(i))); /* do the call */
updatestack(ci); /* stack may have changed */
i = *(pc++); /* go to next instruction */
lua_assert(GET_OPCODE(i) == OP_TFORLOOP && ra == RA(i));
goto l_tforloop;
}
vmcase(OP_TFORLOOP) {
l_tforloop:
if (!ttisnil(s2v(ra + 4))) { /* continue loop? */
setobjs2s(L, ra + 2, ra + 4); /* save control variable */
pc -= GETARG_Bx(i); /* jump back */
}
vmbreak;
}
vmcase(OP_SETLIST) {
int n = GETARG_B(i);
unsigned int last = GETARG_C(i);
Table *h = hvalue(s2v(ra));
if (n == 0)
n = cast_int(L->top - ra) - 1; /* get up to the top */
else
L->top = ci->top; /* correct top in case of emergency GC */
last += n;
if (TESTARG_k(i)) {
last += GETARG_Ax(*pc) * (MAXARG_C + 1);
pc++;
}
if (last > luaH_realasize(h)) /* needs more space? */
luaH_resizearray(L, h, last); /* preallocate it at once */
for (; n > 0; n--) {
TValue *val = s2v(ra + n);
setobj2t(L, &h->array[last - 1], val);
last--;
luaC_barrierback(L, obj2gco(h), val);
}
vmbreak;
}
vmcase(OP_CLOSURE) {
Proto *p = cl->p->p[GETARG_Bx(i)];
halfProtect(pushclosure(L, p, cl->upvals, base, ra));
checkGC(L, ra + 1);
vmbreak;
}
vmcase(OP_VARARG) {
int n = GETARG_C(i) - 1; /* required results */
Protect(luaT_getvarargs(L, ci, ra, n));
vmbreak;
}
vmcase(OP_VARARGPREP) {
luaT_adjustvarargs(L, GETARG_A(i), ci, cl->p);
updatetrap(ci);
if (trap) {
luaD_hookcall(L, ci);
L->oldpc = pc + 1; /* next opcode will be seen as a "new" line */
}
updatebase(ci); /* function has new base after adjustment */
vmbreak;
}
vmcase(OP_EXTRAARG) {
lua_assert(0);
vmbreak;
}
}
}
} | 4165 | True | 1 |
CVE-2020-15889 | False | False | False | False | AV:N/AC:L/Au:N/C:P/I:P/A:P | NETWORK | LOW | NONE | PARTIAL | PARTIAL | PARTIAL | 7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | HIGH | HIGH | HIGH | 9.8 | CRITICAL | 3.9 | 5.9 | False | [{'url': 'https://github.com/lua/lua/commit/127e7a6c8942b362aa3c6627f44d660a4fb75312', 'name': 'https://github.com/lua/lua/commit/127e7a6c8942b362aa3c6627f44d660a4fb75312', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00078.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00078.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-12/msg00157.html', 'name': 'http://lua-users.org/lists/lua-l/2020-12/msg00157.html', 'refsource': 'MISC', 'tags': ['Mailing List', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:lua:lua:5.4.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Lua 5.4.0 has a getobjname heap-based buffer over-read because youngcollection in lgc.c uses markold for an insufficient number of list members.'}] | 2020-12-23T17:41Z | 2020-07-21T22:15Z | Out-of-bounds Read | The software reads data past the end, or before the beginning, of the intended buffer. | Typically, this can allow attackers to read sensitive information from other memory locations or cause a crash. A crash can occur when the code reads a variable amount of data and assumes that a sentinel exists to stop the read operation, such as a NUL in a string. The expected sentinel might not be located in the out-of-bounds memory, causing excessive data to be read, leading to a segmentation fault or a buffer overflow. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent read operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/125.html | 0 | Roberto Ierusalimschy | 2020-07-10 14:13:50-03:00 | Fixed bug of old finalized objects in the GC
When an object aged OLD1 is finalized, it is moved from the list
'finobj' to the *beginning* of the list 'allgc'. So, this part of the
list (and not only the survival list) must be visited by 'markold'. | 127e7a6c8942b362aa3c6627f44d660a4fb75312 | False | lua/lua | The Lua development repository, as seen by the Lua team. Mirrored irregularly. Please DO NOT send pull requests. Report issues in the Lua mailing list https://www.lua.org/lua-l.html | 2012-09-14 05:55:07 | 2022-08-24 20:40:26 | https://www.lua.org/ | lua | 5964.0 | 1279.0 | youngcollection | youngcollection( lua_State * L , global_State * g) | ['L', 'g'] | static void youngcollection (lua_State *L, global_State *g) {
GCObject **psurvival; /* to point to first non-dead survival object */
lua_assert(g->gcstate == GCSpropagate);
markold(g, g->survival, g->reallyold);
markold(g, g->finobj, g->finobjrold);
atomic(L);
/* sweep nursery and get a pointer to its last live element */
psurvival = sweepgen(L, g, &g->allgc, g->survival);
/* sweep 'survival' and 'old' */
sweepgen(L, g, psurvival, g->reallyold);
g->reallyold = g->old;
g->old = *psurvival; /* 'survival' survivals are old now */
g->survival = g->allgc; /* all news are survivals */
/* repeat for 'finobj' lists */
psurvival = sweepgen(L, g, &g->finobj, g->finobjsur);
/* sweep 'survival' and 'old' */
sweepgen(L, g, psurvival, g->finobjrold);
g->finobjrold = g->finobjold;
g->finobjold = *psurvival; /* 'survival' survivals are old now */
g->finobjsur = g->finobj; /* all news are survivals */
sweepgen(L, g, &g->tobefnz, NULL);
finishgencycle(L, g);
} | 185 | True | 1 |
CVE-2020-15945 | False | False | False | False | AV:L/AC:L/Au:N/C:N/I:N/A:P | LOCAL | LOW | NONE | NONE | NONE | PARTIAL | 2.1 | CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H | LOCAL | LOW | LOW | NONE | UNCHANGED | NONE | NONE | HIGH | 5.5 | MEDIUM | 1.8 | 3.6 | False | [{'url': 'https://github.com/lua/lua/commit/a2195644d89812e5b157ce7bac35543e06db05e3', 'name': 'https://github.com/lua/lua/commit/a2195644d89812e5b157ce7bac35543e06db05e3', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00123.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00123.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'NVD-CWE-Other'}]}] | LOW | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:lua:lua:*:*:*:*:*:*:*:*', 'versionEndIncluding': '5.4.0', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Lua through 5.4.0 has a segmentation fault in changedline in ldebug.c (e.g., when called by luaG_traceexec) because it incorrectly expects that an oldpc value is always updated upon a return of the flow of control to a function.'}] | 2020-08-11T17:30Z | 2020-07-24T21:15Z | Other | NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset. | Insufficient Information | https://nvd.nist.gov/vuln/categories | 0 | Roberto Ierusalimschy | 2020-07-17 11:01:05-03:00 | Fixed bug: invalid 'oldpc' when returning to a function
The field 'L->oldpc' is not always updated when control returns to a
function; an invalid value can seg. fault when computing 'changedline'.
(One example is an error in a finalizer; control can return to
'luaV_execute' without executing 'luaD_poscall'.) Instead of trying to
fix all possible corner cases, it seems safer to be resilient to invalid
values for 'oldpc'. Valid but wrong values at most cause an extra call
to a line hook. | a2195644d89812e5b157ce7bac35543e06db05e3 | False | lua/lua | The Lua development repository, as seen by the Lua team. Mirrored irregularly. Please DO NOT send pull requests. Report issues in the Lua mailing list https://www.lua.org/lua-l.html | 2012-09-14 05:55:07 | 2022-08-24 20:40:26 | https://www.lua.org/ | lua | 5964.0 | 1279.0 | luaG_traceexec | luaG_traceexec( lua_State * L , const Instruction * pc) | ['L', 'pc'] | int luaG_traceexec (lua_State *L, const Instruction *pc) {
CallInfo *ci = L->ci;
lu_byte mask = L->hookmask;
int counthook;
if (!(mask & (LUA_MASKLINE | LUA_MASKCOUNT))) { /* no hooks? */
ci->u.l.trap = 0; /* don't need to stop again */
return 0; /* turn off 'trap' */
}
pc++; /* reference is always next instruction */
ci->u.l.savedpc = pc; /* save 'pc' */
counthook = (--L->hookcount == 0 && (mask & LUA_MASKCOUNT));
if (counthook)
resethookcount(L); /* reset count */
else if (!(mask & LUA_MASKLINE))
return 1; /* no line hook and count != 0; nothing to be done now */
if (ci->callstatus & CIST_HOOKYIELD) { /* called hook last time? */
ci->callstatus &= ~CIST_HOOKYIELD; /* erase mark */
return 1; /* do not call hook again (VM yielded, so it did not move) */
}
if (!isIT(*(ci->u.l.savedpc - 1)))
L->top = ci->top; /* prepare top */
if (counthook)
luaD_hook(L, LUA_HOOKCOUNT, -1, 0, 0); /* call count hook */
if (mask & LUA_MASKLINE) {
const Proto *p = ci_func(ci)->p;
int npci = pcRel(pc, p);
if (npci == 0 || /* call linehook when enter a new function, */
pc <= L->oldpc || /* when jump back (loop), or when */
changedline(p, pcRel(L->oldpc, p), npci)) { /* enter new line */
int newline = luaG_getfuncline(p, npci);
luaD_hook(L, LUA_HOOKLINE, newline, 0, 0); /* call line hook */
}
L->oldpc = pc; /* 'pc' of last call to line hook */
}
if (L->status == LUA_YIELD) { /* did hook yield? */
if (counthook)
L->hookcount = 1; /* undo decrement to zero */
ci->u.l.savedpc--; /* undo increment (resume will increment it again) */
ci->callstatus |= CIST_HOOKYIELD; /* mark that it yielded */
luaD_throw(L, LUA_YIELD);
}
return 1; /* keep 'trap' on */
} | 309 | True | 1 |
CVE-2020-15945 | False | False | False | False | AV:L/AC:L/Au:N/C:N/I:N/A:P | LOCAL | LOW | NONE | NONE | NONE | PARTIAL | 2.1 | CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H | LOCAL | LOW | LOW | NONE | UNCHANGED | NONE | NONE | HIGH | 5.5 | MEDIUM | 1.8 | 3.6 | False | [{'url': 'https://github.com/lua/lua/commit/a2195644d89812e5b157ce7bac35543e06db05e3', 'name': 'https://github.com/lua/lua/commit/a2195644d89812e5b157ce7bac35543e06db05e3', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00123.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00123.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'NVD-CWE-Other'}]}] | LOW | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:lua:lua:*:*:*:*:*:*:*:*', 'versionEndIncluding': '5.4.0', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Lua through 5.4.0 has a segmentation fault in changedline in ldebug.c (e.g., when called by luaG_traceexec) because it incorrectly expects that an oldpc value is always updated upon a return of the flow of control to a function.'}] | 2020-08-11T17:30Z | 2020-07-24T21:15Z | Other | NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset. | Insufficient Information | https://nvd.nist.gov/vuln/categories | 0 | Roberto Ierusalimschy | 2020-07-17 11:01:05-03:00 | Fixed bug: invalid 'oldpc' when returning to a function
The field 'L->oldpc' is not always updated when control returns to a
function; an invalid value can seg. fault when computing 'changedline'.
(One example is an error in a finalizer; control can return to
'luaV_execute' without executing 'luaD_poscall'.) Instead of trying to
fix all possible corner cases, it seems safer to be resilient to invalid
values for 'oldpc'. Valid but wrong values at most cause an extra call
to a line hook. | a2195644d89812e5b157ce7bac35543e06db05e3 | False | lua/lua | The Lua development repository, as seen by the Lua team. Mirrored irregularly. Please DO NOT send pull requests. Report issues in the Lua mailing list https://www.lua.org/lua-l.html | 2012-09-14 05:55:07 | 2022-08-24 20:40:26 | https://www.lua.org/ | lua | 5964.0 | 1279.0 | lua_sethook | lua_sethook( lua_State * L , lua_Hook func , int mask , int count) | ['L', 'func', 'mask', 'count'] | LUA_API void lua_sethook (lua_State *L, lua_Hook func, int mask, int count) {
if (func == NULL || mask == 0) { /* turn off hooks? */
mask = 0;
func = NULL;
}
if (isLua(L->ci))
L->oldpc = L->ci->u.l.savedpc;
L->hook = func;
L->basehookcount = count;
resethookcount(L);
L->hookmask = cast_byte(mask);
if (mask)
settraps(L->ci); /* to trace inside 'luaV_execute' */
} | 97 | True | 1 |
CVE-2020-15945 | False | False | False | False | AV:L/AC:L/Au:N/C:N/I:N/A:P | LOCAL | LOW | NONE | NONE | NONE | PARTIAL | 2.1 | CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H | LOCAL | LOW | LOW | NONE | UNCHANGED | NONE | NONE | HIGH | 5.5 | MEDIUM | 1.8 | 3.6 | False | [{'url': 'https://github.com/lua/lua/commit/a2195644d89812e5b157ce7bac35543e06db05e3', 'name': 'https://github.com/lua/lua/commit/a2195644d89812e5b157ce7bac35543e06db05e3', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00123.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00123.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'NVD-CWE-Other'}]}] | LOW | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:lua:lua:*:*:*:*:*:*:*:*', 'versionEndIncluding': '5.4.0', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Lua through 5.4.0 has a segmentation fault in changedline in ldebug.c (e.g., when called by luaG_traceexec) because it incorrectly expects that an oldpc value is always updated upon a return of the flow of control to a function.'}] | 2020-08-11T17:30Z | 2020-07-24T21:15Z | Other | NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset. | Insufficient Information | https://nvd.nist.gov/vuln/categories | 0 | Roberto Ierusalimschy | 2020-07-17 11:01:05-03:00 | Fixed bug: invalid 'oldpc' when returning to a function
The field 'L->oldpc' is not always updated when control returns to a
function; an invalid value can seg. fault when computing 'changedline'.
(One example is an error in a finalizer; control can return to
'luaV_execute' without executing 'luaD_poscall'.) Instead of trying to
fix all possible corner cases, it seems safer to be resilient to invalid
values for 'oldpc'. Valid but wrong values at most cause an extra call
to a line hook. | a2195644d89812e5b157ce7bac35543e06db05e3 | False | lua/lua | The Lua development repository, as seen by the Lua team. Mirrored irregularly. Please DO NOT send pull requests. Report issues in the Lua mailing list https://www.lua.org/lua-l.html | 2012-09-14 05:55:07 | 2022-08-24 20:40:26 | https://www.lua.org/ | lua | 5964.0 | 1279.0 | rethook | rethook( lua_State * L , CallInfo * ci , StkId firstres , int nres) | ['L', 'ci', 'firstres', 'nres'] | static StkId rethook (lua_State *L, CallInfo *ci, StkId firstres, int nres) {
ptrdiff_t oldtop = savestack(L, L->top); /* hook may change top */
int delta = 0;
if (isLuacode(ci)) {
Proto *p = clLvalue(s2v(ci->func))->p;
if (p->is_vararg)
delta = ci->u.l.nextraargs + p->numparams + 1;
if (L->top < ci->top)
L->top = ci->top; /* correct top to run hook */
}
if (L->hookmask & LUA_MASKRET) { /* is return hook on? */
int ftransfer;
ci->func += delta; /* if vararg, back to virtual 'func' */
ftransfer = cast(unsigned short, firstres - ci->func);
luaD_hook(L, LUA_HOOKRET, -1, ftransfer, nres); /* call it */
ci->func -= delta;
}
if (isLua(ci->previous))
L->oldpc = ci->previous->u.l.savedpc; /* update 'oldpc' */
return restorestack(L, oldtop);
} | 184 | True | 1 |
CVE-2020-15945 | False | False | False | False | AV:L/AC:L/Au:N/C:N/I:N/A:P | LOCAL | LOW | NONE | NONE | NONE | PARTIAL | 2.1 | CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H | LOCAL | LOW | LOW | NONE | UNCHANGED | NONE | NONE | HIGH | 5.5 | MEDIUM | 1.8 | 3.6 | False | [{'url': 'https://github.com/lua/lua/commit/a2195644d89812e5b157ce7bac35543e06db05e3', 'name': 'https://github.com/lua/lua/commit/a2195644d89812e5b157ce7bac35543e06db05e3', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00123.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00123.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'NVD-CWE-Other'}]}] | LOW | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:lua:lua:*:*:*:*:*:*:*:*', 'versionEndIncluding': '5.4.0', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Lua through 5.4.0 has a segmentation fault in changedline in ldebug.c (e.g., when called by luaG_traceexec) because it incorrectly expects that an oldpc value is always updated upon a return of the flow of control to a function.'}] | 2020-08-11T17:30Z | 2020-07-24T21:15Z | Other | NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset. | Insufficient Information | https://nvd.nist.gov/vuln/categories | 0 | Roberto Ierusalimschy | 2020-07-17 11:01:05-03:00 | Fixed bug: invalid 'oldpc' when returning to a function
The field 'L->oldpc' is not always updated when control returns to a
function; an invalid value can seg. fault when computing 'changedline'.
(One example is an error in a finalizer; control can return to
'luaV_execute' without executing 'luaD_poscall'.) Instead of trying to
fix all possible corner cases, it seems safer to be resilient to invalid
values for 'oldpc'. Valid but wrong values at most cause an extra call
to a line hook. | a2195644d89812e5b157ce7bac35543e06db05e3 | False | lua/lua | The Lua development repository, as seen by the Lua team. Mirrored irregularly. Please DO NOT send pull requests. Report issues in the Lua mailing list https://www.lua.org/lua-l.html | 2012-09-14 05:55:07 | 2022-08-24 20:40:26 | https://www.lua.org/ | lua | 5964.0 | 1279.0 | luaV_execute | luaV_execute( lua_State * L , CallInfo * ci) | ['L', 'ci'] | void luaV_execute (lua_State *L, CallInfo *ci) {
LClosure *cl;
TValue *k;
StkId base;
const Instruction *pc;
int trap;
#if LUA_USE_JUMPTABLE
#include "ljumptab.h"
#endif
tailcall:
trap = L->hookmask;
cl = clLvalue(s2v(ci->func));
k = cl->p->k;
pc = ci->u.l.savedpc;
if (trap) {
if (cl->p->is_vararg)
trap = 0; /* hooks will start after VARARGPREP instruction */
else if (pc == cl->p->code) /* first instruction (not resuming)? */
luaD_hookcall(L, ci);
ci->u.l.trap = 1; /* there may be other hooks */
}
base = ci->func + 1;
/* main loop of interpreter */
for (;;) {
Instruction i; /* instruction being executed */
StkId ra; /* instruction's A register */
vmfetch();
lua_assert(base == ci->func + 1);
lua_assert(base <= L->top && L->top < L->stack + L->stacksize);
/* invalidate top for instructions not expecting it */
lua_assert(isIT(i) || (cast_void(L->top = base), 1));
vmdispatch (GET_OPCODE(i)) {
vmcase(OP_MOVE) {
setobjs2s(L, ra, RB(i));
vmbreak;
}
vmcase(OP_LOADI) {
lua_Integer b = GETARG_sBx(i);
setivalue(s2v(ra), b);
vmbreak;
}
vmcase(OP_LOADF) {
int b = GETARG_sBx(i);
setfltvalue(s2v(ra), cast_num(b));
vmbreak;
}
vmcase(OP_LOADK) {
TValue *rb = k + GETARG_Bx(i);
setobj2s(L, ra, rb);
vmbreak;
}
vmcase(OP_LOADKX) {
TValue *rb;
rb = k + GETARG_Ax(*pc); pc++;
setobj2s(L, ra, rb);
vmbreak;
}
vmcase(OP_LOADFALSE) {
setbfvalue(s2v(ra));
vmbreak;
}
vmcase(OP_LFALSESKIP) {
setbfvalue(s2v(ra));
pc++; /* skip next instruction */
vmbreak;
}
vmcase(OP_LOADTRUE) {
setbtvalue(s2v(ra));
vmbreak;
}
vmcase(OP_LOADNIL) {
int b = GETARG_B(i);
do {
setnilvalue(s2v(ra++));
} while (b--);
vmbreak;
}
vmcase(OP_GETUPVAL) {
int b = GETARG_B(i);
setobj2s(L, ra, cl->upvals[b]->v);
vmbreak;
}
vmcase(OP_SETUPVAL) {
UpVal *uv = cl->upvals[GETARG_B(i)];
setobj(L, uv->v, s2v(ra));
luaC_barrier(L, uv, s2v(ra));
vmbreak;
}
vmcase(OP_GETTABUP) {
const TValue *slot;
TValue *upval = cl->upvals[GETARG_B(i)]->v;
TValue *rc = KC(i);
TString *key = tsvalue(rc); /* key must be a string */
if (luaV_fastget(L, upval, key, slot, luaH_getshortstr)) {
setobj2s(L, ra, slot);
}
else
Protect(luaV_finishget(L, upval, rc, ra, slot));
vmbreak;
}
vmcase(OP_GETTABLE) {
const TValue *slot;
TValue *rb = vRB(i);
TValue *rc = vRC(i);
lua_Unsigned n;
if (ttisinteger(rc) /* fast track for integers? */
? (cast_void(n = ivalue(rc)), luaV_fastgeti(L, rb, n, slot))
: luaV_fastget(L, rb, rc, slot, luaH_get)) {
setobj2s(L, ra, slot);
}
else
Protect(luaV_finishget(L, rb, rc, ra, slot));
vmbreak;
}
vmcase(OP_GETI) {
const TValue *slot;
TValue *rb = vRB(i);
int c = GETARG_C(i);
if (luaV_fastgeti(L, rb, c, slot)) {
setobj2s(L, ra, slot);
}
else {
TValue key;
setivalue(&key, c);
Protect(luaV_finishget(L, rb, &key, ra, slot));
}
vmbreak;
}
vmcase(OP_GETFIELD) {
const TValue *slot;
TValue *rb = vRB(i);
TValue *rc = KC(i);
TString *key = tsvalue(rc); /* key must be a string */
if (luaV_fastget(L, rb, key, slot, luaH_getshortstr)) {
setobj2s(L, ra, slot);
}
else
Protect(luaV_finishget(L, rb, rc, ra, slot));
vmbreak;
}
vmcase(OP_SETTABUP) {
const TValue *slot;
TValue *upval = cl->upvals[GETARG_A(i)]->v;
TValue *rb = KB(i);
TValue *rc = RKC(i);
TString *key = tsvalue(rb); /* key must be a string */
if (luaV_fastget(L, upval, key, slot, luaH_getshortstr)) {
luaV_finishfastset(L, upval, slot, rc);
}
else
Protect(luaV_finishset(L, upval, rb, rc, slot));
vmbreak;
}
vmcase(OP_SETTABLE) {
const TValue *slot;
TValue *rb = vRB(i); /* key (table is in 'ra') */
TValue *rc = RKC(i); /* value */
lua_Unsigned n;
if (ttisinteger(rb) /* fast track for integers? */
? (cast_void(n = ivalue(rb)), luaV_fastgeti(L, s2v(ra), n, slot))
: luaV_fastget(L, s2v(ra), rb, slot, luaH_get)) {
luaV_finishfastset(L, s2v(ra), slot, rc);
}
else
Protect(luaV_finishset(L, s2v(ra), rb, rc, slot));
vmbreak;
}
vmcase(OP_SETI) {
const TValue *slot;
int c = GETARG_B(i);
TValue *rc = RKC(i);
if (luaV_fastgeti(L, s2v(ra), c, slot)) {
luaV_finishfastset(L, s2v(ra), slot, rc);
}
else {
TValue key;
setivalue(&key, c);
Protect(luaV_finishset(L, s2v(ra), &key, rc, slot));
}
vmbreak;
}
vmcase(OP_SETFIELD) {
const TValue *slot;
TValue *rb = KB(i);
TValue *rc = RKC(i);
TString *key = tsvalue(rb); /* key must be a string */
if (luaV_fastget(L, s2v(ra), key, slot, luaH_getshortstr)) {
luaV_finishfastset(L, s2v(ra), slot, rc);
}
else
Protect(luaV_finishset(L, s2v(ra), rb, rc, slot));
vmbreak;
}
vmcase(OP_NEWTABLE) {
int b = GETARG_B(i); /* log2(hash size) + 1 */
int c = GETARG_C(i); /* array size */
Table *t;
if (b > 0)
b = 1 << (b - 1); /* size is 2^(b - 1) */
lua_assert((!TESTARG_k(i)) == (GETARG_Ax(*pc) == 0));
if (TESTARG_k(i)) /* non-zero extra argument? */
c += GETARG_Ax(*pc) * (MAXARG_C + 1); /* add it to size */
pc++; /* skip extra argument */
L->top = ra + 1; /* correct top in case of emergency GC */
t = luaH_new(L); /* memory allocation */
sethvalue2s(L, ra, t);
if (b != 0 || c != 0)
luaH_resize(L, t, c, b); /* idem */
checkGC(L, ra + 1);
vmbreak;
}
vmcase(OP_SELF) {
const TValue *slot;
TValue *rb = vRB(i);
TValue *rc = RKC(i);
TString *key = tsvalue(rc); /* key must be a string */
setobj2s(L, ra + 1, rb);
if (luaV_fastget(L, rb, key, slot, luaH_getstr)) {
setobj2s(L, ra, slot);
}
else
Protect(luaV_finishget(L, rb, rc, ra, slot));
vmbreak;
}
vmcase(OP_ADDI) {
op_arithI(L, l_addi, luai_numadd);
vmbreak;
}
vmcase(OP_ADDK) {
op_arithK(L, l_addi, luai_numadd);
vmbreak;
}
vmcase(OP_SUBK) {
op_arithK(L, l_subi, luai_numsub);
vmbreak;
}
vmcase(OP_MULK) {
op_arithK(L, l_muli, luai_nummul);
vmbreak;
}
vmcase(OP_MODK) {
op_arithK(L, luaV_mod, luaV_modf);
vmbreak;
}
vmcase(OP_POWK) {
op_arithfK(L, luai_numpow);
vmbreak;
}
vmcase(OP_DIVK) {
op_arithfK(L, luai_numdiv);
vmbreak;
}
vmcase(OP_IDIVK) {
op_arithK(L, luaV_idiv, luai_numidiv);
vmbreak;
}
vmcase(OP_BANDK) {
op_bitwiseK(L, l_band);
vmbreak;
}
vmcase(OP_BORK) {
op_bitwiseK(L, l_bor);
vmbreak;
}
vmcase(OP_BXORK) {
op_bitwiseK(L, l_bxor);
vmbreak;
}
vmcase(OP_SHRI) {
TValue *rb = vRB(i);
int ic = GETARG_sC(i);
lua_Integer ib;
if (tointegerns(rb, &ib)) {
pc++; setivalue(s2v(ra), luaV_shiftl(ib, -ic));
}
vmbreak;
}
vmcase(OP_SHLI) {
TValue *rb = vRB(i);
int ic = GETARG_sC(i);
lua_Integer ib;
if (tointegerns(rb, &ib)) {
pc++; setivalue(s2v(ra), luaV_shiftl(ic, ib));
}
vmbreak;
}
vmcase(OP_ADD) {
op_arith(L, l_addi, luai_numadd);
vmbreak;
}
vmcase(OP_SUB) {
op_arith(L, l_subi, luai_numsub);
vmbreak;
}
vmcase(OP_MUL) {
op_arith(L, l_muli, luai_nummul);
vmbreak;
}
vmcase(OP_MOD) {
op_arith(L, luaV_mod, luaV_modf);
vmbreak;
}
vmcase(OP_POW) {
op_arithf(L, luai_numpow);
vmbreak;
}
vmcase(OP_DIV) { /* float division (always with floats) */
op_arithf(L, luai_numdiv);
vmbreak;
}
vmcase(OP_IDIV) { /* floor division */
op_arith(L, luaV_idiv, luai_numidiv);
vmbreak;
}
vmcase(OP_BAND) {
op_bitwise(L, l_band);
vmbreak;
}
vmcase(OP_BOR) {
op_bitwise(L, l_bor);
vmbreak;
}
vmcase(OP_BXOR) {
op_bitwise(L, l_bxor);
vmbreak;
}
vmcase(OP_SHR) {
op_bitwise(L, luaV_shiftr);
vmbreak;
}
vmcase(OP_SHL) {
op_bitwise(L, luaV_shiftl);
vmbreak;
}
vmcase(OP_MMBIN) {
Instruction pi = *(pc - 2); /* original arith. expression */
TValue *rb = vRB(i);
TMS tm = (TMS)GETARG_C(i);
StkId result = RA(pi);
lua_assert(OP_ADD <= GET_OPCODE(pi) && GET_OPCODE(pi) <= OP_SHR);
Protect(luaT_trybinTM(L, s2v(ra), rb, result, tm));
vmbreak;
}
vmcase(OP_MMBINI) {
Instruction pi = *(pc - 2); /* original arith. expression */
int imm = GETARG_sB(i);
TMS tm = (TMS)GETARG_C(i);
int flip = GETARG_k(i);
StkId result = RA(pi);
Protect(luaT_trybiniTM(L, s2v(ra), imm, flip, result, tm));
vmbreak;
}
vmcase(OP_MMBINK) {
Instruction pi = *(pc - 2); /* original arith. expression */
TValue *imm = KB(i);
TMS tm = (TMS)GETARG_C(i);
int flip = GETARG_k(i);
StkId result = RA(pi);
Protect(luaT_trybinassocTM(L, s2v(ra), imm, flip, result, tm));
vmbreak;
}
vmcase(OP_UNM) {
TValue *rb = vRB(i);
lua_Number nb;
if (ttisinteger(rb)) {
lua_Integer ib = ivalue(rb);
setivalue(s2v(ra), intop(-, 0, ib));
}
else if (tonumberns(rb, nb)) {
setfltvalue(s2v(ra), luai_numunm(L, nb));
}
else
Protect(luaT_trybinTM(L, rb, rb, ra, TM_UNM));
vmbreak;
}
vmcase(OP_BNOT) {
TValue *rb = vRB(i);
lua_Integer ib;
if (tointegerns(rb, &ib)) {
setivalue(s2v(ra), intop(^, ~l_castS2U(0), ib));
}
else
Protect(luaT_trybinTM(L, rb, rb, ra, TM_BNOT));
vmbreak;
}
vmcase(OP_NOT) {
TValue *rb = vRB(i);
if (l_isfalse(rb))
setbtvalue(s2v(ra));
else
setbfvalue(s2v(ra));
vmbreak;
}
vmcase(OP_LEN) {
Protect(luaV_objlen(L, ra, vRB(i)));
vmbreak;
}
vmcase(OP_CONCAT) {
int n = GETARG_B(i); /* number of elements to concatenate */
L->top = ra + n; /* mark the end of concat operands */
ProtectNT(luaV_concat(L, n));
checkGC(L, L->top); /* 'luaV_concat' ensures correct top */
vmbreak;
}
vmcase(OP_CLOSE) {
Protect(luaF_close(L, ra, LUA_OK));
vmbreak;
}
vmcase(OP_TBC) {
/* create new to-be-closed upvalue */
halfProtect(luaF_newtbcupval(L, ra));
vmbreak;
}
vmcase(OP_JMP) {
dojump(ci, i, 0);
vmbreak;
}
vmcase(OP_EQ) {
int cond;
TValue *rb = vRB(i);
Protect(cond = luaV_equalobj(L, s2v(ra), rb));
docondjump();
vmbreak;
}
vmcase(OP_LT) {
op_order(L, l_lti, LTnum, lessthanothers);
vmbreak;
}
vmcase(OP_LE) {
op_order(L, l_lei, LEnum, lessequalothers);
vmbreak;
}
vmcase(OP_EQK) {
TValue *rb = KB(i);
/* basic types do not use '__eq'; we can use raw equality */
int cond = luaV_rawequalobj(s2v(ra), rb);
docondjump();
vmbreak;
}
vmcase(OP_EQI) {
int cond;
int im = GETARG_sB(i);
if (ttisinteger(s2v(ra)))
cond = (ivalue(s2v(ra)) == im);
else if (ttisfloat(s2v(ra)))
cond = luai_numeq(fltvalue(s2v(ra)), cast_num(im));
else
cond = 0; /* other types cannot be equal to a number */
docondjump();
vmbreak;
}
vmcase(OP_LTI) {
op_orderI(L, l_lti, luai_numlt, 0, TM_LT);
vmbreak;
}
vmcase(OP_LEI) {
op_orderI(L, l_lei, luai_numle, 0, TM_LE);
vmbreak;
}
vmcase(OP_GTI) {
op_orderI(L, l_gti, luai_numgt, 1, TM_LT);
vmbreak;
}
vmcase(OP_GEI) {
op_orderI(L, l_gei, luai_numge, 1, TM_LE);
vmbreak;
}
vmcase(OP_TEST) {
int cond = !l_isfalse(s2v(ra));
docondjump();
vmbreak;
}
vmcase(OP_TESTSET) {
TValue *rb = vRB(i);
if (l_isfalse(rb) == GETARG_k(i))
pc++;
else {
setobj2s(L, ra, rb);
donextjump(ci);
}
vmbreak;
}
vmcase(OP_CALL) {
int b = GETARG_B(i);
int nresults = GETARG_C(i) - 1;
if (b != 0) /* fixed number of arguments? */
L->top = ra + b; /* top signals number of arguments */
/* else previous instruction set top */
ProtectNT(luaD_call(L, ra, nresults));
vmbreak;
}
vmcase(OP_TAILCALL) {
int b = GETARG_B(i); /* number of arguments + 1 (function) */
int nparams1 = GETARG_C(i);
/* delat is virtual 'func' - real 'func' (vararg functions) */
int delta = (nparams1) ? ci->u.l.nextraargs + nparams1 : 0;
if (b != 0)
L->top = ra + b;
else /* previous instruction set top */
b = cast_int(L->top - ra);
savepc(ci); /* some calls here can raise errors */
if (TESTARG_k(i)) {
/* close upvalues from current call; the compiler ensures
that there are no to-be-closed variables here, so this
call cannot change the stack */
luaF_close(L, base, NOCLOSINGMETH);
lua_assert(base == ci->func + 1);
}
while (!ttisfunction(s2v(ra))) { /* not a function? */
luaD_tryfuncTM(L, ra); /* try '__call' metamethod */
b++; /* there is now one extra argument */
checkstackGCp(L, 1, ra);
}
if (!ttisLclosure(s2v(ra))) { /* C function? */
luaD_call(L, ra, LUA_MULTRET); /* call it */
updatetrap(ci);
updatestack(ci); /* stack may have been relocated */
ci->func -= delta;
luaD_poscall(L, ci, cast_int(L->top - ra));
return;
}
ci->func -= delta;
luaD_pretailcall(L, ci, ra, b); /* prepare call frame */
goto tailcall;
}
vmcase(OP_RETURN) {
int n = GETARG_B(i) - 1; /* number of results */
int nparams1 = GETARG_C(i);
if (n < 0) /* not fixed? */
n = cast_int(L->top - ra); /* get what is available */
savepc(ci);
if (TESTARG_k(i)) { /* may there be open upvalues? */
if (L->top < ci->top)
L->top = ci->top;
luaF_close(L, base, LUA_OK);
updatetrap(ci);
updatestack(ci);
}
if (nparams1) /* vararg function? */
ci->func -= ci->u.l.nextraargs + nparams1;
L->top = ra + n; /* set call for 'luaD_poscall' */
luaD_poscall(L, ci, n);
return;
}
vmcase(OP_RETURN0) {
if (L->hookmask) {
L->top = ra;
halfProtectNT(luaD_poscall(L, ci, 0)); /* no hurry... */
}
else { /* do the 'poscall' here */
int nres = ci->nresults;
L->ci = ci->previous; /* back to caller */
L->top = base - 1;
while (nres-- > 0)
setnilvalue(s2v(L->top++)); /* all results are nil */
}
return;
}
vmcase(OP_RETURN1) {
if (L->hookmask) {
L->top = ra + 1;
halfProtectNT(luaD_poscall(L, ci, 1)); /* no hurry... */
}
else { /* do the 'poscall' here */
int nres = ci->nresults;
L->ci = ci->previous; /* back to caller */
if (nres == 0)
L->top = base - 1; /* asked for no results */
else {
setobjs2s(L, base - 1, ra); /* at least this result */
L->top = base;
while (--nres > 0) /* complete missing results */
setnilvalue(s2v(L->top++));
}
}
return;
}
vmcase(OP_FORLOOP) {
if (ttisinteger(s2v(ra + 2))) { /* integer loop? */
lua_Unsigned count = l_castS2U(ivalue(s2v(ra + 1)));
if (count > 0) { /* still more iterations? */
lua_Integer step = ivalue(s2v(ra + 2));
lua_Integer idx = ivalue(s2v(ra)); /* internal index */
chgivalue(s2v(ra + 1), count - 1); /* update counter */
idx = intop(+, idx, step); /* add step to index */
chgivalue(s2v(ra), idx); /* update internal index */
setivalue(s2v(ra + 3), idx); /* and control variable */
pc -= GETARG_Bx(i); /* jump back */
}
}
else if (floatforloop(ra)) /* float loop */
pc -= GETARG_Bx(i); /* jump back */
updatetrap(ci); /* allows a signal to break the loop */
vmbreak;
}
vmcase(OP_FORPREP) {
savestate(L, ci); /* in case of errors */
if (forprep(L, ra))
pc += GETARG_Bx(i) + 1; /* skip the loop */
vmbreak;
}
vmcase(OP_TFORPREP) {
/* create to-be-closed upvalue (if needed) */
halfProtect(luaF_newtbcupval(L, ra + 3));
pc += GETARG_Bx(i);
i = *(pc++); /* go to next instruction */
lua_assert(GET_OPCODE(i) == OP_TFORCALL && ra == RA(i));
goto l_tforcall;
}
vmcase(OP_TFORCALL) {
l_tforcall:
/* 'ra' has the iterator function, 'ra + 1' has the state,
'ra + 2' has the control variable, and 'ra + 3' has the
to-be-closed variable. The call will use the stack after
these values (starting at 'ra + 4')
*/
/* push function, state, and control variable */
memcpy(ra + 4, ra, 3 * sizeof(*ra));
L->top = ra + 4 + 3;
ProtectNT(luaD_call(L, ra + 4, GETARG_C(i))); /* do the call */
updatestack(ci); /* stack may have changed */
i = *(pc++); /* go to next instruction */
lua_assert(GET_OPCODE(i) == OP_TFORLOOP && ra == RA(i));
goto l_tforloop;
}
vmcase(OP_TFORLOOP) {
l_tforloop:
if (!ttisnil(s2v(ra + 4))) { /* continue loop? */
setobjs2s(L, ra + 2, ra + 4); /* save control variable */
pc -= GETARG_Bx(i); /* jump back */
}
vmbreak;
}
vmcase(OP_SETLIST) {
int n = GETARG_B(i);
unsigned int last = GETARG_C(i);
Table *h = hvalue(s2v(ra));
if (n == 0)
n = cast_int(L->top - ra) - 1; /* get up to the top */
else
L->top = ci->top; /* correct top in case of emergency GC */
last += n;
if (TESTARG_k(i)) {
last += GETARG_Ax(*pc) * (MAXARG_C + 1);
pc++;
}
if (last > luaH_realasize(h)) /* needs more space? */
luaH_resizearray(L, h, last); /* preallocate it at once */
for (; n > 0; n--) {
TValue *val = s2v(ra + n);
setobj2t(L, &h->array[last - 1], val);
last--;
luaC_barrierback(L, obj2gco(h), val);
}
vmbreak;
}
vmcase(OP_CLOSURE) {
Proto *p = cl->p->p[GETARG_Bx(i)];
halfProtect(pushclosure(L, p, cl->upvals, base, ra));
checkGC(L, ra + 1);
vmbreak;
}
vmcase(OP_VARARG) {
int n = GETARG_C(i) - 1; /* required results */
Protect(luaT_getvarargs(L, ci, ra, n));
vmbreak;
}
vmcase(OP_VARARGPREP) {
ProtectNT(luaT_adjustvarargs(L, GETARG_A(i), ci, cl->p));
if (trap) {
luaD_hookcall(L, ci);
L->oldpc = pc + 1; /* next opcode will be seen as a "new" line */
}
updatebase(ci); /* function has new base after adjustment */
vmbreak;
}
vmcase(OP_EXTRAARG) {
lua_assert(0);
vmbreak;
}
}
}
} | 4163 | True | 1 |
CVE-2020-24342 | False | False | False | True | AV:N/AC:M/Au:N/C:P/I:P/A:P | NETWORK | MEDIUM | NONE | PARTIAL | PARTIAL | PARTIAL | 6.8 | CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H | LOCAL | LOW | NONE | REQUIRED | UNCHANGED | HIGH | HIGH | HIGH | 7.8 | HIGH | 1.8 | 5.9 | False | [{'url': 'https://github.com/lua/lua/commit/34affe7a63fc5d842580a9f23616d057e17dfe27', 'name': 'https://github.com/lua/lua/commit/34affe7a63fc5d842580a9f23616d057e17dfe27', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00052.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00052.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Vendor Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/QA5Q5MDQMTGXRQO3PAQ4EZFTYWJXZM5N/', 'name': 'FEDORA-2020-38e35de8aa', 'refsource': 'FEDORA', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-119'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:lua:lua:5.4.0:*:*:*:*:*:*:*', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:fedoraproject:fedora:33:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Lua through 5.4.0 allows a stack redzone cross in luaO_pushvfstring because a protection mechanism wrongly calls luaD_callnoyield twice in a row.'}] | 2021-01-26T15:54Z | 2020-08-13T19:15Z | Improper Restriction of Operations within the Bounds of a Memory Buffer | The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer. |
Certain languages allow direct addressing of memory locations and do not automatically ensure that these locations are valid for the memory buffer that is being referenced. This can cause read or write operations to be performed on memory locations that may be associated with other variables, data structures, or internal program data.
As a result, an attacker may be able to execute arbitrary code, alter the intended control flow, read sensitive information, or cause the system to crash.
| https://cwe.mitre.org/data/definitions/119.html | 0 | Roberto Ierusalimschy | 2020-07-17 14:54:26-03:00 | Fixed bug: 'luaD_callnoyield' called twice in a row
In luaD_callnoyield, when there is a possible stack overflow, it
zeros the number of CallInfos to force a check when calling the
function. However, if the "function" is not a function, the code will
raise an error before checking the stack. Then, the error handling calls
luaD_callnoyield again and nCcalls is decremented again, crossing the
stack redzone without raising an error. (This loop can only happens
once, because the error handler must be a function. But once is enough
to cross the redzone.) | 34affe7a63fc5d842580a9f23616d057e17dfe27 | False | lua/lua | The Lua development repository, as seen by the Lua team. Mirrored irregularly. Please DO NOT send pull requests. Report issues in the Lua mailing list https://www.lua.org/lua-l.html | 2012-09-14 05:55:07 | 2022-08-24 20:40:26 | https://www.lua.org/ | lua | 5964.0 | 1279.0 | luaD_callnoyield | luaD_callnoyield( lua_State * L , StkId func , int nResults) | ['L', 'func', 'nResults'] | void luaD_callnoyield (lua_State *L, StkId func, int nResults) {
incXCcalls(L);
if (getCcalls(L) <= CSTACKERR) /* possible stack overflow? */
luaE_freeCI(L);
luaD_call(L, func, nResults);
decXCcalls(L);
} | 47 | True | 1 |
CVE-2020-24371 | False | False | False | False | AV:N/AC:L/Au:N/C:N/I:N/A:P | NETWORK | LOW | NONE | NONE | NONE | PARTIAL | 5.0 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L | NETWORK | LOW | NONE | NONE | UNCHANGED | NONE | NONE | LOW | 5.3 | MEDIUM | 3.9 | 1.4 | False | [{'url': 'https://github.com/lua/lua/commit/a6da1472c0c5e05ff249325f979531ad51533110', 'name': 'https://github.com/lua/lua/commit/a6da1472c0c5e05ff249325f979531ad51533110', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://www.lua.org/bugs.html#5.4.0-10', 'name': 'https://www.lua.org/bugs.html#5.4.0-10', 'refsource': 'MISC', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-763'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:lua:lua:5.4.0:-:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'lgc.c in Lua 5.4.0 mishandles the interaction between barriers and the sweep phase, leading to a memory access violation involving collectgarbage.'}] | 2020-09-30T21:15Z | 2020-08-17T17:15Z | Release of Invalid Pointer or Reference | The application attempts to return a memory resource to the system, but calls the wrong release function or calls the appropriate release function incorrectly. |
This weakness can take several forms, such as:
The memory was allocated, explicitly or implicitly, via one memory management method and deallocated using a different, non-compatible function (CWE-762).
The function calls or memory management routines chosen are appropriate, however they are used incorrectly, such as in CWE-761.
| https://cwe.mitre.org/data/definitions/763.html | 0 | Roberto Ierusalimschy | 2020-07-27 10:26:20-03:00 | Fixed bug: barriers cannot be active during sweep
Barriers cannot be active during sweep, even in generational mode.
(Although gen. mode is not incremental, it can hit a barrier when
deleting a thread and closing its upvalues.) The colors of objects are
being changed during sweep and, therefore, cannot be trusted. | a6da1472c0c5e05ff249325f979531ad51533110 | False | lua/lua | The Lua development repository, as seen by the Lua team. Mirrored irregularly. Please DO NOT send pull requests. Report issues in the Lua mailing list https://www.lua.org/lua-l.html | 2012-09-14 05:55:07 | 2022-08-24 20:40:26 | https://www.lua.org/ | lua | 5964.0 | 1279.0 | correctgraylist | correctgraylist( GCObject ** p) | ['p'] | static GCObject **correctgraylist (GCObject **p) {
GCObject *curr;
while ((curr = *p) != NULL) {
switch (curr->tt) {
case LUA_VTABLE: case LUA_VUSERDATA: {
GCObject **next = getgclist(curr);
if (getage(curr) == G_TOUCHED1) { /* touched in this cycle? */
lua_assert(isgray(curr));
gray2black(curr); /* make it black, for next barrier */
changeage(curr, G_TOUCHED1, G_TOUCHED2);
p = next; /* go to next element */
}
else { /* not touched in this cycle */
if (!iswhite(curr)) { /* not white? */
lua_assert(isold(curr));
if (getage(curr) == G_TOUCHED2) /* advance from G_TOUCHED2... */
changeage(curr, G_TOUCHED2, G_OLD); /* ... to G_OLD */
gray2black(curr); /* make it black */
}
/* else, object is white: just remove it from this list */
*p = *next; /* remove 'curr' from gray list */
}
break;
}
case LUA_VTHREAD: {
lua_State *th = gco2th(curr);
lua_assert(!isblack(th));
if (iswhite(th)) /* new object? */
*p = th->gclist; /* remove from gray list */
else /* old threads remain gray */
p = &th->gclist; /* go to next element */
break;
}
default: lua_assert(0); /* nothing more could be gray here */
}
}
return p;
} | 196 | True | 1 |
CVE-2020-24371 | False | False | False | False | AV:N/AC:L/Au:N/C:N/I:N/A:P | NETWORK | LOW | NONE | NONE | NONE | PARTIAL | 5.0 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L | NETWORK | LOW | NONE | NONE | UNCHANGED | NONE | NONE | LOW | 5.3 | MEDIUM | 3.9 | 1.4 | False | [{'url': 'https://github.com/lua/lua/commit/a6da1472c0c5e05ff249325f979531ad51533110', 'name': 'https://github.com/lua/lua/commit/a6da1472c0c5e05ff249325f979531ad51533110', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://www.lua.org/bugs.html#5.4.0-10', 'name': 'https://www.lua.org/bugs.html#5.4.0-10', 'refsource': 'MISC', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-763'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:lua:lua:5.4.0:-:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'lgc.c in Lua 5.4.0 mishandles the interaction between barriers and the sweep phase, leading to a memory access violation involving collectgarbage.'}] | 2020-09-30T21:15Z | 2020-08-17T17:15Z | Release of Invalid Pointer or Reference | The application attempts to return a memory resource to the system, but calls the wrong release function or calls the appropriate release function incorrectly. |
This weakness can take several forms, such as:
The memory was allocated, explicitly or implicitly, via one memory management method and deallocated using a different, non-compatible function (CWE-762).
The function calls or memory management routines chosen are appropriate, however they are used incorrectly, such as in CWE-761.
| https://cwe.mitre.org/data/definitions/763.html | 0 | Roberto Ierusalimschy | 2020-07-27 10:26:20-03:00 | Fixed bug: barriers cannot be active during sweep
Barriers cannot be active during sweep, even in generational mode.
(Although gen. mode is not incremental, it can hit a barrier when
deleting a thread and closing its upvalues.) The colors of objects are
being changed during sweep and, therefore, cannot be trusted. | a6da1472c0c5e05ff249325f979531ad51533110 | False | lua/lua | The Lua development repository, as seen by the Lua team. Mirrored irregularly. Please DO NOT send pull requests. Report issues in the Lua mailing list https://www.lua.org/lua-l.html | 2012-09-14 05:55:07 | 2022-08-24 20:40:26 | https://www.lua.org/ | lua | 5964.0 | 1279.0 | luaC_barrier_ | luaC_barrier_( lua_State * L , GCObject * o , GCObject * v) | ['L', 'o', 'v'] | void luaC_barrier_ (lua_State *L, GCObject *o, GCObject *v) {
global_State *g = G(L);
lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o));
if (keepinvariant(g)) { /* must keep invariant? */
reallymarkobject(g, v); /* restore invariant */
if (isold(o)) {
lua_assert(!isold(v)); /* white object could not be old */
setage(v, G_OLD0); /* restore generational invariant */
}
}
else { /* sweep phase */
lua_assert(issweepphase(g));
makewhite(g, o); /* mark main obj. as white to avoid other barriers */
}
} | 113 | True | 1 |
CVE-2020-24370 | False | False | False | False | AV:N/AC:L/Au:N/C:N/I:N/A:P | NETWORK | LOW | NONE | NONE | NONE | PARTIAL | 5.0 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L | NETWORK | LOW | NONE | NONE | UNCHANGED | NONE | NONE | LOW | 5.3 | MEDIUM | 3.9 | 1.4 | False | [{'url': 'https://github.com/lua/lua/commit/a585eae6e7ada1ca9271607a4f48dfb17868ab7b', 'name': 'https://github.com/lua/lua/commit/a585eae6e7ada1ca9271607a4f48dfb17868ab7b', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00324.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00324.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Vendor Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/QXYMCIUNGK26VHAYHGP5LPW56G2KWOHQ/', 'name': 'FEDORA-2020-d7ed9f18ff', 'refsource': 'FEDORA', 'tags': []}, {'url': 'https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/E6KONNG6UEI3FMEOY67NDZC32NBGBI44/', 'name': 'FEDORA-2020-c83556709c', 'refsource': 'FEDORA', 'tags': []}, {'url': 'https://lists.debian.org/debian-lts-announce/2020/09/msg00019.html', 'name': '[debian-lts-announce] 20200926 [SECURITY] [DLA 2381-1] lua5.3 security update', 'refsource': 'MLIST', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-191'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:lua:lua:5.4.0:-:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'ldebug.c in Lua 5.4.0 allows a negation overflow and segmentation fault in getlocal and setlocal, as demonstrated by getlocal(3,2^31).'}] | 2020-09-26T16:15Z | 2020-08-17T17:15Z | Integer Underflow (Wrap or Wraparound) | The product subtracts one value from another, such that the result is less than the minimum allowable integer value, which produces a value that is not equal to the correct result. | This can happen in signed and unsigned cases.
| https://cwe.mitre.org/data/definitions/191.html | 0 | Roberto Ierusalimschy | 2020-07-27 12:01:38-03:00 | Fixed bug: Negation overflow in getlocal/setlocal | a585eae6e7ada1ca9271607a4f48dfb17868ab7b | False | lua/lua | The Lua development repository, as seen by the Lua team. Mirrored irregularly. Please DO NOT send pull requests. Report issues in the Lua mailing list https://www.lua.org/lua-l.html | 2012-09-14 05:55:07 | 2022-08-24 20:40:26 | https://www.lua.org/ | lua | 5964.0 | 1279.0 | findvararg | findvararg( CallInfo * ci , int n , StkId * pos) | ['ci', 'n', 'pos'] | static const char *findvararg (CallInfo *ci, int n, StkId *pos) {
if (clLvalue(s2v(ci->func))->p->is_vararg) {
int nextra = ci->u.l.nextraargs;
if (n <= nextra) {
*pos = ci->func - nextra + (n - 1);
return "(vararg)"; /* generic name for any vararg */
}
}
return NULL; /* no such vararg */
} | 73 | True | 1 |
CVE-2020-24370 | False | False | False | False | AV:N/AC:L/Au:N/C:N/I:N/A:P | NETWORK | LOW | NONE | NONE | NONE | PARTIAL | 5.0 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L | NETWORK | LOW | NONE | NONE | UNCHANGED | NONE | NONE | LOW | 5.3 | MEDIUM | 3.9 | 1.4 | False | [{'url': 'https://github.com/lua/lua/commit/a585eae6e7ada1ca9271607a4f48dfb17868ab7b', 'name': 'https://github.com/lua/lua/commit/a585eae6e7ada1ca9271607a4f48dfb17868ab7b', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://lua-users.org/lists/lua-l/2020-07/msg00324.html', 'name': 'http://lua-users.org/lists/lua-l/2020-07/msg00324.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Vendor Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/QXYMCIUNGK26VHAYHGP5LPW56G2KWOHQ/', 'name': 'FEDORA-2020-d7ed9f18ff', 'refsource': 'FEDORA', 'tags': []}, {'url': 'https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/E6KONNG6UEI3FMEOY67NDZC32NBGBI44/', 'name': 'FEDORA-2020-c83556709c', 'refsource': 'FEDORA', 'tags': []}, {'url': 'https://lists.debian.org/debian-lts-announce/2020/09/msg00019.html', 'name': '[debian-lts-announce] 20200926 [SECURITY] [DLA 2381-1] lua5.3 security update', 'refsource': 'MLIST', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-191'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:lua:lua:5.4.0:-:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'ldebug.c in Lua 5.4.0 allows a negation overflow and segmentation fault in getlocal and setlocal, as demonstrated by getlocal(3,2^31).'}] | 2020-09-26T16:15Z | 2020-08-17T17:15Z | Integer Underflow (Wrap or Wraparound) | The product subtracts one value from another, such that the result is less than the minimum allowable integer value, which produces a value that is not equal to the correct result. | This can happen in signed and unsigned cases.
| https://cwe.mitre.org/data/definitions/191.html | 0 | Roberto Ierusalimschy | 2020-07-27 12:01:38-03:00 | Fixed bug: Negation overflow in getlocal/setlocal | a585eae6e7ada1ca9271607a4f48dfb17868ab7b | False | lua/lua | The Lua development repository, as seen by the Lua team. Mirrored irregularly. Please DO NOT send pull requests. Report issues in the Lua mailing list https://www.lua.org/lua-l.html | 2012-09-14 05:55:07 | 2022-08-24 20:40:26 | https://www.lua.org/ | lua | 5964.0 | 1279.0 | luaG_findlocal | luaG_findlocal( lua_State * L , CallInfo * ci , int n , StkId * pos) | ['L', 'ci', 'n', 'pos'] | const char *luaG_findlocal (lua_State *L, CallInfo *ci, int n, StkId *pos) {
StkId base = ci->func + 1;
const char *name = NULL;
if (isLua(ci)) {
if (n < 0) /* access to vararg values? */
return findvararg(ci, -n, pos);
else
name = luaF_getlocalname(ci_func(ci)->p, n, currentpc(ci));
}
if (name == NULL) { /* no 'standard' name? */
StkId limit = (ci == L->ci) ? L->top : ci->next->func;
if (limit - base >= n && n > 0) { /* is 'n' inside 'ci' stack? */
/* generic name for any valid slot */
name = isLua(ci) ? "(temporary)" : "(C temporary)";
}
else
return NULL; /* no name */
}
if (pos)
*pos = base + (n - 1);
return name;
} | 157 | True | 1 |
CVE-2020-24369 | False | False | False | False | AV:N/AC:L/Au:N/C:N/I:N/A:P | NETWORK | LOW | NONE | NONE | NONE | PARTIAL | 5.0 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | NONE | NONE | HIGH | 7.5 | HIGH | 3.9 | 3.6 | False | [{'url': 'https://github.com/lua/lua/commit/ae5b5ba529753c7a653901ffc29b5ea24c3fdf3a', 'name': 'https://github.com/lua/lua/commit/ae5b5ba529753c7a653901ffc29b5ea24c3fdf3a', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://www.lua.org/bugs.html#5.4.0-12', 'name': 'https://www.lua.org/bugs.html#5.4.0-12', 'refsource': 'MISC', 'tags': ['Exploit', 'Vendor Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-476'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:lua:lua:5.4.0:-:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'ldebug.c in Lua 5.4.0 attempts to access debug information via the line hook of a stripped function, leading to a NULL pointer dereference.'}] | 2020-08-24T18:26Z | 2020-08-17T17:15Z | NULL Pointer Dereference | A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit. | NULL pointer dereference issues can occur through a number of flaws, including race conditions, and simple programming omissions.
| https://cwe.mitre.org/data/definitions/476.html | 0 | Roberto Ierusalimschy | 2020-07-27 13:23:05-03:00 | Fixed bug: line hooks in stripped functions
Line-hook handling was accessing debug info. without checking whether
it was present. | ae5b5ba529753c7a653901ffc29b5ea24c3fdf3a | False | lua/lua | The Lua development repository, as seen by the Lua team. Mirrored irregularly. Please DO NOT send pull requests. Report issues in the Lua mailing list https://www.lua.org/lua-l.html | 2012-09-14 05:55:07 | 2022-08-24 20:40:26 | https://www.lua.org/ | lua | 5964.0 | 1279.0 | changedline | changedline( const Proto * p , int oldpc , int newpc) | ['p', 'oldpc', 'newpc'] | static int changedline (const Proto *p, int oldpc, int newpc) {
while (oldpc++ < newpc) {
if (p->lineinfo[oldpc] != 0)
return (luaG_getfuncline(p, oldpc - 1) != luaG_getfuncline(p, newpc));
}
return 0; /* no line changes in the way */
} | 57 | True | 1 |
CVE-2022-33099 | False | False | False | False | AV:N/AC:L/Au:N/C:N/I:N/A:P | NETWORK | LOW | NONE | NONE | NONE | PARTIAL | 5.0 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | NONE | NONE | HIGH | 7.5 | HIGH | 3.9 | 3.6 | False | [{'url': 'https://lua-users.org/lists/lua-l/2022-05/msg00073.html', 'name': 'https://lua-users.org/lists/lua-l/2022-05/msg00073.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Vendor Advisory']}, {'url': 'https://lua-users.org/lists/lua-l/2022-05/msg00042.html', 'name': 'https://lua-users.org/lists/lua-l/2022-05/msg00042.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Vendor Advisory']}, {'url': 'https://www.lua.org/bugs.html#Lua-stack%20overflow%20when%20C%20stack%20overflows%20while%20handling%20an%20error:~:text=Lua%2Dstack%20overflow%20when%20C%20stack%20overflows%20while%20handling%20an%20error', 'name': 'https://www.lua.org/bugs.html#Lua-stack%20overflow%20when%20C%20stack%20overflows%20while%20handling%20an%20error:~:text=Lua%2Dstack%20overflow%20when%20C%20stack%20overflows%20while%20handling%20an%20error', 'refsource': 'MISC', 'tags': ['Exploit', 'Patch', 'Vendor Advisory']}, {'url': 'https://lua-users.org/lists/lua-l/2022-05/msg00035.html', 'name': 'https://lua-users.org/lists/lua-l/2022-05/msg00035.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Vendor Advisory']}, {'url': 'https://github.com/lua/lua/commit/42d40581dd919fb134c07027ca1ce0844c670daf', 'name': 'https://github.com/lua/lua/commit/42d40581dd919fb134c07027ca1ce0844c670daf', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/RJNJ66IFDUKWJJZXHGOLRGIA3HWWC36R/', 'name': 'FEDORA-2022-b9ed35a7ad', 'refsource': 'FEDORA', 'tags': []}, {'url': 'https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/UHYZOEFDVLVAD6EEP4CDW6DNONIVVHPA/', 'name': 'FEDORA-2022-5b5889f43a', 'refsource': 'FEDORA', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-787'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:lua:lua:*:*:*:*:*:*:*:*', 'versionStartIncluding': '5.4.2', 'versionEndIncluding': '5.4.4', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'An issue in the component luaG_runerror of Lua v5.4.4 and below leads to a heap-buffer overflow when a recursive error occurs.'}] | 2022-08-04T04:15Z | 2022-07-01T12:15Z | Out-of-bounds Write | The software writes data past the end, or before the beginning, of the intended buffer. | Typically, this can result in corruption of data, a crash, or code execution. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent write operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/787.html | 0 | Roberto Ierusalimschy | 2022-05-20 13:14:33-03:00 | Save stack space while handling errors
Because error handling (luaG_errormsg) uses slots from EXTRA_STACK,
and some errors can recur (e.g., string overflow while creating an
error message in 'luaG_runerror', or a C-stack overflow before calling
the message handler), the code should use stack slots with parsimony.
This commit fixes the bug "Lua-stack overflow when C stack overflows
while handling an error". | 42d40581dd919fb134c07027ca1ce0844c670daf | False | lua/lua | The Lua development repository, as seen by the Lua team. Mirrored irregularly. Please DO NOT send pull requests. Report issues in the Lua mailing list https://www.lua.org/lua-l.html | 2012-09-14 05:55:07 | 2022-08-24 20:40:26 | https://www.lua.org/ | lua | 5964.0 | 1279.0 | luaG_runerror | luaG_runerror( lua_State * L , const char * fmt , ...) | ['L', 'fmt'] | l_noret luaG_runerror (lua_State *L, const char *fmt, ...) {
CallInfo *ci = L->ci;
const char *msg;
va_list argp;
luaC_checkGC(L); /* error message uses memory */
va_start(argp, fmt);
msg = luaO_pushvfstring(L, fmt, argp); /* format message */
va_end(argp);
if (isLua(ci)) /* if Lua function, add source:line information */
luaG_addinfo(L, msg, ci_func(ci)->p->source, getcurrentline(ci));
luaG_errormsg(L);
} | 92 | True | 1 |
CVE-2022-33099 | False | False | False | False | AV:N/AC:L/Au:N/C:N/I:N/A:P | NETWORK | LOW | NONE | NONE | NONE | PARTIAL | 5.0 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | NONE | NONE | HIGH | 7.5 | HIGH | 3.9 | 3.6 | False | [{'url': 'https://lua-users.org/lists/lua-l/2022-05/msg00073.html', 'name': 'https://lua-users.org/lists/lua-l/2022-05/msg00073.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Vendor Advisory']}, {'url': 'https://lua-users.org/lists/lua-l/2022-05/msg00042.html', 'name': 'https://lua-users.org/lists/lua-l/2022-05/msg00042.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Vendor Advisory']}, {'url': 'https://www.lua.org/bugs.html#Lua-stack%20overflow%20when%20C%20stack%20overflows%20while%20handling%20an%20error:~:text=Lua%2Dstack%20overflow%20when%20C%20stack%20overflows%20while%20handling%20an%20error', 'name': 'https://www.lua.org/bugs.html#Lua-stack%20overflow%20when%20C%20stack%20overflows%20while%20handling%20an%20error:~:text=Lua%2Dstack%20overflow%20when%20C%20stack%20overflows%20while%20handling%20an%20error', 'refsource': 'MISC', 'tags': ['Exploit', 'Patch', 'Vendor Advisory']}, {'url': 'https://lua-users.org/lists/lua-l/2022-05/msg00035.html', 'name': 'https://lua-users.org/lists/lua-l/2022-05/msg00035.html', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Vendor Advisory']}, {'url': 'https://github.com/lua/lua/commit/42d40581dd919fb134c07027ca1ce0844c670daf', 'name': 'https://github.com/lua/lua/commit/42d40581dd919fb134c07027ca1ce0844c670daf', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/RJNJ66IFDUKWJJZXHGOLRGIA3HWWC36R/', 'name': 'FEDORA-2022-b9ed35a7ad', 'refsource': 'FEDORA', 'tags': []}, {'url': 'https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/UHYZOEFDVLVAD6EEP4CDW6DNONIVVHPA/', 'name': 'FEDORA-2022-5b5889f43a', 'refsource': 'FEDORA', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-787'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:lua:lua:*:*:*:*:*:*:*:*', 'versionStartIncluding': '5.4.2', 'versionEndIncluding': '5.4.4', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'An issue in the component luaG_runerror of Lua v5.4.4 and below leads to a heap-buffer overflow when a recursive error occurs.'}] | 2022-08-04T04:15Z | 2022-07-01T12:15Z | Out-of-bounds Write | The software writes data past the end, or before the beginning, of the intended buffer. | Typically, this can result in corruption of data, a crash, or code execution. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent write operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/787.html | 0 | Roberto Ierusalimschy | 2022-05-20 13:14:33-03:00 | Save stack space while handling errors
Because error handling (luaG_errormsg) uses slots from EXTRA_STACK,
and some errors can recur (e.g., string overflow while creating an
error message in 'luaG_runerror', or a C-stack overflow before calling
the message handler), the code should use stack slots with parsimony.
This commit fixes the bug "Lua-stack overflow when C stack overflows
while handling an error". | 42d40581dd919fb134c07027ca1ce0844c670daf | False | lua/lua | The Lua development repository, as seen by the Lua team. Mirrored irregularly. Please DO NOT send pull requests. Report issues in the Lua mailing list https://www.lua.org/lua-l.html | 2012-09-14 05:55:07 | 2022-08-24 20:40:26 | https://www.lua.org/ | lua | 5964.0 | 1279.0 | luaV_concat | luaV_concat( lua_State * L , int total) | ['L', 'total'] | void luaV_concat (lua_State *L, int total) {
if (total == 1)
return; /* "all" values already concatenated */
do {
StkId top = L->top;
int n = 2; /* number of elements handled in this pass (at least 2) */
if (!(ttisstring(s2v(top - 2)) || cvt2str(s2v(top - 2))) ||
!tostring(L, s2v(top - 1)))
luaT_tryconcatTM(L);
else if (isemptystr(s2v(top - 1))) /* second operand is empty? */
cast_void(tostring(L, s2v(top - 2))); /* result is first operand */
else if (isemptystr(s2v(top - 2))) { /* first operand is empty string? */
setobjs2s(L, top - 2, top - 1); /* result is second op. */
}
else {
/* at least two non-empty string values; get as many as possible */
size_t tl = vslen(s2v(top - 1));
TString *ts;
/* collect total length and number of strings */
for (n = 1; n < total && tostring(L, s2v(top - n - 1)); n++) {
size_t l = vslen(s2v(top - n - 1));
if (l_unlikely(l >= (MAX_SIZE/sizeof(char)) - tl))
luaG_runerror(L, "string length overflow");
tl += l;
}
if (tl <= LUAI_MAXSHORTLEN) { /* is result a short string? */
char buff[LUAI_MAXSHORTLEN];
copy2buff(top, n, buff); /* copy strings to buffer */
ts = luaS_newlstr(L, buff, tl);
}
else { /* long string; copy strings directly to final result */
ts = luaS_createlngstrobj(L, tl);
copy2buff(top, n, getstr(ts));
}
setsvalue2s(L, top - n, ts); /* create result */
}
total -= n-1; /* got 'n' strings to create 1 new */
L->top -= n-1; /* popped 'n' strings and pushed one */
} while (total > 1); /* repeat until only 1 result left */
} | 316 | True | 1 |
CVE-2020-15900 | False | False | False | False | AV:N/AC:L/Au:N/C:P/I:P/A:P | NETWORK | LOW | NONE | PARTIAL | PARTIAL | PARTIAL | 7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | HIGH | HIGH | HIGH | 9.8 | CRITICAL | 3.9 | 5.9 | False | [{'url': 'https://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=5d499272b95a6b890a1397e11d20937de000d31b', 'name': 'https://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=5d499272b95a6b890a1397e11d20937de000d31b', 'refsource': 'MISC', 'tags': ['Patch', 'Vendor Advisory']}, {'url': 'https://github.com/ArtifexSoftware/ghostpdl/commits/master/psi/zstring.c', 'name': 'https://github.com/ArtifexSoftware/ghostpdl/commits/master/psi/zstring.c', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://git.ghostscript.com/?p=ghostpdl.git;a=log', 'name': 'http://git.ghostscript.com/?p=ghostpdl.git;a=log', 'refsource': 'MISC', 'tags': ['Mailing List', 'Vendor Advisory']}, {'url': 'https://github.com/ArtifexSoftware/ghostpdl/commit/5d499272b95a6b890a1397e11d20937de000d31b', 'name': 'https://github.com/ArtifexSoftware/ghostpdl/commit/5d499272b95a6b890a1397e11d20937de000d31b', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://artifex.com/security-advisories/CVE-2020-15900', 'name': 'https://artifex.com/security-advisories/CVE-2020-15900', 'refsource': 'CONFIRM', 'tags': ['Vendor Advisory']}, {'url': 'http://lists.opensuse.org/opensuse-security-announce/2020-08/msg00004.html', 'name': 'openSUSE-SU-2020:1142', 'refsource': 'SUSE', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'http://lists.opensuse.org/opensuse-security-announce/2020-08/msg00006.html', 'name': 'openSUSE-SU-2020:1146', 'refsource': 'SUSE', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://usn.ubuntu.com/4445-1/', 'name': 'USN-4445-1', 'refsource': 'UBUNTU', 'tags': ['Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202008-20', 'name': 'GLSA-202008-20', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-787'}, {'lang': 'en', 'value': 'CWE-191'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:artifex:ghostscript:9.52:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:artifex:ghostscript:9.50:*:*:*:*:*:*:*', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:canonical:ubuntu_linux:20.04:*:*:*:lts:*:*:*', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:opensuse:leap:15.1:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:opensuse:leap:15.2:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': "A memory corruption issue was found in Artifex Ghostscript 9.50 and 9.52. Use of a non-standard PostScript operator can allow overriding of file access controls. The 'rsearch' calculation for the 'post' size resulted in a size that was too large, and could underflow to max uint32_t. This was fixed in commit 5d499272b95a6b890a1397e11d20937de000d31b."}] | 2022-04-27T16:28Z | 2020-07-28T16:15Z | Integer Underflow (Wrap or Wraparound) | The product subtracts one value from another, such that the result is less than the minimum allowable integer value, which produces a value that is not equal to the correct result. | This can happen in signed and unsigned cases.
| https://cwe.mitre.org/data/definitions/191.html | 0 | Ray Johnston | 2020-07-22 09:57:54-07:00 | Bug 702582, CVE 2020-15900 Memory Corruption in Ghostscript 9.52
Fix the 'rsearch' calculation for the 'post' size to give the correct
size. Previous calculation would result in a size that was too large,
and could underflow to max uint32_t. Also fix 'rsearch' to return the
correct 'pre' string with empty string match.
A future change may 'undefine' this undocumented, non-standard operator
during initialization as we do with the many other non-standard internal
PostScript operators and procedures. | 5d499272b95a6b890a1397e11d20937de000d31b | False | ArtifexSoftware/ghostpdl | This is a mirror: the canonical repo is: git.ghostscript.com/ghostpdl.git https://www.ghostscript.com | 2020-05-06 09:56:06 | 2022-08-26 14:04:38 | null | ArtifexSoftware | 57.0 | 21.0 | search_impl | search_impl( i_ctx_t * i_ctx_p , bool forward) | ['i_ctx_p', 'forward'] | search_impl(i_ctx_t *i_ctx_p, bool forward)
{
os_ptr op = osp;
os_ptr op1 = op - 1;
uint size = r_size(op);
uint count;
byte *pat;
byte *ptr;
byte ch;
int incr = forward ? 1 : -1;
check_read_type(*op1, t_string);
check_read_type(*op, t_string);
if (size > r_size(op1)) { /* can't match */
make_false(op);
return 0;
}
count = r_size(op1) - size;
ptr = op1->value.bytes;
if (size == 0)
goto found;
if (!forward)
ptr += count;
pat = op->value.bytes;
ch = pat[0];
do {
if (*ptr == ch && (size == 1 || !memcmp(ptr, pat, size)))
goto found;
ptr += incr;
}
while (count--);
/* No match */
make_false(op);
return 0;
found:
op->tas.type_attrs = op1->tas.type_attrs;
op->value.bytes = ptr;
r_set_size(op, size);
push(2);
op[-1] = *op1;
r_set_size(op - 1, ptr - op[-1].value.bytes);
op1->value.bytes = ptr + size;
r_set_size(op1, count + (!forward ? (size - 1) : 0));
make_true(op);
return 0;
} | 287 | True | 1 |
CVE-2020-15900 | False | False | False | False | AV:N/AC:L/Au:N/C:P/I:P/A:P | NETWORK | LOW | NONE | PARTIAL | PARTIAL | PARTIAL | 7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | HIGH | HIGH | HIGH | 9.8 | CRITICAL | 3.9 | 5.9 | False | [{'url': 'https://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=5d499272b95a6b890a1397e11d20937de000d31b', 'name': 'https://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=5d499272b95a6b890a1397e11d20937de000d31b', 'refsource': 'MISC', 'tags': ['Patch', 'Vendor Advisory']}, {'url': 'https://github.com/ArtifexSoftware/ghostpdl/commits/master/psi/zstring.c', 'name': 'https://github.com/ArtifexSoftware/ghostpdl/commits/master/psi/zstring.c', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://git.ghostscript.com/?p=ghostpdl.git;a=log', 'name': 'http://git.ghostscript.com/?p=ghostpdl.git;a=log', 'refsource': 'MISC', 'tags': ['Mailing List', 'Vendor Advisory']}, {'url': 'https://github.com/ArtifexSoftware/ghostpdl/commit/5d499272b95a6b890a1397e11d20937de000d31b', 'name': 'https://github.com/ArtifexSoftware/ghostpdl/commit/5d499272b95a6b890a1397e11d20937de000d31b', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://artifex.com/security-advisories/CVE-2020-15900', 'name': 'https://artifex.com/security-advisories/CVE-2020-15900', 'refsource': 'CONFIRM', 'tags': ['Vendor Advisory']}, {'url': 'http://lists.opensuse.org/opensuse-security-announce/2020-08/msg00004.html', 'name': 'openSUSE-SU-2020:1142', 'refsource': 'SUSE', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'http://lists.opensuse.org/opensuse-security-announce/2020-08/msg00006.html', 'name': 'openSUSE-SU-2020:1146', 'refsource': 'SUSE', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://usn.ubuntu.com/4445-1/', 'name': 'USN-4445-1', 'refsource': 'UBUNTU', 'tags': ['Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202008-20', 'name': 'GLSA-202008-20', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-787'}, {'lang': 'en', 'value': 'CWE-191'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:artifex:ghostscript:9.52:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:artifex:ghostscript:9.50:*:*:*:*:*:*:*', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:canonical:ubuntu_linux:20.04:*:*:*:lts:*:*:*', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:opensuse:leap:15.1:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:opensuse:leap:15.2:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': "A memory corruption issue was found in Artifex Ghostscript 9.50 and 9.52. Use of a non-standard PostScript operator can allow overriding of file access controls. The 'rsearch' calculation for the 'post' size resulted in a size that was too large, and could underflow to max uint32_t. This was fixed in commit 5d499272b95a6b890a1397e11d20937de000d31b."}] | 2022-04-27T16:28Z | 2020-07-28T16:15Z | Out-of-bounds Write | The software writes data past the end, or before the beginning, of the intended buffer. | Typically, this can result in corruption of data, a crash, or code execution. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent write operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/787.html | 0 | Ray Johnston | 2020-07-22 09:57:54-07:00 | Bug 702582, CVE 2020-15900 Memory Corruption in Ghostscript 9.52
Fix the 'rsearch' calculation for the 'post' size to give the correct
size. Previous calculation would result in a size that was too large,
and could underflow to max uint32_t. Also fix 'rsearch' to return the
correct 'pre' string with empty string match.
A future change may 'undefine' this undocumented, non-standard operator
during initialization as we do with the many other non-standard internal
PostScript operators and procedures. | 5d499272b95a6b890a1397e11d20937de000d31b | False | ArtifexSoftware/ghostpdl | This is a mirror: the canonical repo is: git.ghostscript.com/ghostpdl.git https://www.ghostscript.com | 2020-05-06 09:56:06 | 2022-08-26 14:04:38 | null | ArtifexSoftware | 57.0 | 21.0 | search_impl | search_impl( i_ctx_t * i_ctx_p , bool forward) | ['i_ctx_p', 'forward'] | search_impl(i_ctx_t *i_ctx_p, bool forward)
{
os_ptr op = osp;
os_ptr op1 = op - 1;
uint size = r_size(op);
uint count;
byte *pat;
byte *ptr;
byte ch;
int incr = forward ? 1 : -1;
check_read_type(*op1, t_string);
check_read_type(*op, t_string);
if (size > r_size(op1)) { /* can't match */
make_false(op);
return 0;
}
count = r_size(op1) - size;
ptr = op1->value.bytes;
if (size == 0)
goto found;
if (!forward)
ptr += count;
pat = op->value.bytes;
ch = pat[0];
do {
if (*ptr == ch && (size == 1 || !memcmp(ptr, pat, size)))
goto found;
ptr += incr;
}
while (count--);
/* No match */
make_false(op);
return 0;
found:
op->tas.type_attrs = op1->tas.type_attrs;
op->value.bytes = ptr;
r_set_size(op, size);
push(2);
op[-1] = *op1;
r_set_size(op - 1, ptr - op[-1].value.bytes);
op1->value.bytes = ptr + size;
r_set_size(op1, count + (!forward ? (size - 1) : 0));
make_true(op);
return 0;
} | 287 | True | 1 |
CVE-2020-15904 | False | False | False | True | AV:N/AC:M/Au:N/C:P/I:P/A:P | NETWORK | MEDIUM | NONE | PARTIAL | PARTIAL | PARTIAL | 6.8 | CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H | LOCAL | LOW | NONE | REQUIRED | UNCHANGED | HIGH | HIGH | HIGH | 7.8 | HIGH | 1.8 | 5.9 | False | [{'url': 'https://github.com/ilanschnell/bsdiff4/commit/49a4cee2feef7deaf9d89e5e793a8824930284d7', 'name': 'https://github.com/ilanschnell/bsdiff4/commit/49a4cee2feef7deaf9d89e5e793a8824930284d7', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/ilanschnell/bsdiff4/blob/master/CHANGELOG.txt', 'name': 'https://github.com/ilanschnell/bsdiff4/blob/master/CHANGELOG.txt', 'refsource': 'MISC', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-787'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:pypi:bsdiff4:*:*:*:*:*:*:*:*', 'versionEndExcluding': '1.2.0', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'A buffer overflow in the patching routine of bsdiff4 before 1.2.0 allows an attacker to write to heap memory (beyond allocated bounds) via a crafted patch file.'}] | 2020-07-31T16:15Z | 2020-07-22T23:15Z | Out-of-bounds Write | The software writes data past the end, or before the beginning, of the intended buffer. | Typically, this can result in corruption of data, a crash, or code execution. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent write operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/787.html | 0 | Ilan Schnell | 2020-07-13 21:40:37-05:00 | apply patch from Robert Scott to fix - shifting some bounds checking | 49a4cee2feef7deaf9d89e5e793a8824930284d7 | False | ilanschnell/bsdiff4 | binary diff and patch using the BSDIFF4-format | 2011-05-21 21:36:33 | 2022-08-23 03:43:44 | ilanschnell | 90.0 | 21.0 | patch | patch( PyObject * self , PyObject * args) | ['self', 'args'] | static PyObject* patch(PyObject* self, PyObject* args)
{
char *origData, *newData, *diffBlock, *extraBlock, *diffPtr, *extraPtr;
Py_ssize_t origDataLength, newDataLength, diffBlockLength, extraBlockLength;
PyObject *controlTuples, *tuple, *results;
off_t oldpos, newpos, x, y, z;
int i, j, numTuples;
if (!PyArg_ParseTuple(args, "s#nO!s#s#",
&origData, &origDataLength, &newDataLength,
&PyList_Type, &controlTuples,
&diffBlock, &diffBlockLength,
&extraBlock, &extraBlockLength))
return NULL;
/* allocate the memory for the new data */
newData = PyMem_Malloc(newDataLength + 1);
if (!newData)
return PyErr_NoMemory();
oldpos = 0;
newpos = 0;
diffPtr = diffBlock;
extraPtr = extraBlock;
numTuples = PyList_GET_SIZE(controlTuples);
for (i = 0; i < numTuples; i++) {
tuple = PyList_GET_ITEM(controlTuples, i);
if (!PyTuple_Check(tuple)) {
PyMem_Free(newData);
PyErr_SetString(PyExc_TypeError, "expecting tuple");
return NULL;
}
if (PyTuple_GET_SIZE(tuple) != 3) {
PyMem_Free(newData);
PyErr_SetString(PyExc_TypeError, "expecting tuple of size 3");
return NULL;
}
x = PyLong_AsLong(PyTuple_GET_ITEM(tuple, 0));
y = PyLong_AsLong(PyTuple_GET_ITEM(tuple, 1));
z = PyLong_AsLong(PyTuple_GET_ITEM(tuple, 2));
if (newpos + x > newDataLength ||
diffPtr + x > diffBlock + diffBlockLength ||
extraPtr + y > extraBlock + extraBlockLength) {
PyMem_Free(newData);
PyErr_SetString(PyExc_ValueError, "corrupt patch (overflow)");
return NULL;
}
memcpy(newData + newpos, diffPtr, x);
diffPtr += x;
for (j = 0; j < x; j++)
if ((oldpos + j >= 0) && (oldpos + j < origDataLength))
newData[newpos + j] += origData[oldpos + j];
newpos += x;
oldpos += x;
memcpy(newData + newpos, extraPtr, y);
extraPtr += y;
newpos += y;
oldpos += z;
}
/* confirm that a valid patch was applied */
if (newpos != newDataLength ||
diffPtr != diffBlock + diffBlockLength ||
extraPtr != extraBlock + extraBlockLength) {
PyMem_Free(newData);
PyErr_SetString(PyExc_ValueError, "corrupt patch (underflow)");
return NULL;
}
results = PyBytes_FromStringAndSize(newData, newDataLength);
PyMem_Free(newData);
return results;
} | 445 | True | 1 |
|
CVE-2020-15908 | False | False | False | False | AV:N/AC:L/Au:N/C:P/I:N/A:N | NETWORK | LOW | NONE | PARTIAL | NONE | NONE | 5.0 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N | NETWORK | LOW | NONE | NONE | UNCHANGED | HIGH | NONE | NONE | 7.5 | HIGH | 3.9 | 3.6 | False | [{'url': 'https://github.com/CauldronDevelopmentLLC/cbang/commit/1c1dba62bd3e6fa9d0d0c0aa21926043b75382c7', 'name': 'https://github.com/CauldronDevelopmentLLC/cbang/commit/1c1dba62bd3e6fa9d0d0c0aa21926043b75382c7', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/CauldronDevelopmentLLC/cbang/compare/1.5.1...1.6.0', 'name': 'https://github.com/CauldronDevelopmentLLC/cbang/compare/1.5.1...1.6.0', 'refsource': 'MISC', 'tags': ['Release Notes', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-22'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:cauldrondevelopment:c\\!:*:*:*:*:*:*:*:*', 'versionEndExcluding': '1.6.0', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'tar/TarFileReader.cpp in Cauldron cbang (aka C-Bang or C!) before 1.6.0 allows Directory Traversal during extraction from a TAR archive.'}] | 2020-07-27T20:09Z | 2020-07-23T04:15Z | Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') | The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. |
Many file operations are intended to take place within a restricted directory. By using special elements such as ".." and "/" separators, attackers can escape outside of the restricted location to access files or directories that are elsewhere on the system. One of the most common special elements is the "../" sequence, which in most modern operating systems is interpreted as the parent directory of the current location. This is referred to as relative path traversal. Path traversal also covers the use of absolute pathnames such as "/usr/local/bin", which may also be useful in accessing unexpected files. This is referred to as absolute path traversal.
In many programming languages, the injection of a null byte (the 0 or NUL) may allow an attacker to truncate a generated filename to widen the scope of attack. For example, the software may add ".txt" to any pathname, thus limiting the attacker to text files, but a null injection may effectively remove this restriction.
| https://cwe.mitre.org/data/definitions/22.html | 0 | Joseph Coffland | 2020-07-19 12:43:49-07:00 | Don't allow extraction of tar files outside of the target directory, added tar tests | 1c1dba62bd3e6fa9d0d0c0aa21926043b75382c7 | False | CauldronDevelopmentLLC/cbang | C! (cbang) is a library of cross-platform C++ utilities. | 2014-03-08 00:24:00 | 2022-08-24 11:39:50 | CauldronDevelopmentLLC | 36.0 | 33.0 | TarFileReader::extract | TarFileReader::extract( const string & _path) | ['_path'] | std::string TarFileReader::extract(const string &_path) {
if (_path.empty()) THROW("path cannot be empty");
if (!hasMore()) THROW("No more tar files");
string path = _path;
if (SystemUtilities::isDirectory(path)) path += "/" + getFilename();
LOG_DEBUG(5, "Extracting: " << path);
return extract(*SystemUtilities::oopen(path));
} | 80 | True | 1 |
|
CVE-2020-24654 | False | False | False | True | AV:N/AC:M/Au:N/C:N/I:P/A:N | NETWORK | MEDIUM | NONE | NONE | PARTIAL | NONE | 4.3 | CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N | LOCAL | LOW | NONE | REQUIRED | UNCHANGED | NONE | LOW | NONE | 3.3 | LOW | 1.8 | 1.4 | False | [{'url': 'http://lists.opensuse.org/opensuse-security-announce/2020-09/msg00001.html', 'name': 'openSUSE-SU-2020:1310', 'refsource': 'SUSE', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://kde.org/info/security/advisory-20200827-1.txt', 'name': 'https://kde.org/info/security/advisory-20200827-1.txt', 'refsource': 'CONFIRM', 'tags': ['Vendor Advisory']}, {'url': 'https://bugzilla.suse.com/show_bug.cgi?id=1175857', 'name': 'https://bugzilla.suse.com/show_bug.cgi?id=1175857', 'refsource': 'CONFIRM', 'tags': ['Issue Tracking', 'Third Party Advisory']}, {'url': 'https://github.com/KDE/ark/commit/8bf8c5ef07b0ac5e914d752681e470dea403a5bd', 'name': 'https://github.com/KDE/ark/commit/8bf8c5ef07b0ac5e914d752681e470dea403a5bd', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://www.debian.org/security/2020/dsa-4759', 'name': 'DSA-4759', 'refsource': 'DEBIAN', 'tags': ['Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/LXMMXNJDYOCJRZTESIUGHG6CS4RJKECX/', 'name': 'FEDORA-2020-c2f8a1e8a5', 'refsource': 'FEDORA', 'tags': ['Third Party Advisory']}, {'url': 'https://usn.ubuntu.com/4482-1/', 'name': 'USN-4482-1', 'refsource': 'UBUNTU', 'tags': ['Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/YJOZ6YRNPZX5MJGVBMOCOA7N6Z4EU2OK/', 'name': 'FEDORA-2020-f04f41bcc9', 'refsource': 'FEDORA', 'tags': []}, {'url': 'https://security.gentoo.org/glsa/202010-06', 'name': 'GLSA-202010-06', 'refsource': 'GENTOO', 'tags': []}, {'url': 'https://security.gentoo.org/glsa/202101-06', 'name': 'GLSA-202101-06', 'refsource': 'GENTOO', 'tags': []}, {'url': 'https://lists.debian.org/debian-lts-announce/2022/05/msg00026.html', 'name': '[debian-lts-announce] 20220520 [SECURITY] [DLA 3015-1] ark security update', 'refsource': 'MLIST', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-59'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:kde:ark:*:*:*:*:*:*:*:*', 'versionEndExcluding': '20.08.1', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:canonical:ubuntu_linux:16.04:*:*:*:lts:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:debian:debian_linux:10.0:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:canonical:ubuntu_linux:18.04:*:*:*:lts:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:opensuse:leap:15.1:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:fedoraproject:fedora:32:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:canonical:ubuntu_linux:20.04:*:*:*:lts:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:opensuse:leap:15.2:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': "In KDE Ark before 20.08.1, a crafted TAR archive with symlinks can install files outside the extraction directory, as demonstrated by a write operation to a user's home directory."}] | 2022-05-20T14:15Z | 2020-09-02T17:15Z | Improper Link Resolution Before File Access ('Link Following') | The software attempts to access a file based on the filename, but it does not properly prevent that filename from identifying a link or shortcut that resolves to an unintended resource. | https://cwe.mitre.org/data/definitions/59.html | 0 | Fabian Vogt | 2020-08-25 22:14:37+02:00 | Pass the ARCHIVE_EXTRACT_SECURE_SYMLINKS flag to libarchive
There are archive types which allow to first create a symlink and then
later on dereference it. If the symlink points outside of the archive,
this results in writing outside of the destination directory.
With the ARCHIVE_EXTRACT_SECURE_SYMLINKS option set, libarchive avoids
this situation by verifying that none of the target path components are
symlinks before writing.
Remove the commented out code in the method, which would actually
misbehave if enabled again.
Signed-off-by: Fabian Vogt <fabian@ritter-vogt.de> | 8bf8c5ef07b0ac5e914d752681e470dea403a5bd | False | KDE/ark | File archiver by KDE | 2015-09-18 13:38:09 | 2022-08-26 20:32:06 | https://invent.kde.org/utilities/ark | KDE | 54.0 | 17.0 | LibarchivePlugin::extractionFlags | LibarchivePlugin::extractionFlags() const | [] | int LibarchivePlugin::extractionFlags() const
{
int result = ARCHIVE_EXTRACT_TIME;
result |= ARCHIVE_EXTRACT_SECURE_NODOTDOT;
// TODO: Don't use arksettings here
/*if ( ArkSettings::preservePerms() )
{
result &= ARCHIVE_EXTRACT_PERM;
}
if ( !ArkSettings::extractOverwrite() )
{
result &= ARCHIVE_EXTRACT_NO_OVERWRITE;
}*/
return result;
} | 20 | True | 1 |
|
CVE-2020-16587 | False | False | False | True | AV:N/AC:M/Au:N/C:N/I:N/A:P | NETWORK | MEDIUM | NONE | NONE | NONE | PARTIAL | 4.3 | CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H | LOCAL | LOW | NONE | REQUIRED | UNCHANGED | NONE | NONE | HIGH | 5.5 | MEDIUM | 1.8 | 3.6 | False | [{'url': 'https://github.com/AcademySoftwareFoundation/openexr/commit/8b5370c688a7362673c3a5256d93695617a4cd9a', 'name': 'https://github.com/AcademySoftwareFoundation/openexr/commit/8b5370c688a7362673c3a5256d93695617a4cd9a', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/AcademySoftwareFoundation/openexr/issues/491', 'name': 'https://github.com/AcademySoftwareFoundation/openexr/issues/491', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2021/07/msg00001.html', 'name': '[debian-lts-announce] 20210703 [SECURITY] [DLA 2701-1] openexr security update', 'refsource': 'MLIST', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-787'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:openexr:openexr:2.3.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'A heap-based buffer overflow vulnerability exists in Academy Software Foundation OpenEXR 2.3.0 in chunkOffsetReconstruction in ImfMultiPartInputFile.cpp that can cause a denial of service via a crafted EXR file.'}] | 2021-07-03T21:15Z | 2020-12-09T21:15Z | Out-of-bounds Write | The software writes data past the end, or before the beginning, of the intended buffer. | Typically, this can result in corruption of data, a crash, or code execution. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent write operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/787.html | 0 | Kimball Thurston | 2019-07-25 20:01:56+12:00 | Fix #491, issue with part number range check reconstructing chunk offset table
The chunk offset was incorrectly testing for a part number that was the
same size (i.e. an invalid index)
Signed-off-by: Kimball Thurston <kdt3rd@gmail.com> | 8b5370c688a7362673c3a5256d93695617a4cd9a | False | AcademySoftwareFoundation/openexr | The OpenEXR project provides the specification and reference implementation of the EXR file format, the professional-grade image storage format of the motion picture industry. | 2012-02-24 06:30:00 | 2022-08-01 19:17:43 | http://www.openexr.com/ | AcademySoftwareFoundation | 1258.0 | 508.0 | MultiPartInputFile::Data::chunkOffsetReconstruction | MultiPartInputFile::Data::chunkOffsetReconstruction( OPENEXR_IMF_INTERNAL_NAMESPACE :: IStream & is , const vector<InputPartData*> & parts) | ['is', 'parts'] | MultiPartInputFile::Data::chunkOffsetReconstruction(OPENEXR_IMF_INTERNAL_NAMESPACE::IStream& is, const vector<InputPartData*>& parts)
{
//
// Reconstruct broken chunk offset tables. Stop once we received any exception.
//
Int64 position = is.tellg();
//
// check we understand all the parts available: if not, we cannot continue
// exceptions thrown here should trickle back up to the constructor
//
for (size_t i = 0; i < parts.size(); i++)
{
Header& header=parts[i]->header;
//
// do we have a valid type entry?
// we only need them for true multipart files or single part non-image (deep) files
//
if(!header.hasType() && (isMultiPart(version) || isNonImage(version)))
{
throw IEX_NAMESPACE::ArgExc("cannot reconstruct incomplete file: part with missing type");
}
if(!isSupportedType(header.type()))
{
throw IEX_NAMESPACE::ArgExc("cannot reconstruct incomplete file: part with unknown type "+header.type());
}
}
// how many chunks should we read? We should stop when we reach the end
size_t total_chunks = 0;
// for tiled-based parts, array of (pointers to) tileOffsets objects
// to create mapping between tile coordinates and chunk table indices
vector<TileOffsets*> tileOffsets(parts.size());
// for scanline-based parts, number of scanlines in each chunk
vector<int> rowsizes(parts.size());
for(size_t i = 0 ; i < parts.size() ; i++)
{
total_chunks += parts[i]->chunkOffsets.size();
if (isTiled(parts[i]->header.type()))
{
tileOffsets[i] = createTileOffsets(parts[i]->header);
}else{
tileOffsets[i] = NULL;
// (TODO) fix this so that it doesn't need to be revised for future compression types.
switch(parts[i]->header.compression())
{
case DWAB_COMPRESSION :
rowsizes[i] = 256;
break;
case PIZ_COMPRESSION :
case B44_COMPRESSION :
case B44A_COMPRESSION :
case DWAA_COMPRESSION :
rowsizes[i]=32;
break;
case ZIP_COMPRESSION :
case PXR24_COMPRESSION :
rowsizes[i]=16;
break;
case ZIPS_COMPRESSION :
case RLE_COMPRESSION :
case NO_COMPRESSION :
rowsizes[i]=1;
break;
default :
throw(IEX_NAMESPACE::ArgExc("Unknown compression method in chunk offset reconstruction"));
}
}
}
try
{
//
//
//
Int64 chunk_start = position;
for (size_t i = 0; i < total_chunks ; i++)
{
//
// do we have a part number?
//
int partNumber = 0;
if(isMultiPart(version))
{
OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::read <OPENEXR_IMF_INTERNAL_NAMESPACE::StreamIO> (is, partNumber);
}
if(partNumber<0 || partNumber> static_cast<int>(parts.size()))
{
throw IEX_NAMESPACE::IoExc("part number out of range");
}
Header& header = parts[partNumber]->header;
// size of chunk NOT including multipart field
Int64 size_of_chunk=0;
if (isTiled(header.type()))
{
//
//
//
int tilex,tiley,levelx,levely;
OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::read <OPENEXR_IMF_INTERNAL_NAMESPACE::StreamIO> (is, tilex);
OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::read <OPENEXR_IMF_INTERNAL_NAMESPACE::StreamIO> (is, tiley);
OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::read <OPENEXR_IMF_INTERNAL_NAMESPACE::StreamIO> (is, levelx);
OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::read <OPENEXR_IMF_INTERNAL_NAMESPACE::StreamIO> (is, levely);
//std::cout << "chunk_start for " << tilex <<',' << tiley << ',' << levelx << ' ' << levely << ':' << chunk_start << std::endl;
if(!tileOffsets[partNumber])
{
// this shouldn't actually happen - we should have allocated a valid
// tileOffsets for any part which isTiled
throw IEX_NAMESPACE::IoExc("part not tiled");
}
if(!tileOffsets[partNumber]->isValidTile(tilex,tiley,levelx,levely))
{
throw IEX_NAMESPACE::IoExc("invalid tile coordinates");
}
(*tileOffsets[partNumber])(tilex,tiley,levelx,levely)=chunk_start;
// compute chunk sizes - different procedure for deep tiles and regular
// ones
if(header.type()==DEEPTILE)
{
Int64 packed_offset;
Int64 packed_sample;
OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::read <OPENEXR_IMF_INTERNAL_NAMESPACE::StreamIO> (is, packed_offset);
OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::read <OPENEXR_IMF_INTERNAL_NAMESPACE::StreamIO> (is, packed_sample);
//add 40 byte header to packed sizes (tile coordinates, packed sizes, unpacked size)
size_of_chunk=packed_offset+packed_sample+40;
}
else
{
// regular image has 20 bytes of header, 4 byte chunksize;
int chunksize;
OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::read <OPENEXR_IMF_INTERNAL_NAMESPACE::StreamIO> (is, chunksize);
size_of_chunk=chunksize+20;
}
}
else
{
int y_coordinate;
OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::read <OPENEXR_IMF_INTERNAL_NAMESPACE::StreamIO> (is, y_coordinate);
if(y_coordinate < header.dataWindow().min.y || y_coordinate > header.dataWindow().max.y)
{
throw IEX_NAMESPACE::IoExc("y out of range");
}
y_coordinate -= header.dataWindow().min.y;
y_coordinate /= rowsizes[partNumber];
if(y_coordinate < 0 || y_coordinate >= int(parts[partNumber]->chunkOffsets.size()))
{
throw IEX_NAMESPACE::IoExc("chunk index out of range");
}
parts[partNumber]->chunkOffsets[y_coordinate]=chunk_start;
if(header.type()==DEEPSCANLINE)
{
Int64 packed_offset;
Int64 packed_sample;
OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::read <OPENEXR_IMF_INTERNAL_NAMESPACE::StreamIO> (is, packed_offset);
OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::read <OPENEXR_IMF_INTERNAL_NAMESPACE::StreamIO> (is, packed_sample);
size_of_chunk=packed_offset+packed_sample+28;
}
else
{
int chunksize;
OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::read <OPENEXR_IMF_INTERNAL_NAMESPACE::StreamIO> (is, chunksize);
size_of_chunk=chunksize+8;
}
}
if(isMultiPart(version))
{
chunk_start+=4;
}
chunk_start+=size_of_chunk;
is.seekg(chunk_start);
}
}
catch (...)
{
//
// Suppress all exceptions. This functions is
// called only to reconstruct the line offset
// table for incomplete files, and exceptions
// are likely.
//
}
// copy tiled part data back to chunk offsets
for(size_t partNumber=0;partNumber<parts.size();partNumber++)
{
if(tileOffsets[partNumber])
{
size_t pos=0;
vector<vector<vector <Int64> > > offsets = tileOffsets[partNumber]->getOffsets();
for (size_t l = 0; l < offsets.size(); l++)
for (size_t y = 0; y < offsets[l].size(); y++)
for (size_t x = 0; x < offsets[l][y].size(); x++)
{
parts[ partNumber ]->chunkOffsets[pos] = offsets[l][y][x];
pos++;
}
delete tileOffsets[partNumber];
}
}
is.clear();
is.seekg (position);
} | 1062 | True | 1 |
CVE-2020-16588 | False | False | False | True | AV:N/AC:M/Au:N/C:N/I:N/A:P | NETWORK | MEDIUM | NONE | NONE | NONE | PARTIAL | 4.3 | CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H | LOCAL | LOW | NONE | REQUIRED | UNCHANGED | NONE | NONE | HIGH | 5.5 | MEDIUM | 1.8 | 3.6 | False | [{'url': 'https://github.com/AcademySoftwareFoundation/openexr/commit/74504503cff86e986bac441213c403b0ba28d58f', 'name': 'https://github.com/AcademySoftwareFoundation/openexr/commit/74504503cff86e986bac441213c403b0ba28d58f', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/AcademySoftwareFoundation/openexr/issues/493', 'name': 'https://github.com/AcademySoftwareFoundation/openexr/issues/493', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-476'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:openexr:openexr:2.3.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'A Null Pointer Deference issue exists in Academy Software Foundation OpenEXR 2.3.0 in generatePreview in makePreview.cpp that can cause a denial of service via a crafted EXR file.'}] | 2021-04-20T12:09Z | 2020-12-09T21:15Z | NULL Pointer Dereference | A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit. | NULL pointer dereference issues can occur through a number of flaws, including race conditions, and simple programming omissions.
| https://cwe.mitre.org/data/definitions/476.html | 0 | Peter Hillman | 2019-07-25 19:50:11+12:00 | Fix logic for 1 pixel high/wide preview images (Fixes #493) | 74504503cff86e986bac441213c403b0ba28d58f | False | AcademySoftwareFoundation/openexr | The OpenEXR project provides the specification and reference implementation of the EXR file format, the professional-grade image storage format of the motion picture industry. | 2012-02-24 06:30:00 | 2022-08-01 19:17:43 | http://www.openexr.com/ | AcademySoftwareFoundation | 1258.0 | 508.0 | generatePreview | generatePreview( const char inFileName [ ] , float exposure , int previewWidth , int & previewHeight , Array2D<PreviewRgba> & previewPixels) | ['exposure', 'previewWidth', 'previewHeight', 'previewPixels'] | generatePreview (const char inFileName[],
float exposure,
int previewWidth,
int &previewHeight,
Array2D <PreviewRgba> &previewPixels)
{
//
// Read the input file
//
RgbaInputFile in (inFileName);
Box2i dw = in.dataWindow();
float a = in.pixelAspectRatio();
int w = dw.max.x - dw.min.x + 1;
int h = dw.max.y - dw.min.y + 1;
Array2D <Rgba> pixels (h, w);
in.setFrameBuffer (ComputeBasePointer (&pixels[0][0], dw), 1, w);
in.readPixels (dw.min.y, dw.max.y);
//
// Make a preview image
//
previewHeight = max (int (h / (w * a) * previewWidth + .5f), 1);
previewPixels.resizeErase (previewHeight, previewWidth);
float fx = (previewWidth > 0)? (float (w - 1) / (previewWidth - 1)): 1;
float fy = (previewHeight > 0)? (float (h - 1) / (previewHeight - 1)): 1;
float m = Math<float>::pow (2.f, IMATH_NAMESPACE::clamp (exposure + 2.47393f, -20.f, 20.f));
for (int y = 0; y < previewHeight; ++y)
{
for (int x = 0; x < previewWidth; ++x)
{
PreviewRgba &preview = previewPixels[y][x];
const Rgba &pixel = pixels[int (y * fy + .5f)][int (x * fx + .5f)];
preview.r = gamma (pixel.r, m);
preview.g = gamma (pixel.g, m);
preview.b = gamma (pixel.b, m);
preview.a = int (IMATH_NAMESPACE::clamp (pixel.a * 255.f, 0.f, 255.f) + .5f);
}
}
} | 398 | True | 1 |
CVE-2021-20298 | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | NONE | NONE | HIGH | 7.5 | HIGH | 3.9 | 3.6 | nan | [{'url': 'https://github.com/AcademySoftwareFoundation/openexr/commit/85fd638ae0d5fa132434f4cbf32590261c1dba97', 'name': 'https://github.com/AcademySoftwareFoundation/openexr/commit/85fd638ae0d5fa132434f4cbf32590261c1dba97', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=25913', 'name': 'https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=25913', 'refsource': 'MISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://bugzilla.redhat.com/show_bug.cgi?id=1939156', 'name': 'https://bugzilla.redhat.com/show_bug.cgi?id=1939156', 'refsource': 'MISC', 'tags': ['Issue Tracking', 'Third Party Advisory']}, {'url': 'https://access.redhat.com/security/cve/CVE-2021-20298', 'name': 'https://access.redhat.com/security/cve/CVE-2021-20298', 'refsource': 'MISC', 'tags': ['Third Party Advisory']}, {'url': 'https://github.com/AcademySoftwareFoundation/openexr/pull/843', 'name': 'https://github.com/AcademySoftwareFoundation/openexr/pull/843', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-787'}]}] | nan | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:openexr:openexr:*:*:*:*:*:*:*:*', 'versionEndIncluding': '2.5.7', 'cpe_name': []}]}] | [{'lang': 'en', 'value': "A flaw was found in OpenEXR's B44Compressor. This flaw allows an attacker who can submit a crafted file to be processed by OpenEXR, to exhaust all memory accessible to the application. The highest threat from this vulnerability is to system availability."}] | 2022-08-26T16:02Z | 2022-08-23T16:15Z | Out-of-bounds Write | The software writes data past the end, or before the beginning, of the intended buffer. | Typically, this can result in corruption of data, a crash, or code execution. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent write operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/787.html | 0 | peterhillman | 2020-10-07 14:38:59+13:00 | reduce B44 _tmpBufferSize (was allocating two bytes per byte) (#843)
Signed-off-by: Peter Hillman <peterh@wetafx.co.nz> | 85fd638ae0d5fa132434f4cbf32590261c1dba97 | False | AcademySoftwareFoundation/openexr | The OpenEXR project provides the specification and reference implementation of the EXR file format, the professional-grade image storage format of the motion picture industry. | 2012-02-24 06:30:00 | 2022-08-01 19:17:43 | http://www.openexr.com/ | AcademySoftwareFoundation | 1258.0 | 508.0 | B44Compressor::B44Compressor | B44Compressor::B44Compressor( const Header & hdr , size_t maxScanLineSize , size_t numScanLines , bool optFlatFields) | ['hdr', 'maxScanLineSize', 'numScanLines', 'optFlatFields'] | B44Compressor::B44Compressor
(const Header &hdr,
size_t maxScanLineSize,
size_t numScanLines,
bool optFlatFields)
:
Compressor (hdr),
_maxScanLineSize (maxScanLineSize),
_optFlatFields (optFlatFields),
_format (XDR),
_numScanLines (numScanLines),
_tmpBuffer (0),
_outBuffer (0),
_numChans (0),
_channels (hdr.channels()),
_channelData (0)
{
// TODO: Remove this when we can change the ABI
(void)_maxScanLineSize;
//
// Allocate buffers for compressed an uncompressed pixel data,
// allocate a set of ChannelData structs to help speed up the
// compress() and uncompress() functions, below, and determine
// if uncompressed pixel data should be in native or Xdr format.
//
_tmpBuffer = new unsigned short
[checkArraySize (uiMult (maxScanLineSize, numScanLines),
sizeof (unsigned short))];
const ChannelList &channels = header().channels();
int numHalfChans = 0;
for (ChannelList::ConstIterator c = channels.begin();
c != channels.end();
++c)
{
assert (pixelTypeSize (c.channel().type) % pixelTypeSize (HALF) == 0);
++_numChans;
if (c.channel().type == HALF)
++numHalfChans;
}
//
// Compressed data may be larger than the input data
//
size_t padding = 12 * numHalfChans * (numScanLines + 3) / 4;
_outBuffer = new char
[uiAdd (uiMult (maxScanLineSize, numScanLines), padding)];
_channelData = new ChannelData[_numChans];
int i = 0;
for (ChannelList::ConstIterator c = channels.begin();
c != channels.end();
++c, ++i)
{
_channelData[i].ys = c.channel().ySampling;
_channelData[i].type = c.channel().type;
_channelData[i].pLinear = c.channel().pLinear;
_channelData[i].size =
pixelTypeSize (c.channel().type) / pixelTypeSize (HALF);
}
const Box2i &dataWindow = hdr.dataWindow();
_minX = dataWindow.min.x;
_maxX = dataWindow.max.x;
_maxY = dataWindow.max.y;
//
// We can support uncompressed data in the machine's native
// format only if all image channels are of type HALF.
//
assert (sizeof (unsigned short) == pixelTypeSize (HALF));
if (_numChans == numHalfChans)
_format = NATIVE;
} | 387 | True | 1 |
CVE-2021-20304 | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | NONE | NONE | HIGH | 7.5 | HIGH | 3.9 | 3.6 | nan | [{'url': 'https://access.redhat.com/security/cve/CVE-2021-20304', 'name': 'https://access.redhat.com/security/cve/CVE-2021-20304', 'refsource': 'MISC', 'tags': ['Third Party Advisory']}, {'url': 'https://github.com/AcademySoftwareFoundation/openexr/pull/849', 'name': 'https://github.com/AcademySoftwareFoundation/openexr/pull/849', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/AcademySoftwareFoundation/openexr/commit/51a92d67f53c08230734e74564c807043cbfe41e', 'name': 'https://github.com/AcademySoftwareFoundation/openexr/commit/51a92d67f53c08230734e74564c807043cbfe41e', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://bugzilla.redhat.com/show_bug.cgi?id=1939157', 'name': 'https://bugzilla.redhat.com/show_bug.cgi?id=1939157', 'refsource': 'MISC', 'tags': ['Issue Tracking', 'Third Party Advisory']}, {'url': 'https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=26229', 'name': 'https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=26229', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-190'}]}] | nan | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:openexr:openexr:*:*:*:*:*:*:*:*', 'versionEndIncluding': '2.5.7', 'cpe_name': []}]}] | [{'lang': 'en', 'value': "A flaw was found in OpenEXR's hufDecode functionality. This flaw allows an attacker who can pass a crafted file to be processed by OpenEXR, to trigger an undefined right shift error. The highest threat from this vulnerability is to system availability."}] | 2022-08-26T16:10Z | 2022-08-23T16:15Z | Integer Overflow or Wraparound | The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | An integer overflow or wraparound occurs when an integer value is incremented to a value that is too large to store in the associated representation. When this occurs, the value may wrap to become a very small or negative number. While this may be intended behavior in circumstances that rely on wrapping, it can have security consequences if the wrap is unexpected. This is especially the case if the integer overflow can be triggered using user-supplied inputs. This becomes security-critical when the result is used to control looping, make a security decision, or determine the offset or size in behaviors such as memory allocation, copying, concatenation, etc.
| https://cwe.mitre.org/data/definitions/190.html | 0 | peterhillman | 2020-10-13 08:03:57+13:00 | check for valid Huf code lengths (#849)
* check for valid Huf code lengths
* test non-fast huf decoder in testHuf
Signed-off-by: Peter Hillman <peterh@wetafx.co.nz> | 51a92d67f53c08230734e74564c807043cbfe41e | False | AcademySoftwareFoundation/openexr | The OpenEXR project provides the specification and reference implementation of the EXR file format, the professional-grade image storage format of the motion picture industry. | 2012-02-24 06:30:00 | 2022-08-01 19:17:43 | http://www.openexr.com/ | AcademySoftwareFoundation | 1258.0 | 508.0 | testHuf | testHuf( const std :: string &) | [] | testHuf (const std::string&)
{
try
{
cout << "Testing Huffman encoder" << endl;
IMATH_NAMESPACE::Rand48 rand48 (0);
const int N = 1000000;
Array <unsigned short> raw (N);
fill1 (raw, N, 1, rand48); // test various symbol distributions
compressUncompress (raw, N);
compressUncompressSubset (raw, N);
fill1 (raw, N, 10, rand48);
compressUncompress (raw, N);
compressUncompressSubset (raw, N);
fill1 (raw, N, 100, rand48);
compressUncompress (raw, N);
compressUncompressSubset (raw, N);
fill1 (raw, N, 1000, rand48);
compressUncompress (raw, N);
compressUncompressSubset (raw, N);
fill2 (raw, N, 1, rand48);
compressUncompress (raw, N);
compressUncompressSubset (raw, N);
fill2 (raw, N, 10, rand48);
compressUncompress (raw, N);
compressUncompressSubset (raw, N);
fill2 (raw, N, 100, rand48);
compressUncompress (raw, N);
compressUncompressSubset (raw, N);
fill2 (raw, N, 1000, rand48);
compressUncompress (raw, N);
compressUncompressSubset (raw, N);
fill3 (raw, N, 0);
compressUncompress (raw, N);
compressUncompressSubset (raw, N);
fill3 (raw, N, 1);
compressUncompress (raw, N);
compressUncompressSubset (raw, N);
fill3 (raw, N, USHRT_MAX - 1);
compressUncompress (raw, N);
compressUncompressSubset (raw, N);
fill3 (raw, N, USHRT_MAX);
compressUncompress (raw, N);
compressUncompressSubset (raw, N);
fill4 (raw, USHRT_MAX + 1);
compressVerify(raw, USHRT_MAX + 1, HUF_COMPRESS_DEK_HASH_FOR_FILL4_USHRT_MAX_PLUS_ONE);
compressUncompress (raw, USHRT_MAX + 1);
compressUncompressSubset (raw, USHRT_MAX + 1);
fill4 (raw, N);
compressVerify(raw, N, HUF_COMPRESS_DEK_HASH_FOR_FILL4_N);
compressUncompress (raw, N);
compressUncompressSubset (raw, N);
fill4 (raw, 0);
compressUncompress (raw, 0); // test small input data sets
fill4 (raw, 1);
compressUncompress (raw, 1);
fill4 (raw, 2);
compressUncompress (raw, 2);
fill4 (raw, 3);
compressUncompress (raw, 3);
fill5 (raw, N); // test run-length coding of code table
compressVerify(raw, N, HUF_COMPRESS_DEK_HASH_FOR_FILL5_N);
compressUncompress (raw, N);
compressUncompressSubset (raw, N);
cout << "ok\n" << endl;
}
catch (const std::exception &e)
{
cerr << "ERROR -- caught exception: " << e.what() << endl;
assert (false);
}
} | 532 | True | 1 |
CVE-2021-45942 | False | False | False | True | AV:N/AC:M/Au:N/C:N/I:N/A:P | NETWORK | MEDIUM | NONE | NONE | NONE | PARTIAL | 4.3 | CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H | LOCAL | LOW | NONE | REQUIRED | UNCHANGED | NONE | NONE | HIGH | 5.5 | MEDIUM | 1.8 | 3.6 | False | [{'url': 'https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=41416', 'name': 'https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=41416', 'refsource': 'MISC', 'tags': ['Exploit', 'Issue Tracking', 'Mailing List', 'Patch', 'Third Party Advisory']}, {'url': 'https://github.com/google/oss-fuzz-vulns/blob/main/vulns/openexr/OSV-2021-1627.yaml', 'name': 'https://github.com/google/oss-fuzz-vulns/blob/main/vulns/openexr/OSV-2021-1627.yaml', 'refsource': 'MISC', 'tags': ['Third Party Advisory']}, {'url': 'https://github.com/AcademySoftwareFoundation/openexr/commit/db217f29dfb24f6b4b5100c24ac5e7490e1c57d0', 'name': 'https://github.com/AcademySoftwareFoundation/openexr/commit/db217f29dfb24f6b4b5100c24ac5e7490e1c57d0', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/AcademySoftwareFoundation/openexr/commit/11cad77da87c4fa2aab7d58dd5339e254db7937e', 'name': 'https://github.com/AcademySoftwareFoundation/openexr/commit/11cad77da87c4fa2aab7d58dd5339e254db7937e', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/AcademySoftwareFoundation/openexr/pull/1209', 'name': 'https://github.com/AcademySoftwareFoundation/openexr/pull/1209', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Patch', 'Third Party Advisory']}, {'url': 'https://github.com/AcademySoftwareFoundation/openexr/releases/tag/v3.1.4', 'name': 'https://github.com/AcademySoftwareFoundation/openexr/releases/tag/v3.1.4', 'refsource': 'CONFIRM', 'tags': ['Release Notes', 'Third Party Advisory']}, {'url': 'https://github.com/AcademySoftwareFoundation/openexr/blob/v3.1.4/CHANGES.md#version-314-january-26-2022', 'name': 'https://github.com/AcademySoftwareFoundation/openexr/blob/v3.1.4/CHANGES.md#version-314-january-26-2022', 'refsource': 'CONFIRM', 'tags': ['Release Notes', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/HJ5PW4WNXBKCRFGDZGAQOSVH2BKZKL4X/', 'name': 'FEDORA-2022-89c31c0a0c', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/XJUK7WIQV5EKWTCZBRXFN6INHG6MLS5O/', 'name': 'FEDORA-2022-b0a85ed1b3', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/6TEZDE2S2DB4BF4LZSSV4W3DNW7DSRHJ/', 'name': 'FEDORA-2022-f2e0d16c90', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-787'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:openexr:openexr:*:*:*:*:*:*:*:*', 'versionStartIncluding': '3.1.0', 'versionEndExcluding': '3.1.4', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:fedoraproject:fedora:34:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:fedoraproject:fedora:35:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:fedoraproject:fedora:36:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'OpenEXR 3.1.x before 3.1.4 has a heap-based buffer overflow in Imf_3_1::LineCompositeTask::execute (called from IlmThread_3_1::NullThreadPoolProvider::addTask and IlmThread_3_1::ThreadPool::addGlobalTask). NOTE: db217f2 may be inapplicable.'}] | 2022-04-26T15:35Z | 2022-01-01T01:15Z | Out-of-bounds Write | The software writes data past the end, or before the beginning, of the intended buffer. | Typically, this can result in corruption of data, a crash, or code execution. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent write operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/787.html | 0 | peterhillman | 2021-11-19 09:00:21+13:00 | DeepScanlineInputFile now uses chunk size test from DeepTiledInputFile (#1205)
Signed-off-by: Peter Hillman <peterh@wetafx.co.nz> | db217f29dfb24f6b4b5100c24ac5e7490e1c57d0 | False | AcademySoftwareFoundation/openexr | The OpenEXR project provides the specification and reference implementation of the EXR file format, the professional-grade image storage format of the motion picture industry. | 2012-02-24 06:30:00 | 2022-08-01 19:17:43 | http://www.openexr.com/ | AcademySoftwareFoundation | 1258.0 | 508.0 | readSampleCountForLineBlock | readSampleCountForLineBlock( InputStreamMutex * streamData , DeepScanLineInputFile :: Data * data , int lineBlockId) | ['streamData', 'data', 'lineBlockId'] | readSampleCountForLineBlock(InputStreamMutex* streamData,
DeepScanLineInputFile::Data* data,
int lineBlockId)
{
streamData->is->seekg(data->lineOffsets[lineBlockId]);
if (isMultiPart(data->version))
{
int partNumber;
OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::read <OPENEXR_IMF_INTERNAL_NAMESPACE::StreamIO> (*streamData->is, partNumber);
if (partNumber != data->partNumber)
throw IEX_NAMESPACE::ArgExc("Unexpected part number.");
}
int minY;
OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::read <OPENEXR_IMF_INTERNAL_NAMESPACE::StreamIO> (*streamData->is, minY);
//
// Check the correctness of minY.
//
if (minY != data->minY + lineBlockId * data->linesInBuffer)
throw IEX_NAMESPACE::ArgExc("Unexpected data block y coordinate.");
int maxY;
maxY = min(minY + data->linesInBuffer - 1, data->maxY);
uint64_t sampleCountTableDataSize;
OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::read <OPENEXR_IMF_INTERNAL_NAMESPACE::StreamIO> (*streamData->is, sampleCountTableDataSize);
if(sampleCountTableDataSize>static_cast<uint64_t>(data->maxSampleCountTableSize))
{
THROW (IEX_NAMESPACE::ArgExc, "Bad sampleCountTableDataSize read from chunk "<< lineBlockId << ": expected " << data->maxSampleCountTableSize << " or less, got "<< sampleCountTableDataSize);
}
uint64_t packedDataSize;
uint64_t unpackedDataSize;
OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::read <OPENEXR_IMF_INTERNAL_NAMESPACE::StreamIO> (*streamData->is, packedDataSize);
OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::read <OPENEXR_IMF_INTERNAL_NAMESPACE::StreamIO> (*streamData->is, unpackedDataSize);
//
// We make a check on the data size requirements here.
// Whilst we wish to store 64bit sizes on disk, not all the compressors
// have been made to work with such data sizes and are still limited to
// using signed 32 bit (int) for the data size. As such, this version
// insists that we validate that the data size does not exceed the data
// type max limit.
// @TODO refactor the compressor code to ensure full 64-bit support.
//
int compressorMaxDataSize = std::numeric_limits<int>::max();
if (sampleCountTableDataSize > uint64_t(compressorMaxDataSize))
{
THROW (IEX_NAMESPACE::ArgExc, "This version of the library does not "
<< "support the allocation of data with size > "
<< compressorMaxDataSize
<< " file table size :" << sampleCountTableDataSize << ".\n");
}
streamData->is->read(data->sampleCountTableBuffer, static_cast<int>(sampleCountTableDataSize));
const char* readPtr;
//
// If the sample count table is compressed, we'll uncompress it.
//
if (sampleCountTableDataSize < static_cast<uint64_t>(data->maxSampleCountTableSize))
{
if(!data->sampleCountTableComp)
{
THROW(IEX_NAMESPACE::ArgExc,"Deep scanline data corrupt at chunk " << lineBlockId << " (sampleCountTableDataSize error)");
}
data->sampleCountTableComp->uncompress(data->sampleCountTableBuffer,
static_cast<int>(sampleCountTableDataSize),
minY,
readPtr);
}
else readPtr = data->sampleCountTableBuffer;
char* base = data->sampleCountSliceBase;
int xStride = data->sampleCountXStride;
int yStride = data->sampleCountYStride;
// total number of samples in block: used to check samplecount table doesn't
// reference more data than exists
size_t cumulative_total_samples=0;
for (int y = minY; y <= maxY; y++)
{
int yInDataWindow = y - data->minY;
data->lineSampleCount[yInDataWindow] = 0;
int lastAccumulatedCount = 0;
for (int x = data->minX; x <= data->maxX; x++)
{
int accumulatedCount, count;
//
// Read the sample count for pixel (x, y).
//
Xdr::read <CharPtrIO> (readPtr, accumulatedCount);
// sample count table should always contain monotonically
// increasing values.
if (accumulatedCount < lastAccumulatedCount)
{
THROW(IEX_NAMESPACE::ArgExc,"Deep scanline sampleCount data corrupt at chunk " << lineBlockId << " (negative sample count detected)");
}
count = accumulatedCount - lastAccumulatedCount;
lastAccumulatedCount = accumulatedCount;
//
// Store the data in both internal and external data structure.
//
data->sampleCount[yInDataWindow][x - data->minX] = count;
data->lineSampleCount[yInDataWindow] += count;
sampleCount(base, xStride, yStride, x, y) = count;
}
cumulative_total_samples+=data->lineSampleCount[yInDataWindow];
if(cumulative_total_samples*data->combinedSampleSize > unpackedDataSize)
{
THROW(IEX_NAMESPACE::ArgExc,"Deep scanline sampleCount data corrupt at chunk " << lineBlockId << ": pixel data only contains " << unpackedDataSize
<< " bytes of data but table references at least " << cumulative_total_samples*data->combinedSampleSize << " bytes of sample data" );
}
data->gotSampleCount[y - data->minY] = true;
}
} | 636 | True | 1 |
CVE-2020-18750 | False | False | False | False | AV:L/AC:L/Au:N/C:P/I:P/A:P | LOCAL | LOW | NONE | PARTIAL | PARTIAL | PARTIAL | 4.6 | CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H | LOCAL | LOW | LOW | NONE | UNCHANGED | HIGH | HIGH | HIGH | 7.8 | HIGH | 1.8 | 5.9 | False | [{'url': 'https://github.com/flexpaper/pdf2json/issues/22', 'name': 'https://github.com/flexpaper/pdf2json/issues/22', 'refsource': 'MISC', 'tags': ['Exploit', 'Issue Tracking', 'Third Party Advisory']}, {'url': 'https://github.com/flexpaper/pdf2json/commit/80bf71f16c804108fd933e267fe31692aaa509b4', 'name': 'https://github.com/flexpaper/pdf2json/commit/80bf71f16c804108fd933e267fe31692aaa509b4', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-120'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:flowpaper:pdf2json:0.69:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Buffer overflow in pdf2json 0.69 allows local users to execute arbitrary code by converting a crafted PDF file.'}] | 2021-02-08T18:03Z | 2021-02-05T19:15Z | Buffer Copy without Checking Size of Input ('Classic Buffer Overflow') | The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow. | A buffer overflow condition exists when a program attempts to put more data in a buffer than it can hold, or when a program attempts to put data in a memory area outside of the boundaries of a buffer. The simplest type of error, and the most common cause of buffer overflows, is the "classic" case in which the program copies the buffer without restricting how much is copied. Other variants exist, but the existence of a classic overflow strongly suggests that the programmer is not considering even the most basic of security protections.
| https://cwe.mitre.org/data/definitions/120.html | 0 | Erik | 2019-03-23 20:05:52+13:00 | Fix for heap vulnerability | 80bf71f16c804108fd933e267fe31692aaa509b4 | False | flexpaper/pdf2json | PDF2JSON is a conversion library based on XPDF (3.02) which can be used for high performance PDF page by page conversion to JSON and XML format. It also supports compressing data to minimize size. PDF2JSON is available for Windows, OSX and Linux. Please see https://flowpaper.com for more information | 2015-04-07 19:56:47 | 2020-06-21 20:22:41 | flexpaper | 258.0 | 44.0 | CharCodeToUnicode::addMapping | CharCodeToUnicode::addMapping( CharCode code , char * uStr , int n , int offset) | ['code', 'uStr', 'n', 'offset'] | void CharCodeToUnicode::addMapping(CharCode code, char *uStr, int n,
int offset) {
CharCode oldLen, i;
Unicode u;
char uHex[5];
int j;
if (code >= mapLen) {
oldLen = mapLen;
mapLen = (code + 256) & ~255;
map = (Unicode *)greallocn(map, mapLen, sizeof(Unicode));
for (i = oldLen; i < mapLen; ++i) {
map[i] = 0;
}
}
if (n <= 4) {
if (sscanf(uStr, "%x", &u) != 1) {
error(-1, "Illegal entry in ToUnicode CMap");
return;
}
map[code] = u + offset;
} else {
if (sMapLen >= sMapSize) {
sMapSize = sMapSize + 16;
sMap = (CharCodeToUnicodeString *)
greallocn(sMap, sMapSize, sizeof(CharCodeToUnicodeString));
}
map[code] = 0;
sMap[sMapLen].c = code;
sMap[sMapLen].len = n / 4;
for (j = 0; j < sMap[sMapLen].len && j < maxUnicodeString; ++j) {
strncpy(uHex, uStr + j*4, 4);
uHex[4] = '\0';
if (sscanf(uHex, "%x", &sMap[sMapLen].u[j]) != 1) {
error(-1, "Illegal entry in ToUnicode CMap");
}
}
sMap[sMapLen].u[sMap[sMapLen].len - 1] += offset;
++sMapLen;
}
} | 301 | True | 1 |
|
CVE-2021-24045 | False | False | False | False | AV:N/AC:M/Au:N/C:P/I:P/A:P | NETWORK | MEDIUM | NONE | PARTIAL | PARTIAL | PARTIAL | 6.8 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | HIGH | HIGH | HIGH | 9.8 | CRITICAL | 3.9 | 5.9 | False | [{'url': 'https://www.facebook.com/security/advisories/cve-2021-24045', 'name': 'https://www.facebook.com/security/advisories/cve-2021-24045', 'refsource': 'CONFIRM', 'tags': ['Vendor Advisory']}, {'url': 'https://github.com/facebook/hermes/commit/55e1b2343f4deb1a1b5726cfe1e23b2068217ff2', 'name': 'https://github.com/facebook/hermes/commit/55e1b2343f4deb1a1b5726cfe1e23b2068217ff2', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-843'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:facebook:hermes:*:*:*:*:*:*:*:*', 'versionEndExcluding': '0.10.0', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'A type confusion vulnerability could be triggered when resolving the "typeof" unary operator in Facebook Hermes prior to v0.10.0. Note that this is only exploitable if the application using Hermes permits evaluation of untrusted JavaScript. Hence, most React Native applications are not affected.'}] | 2021-12-15T21:49Z | 2021-12-13T21:15Z | Access of Resource Using Incompatible Type ('Type Confusion') | The program allocates or initializes a resource such as a pointer, object, or variable using one type, but it later accesses that resource using a type that is incompatible with the original type. |
When the program accesses the resource using an incompatible type, this could trigger logical errors because the resource does not have expected properties. In languages without memory safety, such as C and C++, type confusion can lead to out-of-bounds memory access.
While this weakness is frequently associated with unions when parsing data with many different embedded object types in C, it can be present in any application that can interpret the same variable or memory location in multiple ways.
This weakness is not unique to C and C++. For example, errors in PHP applications can be triggered by providing array parameters when scalars are expected, or vice versa. Languages such as Perl, which perform automatic conversion of a variable of one type when it is accessed as if it were another type, can also contain these issues.
| https://cwe.mitre.org/data/definitions/843.html | 0 | Neil Dhar | 2021-10-13 11:18:13-07:00 | Handle typeof applied to empty in InstSimplify
Summary:
Do not simplify `typeof` if it is applied to an invalid type. This
handles a case like the one in the added test, where `typeof` is called
on a literal empty in unreachable code.
Reviewed By: kodafb
Differential Revision: D31000173
fbshipit-source-id: 2d7f69cbcc9c1bb0a916585c07171089444c85dc | 55e1b2343f4deb1a1b5726cfe1e23b2068217ff2 | False | facebook/hermes | A JavaScript engine optimized for running React Native. | 2018-10-22 19:13:00 | 2022-08-27 17:16:04 | https://hermesengine.dev/ | facebook | 7427.0 | 453.0 | hermes::evalUnaryOperator | hermes::evalUnaryOperator( UnaryOperatorInst :: OpKind kind , IRBuilder & builder , Literal * operand) | ['kind', 'builder', 'operand'] | Literal *hermes::evalUnaryOperator(
UnaryOperatorInst::OpKind kind,
IRBuilder &builder,
Literal *operand) {
switch (kind) {
case UnaryOperatorInst::OpKind::MinusKind:
// Negate constant integers.
switch (operand->getKind()) {
case ValueKind::LiteralNumberKind:
if (auto *literalNum = llvh::dyn_cast<LiteralNumber>(operand)) {
auto V = -literalNum->getValue();
return builder.getLiteralNumber(V);
}
break;
case ValueKind::LiteralUndefinedKind:
return builder.getLiteralNaN();
case ValueKind::LiteralBoolKind:
if (evalIsTrue(builder, operand)) {
return builder.getLiteralNumber(-1);
} else { // evalIsFalse(operand)
return builder.getLiteralNegativeZero();
}
case ValueKind::LiteralNullKind:
return builder.getLiteralNegativeZero();
default:
break;
}
break;
case UnaryOperatorInst::OpKind::TypeofKind:
switch (operand->getKind()) {
case ValueKind::GlobalObjectKind:
case ValueKind::LiteralNullKind:
return builder.getLiteralString("object");
case ValueKind::LiteralUndefinedKind:
return builder.getLiteralString("undefined");
case ValueKind::LiteralBoolKind:
return builder.getLiteralString("boolean");
case ValueKind::LiteralNumberKind:
return builder.getLiteralString("number");
case ValueKind::LiteralStringKind:
return builder.getLiteralString("string");
default:
llvm_unreachable("Invalid literal kind.");
}
break;
case UnaryOperatorInst::OpKind::BangKind:
if (evalIsTrue(builder, operand)) {
return builder.getLiteralBool(false);
}
if (evalIsFalse(builder, operand)) {
return builder.getLiteralBool(true);
}
break;
case UnaryOperatorInst::OpKind::VoidKind:
return builder.getLiteralUndefined();
default:
break;
}
return nullptr;
} | 314 | True | 1 |
CVE-2020-1913 | False | False | False | False | AV:N/AC:M/Au:N/C:P/I:P/A:P | NETWORK | MEDIUM | NONE | PARTIAL | PARTIAL | PARTIAL | 6.8 | CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H | NETWORK | HIGH | NONE | NONE | UNCHANGED | HIGH | HIGH | HIGH | 8.1 | HIGH | 2.2 | 5.9 | False | [{'url': 'https://github.com/facebook/hermes/commit/2c7af7ec481ceffd0d14ce2d7c045e475fd71dc6', 'name': 'https://github.com/facebook/hermes/commit/2c7af7ec481ceffd0d14ce2d7c045e475fd71dc6', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://www.facebook.com/security/advisories/cve-2020-1913', 'name': 'https://www.facebook.com/security/advisories/cve-2020-1913', 'refsource': 'CONFIRM', 'tags': ['Vendor Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-681'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:facebook:hermes:*:*:*:*:*:*:*:*', 'versionEndIncluding': '0.4.3', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'An Integer signedness error in the JavaScript Interpreter in Facebook Hermes prior to commit 2c7af7ec481ceffd0d14ce2d7c045e475fd71dc6 allows attackers to cause a denial of service attack or a potential RCE via crafted JavaScript. Note that this is only exploitable if the application using Hermes permits evaluation of untrusted JavaScript. Hence, most React Native applications are not affected.'}] | 2020-09-15T14:56Z | 2020-09-09T19:15Z | Incorrect Conversion between Numeric Types | When converting from one data type to another, such as long to integer, data can be omitted or translated in a way that produces unexpected values. If the resulting values are used in a sensitive context, then dangerous behaviors may occur. | https://cwe.mitre.org/data/definitions/681.html | 0 | Aakash Patel | 2020-08-14 13:49:03-07:00 | Fix backward branching in SwitchImm.
Summary:
`SwitchImm` can subtract from `ip`, but it was reading the offset
from a `uint32_t *` instead of `int32_t *`.
Change the type to the correct one.
Reviewed By: dulinriley
Differential Revision: D23114516
fbshipit-source-id: d4ddab94eb16dc1ce479590851eeb1ab428bd5d6 | 2c7af7ec481ceffd0d14ce2d7c045e475fd71dc6 | False | facebook/hermes | A JavaScript engine optimized for running React Native. | 2018-10-22 19:13:00 | 2022-08-27 17:16:04 | https://hermesengine.dev/ | facebook | 7427.0 | 453.0 | hermes::vm::Interpreter::interpretFunction | hermes::vm::Interpreter::interpretFunction( Runtime * runtime , InterpreterState & state) | ['runtime', 'state'] | CallResult<HermesValue> Interpreter::interpretFunction(
Runtime *runtime,
InterpreterState &state) {
// The interepter is re-entrant and also saves/restores its IP via the runtime
// whenever a call out is made (see the CAPTURE_IP_* macros). As such, failure
// to preserve the IP across calls to interpeterFunction() disrupt interpreter
// calls further up the C++ callstack. The RAII utility class below makes sure
// we always do this correctly.
//
// TODO: The IPs stored in the C++ callstack via this holder will generally be
// the same as in the JS stack frames via the Saved IP field. We can probably
// get rid of one of these redundant stores. Doing this isn't completely
// trivial as there are currently cases where we re-enter the interpreter
// without calling Runtime::saveCallerIPInStackFrame(), and there are features
// (I think mostly the debugger + stack traces) which implicitly rely on
// this behavior. At least their tests break if this behavior is not
// preserved.
struct IPSaver {
IPSaver(Runtime *runtime)
: ip_(runtime->getCurrentIP()), runtime_(runtime) {}
~IPSaver() {
runtime_->setCurrentIP(ip_);
}
private:
const Inst *ip_;
Runtime *runtime_;
};
IPSaver ipSaver(runtime);
#ifndef HERMES_ENABLE_DEBUGGER
static_assert(!SingleStep, "can't use single-step mode without the debugger");
#endif
// Make sure that the cache can use an optimization by avoiding a branch to
// access the property storage.
static_assert(
HiddenClass::kDictionaryThreshold <=
SegmentedArray::kValueToSegmentThreshold,
"Cannot avoid branches in cache check if the dictionary "
"crossover point is larger than the inline storage");
CodeBlock *curCodeBlock = state.codeBlock;
const Inst *ip = nullptr;
// Holds runtime->currentFrame_.ptr()-1 which is the first local
// register. This eliminates the indirect load from Runtime and the -1 offset.
PinnedHermesValue *frameRegs;
// Strictness of current function.
bool strictMode;
// Default flags when accessing properties.
PropOpFlags defaultPropOpFlags;
// These CAPTURE_IP* macros should wrap around any major calls out of the
// interpeter loop. They stash and retrieve the IP via the current Runtime
// allowing the IP to be externally observed and even altered to change the flow
// of execution. Explicitly saving AND restoring the IP from the Runtime in this
// way means the C++ compiler will keep IP in a register within the rest of the
// interpeter loop.
//
// When assertions are enabled we take the extra step of "invalidating" the IP
// between captures so we can detect if it's erroneously accessed.
//
// In some cases we explicitly don't want to invalidate the IP and instead want
// it to stay set. For this we use the *NO_INVALIDATE variants. This comes up
// when we're performing a call operation which may re-enter the interpeter
// loop, and so need the IP available for the saveCallerIPInStackFrame() call
// when we next enter.
#define CAPTURE_IP_ASSIGN_NO_INVALIDATE(dst, expr) \
runtime->setCurrentIP(ip); \
dst = expr; \
ip = runtime->getCurrentIP();
#ifdef NDEBUG
#define CAPTURE_IP(expr) \
runtime->setCurrentIP(ip); \
(void)expr; \
ip = runtime->getCurrentIP();
#define CAPTURE_IP_ASSIGN(dst, expr) CAPTURE_IP_ASSIGN_NO_INVALIDATE(dst, expr)
#else // !NDEBUG
#define CAPTURE_IP(expr) \
runtime->setCurrentIP(ip); \
(void)expr; \
ip = runtime->getCurrentIP(); \
runtime->invalidateCurrentIP();
#define CAPTURE_IP_ASSIGN(dst, expr) \
runtime->setCurrentIP(ip); \
dst = expr; \
ip = runtime->getCurrentIP(); \
runtime->invalidateCurrentIP();
#endif // NDEBUG
LLVM_DEBUG(dbgs() << "interpretFunction() called\n");
ScopedNativeDepthTracker depthTracker{runtime};
if (LLVM_UNLIKELY(depthTracker.overflowed())) {
return runtime->raiseStackOverflow(Runtime::StackOverflowKind::NativeStack);
}
if (!SingleStep) {
if (auto jitPtr = runtime->jitContext_.compile(runtime, curCodeBlock)) {
return (*jitPtr)(runtime);
}
}
GCScope gcScope(runtime);
// Avoid allocating a handle dynamically by reusing this one.
MutableHandle<> tmpHandle(runtime);
CallResult<HermesValue> res{ExecutionStatus::EXCEPTION};
CallResult<PseudoHandle<>> resPH{ExecutionStatus::EXCEPTION};
CallResult<Handle<Arguments>> resArgs{ExecutionStatus::EXCEPTION};
CallResult<bool> boolRes{ExecutionStatus::EXCEPTION};
// Mark the gcScope so we can clear all allocated handles.
// Remember how many handles the scope has so we can clear them in the loop.
static constexpr unsigned KEEP_HANDLES = 1;
assert(
gcScope.getHandleCountDbg() == KEEP_HANDLES &&
"scope has unexpected number of handles");
INIT_OPCODE_PROFILER;
#if !defined(HERMESVM_PROFILER_EXTERN)
tailCall:
#endif
PROFILER_ENTER_FUNCTION(curCodeBlock);
#ifdef HERMES_ENABLE_DEBUGGER
runtime->getDebugger().willEnterCodeBlock(curCodeBlock);
#endif
runtime->getCodeCoverageProfiler().markExecuted(runtime, curCodeBlock);
// Update function executionCount_ count
curCodeBlock->incrementExecutionCount();
if (!SingleStep) {
auto newFrame = runtime->setCurrentFrameToTopOfStack();
runtime->saveCallerIPInStackFrame();
#ifndef NDEBUG
runtime->invalidateCurrentIP();
#endif
// Point frameRegs to the first register in the new frame. Note that at this
// moment technically it points above the top of the stack, but we are never
// going to access it.
frameRegs = &newFrame.getFirstLocalRef();
#ifndef NDEBUG
LLVM_DEBUG(
dbgs() << "function entry: stackLevel=" << runtime->getStackLevel()
<< ", argCount=" << runtime->getCurrentFrame().getArgCount()
<< ", frameSize=" << curCodeBlock->getFrameSize() << "\n");
LLVM_DEBUG(
dbgs() << " callee "
<< DumpHermesValue(
runtime->getCurrentFrame().getCalleeClosureOrCBRef())
<< "\n");
LLVM_DEBUG(
dbgs() << " this "
<< DumpHermesValue(runtime->getCurrentFrame().getThisArgRef())
<< "\n");
for (uint32_t i = 0; i != runtime->getCurrentFrame()->getArgCount(); ++i) {
LLVM_DEBUG(
dbgs() << " " << llvh::format_decimal(i, 4) << " "
<< DumpHermesValue(runtime->getCurrentFrame().getArgRef(i))
<< "\n");
}
#endif
// Allocate the registers for the new frame.
if (LLVM_UNLIKELY(!runtime->checkAndAllocStack(
curCodeBlock->getFrameSize() +
StackFrameLayout::CalleeExtraRegistersAtStart,
HermesValue::encodeUndefinedValue())))
goto stackOverflow;
ip = (Inst const *)curCodeBlock->begin();
// Check for invalid invocation.
if (LLVM_UNLIKELY(curCodeBlock->getHeaderFlags().isCallProhibited(
newFrame.isConstructorCall()))) {
if (!newFrame.isConstructorCall()) {
CAPTURE_IP(
runtime->raiseTypeError("Class constructor invoked without new"));
} else {
CAPTURE_IP(runtime->raiseTypeError("Function is not a constructor"));
}
goto handleExceptionInParent;
}
} else {
// Point frameRegs to the first register in the frame.
frameRegs = &runtime->getCurrentFrame().getFirstLocalRef();
ip = (Inst const *)(curCodeBlock->begin() + state.offset);
}
assert((const uint8_t *)ip < curCodeBlock->end() && "CodeBlock is empty");
INIT_STATE_FOR_CODEBLOCK(curCodeBlock);
#define BEFORE_OP_CODE \
{ \
UPDATE_OPCODE_TIME_SPENT; \
HERMES_SLOW_ASSERT((printDebugInfo(curCodeBlock, frameRegs, ip), true)); \
HERMES_SLOW_ASSERT( \
gcScope.getHandleCountDbg() == KEEP_HANDLES && \
"unaccounted handles were created"); \
HERMES_SLOW_ASSERT(tmpHandle->isUndefined() && "tmpHandle not cleared"); \
RECORD_OPCODE_START_TIME; \
INC_OPCODE_COUNT; \
}
#ifdef HERMESVM_INDIRECT_THREADING
static void *opcodeDispatch[] = {
#define DEFINE_OPCODE(name) &&case_##name,
#include "hermes/BCGen/HBC/BytecodeList.def"
&&case__last};
#define CASE(name) case_##name:
#define DISPATCH \
BEFORE_OP_CODE; \
if (SingleStep) { \
state.codeBlock = curCodeBlock; \
state.offset = CUROFFSET; \
return HermesValue::encodeUndefinedValue(); \
} \
goto *opcodeDispatch[(unsigned)ip->opCode]
#else // HERMESVM_INDIRECT_THREADING
#define CASE(name) case OpCode::name:
#define DISPATCH \
if (SingleStep) { \
state.codeBlock = curCodeBlock; \
state.offset = CUROFFSET; \
return HermesValue::encodeUndefinedValue(); \
} \
continue
#endif // HERMESVM_INDIRECT_THREADING
#define RUN_DEBUGGER_ASYNC_BREAK(flags) \
do { \
CAPTURE_IP_ASSIGN( \
auto dRes, \
runDebuggerUpdatingState( \
(uint8_t)(flags) & \
(uint8_t)Runtime::AsyncBreakReasonBits::DebuggerExplicit \
? Debugger::RunReason::AsyncBreakExplicit \
: Debugger::RunReason::AsyncBreakImplicit, \
runtime, \
curCodeBlock, \
ip, \
frameRegs)); \
if (dRes == ExecutionStatus::EXCEPTION) \
goto exception; \
} while (0)
for (;;) {
BEFORE_OP_CODE;
#ifdef HERMESVM_INDIRECT_THREADING
goto *opcodeDispatch[(unsigned)ip->opCode];
#else
switch (ip->opCode)
#endif
{
const Inst *nextIP;
uint32_t idVal;
bool tryProp;
uint32_t callArgCount;
// This is HermesValue::getRaw(), since HermesValue cannot be assigned
// to. It is meant to be used only for very short durations, in the
// dispatch of call instructions, when there is definitely no possibility
// of a GC.
HermesValue::RawType callNewTarget;
/// Handle an opcode \p name with an out-of-line implementation in a function
/// ExecutionStatus caseName(
/// Runtime *,
/// PinnedHermesValue *frameRegs,
/// Inst *ip)
#define CASE_OUTOFLINE(name) \
CASE(name) { \
CAPTURE_IP_ASSIGN(auto res, case##name(runtime, frameRegs, ip)); \
if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) { \
goto exception; \
} \
gcScope.flushToSmallCount(KEEP_HANDLES); \
ip = NEXTINST(name); \
DISPATCH; \
}
/// Implement a binary arithmetic instruction with a fast path where both
/// operands are numbers.
/// \param name the name of the instruction. The fast path case will have a
/// "n" appended to the name.
/// \param oper the C++ operator to use to actually perform the arithmetic
/// operation.
#define BINOP(name, oper) \
CASE(name) { \
if (LLVM_LIKELY(O2REG(name).isNumber() && O3REG(name).isNumber())) { \
/* Fast-path. */ \
CASE(name##N) { \
O1REG(name) = HermesValue::encodeDoubleValue( \
oper(O2REG(name).getNumber(), O3REG(name).getNumber())); \
ip = NEXTINST(name); \
DISPATCH; \
} \
} \
CAPTURE_IP_ASSIGN(res, toNumber_RJS(runtime, Handle<>(&O2REG(name)))); \
if (res == ExecutionStatus::EXCEPTION) \
goto exception; \
double left = res->getDouble(); \
CAPTURE_IP_ASSIGN(res, toNumber_RJS(runtime, Handle<>(&O3REG(name)))); \
if (res == ExecutionStatus::EXCEPTION) \
goto exception; \
O1REG(name) = \
HermesValue::encodeDoubleValue(oper(left, res->getDouble())); \
gcScope.flushToSmallCount(KEEP_HANDLES); \
ip = NEXTINST(name); \
DISPATCH; \
}
/// Implement a shift instruction with a fast path where both
/// operands are numbers.
/// \param name the name of the instruction.
/// \param oper the C++ operator to use to actually perform the shift
/// operation.
/// \param lConv the conversion function for the LHS of the expression.
/// \param lType the type of the LHS operand.
/// \param returnType the type of the return value.
#define SHIFTOP(name, oper, lConv, lType, returnType) \
CASE(name) { \
if (LLVM_LIKELY( \
O2REG(name).isNumber() && \
O3REG(name).isNumber())) { /* Fast-path. */ \
auto lnum = static_cast<lType>( \
hermes::truncateToInt32(O2REG(name).getNumber())); \
auto rnum = static_cast<uint32_t>( \
hermes::truncateToInt32(O3REG(name).getNumber())) & \
0x1f; \
O1REG(name) = HermesValue::encodeDoubleValue( \
static_cast<returnType>(lnum oper rnum)); \
ip = NEXTINST(name); \
DISPATCH; \
} \
CAPTURE_IP_ASSIGN(res, lConv(runtime, Handle<>(&O2REG(name)))); \
if (res == ExecutionStatus::EXCEPTION) { \
goto exception; \
} \
auto lnum = static_cast<lType>(res->getNumber()); \
CAPTURE_IP_ASSIGN(res, toUInt32_RJS(runtime, Handle<>(&O3REG(name)))); \
if (res == ExecutionStatus::EXCEPTION) { \
goto exception; \
} \
auto rnum = static_cast<uint32_t>(res->getNumber()) & 0x1f; \
gcScope.flushToSmallCount(KEEP_HANDLES); \
O1REG(name) = HermesValue::encodeDoubleValue( \
static_cast<returnType>(lnum oper rnum)); \
ip = NEXTINST(name); \
DISPATCH; \
}
/// Implement a binary bitwise instruction with a fast path where both
/// operands are numbers.
/// \param name the name of the instruction.
/// \param oper the C++ operator to use to actually perform the bitwise
/// operation.
#define BITWISEBINOP(name, oper) \
CASE(name) { \
if (LLVM_LIKELY(O2REG(name).isNumber() && O3REG(name).isNumber())) { \
/* Fast-path. */ \
O1REG(name) = HermesValue::encodeDoubleValue( \
hermes::truncateToInt32(O2REG(name).getNumber()) \
oper hermes::truncateToInt32(O3REG(name).getNumber())); \
ip = NEXTINST(name); \
DISPATCH; \
} \
CAPTURE_IP_ASSIGN(res, toInt32_RJS(runtime, Handle<>(&O2REG(name)))); \
if (res == ExecutionStatus::EXCEPTION) { \
goto exception; \
} \
int32_t left = res->getNumberAs<int32_t>(); \
CAPTURE_IP_ASSIGN(res, toInt32_RJS(runtime, Handle<>(&O3REG(name)))); \
if (res == ExecutionStatus::EXCEPTION) { \
goto exception; \
} \
O1REG(name) = \
HermesValue::encodeNumberValue(left oper res->getNumberAs<int32_t>()); \
gcScope.flushToSmallCount(KEEP_HANDLES); \
ip = NEXTINST(name); \
DISPATCH; \
}
/// Implement a comparison instruction.
/// \param name the name of the instruction.
/// \param oper the C++ operator to use to actually perform the fast arithmetic
/// comparison.
/// \param operFuncName function to call for the slow-path comparison.
#define CONDOP(name, oper, operFuncName) \
CASE(name) { \
if (LLVM_LIKELY(O2REG(name).isNumber() && O3REG(name).isNumber())) { \
/* Fast-path. */ \
O1REG(name) = HermesValue::encodeBoolValue( \
O2REG(name).getNumber() oper O3REG(name).getNumber()); \
ip = NEXTINST(name); \
DISPATCH; \
} \
CAPTURE_IP_ASSIGN( \
boolRes, \
operFuncName( \
runtime, Handle<>(&O2REG(name)), Handle<>(&O3REG(name)))); \
if (boolRes == ExecutionStatus::EXCEPTION) \
goto exception; \
gcScope.flushToSmallCount(KEEP_HANDLES); \
O1REG(name) = HermesValue::encodeBoolValue(boolRes.getValue()); \
ip = NEXTINST(name); \
DISPATCH; \
}
/// Implement a comparison conditional jump with a fast path where both
/// operands are numbers.
/// \param name the name of the instruction. The fast path case will have a
/// "N" appended to the name.
/// \param suffix Optional suffix to be added to the end (e.g. Long)
/// \param oper the C++ operator to use to actually perform the fast arithmetic
/// comparison.
/// \param operFuncName function to call for the slow-path comparison.
/// \param trueDest ip value if the conditional evaluates to true
/// \param falseDest ip value if the conditional evaluates to false
#define JCOND_IMPL(name, suffix, oper, operFuncName, trueDest, falseDest) \
CASE(name##suffix) { \
if (LLVM_LIKELY( \
O2REG(name##suffix).isNumber() && \
O3REG(name##suffix).isNumber())) { \
/* Fast-path. */ \
CASE(name##N##suffix) { \
if (O2REG(name##N##suffix) \
.getNumber() oper O3REG(name##N##suffix) \
.getNumber()) { \
ip = trueDest; \
DISPATCH; \
} \
ip = falseDest; \
DISPATCH; \
} \
} \
CAPTURE_IP_ASSIGN( \
boolRes, \
operFuncName( \
runtime, \
Handle<>(&O2REG(name##suffix)), \
Handle<>(&O3REG(name##suffix)))); \
if (boolRes == ExecutionStatus::EXCEPTION) \
goto exception; \
gcScope.flushToSmallCount(KEEP_HANDLES); \
if (boolRes.getValue()) { \
ip = trueDest; \
DISPATCH; \
} \
ip = falseDest; \
DISPATCH; \
}
/// Implement a strict equality conditional jump
/// \param name the name of the instruction.
/// \param suffix Optional suffix to be added to the end (e.g. Long)
/// \param trueDest ip value if the conditional evaluates to true
/// \param falseDest ip value if the conditional evaluates to false
#define JCOND_STRICT_EQ_IMPL(name, suffix, trueDest, falseDest) \
CASE(name##suffix) { \
if (strictEqualityTest(O2REG(name##suffix), O3REG(name##suffix))) { \
ip = trueDest; \
DISPATCH; \
} \
ip = falseDest; \
DISPATCH; \
}
/// Implement an equality conditional jump
/// \param name the name of the instruction.
/// \param suffix Optional suffix to be added to the end (e.g. Long)
/// \param trueDest ip value if the conditional evaluates to true
/// \param falseDest ip value if the conditional evaluates to false
#define JCOND_EQ_IMPL(name, suffix, trueDest, falseDest) \
CASE(name##suffix) { \
CAPTURE_IP_ASSIGN( \
res, \
abstractEqualityTest_RJS( \
runtime, \
Handle<>(&O2REG(name##suffix)), \
Handle<>(&O3REG(name##suffix)))); \
if (res == ExecutionStatus::EXCEPTION) { \
goto exception; \
} \
gcScope.flushToSmallCount(KEEP_HANDLES); \
if (res->getBool()) { \
ip = trueDest; \
DISPATCH; \
} \
ip = falseDest; \
DISPATCH; \
}
/// Implement the long and short forms of a conditional jump, and its negation.
#define JCOND(name, oper, operFuncName) \
JCOND_IMPL( \
J##name, \
, \
oper, \
operFuncName, \
IPADD(ip->iJ##name.op1), \
NEXTINST(J##name)); \
JCOND_IMPL( \
J##name, \
Long, \
oper, \
operFuncName, \
IPADD(ip->iJ##name##Long.op1), \
NEXTINST(J##name##Long)); \
JCOND_IMPL( \
JNot##name, \
, \
oper, \
operFuncName, \
NEXTINST(JNot##name), \
IPADD(ip->iJNot##name.op1)); \
JCOND_IMPL( \
JNot##name, \
Long, \
oper, \
operFuncName, \
NEXTINST(JNot##name##Long), \
IPADD(ip->iJNot##name##Long.op1));
/// Load a constant.
/// \param value is the value to store in the output register.
#define LOAD_CONST(name, value) \
CASE(name) { \
O1REG(name) = value; \
ip = NEXTINST(name); \
DISPATCH; \
}
#define LOAD_CONST_CAPTURE_IP(name, value) \
CASE(name) { \
CAPTURE_IP_ASSIGN(O1REG(name), value); \
ip = NEXTINST(name); \
DISPATCH; \
}
CASE(Mov) {
O1REG(Mov) = O2REG(Mov);
ip = NEXTINST(Mov);
DISPATCH;
}
CASE(MovLong) {
O1REG(MovLong) = O2REG(MovLong);
ip = NEXTINST(MovLong);
DISPATCH;
}
CASE(LoadParam) {
if (LLVM_LIKELY(ip->iLoadParam.op2 <= FRAME.getArgCount())) {
// index 0 must load 'this'. Index 1 the first argument, etc.
O1REG(LoadParam) = FRAME.getArgRef((int32_t)ip->iLoadParam.op2 - 1);
ip = NEXTINST(LoadParam);
DISPATCH;
}
O1REG(LoadParam) = HermesValue::encodeUndefinedValue();
ip = NEXTINST(LoadParam);
DISPATCH;
}
CASE(LoadParamLong) {
if (LLVM_LIKELY(ip->iLoadParamLong.op2 <= FRAME.getArgCount())) {
// index 0 must load 'this'. Index 1 the first argument, etc.
O1REG(LoadParamLong) =
FRAME.getArgRef((int32_t)ip->iLoadParamLong.op2 - 1);
ip = NEXTINST(LoadParamLong);
DISPATCH;
}
O1REG(LoadParamLong) = HermesValue::encodeUndefinedValue();
ip = NEXTINST(LoadParamLong);
DISPATCH;
}
CASE(CoerceThisNS) {
if (LLVM_LIKELY(O2REG(CoerceThisNS).isObject())) {
O1REG(CoerceThisNS) = O2REG(CoerceThisNS);
} else if (
O2REG(CoerceThisNS).isNull() || O2REG(CoerceThisNS).isUndefined()) {
O1REG(CoerceThisNS) = runtime->global_;
} else {
tmpHandle = O2REG(CoerceThisNS);
nextIP = NEXTINST(CoerceThisNS);
goto coerceThisSlowPath;
}
ip = NEXTINST(CoerceThisNS);
DISPATCH;
}
CASE(LoadThisNS) {
if (LLVM_LIKELY(FRAME.getThisArgRef().isObject())) {
O1REG(LoadThisNS) = FRAME.getThisArgRef();
} else if (
FRAME.getThisArgRef().isNull() ||
FRAME.getThisArgRef().isUndefined()) {
O1REG(LoadThisNS) = runtime->global_;
} else {
tmpHandle = FRAME.getThisArgRef();
nextIP = NEXTINST(LoadThisNS);
goto coerceThisSlowPath;
}
ip = NEXTINST(LoadThisNS);
DISPATCH;
}
coerceThisSlowPath : {
CAPTURE_IP_ASSIGN(res, toObject(runtime, tmpHandle));
if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) {
goto exception;
}
O1REG(CoerceThisNS) = res.getValue();
tmpHandle.clear();
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = nextIP;
DISPATCH;
}
CASE(ConstructLong) {
callArgCount = (uint32_t)ip->iConstructLong.op3;
nextIP = NEXTINST(ConstructLong);
callNewTarget = O2REG(ConstructLong).getRaw();
goto doCall;
}
CASE(CallLong) {
callArgCount = (uint32_t)ip->iCallLong.op3;
nextIP = NEXTINST(CallLong);
callNewTarget = HermesValue::encodeUndefinedValue().getRaw();
goto doCall;
}
// Note in Call1 through Call4, the first argument is 'this' which has
// argument index -1.
// Also note that we are writing to callNewTarget last, to avoid the
// possibility of it being aliased by the arg writes.
CASE(Call1) {
callArgCount = 1;
nextIP = NEXTINST(Call1);
StackFramePtr fr{runtime->stackPointer_};
fr.getArgRefUnsafe(-1) = O3REG(Call1);
callNewTarget = HermesValue::encodeUndefinedValue().getRaw();
goto doCall;
}
CASE(Call2) {
callArgCount = 2;
nextIP = NEXTINST(Call2);
StackFramePtr fr{runtime->stackPointer_};
fr.getArgRefUnsafe(-1) = O3REG(Call2);
fr.getArgRefUnsafe(0) = O4REG(Call2);
callNewTarget = HermesValue::encodeUndefinedValue().getRaw();
goto doCall;
}
CASE(Call3) {
callArgCount = 3;
nextIP = NEXTINST(Call3);
StackFramePtr fr{runtime->stackPointer_};
fr.getArgRefUnsafe(-1) = O3REG(Call3);
fr.getArgRefUnsafe(0) = O4REG(Call3);
fr.getArgRefUnsafe(1) = O5REG(Call3);
callNewTarget = HermesValue::encodeUndefinedValue().getRaw();
goto doCall;
}
CASE(Call4) {
callArgCount = 4;
nextIP = NEXTINST(Call4);
StackFramePtr fr{runtime->stackPointer_};
fr.getArgRefUnsafe(-1) = O3REG(Call4);
fr.getArgRefUnsafe(0) = O4REG(Call4);
fr.getArgRefUnsafe(1) = O5REG(Call4);
fr.getArgRefUnsafe(2) = O6REG(Call4);
callNewTarget = HermesValue::encodeUndefinedValue().getRaw();
goto doCall;
}
CASE(Construct) {
callArgCount = (uint32_t)ip->iConstruct.op3;
nextIP = NEXTINST(Construct);
callNewTarget = O2REG(Construct).getRaw();
goto doCall;
}
CASE(Call) {
callArgCount = (uint32_t)ip->iCall.op3;
nextIP = NEXTINST(Call);
callNewTarget = HermesValue::encodeUndefinedValue().getRaw();
// Fall through.
}
doCall : {
#ifdef HERMES_ENABLE_DEBUGGER
// Check for an async debugger request.
if (uint8_t asyncFlags =
runtime->testAndClearDebuggerAsyncBreakRequest()) {
RUN_DEBUGGER_ASYNC_BREAK(asyncFlags);
gcScope.flushToSmallCount(KEEP_HANDLES);
DISPATCH;
}
#endif
// Subtract 1 from callArgCount as 'this' is considered an argument in the
// instruction, but not in the frame.
CAPTURE_IP_ASSIGN_NO_INVALIDATE(
auto newFrame,
StackFramePtr::initFrame(
runtime->stackPointer_,
FRAME,
ip,
curCodeBlock,
callArgCount - 1,
O2REG(Call),
HermesValue::fromRaw(callNewTarget)));
(void)newFrame;
SLOW_DEBUG(dumpCallArguments(dbgs(), runtime, newFrame));
if (auto *func = dyn_vmcast<JSFunction>(O2REG(Call))) {
assert(!SingleStep && "can't single-step a call");
#ifdef HERMES_ENABLE_ALLOCATION_LOCATION_TRACES
runtime->pushCallStack(curCodeBlock, ip);
#endif
CodeBlock *calleeBlock = func->getCodeBlock();
calleeBlock->lazyCompile(runtime);
#if defined(HERMESVM_PROFILER_EXTERN)
CAPTURE_IP_ASSIGN_NO_INVALIDATE(
res, runtime->interpretFunction(calleeBlock));
if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) {
goto exception;
}
O1REG(Call) = *res;
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = nextIP;
DISPATCH;
#else
if (auto jitPtr = runtime->jitContext_.compile(runtime, calleeBlock)) {
res = (*jitPtr)(runtime);
if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION))
goto exception;
O1REG(Call) = *res;
SLOW_DEBUG(
dbgs() << "JIT return value r" << (unsigned)ip->iCall.op1 << "="
<< DumpHermesValue(O1REG(Call)) << "\n");
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = nextIP;
DISPATCH;
}
curCodeBlock = calleeBlock;
goto tailCall;
#endif
}
CAPTURE_IP_ASSIGN_NO_INVALIDATE(
resPH, Interpreter::handleCallSlowPath(runtime, &O2REG(Call)));
if (LLVM_UNLIKELY(resPH == ExecutionStatus::EXCEPTION)) {
goto exception;
}
O1REG(Call) = std::move(resPH->get());
SLOW_DEBUG(
dbgs() << "native return value r" << (unsigned)ip->iCall.op1 << "="
<< DumpHermesValue(O1REG(Call)) << "\n");
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = nextIP;
DISPATCH;
}
CASE(CallDirect)
CASE(CallDirectLongIndex) {
#ifdef HERMES_ENABLE_DEBUGGER
// Check for an async debugger request.
if (uint8_t asyncFlags =
runtime->testAndClearDebuggerAsyncBreakRequest()) {
RUN_DEBUGGER_ASYNC_BREAK(asyncFlags);
gcScope.flushToSmallCount(KEEP_HANDLES);
DISPATCH;
}
#endif
CAPTURE_IP_ASSIGN(
CodeBlock * calleeBlock,
ip->opCode == OpCode::CallDirect
? curCodeBlock->getRuntimeModule()->getCodeBlockMayAllocate(
ip->iCallDirect.op3)
: curCodeBlock->getRuntimeModule()->getCodeBlockMayAllocate(
ip->iCallDirectLongIndex.op3));
CAPTURE_IP_ASSIGN_NO_INVALIDATE(
auto newFrame,
StackFramePtr::initFrame(
runtime->stackPointer_,
FRAME,
ip,
curCodeBlock,
(uint32_t)ip->iCallDirect.op2 - 1,
HermesValue::encodeNativePointer(calleeBlock),
HermesValue::encodeUndefinedValue()));
(void)newFrame;
LLVM_DEBUG(dumpCallArguments(dbgs(), runtime, newFrame));
assert(!SingleStep && "can't single-step a call");
calleeBlock->lazyCompile(runtime);
#if defined(HERMESVM_PROFILER_EXTERN)
CAPTURE_IP_ASSIGN_NO_INVALIDATE(
res, runtime->interpretFunction(calleeBlock));
if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) {
goto exception;
}
O1REG(CallDirect) = *res;
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = ip->opCode == OpCode::CallDirect ? NEXTINST(CallDirect)
: NEXTINST(CallDirectLongIndex);
DISPATCH;
#else
if (auto jitPtr = runtime->jitContext_.compile(runtime, calleeBlock)) {
res = (*jitPtr)(runtime);
if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION))
goto exception;
O1REG(CallDirect) = *res;
LLVM_DEBUG(
dbgs() << "JIT return value r" << (unsigned)ip->iCallDirect.op1
<< "=" << DumpHermesValue(O1REG(Call)) << "\n");
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = ip->opCode == OpCode::CallDirect ? NEXTINST(CallDirect)
: NEXTINST(CallDirectLongIndex);
DISPATCH;
}
curCodeBlock = calleeBlock;
goto tailCall;
#endif
}
CASE(CallBuiltin) {
NativeFunction *nf =
runtime->getBuiltinNativeFunction(ip->iCallBuiltin.op2);
CAPTURE_IP_ASSIGN(
auto newFrame,
StackFramePtr::initFrame(
runtime->stackPointer_,
FRAME,
ip,
curCodeBlock,
(uint32_t)ip->iCallBuiltin.op3 - 1,
nf,
false));
// "thisArg" is implicitly assumed to "undefined".
newFrame.getThisArgRef() = HermesValue::encodeUndefinedValue();
SLOW_DEBUG(dumpCallArguments(dbgs(), runtime, newFrame));
CAPTURE_IP_ASSIGN(resPH, NativeFunction::_nativeCall(nf, runtime));
if (LLVM_UNLIKELY(resPH == ExecutionStatus::EXCEPTION))
goto exception;
O1REG(CallBuiltin) = std::move(resPH->get());
SLOW_DEBUG(
dbgs() << "native return value r" << (unsigned)ip->iCallBuiltin.op1
<< "=" << DumpHermesValue(O1REG(CallBuiltin)) << "\n");
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = NEXTINST(CallBuiltin);
DISPATCH;
}
CASE(CompleteGenerator) {
auto *innerFn = vmcast<GeneratorInnerFunction>(
runtime->getCurrentFrame().getCalleeClosure());
innerFn->setState(GeneratorInnerFunction::State::Completed);
ip = NEXTINST(CompleteGenerator);
DISPATCH;
}
CASE(SaveGenerator) {
nextIP = IPADD(ip->iSaveGenerator.op1);
goto doSaveGen;
}
CASE(SaveGeneratorLong) {
nextIP = IPADD(ip->iSaveGeneratorLong.op1);
goto doSaveGen;
}
doSaveGen : {
auto *innerFn = vmcast<GeneratorInnerFunction>(
runtime->getCurrentFrame().getCalleeClosure());
innerFn->saveStack(runtime);
innerFn->setNextIP(nextIP);
innerFn->setState(GeneratorInnerFunction::State::SuspendedYield);
ip = NEXTINST(SaveGenerator);
DISPATCH;
}
CASE(StartGenerator) {
auto *innerFn = vmcast<GeneratorInnerFunction>(
runtime->getCurrentFrame().getCalleeClosure());
if (innerFn->getState() ==
GeneratorInnerFunction::State::SuspendedStart) {
nextIP = NEXTINST(StartGenerator);
} else {
nextIP = innerFn->getNextIP();
innerFn->restoreStack(runtime);
}
innerFn->setState(GeneratorInnerFunction::State::Executing);
ip = nextIP;
DISPATCH;
}
CASE(ResumeGenerator) {
auto *innerFn = vmcast<GeneratorInnerFunction>(
runtime->getCurrentFrame().getCalleeClosure());
O1REG(ResumeGenerator) = innerFn->getResult();
O2REG(ResumeGenerator) = HermesValue::encodeBoolValue(
innerFn->getAction() == GeneratorInnerFunction::Action::Return);
innerFn->clearResult(runtime);
if (innerFn->getAction() == GeneratorInnerFunction::Action::Throw) {
runtime->setThrownValue(O1REG(ResumeGenerator));
goto exception;
}
ip = NEXTINST(ResumeGenerator);
DISPATCH;
}
CASE(Ret) {
#ifdef HERMES_ENABLE_DEBUGGER
// Check for an async debugger request.
if (uint8_t asyncFlags =
runtime->testAndClearDebuggerAsyncBreakRequest()) {
RUN_DEBUGGER_ASYNC_BREAK(asyncFlags);
gcScope.flushToSmallCount(KEEP_HANDLES);
DISPATCH;
}
#endif
PROFILER_EXIT_FUNCTION(curCodeBlock);
#ifdef HERMES_ENABLE_ALLOCATION_LOCATION_TRACES
runtime->popCallStack();
#endif
// Store the return value.
res = O1REG(Ret);
ip = FRAME.getSavedIP();
curCodeBlock = FRAME.getSavedCodeBlock();
frameRegs =
&runtime->restoreStackAndPreviousFrame(FRAME).getFirstLocalRef();
SLOW_DEBUG(
dbgs() << "function exit: restored stackLevel="
<< runtime->getStackLevel() << "\n");
// Are we returning to native code?
if (!curCodeBlock) {
SLOW_DEBUG(dbgs() << "function exit: returning to native code\n");
return res;
}
// Return because of recursive calling structure
#if defined(HERMESVM_PROFILER_EXTERN)
return res;
#endif
INIT_STATE_FOR_CODEBLOCK(curCodeBlock);
O1REG(Call) = res.getValue();
ip = nextInstCall(ip);
DISPATCH;
}
CASE(Catch) {
assert(!runtime->thrownValue_.isEmpty() && "Invalid thrown value");
assert(
!isUncatchableError(runtime->thrownValue_) &&
"Uncatchable thrown value was caught");
O1REG(Catch) = runtime->thrownValue_;
runtime->clearThrownValue();
#ifdef HERMES_ENABLE_DEBUGGER
// Signal to the debugger that we're done unwinding an exception,
// and we can resume normal debugging flow.
runtime->debugger_.finishedUnwindingException();
#endif
ip = NEXTINST(Catch);
DISPATCH;
}
CASE(Throw) {
runtime->thrownValue_ = O1REG(Throw);
SLOW_DEBUG(
dbgs() << "Exception thrown: "
<< DumpHermesValue(runtime->thrownValue_) << "\n");
goto exception;
}
CASE(ThrowIfUndefinedInst) {
if (LLVM_UNLIKELY(O1REG(ThrowIfUndefinedInst).isUndefined())) {
SLOW_DEBUG(
dbgs() << "Throwing ReferenceError for undefined variable");
CAPTURE_IP(runtime->raiseReferenceError(
"accessing an uninitialized variable"));
goto exception;
}
ip = NEXTINST(ThrowIfUndefinedInst);
DISPATCH;
}
CASE(Debugger) {
SLOW_DEBUG(dbgs() << "debugger statement executed\n");
#ifdef HERMES_ENABLE_DEBUGGER
{
if (!runtime->debugger_.isDebugging()) {
// Only run the debugger if we're not already debugging.
// Don't want to call it again and mess with its state.
CAPTURE_IP_ASSIGN(
auto res,
runDebuggerUpdatingState(
Debugger::RunReason::Opcode,
runtime,
curCodeBlock,
ip,
frameRegs));
if (res == ExecutionStatus::EXCEPTION) {
// If one of the internal steps threw,
// then handle that here by jumping to where we're supposed to go.
// If we're in mid-step, the breakpoint at the catch point
// will have been set by the debugger.
// We don't want to execute this instruction because it's already
// thrown.
goto exception;
}
}
auto breakpointOpt = runtime->debugger_.getBreakpointLocation(ip);
if (breakpointOpt.hasValue()) {
// We're on a breakpoint but we're supposed to continue.
curCodeBlock->uninstallBreakpointAtOffset(
CUROFFSET, breakpointOpt->opCode);
if (ip->opCode == OpCode::Debugger) {
// Breakpointed a debugger instruction, so move past it
// since we've already called the debugger on this instruction.
ip = NEXTINST(Debugger);
} else {
InterpreterState newState{curCodeBlock, (uint32_t)CUROFFSET};
CAPTURE_IP_ASSIGN(
ExecutionStatus status, runtime->stepFunction(newState));
curCodeBlock->installBreakpointAtOffset(CUROFFSET);
if (status == ExecutionStatus::EXCEPTION) {
goto exception;
}
curCodeBlock = newState.codeBlock;
ip = newState.codeBlock->getOffsetPtr(newState.offset);
INIT_STATE_FOR_CODEBLOCK(curCodeBlock);
// Single-stepping should handle call stack management for us.
frameRegs = &runtime->getCurrentFrame().getFirstLocalRef();
}
} else if (ip->opCode == OpCode::Debugger) {
// No breakpoint here and we've already run the debugger,
// just continue on.
// If the current instruction is no longer a debugger instruction,
// we're just going to keep executing from the current IP.
ip = NEXTINST(Debugger);
}
gcScope.flushToSmallCount(KEEP_HANDLES);
}
DISPATCH;
#else
ip = NEXTINST(Debugger);
DISPATCH;
#endif
}
CASE(AsyncBreakCheck) {
if (LLVM_UNLIKELY(runtime->hasAsyncBreak())) {
#ifdef HERMES_ENABLE_DEBUGGER
if (uint8_t asyncFlags =
runtime->testAndClearDebuggerAsyncBreakRequest()) {
RUN_DEBUGGER_ASYNC_BREAK(asyncFlags);
}
#endif
if (runtime->testAndClearTimeoutAsyncBreakRequest()) {
CAPTURE_IP_ASSIGN(auto nRes, runtime->notifyTimeout());
if (nRes == ExecutionStatus::EXCEPTION) {
goto exception;
}
}
}
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = NEXTINST(AsyncBreakCheck);
DISPATCH;
}
CASE(ProfilePoint) {
#ifdef HERMESVM_PROFILER_BB
auto pointIndex = ip->iProfilePoint.op1;
SLOW_DEBUG(llvh::dbgs() << "ProfilePoint: " << pointIndex << "\n");
CAPTURE_IP(runtime->getBasicBlockExecutionInfo().executeBlock(
curCodeBlock, pointIndex));
#endif
ip = NEXTINST(ProfilePoint);
DISPATCH;
}
CASE(Unreachable) {
llvm_unreachable("Hermes bug: unreachable instruction");
}
CASE(CreateClosure) {
idVal = ip->iCreateClosure.op3;
nextIP = NEXTINST(CreateClosure);
goto createClosure;
}
CASE(CreateClosureLongIndex) {
idVal = ip->iCreateClosureLongIndex.op3;
nextIP = NEXTINST(CreateClosureLongIndex);
goto createClosure;
}
createClosure : {
auto *runtimeModule = curCodeBlock->getRuntimeModule();
CAPTURE_IP_ASSIGN(
O1REG(CreateClosure),
JSFunction::create(
runtime,
runtimeModule->getDomain(runtime),
Handle<JSObject>::vmcast(&runtime->functionPrototype),
Handle<Environment>::vmcast(&O2REG(CreateClosure)),
runtimeModule->getCodeBlockMayAllocate(idVal))
.getHermesValue());
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = nextIP;
DISPATCH;
}
CASE(CreateGeneratorClosure) {
CAPTURE_IP_ASSIGN(
auto res,
createGeneratorClosure(
runtime,
curCodeBlock->getRuntimeModule(),
ip->iCreateClosure.op3,
Handle<Environment>::vmcast(&O2REG(CreateGeneratorClosure))));
if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) {
goto exception;
}
O1REG(CreateGeneratorClosure) = res->getHermesValue();
res->invalidate();
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = NEXTINST(CreateGeneratorClosure);
DISPATCH;
}
CASE(CreateGeneratorClosureLongIndex) {
CAPTURE_IP_ASSIGN(
auto res,
createGeneratorClosure(
runtime,
curCodeBlock->getRuntimeModule(),
ip->iCreateClosureLongIndex.op3,
Handle<Environment>::vmcast(
&O2REG(CreateGeneratorClosureLongIndex))));
if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) {
goto exception;
}
O1REG(CreateGeneratorClosureLongIndex) = res->getHermesValue();
res->invalidate();
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = NEXTINST(CreateGeneratorClosureLongIndex);
DISPATCH;
}
CASE(CreateGenerator) {
CAPTURE_IP_ASSIGN(
auto res,
createGenerator_RJS(
runtime,
curCodeBlock->getRuntimeModule(),
ip->iCreateGenerator.op3,
Handle<Environment>::vmcast(&O2REG(CreateGenerator)),
FRAME.getNativeArgs()));
if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) {
goto exception;
}
O1REG(CreateGenerator) = res->getHermesValue();
res->invalidate();
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = NEXTINST(CreateGenerator);
DISPATCH;
}
CASE(CreateGeneratorLongIndex) {
CAPTURE_IP_ASSIGN(
auto res,
createGenerator_RJS(
runtime,
curCodeBlock->getRuntimeModule(),
ip->iCreateGeneratorLongIndex.op3,
Handle<Environment>::vmcast(&O2REG(CreateGeneratorLongIndex)),
FRAME.getNativeArgs()));
if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) {
goto exception;
}
O1REG(CreateGeneratorLongIndex) = res->getHermesValue();
res->invalidate();
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = NEXTINST(CreateGeneratorLongIndex);
DISPATCH;
}
CASE(GetEnvironment) {
// The currently executing function must exist, so get the environment.
Environment *curEnv =
FRAME.getCalleeClosureUnsafe()->getEnvironment(runtime);
for (unsigned level = ip->iGetEnvironment.op2; level; --level) {
assert(curEnv && "invalid environment relative level");
curEnv = curEnv->getParentEnvironment(runtime);
}
O1REG(GetEnvironment) = HermesValue::encodeObjectValue(curEnv);
ip = NEXTINST(GetEnvironment);
DISPATCH;
}
CASE(CreateEnvironment) {
tmpHandle = HermesValue::encodeObjectValue(
FRAME.getCalleeClosureUnsafe()->getEnvironment(runtime));
CAPTURE_IP_ASSIGN(
res,
Environment::create(
runtime,
tmpHandle->getPointer() ? Handle<Environment>::vmcast(tmpHandle)
: Handle<Environment>::vmcast_or_null(
&runtime->nullPointer_),
curCodeBlock->getEnvironmentSize()));
if (res == ExecutionStatus::EXCEPTION) {
goto exception;
}
O1REG(CreateEnvironment) = *res;
#ifdef HERMES_ENABLE_DEBUGGER
FRAME.getDebugEnvironmentRef() = *res;
#endif
tmpHandle = HermesValue::encodeUndefinedValue();
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = NEXTINST(CreateEnvironment);
DISPATCH;
}
CASE(StoreToEnvironment) {
vmcast<Environment>(O1REG(StoreToEnvironment))
->slot(ip->iStoreToEnvironment.op2)
.set(O3REG(StoreToEnvironment), &runtime->getHeap());
ip = NEXTINST(StoreToEnvironment);
DISPATCH;
}
CASE(StoreToEnvironmentL) {
vmcast<Environment>(O1REG(StoreToEnvironmentL))
->slot(ip->iStoreToEnvironmentL.op2)
.set(O3REG(StoreToEnvironmentL), &runtime->getHeap());
ip = NEXTINST(StoreToEnvironmentL);
DISPATCH;
}
CASE(StoreNPToEnvironment) {
vmcast<Environment>(O1REG(StoreNPToEnvironment))
->slot(ip->iStoreNPToEnvironment.op2)
.setNonPtr(O3REG(StoreNPToEnvironment), &runtime->getHeap());
ip = NEXTINST(StoreNPToEnvironment);
DISPATCH;
}
CASE(StoreNPToEnvironmentL) {
vmcast<Environment>(O1REG(StoreNPToEnvironmentL))
->slot(ip->iStoreNPToEnvironmentL.op2)
.setNonPtr(O3REG(StoreNPToEnvironmentL), &runtime->getHeap());
ip = NEXTINST(StoreNPToEnvironmentL);
DISPATCH;
}
CASE(LoadFromEnvironment) {
O1REG(LoadFromEnvironment) =
vmcast<Environment>(O2REG(LoadFromEnvironment))
->slot(ip->iLoadFromEnvironment.op3);
ip = NEXTINST(LoadFromEnvironment);
DISPATCH;
}
CASE(LoadFromEnvironmentL) {
O1REG(LoadFromEnvironmentL) =
vmcast<Environment>(O2REG(LoadFromEnvironmentL))
->slot(ip->iLoadFromEnvironmentL.op3);
ip = NEXTINST(LoadFromEnvironmentL);
DISPATCH;
}
CASE(GetGlobalObject) {
O1REG(GetGlobalObject) = runtime->global_;
ip = NEXTINST(GetGlobalObject);
DISPATCH;
}
CASE(GetNewTarget) {
O1REG(GetNewTarget) = FRAME.getNewTargetRef();
ip = NEXTINST(GetNewTarget);
DISPATCH;
}
CASE(DeclareGlobalVar) {
DefinePropertyFlags dpf =
DefinePropertyFlags::getDefaultNewPropertyFlags();
dpf.configurable = 0;
// Do not overwrite existing globals with undefined.
dpf.setValue = 0;
CAPTURE_IP_ASSIGN(
auto res,
JSObject::defineOwnProperty(
runtime->getGlobal(),
runtime,
ID(ip->iDeclareGlobalVar.op1),
dpf,
Runtime::getUndefinedValue(),
PropOpFlags().plusThrowOnError()));
if (res == ExecutionStatus::EXCEPTION) {
assert(
!runtime->getGlobal()->isProxyObject() &&
"global can't be a proxy object");
// If the property already exists, this should be a noop.
// Instead of incurring the cost to check every time, do it
// only if an exception is thrown, and swallow the exception
// if it exists, since we didn't want to make the call,
// anyway. This most likely means the property is
// non-configurable.
NamedPropertyDescriptor desc;
CAPTURE_IP_ASSIGN(
auto res,
JSObject::getOwnNamedDescriptor(
runtime->getGlobal(),
runtime,
ID(ip->iDeclareGlobalVar.op1),
desc));
if (!res) {
goto exception;
} else {
runtime->clearThrownValue();
}
// fall through
}
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = NEXTINST(DeclareGlobalVar);
DISPATCH;
}
CASE(TryGetByIdLong) {
tryProp = true;
idVal = ip->iTryGetByIdLong.op4;
nextIP = NEXTINST(TryGetByIdLong);
goto getById;
}
CASE(GetByIdLong) {
tryProp = false;
idVal = ip->iGetByIdLong.op4;
nextIP = NEXTINST(GetByIdLong);
goto getById;
}
CASE(GetByIdShort) {
tryProp = false;
idVal = ip->iGetByIdShort.op4;
nextIP = NEXTINST(GetByIdShort);
goto getById;
}
CASE(TryGetById) {
tryProp = true;
idVal = ip->iTryGetById.op4;
nextIP = NEXTINST(TryGetById);
goto getById;
}
CASE(GetById) {
tryProp = false;
idVal = ip->iGetById.op4;
nextIP = NEXTINST(GetById);
}
getById : {
++NumGetById;
// NOTE: it is safe to use OnREG(GetById) here because all instructions
// have the same layout: opcode, registers, non-register operands, i.e.
// they only differ in the width of the last "identifier" field.
CallResult<HermesValue> propRes{ExecutionStatus::EXCEPTION};
if (LLVM_LIKELY(O2REG(GetById).isObject())) {
auto *obj = vmcast<JSObject>(O2REG(GetById));
auto cacheIdx = ip->iGetById.op3;
auto *cacheEntry = curCodeBlock->getReadCacheEntry(cacheIdx);
#ifdef HERMESVM_PROFILER_BB
{
HERMES_SLOW_ASSERT(
gcScope.getHandleCountDbg() == KEEP_HANDLES &&
"unaccounted handles were created");
auto objHandle = runtime->makeHandle(obj);
auto cacheHCPtr = vmcast_or_null<HiddenClass>(static_cast<GCCell *>(
cacheEntry->clazz.get(runtime, &runtime->getHeap())));
CAPTURE_IP(runtime->recordHiddenClass(
curCodeBlock, ip, ID(idVal), obj->getClass(runtime), cacheHCPtr));
// obj may be moved by GC due to recordHiddenClass
obj = objHandle.get();
}
gcScope.flushToSmallCount(KEEP_HANDLES);
#endif
auto clazzGCPtr = obj->getClassGCPtr();
#ifndef NDEBUG
if (clazzGCPtr.get(runtime)->isDictionary())
++NumGetByIdDict;
#else
(void)NumGetByIdDict;
#endif
// If we have a cache hit, reuse the cached offset and immediately
// return the property.
if (LLVM_LIKELY(cacheEntry->clazz == clazzGCPtr.getStorageType())) {
++NumGetByIdCacheHits;
CAPTURE_IP_ASSIGN(
O1REG(GetById),
JSObject::getNamedSlotValue<PropStorage::Inline::Yes>(
obj, runtime, cacheEntry->slot));
ip = nextIP;
DISPATCH;
}
auto id = ID(idVal);
NamedPropertyDescriptor desc;
CAPTURE_IP_ASSIGN(
OptValue<bool> fastPathResult,
JSObject::tryGetOwnNamedDescriptorFast(obj, runtime, id, desc));
if (LLVM_LIKELY(
fastPathResult.hasValue() && fastPathResult.getValue()) &&
!desc.flags.accessor) {
++NumGetByIdFastPaths;
// cacheIdx == 0 indicates no caching so don't update the cache in
// those cases.
auto *clazz = clazzGCPtr.getNonNull(runtime);
if (LLVM_LIKELY(!clazz->isDictionaryNoCache()) &&
LLVM_LIKELY(cacheIdx != hbc::PROPERTY_CACHING_DISABLED)) {
#ifdef HERMES_SLOW_DEBUG
if (cacheEntry->clazz &&
cacheEntry->clazz != clazzGCPtr.getStorageType())
++NumGetByIdCacheEvicts;
#else
(void)NumGetByIdCacheEvicts;
#endif
// Cache the class, id and property slot.
cacheEntry->clazz = clazzGCPtr.getStorageType();
cacheEntry->slot = desc.slot;
}
CAPTURE_IP_ASSIGN(
O1REG(GetById), JSObject::getNamedSlotValue(obj, runtime, desc));
ip = nextIP;
DISPATCH;
}
// The cache may also be populated via the prototype of the object.
// This value is only reliable if the fast path was a definite
// not-found.
if (fastPathResult.hasValue() && !fastPathResult.getValue() &&
!obj->isProxyObject()) {
CAPTURE_IP_ASSIGN(JSObject * parent, obj->getParent(runtime));
// TODO: This isLazy check is because a lazy object is reported as
// having no properties and therefore cannot contain the property.
// This check does not belong here, it should be merged into
// tryGetOwnNamedDescriptorFast().
if (parent &&
cacheEntry->clazz == parent->getClassGCPtr().getStorageType() &&
LLVM_LIKELY(!obj->isLazy())) {
++NumGetByIdProtoHits;
CAPTURE_IP_ASSIGN(
O1REG(GetById),
JSObject::getNamedSlotValue(parent, runtime, cacheEntry->slot));
ip = nextIP;
DISPATCH;
}
}
#ifdef HERMES_SLOW_DEBUG
CAPTURE_IP_ASSIGN(
JSObject * propObj,
JSObject::getNamedDescriptor(
Handle<JSObject>::vmcast(&O2REG(GetById)), runtime, id, desc));
if (propObj) {
if (desc.flags.accessor)
++NumGetByIdAccessor;
else if (propObj != vmcast<JSObject>(O2REG(GetById)))
++NumGetByIdProto;
} else {
++NumGetByIdNotFound;
}
#else
(void)NumGetByIdAccessor;
(void)NumGetByIdProto;
(void)NumGetByIdNotFound;
#endif
#ifdef HERMES_SLOW_DEBUG
auto *savedClass = cacheIdx != hbc::PROPERTY_CACHING_DISABLED
? cacheEntry->clazz.get(runtime, &runtime->getHeap())
: nullptr;
#endif
++NumGetByIdSlow;
CAPTURE_IP_ASSIGN(
resPH,
JSObject::getNamed_RJS(
Handle<JSObject>::vmcast(&O2REG(GetById)),
runtime,
id,
!tryProp ? defaultPropOpFlags
: defaultPropOpFlags.plusMustExist(),
cacheIdx != hbc::PROPERTY_CACHING_DISABLED ? cacheEntry
: nullptr));
if (LLVM_UNLIKELY(resPH == ExecutionStatus::EXCEPTION)) {
goto exception;
}
#ifdef HERMES_SLOW_DEBUG
if (cacheIdx != hbc::PROPERTY_CACHING_DISABLED && savedClass &&
cacheEntry->clazz.get(runtime, &runtime->getHeap()) != savedClass) {
++NumGetByIdCacheEvicts;
}
#endif
} else {
++NumGetByIdTransient;
assert(!tryProp && "TryGetById can only be used on the global object");
/* Slow path. */
CAPTURE_IP_ASSIGN(
resPH,
Interpreter::getByIdTransient_RJS(
runtime, Handle<>(&O2REG(GetById)), ID(idVal)));
if (LLVM_UNLIKELY(resPH == ExecutionStatus::EXCEPTION)) {
goto exception;
}
}
O1REG(GetById) = resPH->get();
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = nextIP;
DISPATCH;
}
CASE(TryPutByIdLong) {
tryProp = true;
idVal = ip->iTryPutByIdLong.op4;
nextIP = NEXTINST(TryPutByIdLong);
goto putById;
}
CASE(PutByIdLong) {
tryProp = false;
idVal = ip->iPutByIdLong.op4;
nextIP = NEXTINST(PutByIdLong);
goto putById;
}
CASE(TryPutById) {
tryProp = true;
idVal = ip->iTryPutById.op4;
nextIP = NEXTINST(TryPutById);
goto putById;
}
CASE(PutById) {
tryProp = false;
idVal = ip->iPutById.op4;
nextIP = NEXTINST(PutById);
}
putById : {
++NumPutById;
if (LLVM_LIKELY(O1REG(PutById).isObject())) {
auto *obj = vmcast<JSObject>(O1REG(PutById));
auto cacheIdx = ip->iPutById.op3;
auto *cacheEntry = curCodeBlock->getWriteCacheEntry(cacheIdx);
#ifdef HERMESVM_PROFILER_BB
{
HERMES_SLOW_ASSERT(
gcScope.getHandleCountDbg() == KEEP_HANDLES &&
"unaccounted handles were created");
auto objHandle = runtime->makeHandle(obj);
auto cacheHCPtr = vmcast_or_null<HiddenClass>(static_cast<GCCell *>(
cacheEntry->clazz.get(runtime, &runtime->getHeap())));
CAPTURE_IP(runtime->recordHiddenClass(
curCodeBlock, ip, ID(idVal), obj->getClass(runtime), cacheHCPtr));
// obj may be moved by GC due to recordHiddenClass
obj = objHandle.get();
}
gcScope.flushToSmallCount(KEEP_HANDLES);
#endif
auto clazzGCPtr = obj->getClassGCPtr();
// If we have a cache hit, reuse the cached offset and immediately
// return the property.
if (LLVM_LIKELY(cacheEntry->clazz == clazzGCPtr.getStorageType())) {
++NumPutByIdCacheHits;
CAPTURE_IP(JSObject::setNamedSlotValue<PropStorage::Inline::Yes>(
obj, runtime, cacheEntry->slot, O2REG(PutById)));
ip = nextIP;
DISPATCH;
}
auto id = ID(idVal);
NamedPropertyDescriptor desc;
CAPTURE_IP_ASSIGN(
OptValue<bool> hasOwnProp,
JSObject::tryGetOwnNamedDescriptorFast(obj, runtime, id, desc));
if (LLVM_LIKELY(hasOwnProp.hasValue() && hasOwnProp.getValue()) &&
!desc.flags.accessor && desc.flags.writable &&
!desc.flags.internalSetter) {
++NumPutByIdFastPaths;
// cacheIdx == 0 indicates no caching so don't update the cache in
// those cases.
auto *clazz = clazzGCPtr.getNonNull(runtime);
if (LLVM_LIKELY(!clazz->isDictionary()) &&
LLVM_LIKELY(cacheIdx != hbc::PROPERTY_CACHING_DISABLED)) {
#ifdef HERMES_SLOW_DEBUG
if (cacheEntry->clazz &&
cacheEntry->clazz != clazzGCPtr.getStorageType())
++NumPutByIdCacheEvicts;
#else
(void)NumPutByIdCacheEvicts;
#endif
// Cache the class and property slot.
cacheEntry->clazz = clazzGCPtr.getStorageType();
cacheEntry->slot = desc.slot;
}
CAPTURE_IP(JSObject::setNamedSlotValue(
obj, runtime, desc.slot, O2REG(PutById)));
ip = nextIP;
DISPATCH;
}
CAPTURE_IP_ASSIGN(
auto putRes,
JSObject::putNamed_RJS(
Handle<JSObject>::vmcast(&O1REG(PutById)),
runtime,
id,
Handle<>(&O2REG(PutById)),
!tryProp ? defaultPropOpFlags
: defaultPropOpFlags.plusMustExist()));
if (LLVM_UNLIKELY(putRes == ExecutionStatus::EXCEPTION)) {
goto exception;
}
} else {
++NumPutByIdTransient;
assert(!tryProp && "TryPutById can only be used on the global object");
CAPTURE_IP_ASSIGN(
auto retStatus,
Interpreter::putByIdTransient_RJS(
runtime,
Handle<>(&O1REG(PutById)),
ID(idVal),
Handle<>(&O2REG(PutById)),
strictMode));
if (retStatus == ExecutionStatus::EXCEPTION) {
goto exception;
}
}
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = nextIP;
DISPATCH;
}
CASE(GetByVal) {
CallResult<HermesValue> propRes{ExecutionStatus::EXCEPTION};
if (LLVM_LIKELY(O2REG(GetByVal).isObject())) {
CAPTURE_IP_ASSIGN(
resPH,
JSObject::getComputed_RJS(
Handle<JSObject>::vmcast(&O2REG(GetByVal)),
runtime,
Handle<>(&O3REG(GetByVal))));
if (LLVM_UNLIKELY(resPH == ExecutionStatus::EXCEPTION)) {
goto exception;
}
} else {
// This is the "slow path".
CAPTURE_IP_ASSIGN(
resPH,
Interpreter::getByValTransient_RJS(
runtime,
Handle<>(&O2REG(GetByVal)),
Handle<>(&O3REG(GetByVal))));
if (LLVM_UNLIKELY(resPH == ExecutionStatus::EXCEPTION)) {
goto exception;
}
}
gcScope.flushToSmallCount(KEEP_HANDLES);
O1REG(GetByVal) = resPH->get();
ip = NEXTINST(GetByVal);
DISPATCH;
}
CASE(PutByVal) {
if (LLVM_LIKELY(O1REG(PutByVal).isObject())) {
CAPTURE_IP_ASSIGN(
auto putRes,
JSObject::putComputed_RJS(
Handle<JSObject>::vmcast(&O1REG(PutByVal)),
runtime,
Handle<>(&O2REG(PutByVal)),
Handle<>(&O3REG(PutByVal)),
defaultPropOpFlags));
if (LLVM_UNLIKELY(putRes == ExecutionStatus::EXCEPTION)) {
goto exception;
}
} else {
// This is the "slow path".
CAPTURE_IP_ASSIGN(
auto retStatus,
Interpreter::putByValTransient_RJS(
runtime,
Handle<>(&O1REG(PutByVal)),
Handle<>(&O2REG(PutByVal)),
Handle<>(&O3REG(PutByVal)),
strictMode));
if (LLVM_UNLIKELY(retStatus == ExecutionStatus::EXCEPTION)) {
goto exception;
}
}
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = NEXTINST(PutByVal);
DISPATCH;
}
CASE(PutOwnByIndexL) {
nextIP = NEXTINST(PutOwnByIndexL);
idVal = ip->iPutOwnByIndexL.op3;
goto putOwnByIndex;
}
CASE(PutOwnByIndex) {
nextIP = NEXTINST(PutOwnByIndex);
idVal = ip->iPutOwnByIndex.op3;
}
putOwnByIndex : {
tmpHandle = HermesValue::encodeDoubleValue(idVal);
CAPTURE_IP(JSObject::defineOwnComputedPrimitive(
Handle<JSObject>::vmcast(&O1REG(PutOwnByIndex)),
runtime,
tmpHandle,
DefinePropertyFlags::getDefaultNewPropertyFlags(),
Handle<>(&O2REG(PutOwnByIndex))));
gcScope.flushToSmallCount(KEEP_HANDLES);
tmpHandle.clear();
ip = nextIP;
DISPATCH;
}
CASE(GetPNameList) {
CAPTURE_IP_ASSIGN(
auto pRes, handleGetPNameList(runtime, frameRegs, ip));
if (LLVM_UNLIKELY(pRes == ExecutionStatus::EXCEPTION)) {
goto exception;
}
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = NEXTINST(GetPNameList);
DISPATCH;
}
CASE(GetNextPName) {
{
assert(
vmisa<BigStorage>(O2REG(GetNextPName)) &&
"GetNextPName's second op must be BigStorage");
auto obj = Handle<JSObject>::vmcast(&O3REG(GetNextPName));
auto arr = Handle<BigStorage>::vmcast(&O2REG(GetNextPName));
uint32_t idx = O4REG(GetNextPName).getNumber();
uint32_t size = O5REG(GetNextPName).getNumber();
MutableHandle<JSObject> propObj{runtime};
// Loop until we find a property which is present.
while (idx < size) {
tmpHandle = arr->at(idx);
ComputedPropertyDescriptor desc;
CAPTURE_IP(JSObject::getComputedPrimitiveDescriptor(
obj, runtime, tmpHandle, propObj, desc));
if (LLVM_LIKELY(propObj))
break;
++idx;
}
if (idx < size) {
// We must return the property as a string
if (tmpHandle->isNumber()) {
CAPTURE_IP_ASSIGN(auto status, toString_RJS(runtime, tmpHandle));
assert(
status == ExecutionStatus::RETURNED &&
"toString on number cannot fail");
tmpHandle = status->getHermesValue();
}
O1REG(GetNextPName) = tmpHandle.get();
O4REG(GetNextPName) = HermesValue::encodeNumberValue(idx + 1);
} else {
O1REG(GetNextPName) = HermesValue::encodeUndefinedValue();
}
}
gcScope.flushToSmallCount(KEEP_HANDLES);
tmpHandle.clear();
ip = NEXTINST(GetNextPName);
DISPATCH;
}
CASE(ToNumber) {
if (LLVM_LIKELY(O2REG(ToNumber).isNumber())) {
O1REG(ToNumber) = O2REG(ToNumber);
ip = NEXTINST(ToNumber);
} else {
CAPTURE_IP_ASSIGN(
res, toNumber_RJS(runtime, Handle<>(&O2REG(ToNumber))));
if (res == ExecutionStatus::EXCEPTION)
goto exception;
gcScope.flushToSmallCount(KEEP_HANDLES);
O1REG(ToNumber) = res.getValue();
ip = NEXTINST(ToNumber);
}
DISPATCH;
}
CASE(ToInt32) {
CAPTURE_IP_ASSIGN(res, toInt32_RJS(runtime, Handle<>(&O2REG(ToInt32))));
if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION))
goto exception;
gcScope.flushToSmallCount(KEEP_HANDLES);
O1REG(ToInt32) = res.getValue();
ip = NEXTINST(ToInt32);
DISPATCH;
}
CASE(AddEmptyString) {
if (LLVM_LIKELY(O2REG(AddEmptyString).isString())) {
O1REG(AddEmptyString) = O2REG(AddEmptyString);
ip = NEXTINST(AddEmptyString);
} else {
CAPTURE_IP_ASSIGN(
res,
toPrimitive_RJS(
runtime,
Handle<>(&O2REG(AddEmptyString)),
PreferredType::NONE));
if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION))
goto exception;
tmpHandle = res.getValue();
CAPTURE_IP_ASSIGN(auto strRes, toString_RJS(runtime, tmpHandle));
if (LLVM_UNLIKELY(strRes == ExecutionStatus::EXCEPTION))
goto exception;
tmpHandle.clear();
gcScope.flushToSmallCount(KEEP_HANDLES);
O1REG(AddEmptyString) = strRes->getHermesValue();
ip = NEXTINST(AddEmptyString);
}
DISPATCH;
}
CASE(Jmp) {
ip = IPADD(ip->iJmp.op1);
DISPATCH;
}
CASE(JmpLong) {
ip = IPADD(ip->iJmpLong.op1);
DISPATCH;
}
CASE(JmpTrue) {
if (toBoolean(O2REG(JmpTrue)))
ip = IPADD(ip->iJmpTrue.op1);
else
ip = NEXTINST(JmpTrue);
DISPATCH;
}
CASE(JmpTrueLong) {
if (toBoolean(O2REG(JmpTrueLong)))
ip = IPADD(ip->iJmpTrueLong.op1);
else
ip = NEXTINST(JmpTrueLong);
DISPATCH;
}
CASE(JmpFalse) {
if (!toBoolean(O2REG(JmpFalse)))
ip = IPADD(ip->iJmpFalse.op1);
else
ip = NEXTINST(JmpFalse);
DISPATCH;
}
CASE(JmpFalseLong) {
if (!toBoolean(O2REG(JmpFalseLong)))
ip = IPADD(ip->iJmpFalseLong.op1);
else
ip = NEXTINST(JmpFalseLong);
DISPATCH;
}
CASE(JmpUndefined) {
if (O2REG(JmpUndefined).isUndefined())
ip = IPADD(ip->iJmpUndefined.op1);
else
ip = NEXTINST(JmpUndefined);
DISPATCH;
}
CASE(JmpUndefinedLong) {
if (O2REG(JmpUndefinedLong).isUndefined())
ip = IPADD(ip->iJmpUndefinedLong.op1);
else
ip = NEXTINST(JmpUndefinedLong);
DISPATCH;
}
CASE(Add) {
if (LLVM_LIKELY(
O2REG(Add).isNumber() &&
O3REG(Add).isNumber())) { /* Fast-path. */
CASE(AddN) {
O1REG(Add) = HermesValue::encodeDoubleValue(
O2REG(Add).getNumber() + O3REG(Add).getNumber());
ip = NEXTINST(Add);
DISPATCH;
}
}
CAPTURE_IP_ASSIGN(
res,
addOp_RJS(runtime, Handle<>(&O2REG(Add)), Handle<>(&O3REG(Add))));
if (res == ExecutionStatus::EXCEPTION) {
goto exception;
}
gcScope.flushToSmallCount(KEEP_HANDLES);
O1REG(Add) = res.getValue();
ip = NEXTINST(Add);
DISPATCH;
}
CASE(BitNot) {
if (LLVM_LIKELY(O2REG(BitNot).isNumber())) { /* Fast-path. */
O1REG(BitNot) = HermesValue::encodeDoubleValue(
~hermes::truncateToInt32(O2REG(BitNot).getNumber()));
ip = NEXTINST(BitNot);
DISPATCH;
}
CAPTURE_IP_ASSIGN(res, toInt32_RJS(runtime, Handle<>(&O2REG(BitNot))));
if (res == ExecutionStatus::EXCEPTION) {
goto exception;
}
gcScope.flushToSmallCount(KEEP_HANDLES);
O1REG(BitNot) = HermesValue::encodeDoubleValue(
~static_cast<int32_t>(res->getNumber()));
ip = NEXTINST(BitNot);
DISPATCH;
}
CASE(GetArgumentsLength) {
// If the arguments object hasn't been created yet.
if (O2REG(GetArgumentsLength).isUndefined()) {
O1REG(GetArgumentsLength) =
HermesValue::encodeNumberValue(FRAME.getArgCount());
ip = NEXTINST(GetArgumentsLength);
DISPATCH;
}
// The arguments object has been created, so this is a regular property
// get.
assert(
O2REG(GetArgumentsLength).isObject() &&
"arguments lazy register is not an object");
CAPTURE_IP_ASSIGN(
resPH,
JSObject::getNamed_RJS(
Handle<JSObject>::vmcast(&O2REG(GetArgumentsLength)),
runtime,
Predefined::getSymbolID(Predefined::length)));
if (resPH == ExecutionStatus::EXCEPTION) {
goto exception;
}
gcScope.flushToSmallCount(KEEP_HANDLES);
O1REG(GetArgumentsLength) = resPH->get();
ip = NEXTINST(GetArgumentsLength);
DISPATCH;
}
CASE(GetArgumentsPropByVal) {
// If the arguments object hasn't been created yet and we have a
// valid integer index, we use the fast path.
if (O3REG(GetArgumentsPropByVal).isUndefined()) {
// If this is an integer index.
if (auto index = toArrayIndexFastPath(O2REG(GetArgumentsPropByVal))) {
// Is this an existing argument?
if (*index < FRAME.getArgCount()) {
O1REG(GetArgumentsPropByVal) = FRAME.getArgRef(*index);
ip = NEXTINST(GetArgumentsPropByVal);
DISPATCH;
}
}
}
// Slow path.
CAPTURE_IP_ASSIGN(
auto res,
getArgumentsPropByValSlowPath_RJS(
runtime,
&O3REG(GetArgumentsPropByVal),
&O2REG(GetArgumentsPropByVal),
FRAME.getCalleeClosureHandleUnsafe(),
strictMode));
if (res == ExecutionStatus::EXCEPTION) {
goto exception;
}
gcScope.flushToSmallCount(KEEP_HANDLES);
O1REG(GetArgumentsPropByVal) = res->getHermesValue();
ip = NEXTINST(GetArgumentsPropByVal);
DISPATCH;
}
CASE(ReifyArguments) {
// If the arguments object was already created, do nothing.
if (!O1REG(ReifyArguments).isUndefined()) {
assert(
O1REG(ReifyArguments).isObject() &&
"arguments lazy register is not an object");
ip = NEXTINST(ReifyArguments);
DISPATCH;
}
CAPTURE_IP_ASSIGN(
resArgs,
reifyArgumentsSlowPath(
runtime, FRAME.getCalleeClosureHandleUnsafe(), strictMode));
if (LLVM_UNLIKELY(resArgs == ExecutionStatus::EXCEPTION)) {
goto exception;
}
O1REG(ReifyArguments) = resArgs->getHermesValue();
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = NEXTINST(ReifyArguments);
DISPATCH;
}
CASE(NewObject) {
// Create a new object using the built-in constructor. Note that the
// built-in constructor is empty, so we don't actually need to call
// it.
CAPTURE_IP_ASSIGN(
O1REG(NewObject), JSObject::create(runtime).getHermesValue());
assert(
gcScope.getHandleCountDbg() == KEEP_HANDLES &&
"Should not create handles.");
ip = NEXTINST(NewObject);
DISPATCH;
}
CASE(NewObjectWithParent) {
CAPTURE_IP_ASSIGN(
O1REG(NewObjectWithParent),
JSObject::create(
runtime,
O2REG(NewObjectWithParent).isObject()
? Handle<JSObject>::vmcast(&O2REG(NewObjectWithParent))
: O2REG(NewObjectWithParent).isNull()
? Runtime::makeNullHandle<JSObject>()
: Handle<JSObject>::vmcast(&runtime->objectPrototype))
.getHermesValue());
assert(
gcScope.getHandleCountDbg() == KEEP_HANDLES &&
"Should not create handles.");
ip = NEXTINST(NewObjectWithParent);
DISPATCH;
}
CASE(NewObjectWithBuffer) {
CAPTURE_IP_ASSIGN(
resPH,
Interpreter::createObjectFromBuffer(
runtime,
curCodeBlock,
ip->iNewObjectWithBuffer.op3,
ip->iNewObjectWithBuffer.op4,
ip->iNewObjectWithBuffer.op5));
if (LLVM_UNLIKELY(resPH == ExecutionStatus::EXCEPTION)) {
goto exception;
}
O1REG(NewObjectWithBuffer) = resPH->get();
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = NEXTINST(NewObjectWithBuffer);
DISPATCH;
}
CASE(NewObjectWithBufferLong) {
CAPTURE_IP_ASSIGN(
resPH,
Interpreter::createObjectFromBuffer(
runtime,
curCodeBlock,
ip->iNewObjectWithBufferLong.op3,
ip->iNewObjectWithBufferLong.op4,
ip->iNewObjectWithBufferLong.op5));
if (LLVM_UNLIKELY(resPH == ExecutionStatus::EXCEPTION)) {
goto exception;
}
O1REG(NewObjectWithBufferLong) = resPH->get();
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = NEXTINST(NewObjectWithBufferLong);
DISPATCH;
}
CASE(NewArray) {
// Create a new array using the built-in constructor. Note that the
// built-in constructor is empty, so we don't actually need to call
// it.
CAPTURE_IP_ASSIGN(
auto createRes,
JSArray::create(runtime, ip->iNewArray.op2, ip->iNewArray.op2));
if (createRes == ExecutionStatus::EXCEPTION) {
goto exception;
}
O1REG(NewArray) = createRes->getHermesValue();
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = NEXTINST(NewArray);
DISPATCH;
}
CASE(NewArrayWithBuffer) {
CAPTURE_IP_ASSIGN(
resPH,
Interpreter::createArrayFromBuffer(
runtime,
curCodeBlock,
ip->iNewArrayWithBuffer.op2,
ip->iNewArrayWithBuffer.op3,
ip->iNewArrayWithBuffer.op4));
if (LLVM_UNLIKELY(resPH == ExecutionStatus::EXCEPTION)) {
goto exception;
}
O1REG(NewArrayWithBuffer) = resPH->get();
gcScope.flushToSmallCount(KEEP_HANDLES);
tmpHandle.clear();
ip = NEXTINST(NewArrayWithBuffer);
DISPATCH;
}
CASE(NewArrayWithBufferLong) {
CAPTURE_IP_ASSIGN(
resPH,
Interpreter::createArrayFromBuffer(
runtime,
curCodeBlock,
ip->iNewArrayWithBufferLong.op2,
ip->iNewArrayWithBufferLong.op3,
ip->iNewArrayWithBufferLong.op4));
if (LLVM_UNLIKELY(resPH == ExecutionStatus::EXCEPTION)) {
goto exception;
}
O1REG(NewArrayWithBufferLong) = resPH->get();
gcScope.flushToSmallCount(KEEP_HANDLES);
tmpHandle.clear();
ip = NEXTINST(NewArrayWithBufferLong);
DISPATCH;
}
CASE(CreateThis) {
// Registers: output, prototype, closure.
if (LLVM_UNLIKELY(!vmisa<Callable>(O3REG(CreateThis)))) {
CAPTURE_IP(runtime->raiseTypeError("constructor is not callable"));
goto exception;
}
CAPTURE_IP_ASSIGN(
auto res,
Callable::newObject(
Handle<Callable>::vmcast(&O3REG(CreateThis)),
runtime,
Handle<JSObject>::vmcast(
O2REG(CreateThis).isObject() ? &O2REG(CreateThis)
: &runtime->objectPrototype)));
if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) {
goto exception;
}
gcScope.flushToSmallCount(KEEP_HANDLES);
O1REG(CreateThis) = res->getHermesValue();
ip = NEXTINST(CreateThis);
DISPATCH;
}
CASE(SelectObject) {
// Registers: output, thisObject, constructorReturnValue.
O1REG(SelectObject) = O3REG(SelectObject).isObject()
? O3REG(SelectObject)
: O2REG(SelectObject);
ip = NEXTINST(SelectObject);
DISPATCH;
}
CASE(Eq)
CASE(Neq) {
CAPTURE_IP_ASSIGN(
res,
abstractEqualityTest_RJS(
runtime, Handle<>(&O2REG(Eq)), Handle<>(&O3REG(Eq))));
if (res == ExecutionStatus::EXCEPTION) {
goto exception;
}
gcScope.flushToSmallCount(KEEP_HANDLES);
O1REG(Eq) = ip->opCode == OpCode::Eq
? res.getValue()
: HermesValue::encodeBoolValue(!res->getBool());
ip = NEXTINST(Eq);
DISPATCH;
}
CASE(StrictEq) {
O1REG(StrictEq) = HermesValue::encodeBoolValue(
strictEqualityTest(O2REG(StrictEq), O3REG(StrictEq)));
ip = NEXTINST(StrictEq);
DISPATCH;
}
CASE(StrictNeq) {
O1REG(StrictNeq) = HermesValue::encodeBoolValue(
!strictEqualityTest(O2REG(StrictNeq), O3REG(StrictNeq)));
ip = NEXTINST(StrictNeq);
DISPATCH;
}
CASE(Not) {
O1REG(Not) = HermesValue::encodeBoolValue(!toBoolean(O2REG(Not)));
ip = NEXTINST(Not);
DISPATCH;
}
CASE(Negate) {
if (LLVM_LIKELY(O2REG(Negate).isNumber())) {
O1REG(Negate) =
HermesValue::encodeDoubleValue(-O2REG(Negate).getNumber());
} else {
CAPTURE_IP_ASSIGN(
res, toNumber_RJS(runtime, Handle<>(&O2REG(Negate))));
if (res == ExecutionStatus::EXCEPTION)
goto exception;
gcScope.flushToSmallCount(KEEP_HANDLES);
O1REG(Negate) = HermesValue::encodeDoubleValue(-res->getNumber());
}
ip = NEXTINST(Negate);
DISPATCH;
}
CASE(TypeOf) {
CAPTURE_IP_ASSIGN(
O1REG(TypeOf), typeOf(runtime, Handle<>(&O2REG(TypeOf))));
ip = NEXTINST(TypeOf);
DISPATCH;
}
CASE(Mod) {
// We use fmod here for simplicity. Theoretically fmod behaves slightly
// differently than the ECMAScript Spec. fmod applies round-towards-zero
// for the remainder when it's not representable by a double; while the
// spec requires round-to-nearest. As an example, 5 % 0.7 will give
// 0.10000000000000031 using fmod, but using the rounding style
// described
// by the spec, the output should really be 0.10000000000000053.
// Such difference can be ignored in practice.
if (LLVM_LIKELY(O2REG(Mod).isNumber() && O3REG(Mod).isNumber())) {
/* Fast-path. */
O1REG(Mod) = HermesValue::encodeDoubleValue(
std::fmod(O2REG(Mod).getNumber(), O3REG(Mod).getNumber()));
ip = NEXTINST(Mod);
DISPATCH;
}
CAPTURE_IP_ASSIGN(res, toNumber_RJS(runtime, Handle<>(&O2REG(Mod))));
if (res == ExecutionStatus::EXCEPTION)
goto exception;
double left = res->getDouble();
CAPTURE_IP_ASSIGN(res, toNumber_RJS(runtime, Handle<>(&O3REG(Mod))));
if (res == ExecutionStatus::EXCEPTION)
goto exception;
O1REG(Mod) =
HermesValue::encodeDoubleValue(std::fmod(left, res->getDouble()));
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = NEXTINST(Mod);
DISPATCH;
}
CASE(InstanceOf) {
CAPTURE_IP_ASSIGN(
auto result,
instanceOfOperator_RJS(
runtime,
Handle<>(&O2REG(InstanceOf)),
Handle<>(&O3REG(InstanceOf))));
if (LLVM_UNLIKELY(result == ExecutionStatus::EXCEPTION)) {
goto exception;
}
O1REG(InstanceOf) = HermesValue::encodeBoolValue(*result);
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = NEXTINST(InstanceOf);
DISPATCH;
}
CASE(IsIn) {
{
if (LLVM_UNLIKELY(!O3REG(IsIn).isObject())) {
CAPTURE_IP(runtime->raiseTypeError(
"right operand of 'in' is not an object"));
goto exception;
}
CAPTURE_IP_ASSIGN(
auto cr,
JSObject::hasComputed(
Handle<JSObject>::vmcast(&O3REG(IsIn)),
runtime,
Handle<>(&O2REG(IsIn))));
if (cr == ExecutionStatus::EXCEPTION) {
goto exception;
}
O1REG(IsIn) = HermesValue::encodeBoolValue(*cr);
}
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = NEXTINST(IsIn);
DISPATCH;
}
CASE(PutNewOwnByIdShort) {
nextIP = NEXTINST(PutNewOwnByIdShort);
idVal = ip->iPutNewOwnByIdShort.op3;
goto putOwnById;
}
CASE(PutNewOwnNEByIdLong)
CASE(PutNewOwnByIdLong) {
nextIP = NEXTINST(PutNewOwnByIdLong);
idVal = ip->iPutNewOwnByIdLong.op3;
goto putOwnById;
}
CASE(PutNewOwnNEById)
CASE(PutNewOwnById) {
nextIP = NEXTINST(PutNewOwnById);
idVal = ip->iPutNewOwnById.op3;
}
putOwnById : {
assert(
O1REG(PutNewOwnById).isObject() &&
"Object argument of PutNewOwnById must be an object");
CAPTURE_IP_ASSIGN(
auto res,
JSObject::defineNewOwnProperty(
Handle<JSObject>::vmcast(&O1REG(PutNewOwnById)),
runtime,
ID(idVal),
ip->opCode <= OpCode::PutNewOwnByIdLong
? PropertyFlags::defaultNewNamedPropertyFlags()
: PropertyFlags::nonEnumerablePropertyFlags(),
Handle<>(&O2REG(PutNewOwnById))));
if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) {
goto exception;
}
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = nextIP;
DISPATCH;
}
CASE(DelByIdLong) {
idVal = ip->iDelByIdLong.op3;
nextIP = NEXTINST(DelByIdLong);
goto DelById;
}
CASE(DelById) {
idVal = ip->iDelById.op3;
nextIP = NEXTINST(DelById);
}
DelById : {
if (LLVM_LIKELY(O2REG(DelById).isObject())) {
CAPTURE_IP_ASSIGN(
auto status,
JSObject::deleteNamed(
Handle<JSObject>::vmcast(&O2REG(DelById)),
runtime,
ID(idVal),
defaultPropOpFlags));
if (LLVM_UNLIKELY(status == ExecutionStatus::EXCEPTION)) {
goto exception;
}
O1REG(DelById) = HermesValue::encodeBoolValue(status.getValue());
} else {
// This is the "slow path".
CAPTURE_IP_ASSIGN(res, toObject(runtime, Handle<>(&O2REG(DelById))));
if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) {
// If an exception is thrown, likely we are trying to convert
// undefined/null to an object. Passing over the name of the property
// so that we could emit more meaningful error messages.
CAPTURE_IP(amendPropAccessErrorMsgWithPropName(
runtime, Handle<>(&O2REG(DelById)), "delete", ID(idVal)));
goto exception;
}
tmpHandle = res.getValue();
CAPTURE_IP_ASSIGN(
auto status,
JSObject::deleteNamed(
Handle<JSObject>::vmcast(tmpHandle),
runtime,
ID(idVal),
defaultPropOpFlags));
if (LLVM_UNLIKELY(status == ExecutionStatus::EXCEPTION)) {
goto exception;
}
O1REG(DelById) = HermesValue::encodeBoolValue(status.getValue());
tmpHandle.clear();
}
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = nextIP;
DISPATCH;
}
CASE(DelByVal) {
if (LLVM_LIKELY(O2REG(DelByVal).isObject())) {
CAPTURE_IP_ASSIGN(
auto status,
JSObject::deleteComputed(
Handle<JSObject>::vmcast(&O2REG(DelByVal)),
runtime,
Handle<>(&O3REG(DelByVal)),
defaultPropOpFlags));
if (LLVM_UNLIKELY(status == ExecutionStatus::EXCEPTION)) {
goto exception;
}
O1REG(DelByVal) = HermesValue::encodeBoolValue(status.getValue());
} else {
// This is the "slow path".
CAPTURE_IP_ASSIGN(res, toObject(runtime, Handle<>(&O2REG(DelByVal))));
if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) {
goto exception;
}
tmpHandle = res.getValue();
CAPTURE_IP_ASSIGN(
auto status,
JSObject::deleteComputed(
Handle<JSObject>::vmcast(tmpHandle),
runtime,
Handle<>(&O3REG(DelByVal)),
defaultPropOpFlags));
if (LLVM_UNLIKELY(status == ExecutionStatus::EXCEPTION)) {
goto exception;
}
O1REG(DelByVal) = HermesValue::encodeBoolValue(status.getValue());
}
gcScope.flushToSmallCount(KEEP_HANDLES);
tmpHandle.clear();
ip = NEXTINST(DelByVal);
DISPATCH;
}
CASE(CreateRegExp) {
{
// Create the RegExp object.
CAPTURE_IP_ASSIGN(auto re, JSRegExp::create(runtime));
// Initialize the regexp.
CAPTURE_IP_ASSIGN(
auto pattern,
runtime->makeHandle(curCodeBlock->getRuntimeModule()
->getStringPrimFromStringIDMayAllocate(
ip->iCreateRegExp.op2)));
CAPTURE_IP_ASSIGN(
auto flags,
runtime->makeHandle(curCodeBlock->getRuntimeModule()
->getStringPrimFromStringIDMayAllocate(
ip->iCreateRegExp.op3)));
CAPTURE_IP_ASSIGN(
auto bytecode,
curCodeBlock->getRuntimeModule()->getRegExpBytecodeFromRegExpID(
ip->iCreateRegExp.op4));
CAPTURE_IP_ASSIGN(
auto initRes,
JSRegExp::initialize(re, runtime, pattern, flags, bytecode));
if (LLVM_UNLIKELY(initRes == ExecutionStatus::EXCEPTION)) {
goto exception;
}
// Done, return the new object.
O1REG(CreateRegExp) = re.getHermesValue();
}
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = NEXTINST(CreateRegExp);
DISPATCH;
}
CASE(SwitchImm) {
if (LLVM_LIKELY(O1REG(SwitchImm).isNumber())) {
double numVal = O1REG(SwitchImm).getNumber();
uint32_t uintVal = (uint32_t)numVal;
if (LLVM_LIKELY(numVal == uintVal) && // Only integers.
LLVM_LIKELY(uintVal >= ip->iSwitchImm.op4) && // Bounds checking.
LLVM_LIKELY(uintVal <= ip->iSwitchImm.op5)) // Bounds checking.
{
// Calculate the offset into the bytecode where the jump table for
// this SwitchImm starts.
const uint8_t *tablestart = (const uint8_t *)llvh::alignAddr(
(const uint8_t *)ip + ip->iSwitchImm.op2, sizeof(uint32_t));
// Read the offset from the table.
const uint32_t *loc =
(const uint32_t *)tablestart + uintVal - ip->iSwitchImm.op4;
ip = IPADD(*loc);
DISPATCH;
}
}
// Wrong type or out of range, jump to default.
ip = IPADD(ip->iSwitchImm.op3);
DISPATCH;
}
LOAD_CONST(
LoadConstUInt8,
HermesValue::encodeDoubleValue(ip->iLoadConstUInt8.op2));
LOAD_CONST(
LoadConstInt, HermesValue::encodeDoubleValue(ip->iLoadConstInt.op2));
LOAD_CONST(
LoadConstDouble,
HermesValue::encodeDoubleValue(ip->iLoadConstDouble.op2));
LOAD_CONST_CAPTURE_IP(
LoadConstString,
HermesValue::encodeStringValue(
curCodeBlock->getRuntimeModule()
->getStringPrimFromStringIDMayAllocate(
ip->iLoadConstString.op2)));
LOAD_CONST_CAPTURE_IP(
LoadConstStringLongIndex,
HermesValue::encodeStringValue(
curCodeBlock->getRuntimeModule()
->getStringPrimFromStringIDMayAllocate(
ip->iLoadConstStringLongIndex.op2)));
LOAD_CONST(LoadConstUndefined, HermesValue::encodeUndefinedValue());
LOAD_CONST(LoadConstNull, HermesValue::encodeNullValue());
LOAD_CONST(LoadConstTrue, HermesValue::encodeBoolValue(true));
LOAD_CONST(LoadConstFalse, HermesValue::encodeBoolValue(false));
LOAD_CONST(LoadConstZero, HermesValue::encodeDoubleValue(0));
BINOP(Sub, doSub);
BINOP(Mul, doMult);
BINOP(Div, doDiv);
BITWISEBINOP(BitAnd, &);
BITWISEBINOP(BitOr, |);
BITWISEBINOP(BitXor, ^);
// For LShift, we need to use toUInt32 first because lshift on negative
// numbers is undefined behavior in theory.
SHIFTOP(LShift, <<, toUInt32_RJS, uint32_t, int32_t);
SHIFTOP(RShift, >>, toInt32_RJS, int32_t, int32_t);
SHIFTOP(URshift, >>, toUInt32_RJS, uint32_t, uint32_t);
CONDOP(Less, <, lessOp_RJS);
CONDOP(LessEq, <=, lessEqualOp_RJS);
CONDOP(Greater, >, greaterOp_RJS);
CONDOP(GreaterEq, >=, greaterEqualOp_RJS);
JCOND(Less, <, lessOp_RJS);
JCOND(LessEqual, <=, lessEqualOp_RJS);
JCOND(Greater, >, greaterOp_RJS);
JCOND(GreaterEqual, >=, greaterEqualOp_RJS);
JCOND_STRICT_EQ_IMPL(
JStrictEqual, , IPADD(ip->iJStrictEqual.op1), NEXTINST(JStrictEqual));
JCOND_STRICT_EQ_IMPL(
JStrictEqual,
Long,
IPADD(ip->iJStrictEqualLong.op1),
NEXTINST(JStrictEqualLong));
JCOND_STRICT_EQ_IMPL(
JStrictNotEqual,
,
NEXTINST(JStrictNotEqual),
IPADD(ip->iJStrictNotEqual.op1));
JCOND_STRICT_EQ_IMPL(
JStrictNotEqual,
Long,
NEXTINST(JStrictNotEqualLong),
IPADD(ip->iJStrictNotEqualLong.op1));
JCOND_EQ_IMPL(JEqual, , IPADD(ip->iJEqual.op1), NEXTINST(JEqual));
JCOND_EQ_IMPL(
JEqual, Long, IPADD(ip->iJEqualLong.op1), NEXTINST(JEqualLong));
JCOND_EQ_IMPL(
JNotEqual, , NEXTINST(JNotEqual), IPADD(ip->iJNotEqual.op1));
JCOND_EQ_IMPL(
JNotEqual,
Long,
NEXTINST(JNotEqualLong),
IPADD(ip->iJNotEqualLong.op1));
CASE_OUTOFLINE(PutOwnByVal);
CASE_OUTOFLINE(PutOwnGetterSetterByVal);
CASE_OUTOFLINE(DirectEval);
CASE_OUTOFLINE(IteratorBegin);
CASE_OUTOFLINE(IteratorNext);
CASE(IteratorClose) {
if (LLVM_UNLIKELY(O1REG(IteratorClose).isObject())) {
// The iterator must be closed if it's still an object.
// That means it was never an index and is not done iterating (a state
// which is indicated by `undefined`).
CAPTURE_IP_ASSIGN(
auto res,
iteratorClose(
runtime,
Handle<JSObject>::vmcast(&O1REG(IteratorClose)),
Runtime::getEmptyValue()));
if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) {
if (ip->iIteratorClose.op2 &&
!isUncatchableError(runtime->thrownValue_)) {
// Ignore inner exception.
runtime->clearThrownValue();
} else {
goto exception;
}
}
gcScope.flushToSmallCount(KEEP_HANDLES);
}
ip = NEXTINST(IteratorClose);
DISPATCH;
}
CASE(_last) {
llvm_unreachable("Invalid opcode _last");
}
}
llvm_unreachable("unreachable");
// We arrive here if we couldn't allocate the registers for the current frame.
stackOverflow:
CAPTURE_IP(runtime->raiseStackOverflow(
Runtime::StackOverflowKind::JSRegisterStack));
// We arrive here when we raised an exception in a callee, but we don't want
// the callee to be able to handle it.
handleExceptionInParent:
// Restore the caller code block and IP.
curCodeBlock = FRAME.getSavedCodeBlock();
ip = FRAME.getSavedIP();
// Pop to the previous frame where technically the error happened.
frameRegs =
&runtime->restoreStackAndPreviousFrame(FRAME).getFirstLocalRef();
// If we are coming from native code, return.
if (!curCodeBlock)
return ExecutionStatus::EXCEPTION;
// Return because of recursive calling structure
#ifdef HERMESVM_PROFILER_EXTERN
return ExecutionStatus::EXCEPTION;
#endif
// Handle the exception.
exception:
UPDATE_OPCODE_TIME_SPENT;
assert(
!runtime->thrownValue_.isEmpty() &&
"thrownValue unavailable at exception");
bool catchable = true;
// If this is an Error object that was thrown internally, it didn't have
// access to the current codeblock and IP, so collect the stack trace here.
if (auto *jsError = dyn_vmcast<JSError>(runtime->thrownValue_)) {
catchable = jsError->catchable();
if (!jsError->getStackTrace()) {
// Temporarily clear the thrown value for following operations.
CAPTURE_IP_ASSIGN(
auto errorHandle,
runtime->makeHandle(vmcast<JSError>(runtime->thrownValue_)));
runtime->clearThrownValue();
CAPTURE_IP(JSError::recordStackTrace(
errorHandle, runtime, false, curCodeBlock, ip));
// Restore the thrown value.
runtime->setThrownValue(errorHandle.getHermesValue());
}
}
gcScope.flushToSmallCount(KEEP_HANDLES);
tmpHandle.clear();
#ifdef HERMES_ENABLE_DEBUGGER
if (SingleStep) {
// If we're single stepping, don't bother with any more checks,
// and simply signal that we should continue execution with an exception.
state.codeBlock = curCodeBlock;
state.offset = CUROFFSET;
return ExecutionStatus::EXCEPTION;
}
using PauseOnThrowMode = facebook::hermes::debugger::PauseOnThrowMode;
auto mode = runtime->debugger_.getPauseOnThrowMode();
if (mode != PauseOnThrowMode::None) {
if (!runtime->debugger_.isDebugging()) {
// Determine whether the PauseOnThrowMode requires us to stop here.
bool caught =
runtime->debugger_
.findCatchTarget(InterpreterState(curCodeBlock, CUROFFSET))
.hasValue();
bool shouldStop = mode == PauseOnThrowMode::All ||
(mode == PauseOnThrowMode::Uncaught && !caught);
if (shouldStop) {
// When runDebugger is invoked after an exception,
// stepping should never happen internally.
// Any step is a step to an exception handler, which we do
// directly here in the interpreter.
// Thus, the result state should be the same as the input state.
InterpreterState tmpState{curCodeBlock, (uint32_t)CUROFFSET};
CAPTURE_IP_ASSIGN(
ExecutionStatus resultStatus,
runtime->debugger_.runDebugger(
Debugger::RunReason::Exception, tmpState));
(void)resultStatus;
assert(
tmpState == InterpreterState(curCodeBlock, CUROFFSET) &&
"not allowed to step internally in a pauseOnThrow");
gcScope.flushToSmallCount(KEEP_HANDLES);
}
}
}
#endif
int32_t handlerOffset = 0;
// If the exception is not catchable, skip found catch blocks.
while (((handlerOffset = curCodeBlock->findCatchTargetOffset(CUROFFSET)) ==
-1) ||
!catchable) {
PROFILER_EXIT_FUNCTION(curCodeBlock);
#ifdef HERMES_ENABLE_ALLOCATION_LOCATION_TRACES
runtime->popCallStack();
#endif
// Restore the code block and IP.
curCodeBlock = FRAME.getSavedCodeBlock();
ip = FRAME.getSavedIP();
// Pop a stack frame.
frameRegs =
&runtime->restoreStackAndPreviousFrame(FRAME).getFirstLocalRef();
SLOW_DEBUG(
dbgs() << "function exit with exception: restored stackLevel="
<< runtime->getStackLevel() << "\n");
// Are we returning to native code?
if (!curCodeBlock) {
SLOW_DEBUG(
dbgs()
<< "function exit with exception: returning to native code\n");
return ExecutionStatus::EXCEPTION;
}
assert(
isCallType(ip->opCode) &&
"return address is not Call-type instruction");
// Return because of recursive calling structure
#ifdef HERMESVM_PROFILER_EXTERN
return ExecutionStatus::EXCEPTION;
#endif
}
INIT_STATE_FOR_CODEBLOCK(curCodeBlock);
ip = IPADD(handlerOffset - CUROFFSET);
}
} | 12017 | True | 1 |
|
CVE-2021-24037 | False | False | False | False | AV:N/AC:L/Au:N/C:P/I:P/A:P | NETWORK | LOW | NONE | PARTIAL | PARTIAL | PARTIAL | 7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | HIGH | HIGH | HIGH | 9.8 | CRITICAL | 3.9 | 5.9 | False | [{'url': 'https://www.facebook.com/security/advisories/CVE-2021-24037', 'name': 'https://www.facebook.com/security/advisories/CVE-2021-24037', 'refsource': 'CONFIRM', 'tags': ['Vendor Advisory']}, {'url': 'https://github.com/facebook/hermes/commit/d86e185e485b6330216dee8e854455c694e3a36e', 'name': 'https://github.com/facebook/hermes/commit/d86e185e485b6330216dee8e854455c694e3a36e', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-416'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:facebook:hermes:*:*:*:*:*:*:*:*', 'versionEndExcluding': '0.8.0', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'A use after free in hermes, while emitting certain error messages, prior to commit d86e185e485b6330216dee8e854455c694e3a36e allows attackers to potentially execute arbitrary code via crafted JavaScript. Note that this is only exploitable if the application using Hermes permits evaluation of untrusted JavaScript. Hence, most React Native applications are not affected.'}] | 2021-06-23T19:43Z | 2021-06-15T22:15Z | Use After Free | Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code. |
The use of previously-freed memory can have any number of adverse consequences, ranging from the corruption of valid data to the execution of arbitrary code, depending on the instantiation and timing of the flaw. The simplest way data corruption may occur involves the system's reuse of the freed memory. Use-after-free errors have two common and sometimes overlapping causes:
Error conditions and other exceptional circumstances.
Confusion over which part of the program is responsible for freeing the memory.
In this scenario, the memory in question is allocated to another pointer validly at some point after it has been freed. The original pointer to the freed memory is used again and points to somewhere within the new allocation. As the data is changed, it corrupts the validly used memory; this induces undefined behavior in the process.
If the newly allocated data chances to hold a class, in C++ for example, various function pointers may be scattered within the heap data. If one of these function pointers is overwritten with an address to valid shellcode, execution of arbitrary code can be achieved.
| https://cwe.mitre.org/data/definitions/416.html | 0 | Riley Dulin | 2020-08-14 15:37:38-07:00 | Fix a bug in transient object property assignment and getUTF16Ref
Summary:
The returned `UTF16Ref` from `StringView::getUTF16Ref` can be invalidated by
appending more contents to the same allocator.
This case was encountered in `transientObjectPutErrorMessage`, resulting in
using free'd memory.
Reviewed By: tmikov
Differential Revision: D23034855
fbshipit-source-id: 4c25a5369934bf3bdfc5582385503f4b87de3792 | d86e185e485b6330216dee8e854455c694e3a36e | False | facebook/hermes | A JavaScript engine optimized for running React Native. | 2018-10-22 19:13:00 | 2022-08-27 17:16:04 | https://hermesengine.dev/ | facebook | 7427.0 | 453.0 | hermes::vm::transientObjectPutErrorMessage | hermes::vm::transientObjectPutErrorMessage( Runtime * runtime , Handle<> base , SymbolID id) | ['runtime', 'base', 'id'] | transientObjectPutErrorMessage(Runtime *runtime, Handle<> base, SymbolID id) {
// Emit an error message that looks like:
// "Cannot create property '%{id}' on ${typeof base} '${String(base)}'".
StringView propName =
runtime->getIdentifierTable().getStringView(runtime, id);
Handle<StringPrimitive> baseType =
runtime->makeHandle(vmcast<StringPrimitive>(typeOf(runtime, base)));
StringView baseTypeAsString =
StringPrimitive::createStringView(runtime, baseType);
MutableHandle<StringPrimitive> valueAsString{runtime};
if (base->isSymbol()) {
// Special workaround for Symbol which can't be stringified.
auto str = symbolDescriptiveString(runtime, Handle<SymbolID>::vmcast(base));
if (str != ExecutionStatus::EXCEPTION) {
valueAsString = *str;
} else {
runtime->clearThrownValue();
valueAsString = StringPrimitive::createNoThrow(
runtime, "<<Exception occurred getting the value>>");
}
} else {
auto str = toString_RJS(runtime, base);
assert(
str != ExecutionStatus::EXCEPTION &&
"Primitives should be convertible to string without exceptions");
valueAsString = std::move(*str);
}
StringView valueAsStringPrintable =
StringPrimitive::createStringView(runtime, valueAsString);
SmallU16String<32> tmp;
return runtime->raiseTypeError(
TwineChar16("Cannot create property '") + propName + "' on " +
baseTypeAsString.getUTF16Ref(tmp) + " '" +
valueAsStringPrintable.getUTF16Ref(tmp) + "'");
} | 225 | True | 1 |
CVE-2020-1911 | False | False | False | False | AV:N/AC:M/Au:N/C:P/I:P/A:P | NETWORK | MEDIUM | NONE | PARTIAL | PARTIAL | PARTIAL | 6.8 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | HIGH | HIGH | HIGH | 9.8 | CRITICAL | 3.9 | 5.9 | False | [{'url': 'https://www.facebook.com/security/advisories/cve-2020-1911', 'name': 'https://www.facebook.com/security/advisories/cve-2020-1911', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'https://github.com/facebook/hermes/commit/fe52854cdf6725c2eaa9e125995da76e6ceb27da', 'name': 'https://github.com/facebook/hermes/commit/fe52854cdf6725c2eaa9e125995da76e6ceb27da', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-843'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:facebook:hermes:*:*:*:*:*:*:*:*', 'versionEndExcluding': '0.4.3', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'A type confusion vulnerability when resolving properties of JavaScript objects with specially-crafted prototype chains in Facebook Hermes prior to commit fe52854cdf6725c2eaa9e125995da76e6ceb27da allows attackers to potentially execute arbitrary code via crafted JavaScript. Note that this is only exploitable if the application using Hermes permits evaluation of untrusted JavaScript. Hence, most React Native applications are not affected.'}] | 2020-09-11T17:02Z | 2020-09-04T03:15Z | Access of Resource Using Incompatible Type ('Type Confusion') | The program allocates or initializes a resource such as a pointer, object, or variable using one type, but it later accesses that resource using a type that is incompatible with the original type. |
When the program accesses the resource using an incompatible type, this could trigger logical errors because the resource does not have expected properties. In languages without memory safety, such as C and C++, type confusion can lead to out-of-bounds memory access.
While this weakness is frequently associated with unions when parsing data with many different embedded object types in C, it can be present in any application that can interpret the same variable or memory location in multiple ways.
This weakness is not unique to C and C++. For example, errors in PHP applications can be triggered by providing array parameters when scalars are expected, or vice versa. Languages such as Perl, which perform automatic conversion of a variable of one type when it is accessed as if it were another type, can also contain these issues.
| https://cwe.mitre.org/data/definitions/843.html | 0 | Marc Horowitz | 2020-08-25 20:36:45-07:00 | [CVE-2020-1911] Look up HostObject computed properties on the right object in the prototype chain.
Summary:
The change in the hermes repository fixes the security vulnerability
CVE-2020-1911. This vulnerability only affects applications which
allow evaluation of uncontrolled, untrusted JavaScript code not
shipped with the app, so React Native apps will generally not be affected.
This revision includes a test for the bug. The test is generic JSI
code, so it is included in the hermes and react-native repositories.
Changelog: [Internal]
Reviewed By: tmikov
Differential Revision: D23322992
fbshipit-source-id: 4e88c974afe1ad33a263f9cac03e9dc98d33649a | fe52854cdf6725c2eaa9e125995da76e6ceb27da | False | facebook/hermes | A JavaScript engine optimized for running React Native. | 2018-10-22 19:13:00 | 2022-08-27 17:16:04 | https://hermesengine.dev/ | facebook | 7427.0 | 453.0 | hermes::vm::JSObject::getComputedWithReceiver_RJS | hermes::vm::JSObject::getComputedWithReceiver_RJS( Handle<JSObject> selfHandle , Runtime * runtime , Handle<> nameValHandle , Handle<> receiver) | ['selfHandle', 'runtime', 'nameValHandle', 'receiver'] | CallResult<PseudoHandle<>> JSObject::getComputedWithReceiver_RJS(
Handle<JSObject> selfHandle,
Runtime *runtime,
Handle<> nameValHandle,
Handle<> receiver) {
// Try the fast-path first: no "index-like" properties and the "name" already
// is a valid integer index.
if (selfHandle->flags_.fastIndexProperties) {
if (auto arrayIndex = toArrayIndexFastPath(*nameValHandle)) {
// Do we have this value present in our array storage? If so, return it.
PseudoHandle<> ourValue = createPseudoHandle(
getOwnIndexed(selfHandle.get(), runtime, *arrayIndex));
if (LLVM_LIKELY(!ourValue->isEmpty()))
return ourValue;
}
}
// If nameValHandle is an object, we should convert it to string now,
// because toString may have side-effect, and we want to do this only
// once.
auto converted = toPropertyKeyIfObject(runtime, nameValHandle);
if (LLVM_UNLIKELY(converted == ExecutionStatus::EXCEPTION)) {
return ExecutionStatus::EXCEPTION;
}
auto nameValPrimitiveHandle = *converted;
ComputedPropertyDescriptor desc;
// Locate the descriptor. propObj contains the object which may be anywhere
// along the prototype chain.
MutableHandle<JSObject> propObj{runtime};
if (LLVM_UNLIKELY(
getComputedPrimitiveDescriptor(
selfHandle, runtime, nameValPrimitiveHandle, propObj, desc) ==
ExecutionStatus::EXCEPTION)) {
return ExecutionStatus::EXCEPTION;
}
if (!propObj)
return createPseudoHandle(HermesValue::encodeUndefinedValue());
if (LLVM_LIKELY(
!desc.flags.accessor && !desc.flags.hostObject &&
!desc.flags.proxyObject))
return createPseudoHandle(
getComputedSlotValue(propObj.get(), runtime, desc));
if (desc.flags.accessor) {
auto *accessor = vmcast<PropertyAccessor>(
getComputedSlotValue(propObj.get(), runtime, desc));
if (!accessor->getter)
return createPseudoHandle(HermesValue::encodeUndefinedValue());
// Execute the accessor on this object.
return accessor->getter.get(runtime)->executeCall0(
runtime->makeHandle(accessor->getter), runtime, receiver);
} else if (desc.flags.hostObject) {
SymbolID id{};
LAZY_TO_IDENTIFIER(runtime, nameValPrimitiveHandle, id);
auto propRes = vmcast<HostObject>(selfHandle.get())->get(id);
if (propRes == ExecutionStatus::EXCEPTION)
return ExecutionStatus::EXCEPTION;
return createPseudoHandle(*propRes);
} else {
assert(desc.flags.proxyObject && "descriptor flags are impossible");
CallResult<Handle<>> key = toPropertyKey(runtime, nameValPrimitiveHandle);
if (key == ExecutionStatus::EXCEPTION)
return ExecutionStatus::EXCEPTION;
return JSProxy::getComputed(propObj, runtime, *key, receiver);
}
} | 417 | True | 1 |
CVE-2020-1912 | False | False | False | False | AV:N/AC:M/Au:N/C:P/I:P/A:P | NETWORK | MEDIUM | NONE | PARTIAL | PARTIAL | PARTIAL | 6.8 | CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H | NETWORK | HIGH | NONE | NONE | UNCHANGED | HIGH | HIGH | HIGH | 8.1 | HIGH | 2.2 | 5.9 | False | [{'url': 'https://github.com/facebook/hermes/commit/091835377369c8fd5917d9b87acffa721ad2a168', 'name': 'https://github.com/facebook/hermes/commit/091835377369c8fd5917d9b87acffa721ad2a168', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://www.facebook.com/security/advisories/cve-2020-1912', 'name': 'https://www.facebook.com/security/advisories/cve-2020-1912', 'refsource': 'CONFIRM', 'tags': ['Vendor Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}, {'lang': 'en', 'value': 'CWE-787'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:facebook:hermes:*:*:*:*:*:*:*:*', 'versionEndIncluding': '0.4.3', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'An out-of-bounds read/write vulnerability when executing lazily compiled inner generator functions in Facebook Hermes prior to commit 091835377369c8fd5917d9b87acffa721ad2a168 allows attackers to potentially execute arbitrary code via crafted JavaScript. Note that this is only exploitable if the application using Hermes permits evaluation of untrusted JavaScript. Hence, most React Native applications are not affected.'}] | 2020-09-15T15:07Z | 2020-09-09T19:15Z | Out-of-bounds Read | The software reads data past the end, or before the beginning, of the intended buffer. | Typically, this can allow attackers to read sensitive information from other memory locations or cause a crash. A crash can occur when the code reads a variable amount of data and assumes that a sentinel exists to stop the read operation, such as a NUL in a string. The expected sentinel might not be located in the out-of-bounds memory, causing excessive data to be read, leading to a segmentation fault or a buffer overflow. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent read operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/125.html | 0 | Will Holen | 2020-09-08 14:27:55-07:00 | Correctly restore whether or not a function is an inner generator
Summary:
If a generator was large enough to be lazily compiled, we would lose
that information when reconstituting the function's context. This meant
the function was generated as a regular function instead of a generator.
#utd-hermes-ignore-android
Reviewed By: tmikov
Differential Revision: D23580247
fbshipit-source-id: af5628bf322cbdc7c7cdfbb5f8d0756328518ea1 | 091835377369c8fd5917d9b87acffa721ad2a168 | False | facebook/hermes | A JavaScript engine optimized for running React Native. | 2018-10-22 19:13:00 | 2022-08-27 17:16:04 | https://hermesengine.dev/ | facebook | 7427.0 | 453.0 | hermes::irgen::ESTreeIRGen::genGeneratorFunction | hermes::irgen::ESTreeIRGen::genGeneratorFunction( Identifier originalName , Variable * lazyClosureAlias , ESTree :: FunctionLikeNode * functionNode) | ['originalName', 'lazyClosureAlias', 'functionNode'] | Function *ESTreeIRGen::genGeneratorFunction(
Identifier originalName,
Variable *lazyClosureAlias,
ESTree::FunctionLikeNode *functionNode) {
assert(functionNode && "Function AST cannot be null");
// Build the outer function which creates the generator.
// Does not have an associated source range.
auto *outerFn = Builder.createGeneratorFunction(
originalName,
Function::DefinitionKind::ES5Function,
ESTree::isStrict(functionNode->strictness),
/* insertBefore */ nullptr);
auto *innerFn = genES5Function(
genAnonymousLabelName(originalName.isValid() ? originalName.str() : ""),
lazyClosureAlias,
functionNode,
true);
{
FunctionContext outerFnContext{this, outerFn, functionNode->getSemInfo()};
emitFunctionPrologue(
functionNode,
Builder.createBasicBlock(outerFn),
InitES5CaptureState::Yes,
DoEmitParameters::No);
// Create a generator function, which will store the arguments.
auto *gen = Builder.createCreateGeneratorInst(innerFn);
if (!hasSimpleParams(functionNode)) {
// If there are non-simple params, step the inner function once to
// initialize them.
Value *next = Builder.createLoadPropertyInst(gen, "next");
Builder.createCallInst(next, gen, {});
}
emitFunctionEpilogue(gen);
}
return outerFn;
} | 174 | True | 1 |
CVE-2020-1912 | False | False | False | False | AV:N/AC:M/Au:N/C:P/I:P/A:P | NETWORK | MEDIUM | NONE | PARTIAL | PARTIAL | PARTIAL | 6.8 | CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H | NETWORK | HIGH | NONE | NONE | UNCHANGED | HIGH | HIGH | HIGH | 8.1 | HIGH | 2.2 | 5.9 | False | [{'url': 'https://github.com/facebook/hermes/commit/091835377369c8fd5917d9b87acffa721ad2a168', 'name': 'https://github.com/facebook/hermes/commit/091835377369c8fd5917d9b87acffa721ad2a168', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://www.facebook.com/security/advisories/cve-2020-1912', 'name': 'https://www.facebook.com/security/advisories/cve-2020-1912', 'refsource': 'CONFIRM', 'tags': ['Vendor Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}, {'lang': 'en', 'value': 'CWE-787'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:facebook:hermes:*:*:*:*:*:*:*:*', 'versionEndIncluding': '0.4.3', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'An out-of-bounds read/write vulnerability when executing lazily compiled inner generator functions in Facebook Hermes prior to commit 091835377369c8fd5917d9b87acffa721ad2a168 allows attackers to potentially execute arbitrary code via crafted JavaScript. Note that this is only exploitable if the application using Hermes permits evaluation of untrusted JavaScript. Hence, most React Native applications are not affected.'}] | 2020-09-15T15:07Z | 2020-09-09T19:15Z | Out-of-bounds Write | The software writes data past the end, or before the beginning, of the intended buffer. | Typically, this can result in corruption of data, a crash, or code execution. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent write operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/787.html | 0 | Will Holen | 2020-09-08 14:27:55-07:00 | Correctly restore whether or not a function is an inner generator
Summary:
If a generator was large enough to be lazily compiled, we would lose
that information when reconstituting the function's context. This meant
the function was generated as a regular function instead of a generator.
#utd-hermes-ignore-android
Reviewed By: tmikov
Differential Revision: D23580247
fbshipit-source-id: af5628bf322cbdc7c7cdfbb5f8d0756328518ea1 | 091835377369c8fd5917d9b87acffa721ad2a168 | False | facebook/hermes | A JavaScript engine optimized for running React Native. | 2018-10-22 19:13:00 | 2022-08-27 17:16:04 | https://hermesengine.dev/ | facebook | 7427.0 | 453.0 | hermes::irgen::ESTreeIRGen::genGeneratorFunction | hermes::irgen::ESTreeIRGen::genGeneratorFunction( Identifier originalName , Variable * lazyClosureAlias , ESTree :: FunctionLikeNode * functionNode) | ['originalName', 'lazyClosureAlias', 'functionNode'] | Function *ESTreeIRGen::genGeneratorFunction(
Identifier originalName,
Variable *lazyClosureAlias,
ESTree::FunctionLikeNode *functionNode) {
assert(functionNode && "Function AST cannot be null");
// Build the outer function which creates the generator.
// Does not have an associated source range.
auto *outerFn = Builder.createGeneratorFunction(
originalName,
Function::DefinitionKind::ES5Function,
ESTree::isStrict(functionNode->strictness),
/* insertBefore */ nullptr);
auto *innerFn = genES5Function(
genAnonymousLabelName(originalName.isValid() ? originalName.str() : ""),
lazyClosureAlias,
functionNode,
true);
{
FunctionContext outerFnContext{this, outerFn, functionNode->getSemInfo()};
emitFunctionPrologue(
functionNode,
Builder.createBasicBlock(outerFn),
InitES5CaptureState::Yes,
DoEmitParameters::No);
// Create a generator function, which will store the arguments.
auto *gen = Builder.createCreateGeneratorInst(innerFn);
if (!hasSimpleParams(functionNode)) {
// If there are non-simple params, step the inner function once to
// initialize them.
Value *next = Builder.createLoadPropertyInst(gen, "next");
Builder.createCallInst(next, gen, {});
}
emitFunctionEpilogue(gen);
}
return outerFn;
} | 174 | True | 1 |
CVE-2020-1912 | False | False | False | False | AV:N/AC:M/Au:N/C:P/I:P/A:P | NETWORK | MEDIUM | NONE | PARTIAL | PARTIAL | PARTIAL | 6.8 | CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H | NETWORK | HIGH | NONE | NONE | UNCHANGED | HIGH | HIGH | HIGH | 8.1 | HIGH | 2.2 | 5.9 | False | [{'url': 'https://github.com/facebook/hermes/commit/091835377369c8fd5917d9b87acffa721ad2a168', 'name': 'https://github.com/facebook/hermes/commit/091835377369c8fd5917d9b87acffa721ad2a168', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://www.facebook.com/security/advisories/cve-2020-1912', 'name': 'https://www.facebook.com/security/advisories/cve-2020-1912', 'refsource': 'CONFIRM', 'tags': ['Vendor Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}, {'lang': 'en', 'value': 'CWE-787'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:facebook:hermes:*:*:*:*:*:*:*:*', 'versionEndIncluding': '0.4.3', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'An out-of-bounds read/write vulnerability when executing lazily compiled inner generator functions in Facebook Hermes prior to commit 091835377369c8fd5917d9b87acffa721ad2a168 allows attackers to potentially execute arbitrary code via crafted JavaScript. Note that this is only exploitable if the application using Hermes permits evaluation of untrusted JavaScript. Hence, most React Native applications are not affected.'}] | 2020-09-15T15:07Z | 2020-09-09T19:15Z | Out-of-bounds Read | The software reads data past the end, or before the beginning, of the intended buffer. | Typically, this can allow attackers to read sensitive information from other memory locations or cause a crash. A crash can occur when the code reads a variable amount of data and assumes that a sentinel exists to stop the read operation, such as a NUL in a string. The expected sentinel might not be located in the out-of-bounds memory, causing excessive data to be read, leading to a segmentation fault or a buffer overflow. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent read operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/125.html | 0 | Will Holen | 2020-09-08 14:27:55-07:00 | Correctly restore whether or not a function is an inner generator
Summary:
If a generator was large enough to be lazily compiled, we would lose
that information when reconstituting the function's context. This meant
the function was generated as a regular function instead of a generator.
#utd-hermes-ignore-android
Reviewed By: tmikov
Differential Revision: D23580247
fbshipit-source-id: af5628bf322cbdc7c7cdfbb5f8d0756328518ea1 | 091835377369c8fd5917d9b87acffa721ad2a168 | False | facebook/hermes | A JavaScript engine optimized for running React Native. | 2018-10-22 19:13:00 | 2022-08-27 17:16:04 | https://hermesengine.dev/ | facebook | 7427.0 | 453.0 | hermes::irgen::ESTreeIRGen::doLazyFunction | hermes::irgen::ESTreeIRGen::doLazyFunction( hbc :: LazyCompilationData * lazyData) | ['lazyData'] | std::pair<Function *, Function *> ESTreeIRGen::doLazyFunction(
hbc::LazyCompilationData *lazyData) {
// Create a top level function that will never be executed, because:
// 1. IRGen assumes the first function always has global scope
// 2. It serves as the root for dummy functions for lexical data
Function *topLevel = Builder.createTopLevelFunction(lazyData->strictMode, {});
FunctionContext topLevelFunctionContext{this, topLevel, nullptr};
// Save the top-level context, but ensure it doesn't outlive what it is
// pointing to.
llvh::SaveAndRestore<FunctionContext *> saveTopLevelContext(
topLevelContext, &topLevelFunctionContext);
auto *node = cast<ESTree::FunctionLikeNode>(Root);
// We restore scoping information in two separate ways:
// 1. By adding them to ExternalScopes for resolution here
// 2. By adding dummy functions for lexical scoping debug info later
//
// Instruction selection determines the delta between the ExternalScope
// and the dummy function chain, so we add the ExternalScopes with
// positive depth.
lexicalScopeChain = lazyData->parentScope;
materializeScopesInChain(
topLevel, lexicalScopeChain, getDepth(lexicalScopeChain) - 1);
// If lazyData->closureAlias is specified, we must create an alias binding
// between originalName (which must be valid) and the variable identified by
// closureAlias.
Variable *parentVar = nullptr;
if (lazyData->closureAlias.isValid()) {
assert(lazyData->originalName.isValid() && "Original name invalid");
assert(
lazyData->originalName != lazyData->closureAlias &&
"Original name must be different from the alias");
// NOTE: the closureAlias target must exist and must be a Variable.
parentVar = cast<Variable>(nameTable_.lookup(lazyData->closureAlias));
// Re-create the alias.
nameTable_.insert(lazyData->originalName, parentVar);
}
assert(
!llvh::isa<ESTree::ArrowFunctionExpressionNode>(node) &&
"lazy compilation not supported for arrow functions");
auto *func = genES5Function(lazyData->originalName, parentVar, node);
addLexicalDebugInfo(func, topLevel, lexicalScopeChain);
return {func, topLevel};
} | 208 | True | 1 |
CVE-2020-1912 | False | False | False | False | AV:N/AC:M/Au:N/C:P/I:P/A:P | NETWORK | MEDIUM | NONE | PARTIAL | PARTIAL | PARTIAL | 6.8 | CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H | NETWORK | HIGH | NONE | NONE | UNCHANGED | HIGH | HIGH | HIGH | 8.1 | HIGH | 2.2 | 5.9 | False | [{'url': 'https://github.com/facebook/hermes/commit/091835377369c8fd5917d9b87acffa721ad2a168', 'name': 'https://github.com/facebook/hermes/commit/091835377369c8fd5917d9b87acffa721ad2a168', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://www.facebook.com/security/advisories/cve-2020-1912', 'name': 'https://www.facebook.com/security/advisories/cve-2020-1912', 'refsource': 'CONFIRM', 'tags': ['Vendor Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}, {'lang': 'en', 'value': 'CWE-787'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:facebook:hermes:*:*:*:*:*:*:*:*', 'versionEndIncluding': '0.4.3', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'An out-of-bounds read/write vulnerability when executing lazily compiled inner generator functions in Facebook Hermes prior to commit 091835377369c8fd5917d9b87acffa721ad2a168 allows attackers to potentially execute arbitrary code via crafted JavaScript. Note that this is only exploitable if the application using Hermes permits evaluation of untrusted JavaScript. Hence, most React Native applications are not affected.'}] | 2020-09-15T15:07Z | 2020-09-09T19:15Z | Out-of-bounds Write | The software writes data past the end, or before the beginning, of the intended buffer. | Typically, this can result in corruption of data, a crash, or code execution. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent write operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/787.html | 0 | Will Holen | 2020-09-08 14:27:55-07:00 | Correctly restore whether or not a function is an inner generator
Summary:
If a generator was large enough to be lazily compiled, we would lose
that information when reconstituting the function's context. This meant
the function was generated as a regular function instead of a generator.
#utd-hermes-ignore-android
Reviewed By: tmikov
Differential Revision: D23580247
fbshipit-source-id: af5628bf322cbdc7c7cdfbb5f8d0756328518ea1 | 091835377369c8fd5917d9b87acffa721ad2a168 | False | facebook/hermes | A JavaScript engine optimized for running React Native. | 2018-10-22 19:13:00 | 2022-08-27 17:16:04 | https://hermesengine.dev/ | facebook | 7427.0 | 453.0 | hermes::irgen::ESTreeIRGen::doLazyFunction | hermes::irgen::ESTreeIRGen::doLazyFunction( hbc :: LazyCompilationData * lazyData) | ['lazyData'] | std::pair<Function *, Function *> ESTreeIRGen::doLazyFunction(
hbc::LazyCompilationData *lazyData) {
// Create a top level function that will never be executed, because:
// 1. IRGen assumes the first function always has global scope
// 2. It serves as the root for dummy functions for lexical data
Function *topLevel = Builder.createTopLevelFunction(lazyData->strictMode, {});
FunctionContext topLevelFunctionContext{this, topLevel, nullptr};
// Save the top-level context, but ensure it doesn't outlive what it is
// pointing to.
llvh::SaveAndRestore<FunctionContext *> saveTopLevelContext(
topLevelContext, &topLevelFunctionContext);
auto *node = cast<ESTree::FunctionLikeNode>(Root);
// We restore scoping information in two separate ways:
// 1. By adding them to ExternalScopes for resolution here
// 2. By adding dummy functions for lexical scoping debug info later
//
// Instruction selection determines the delta between the ExternalScope
// and the dummy function chain, so we add the ExternalScopes with
// positive depth.
lexicalScopeChain = lazyData->parentScope;
materializeScopesInChain(
topLevel, lexicalScopeChain, getDepth(lexicalScopeChain) - 1);
// If lazyData->closureAlias is specified, we must create an alias binding
// between originalName (which must be valid) and the variable identified by
// closureAlias.
Variable *parentVar = nullptr;
if (lazyData->closureAlias.isValid()) {
assert(lazyData->originalName.isValid() && "Original name invalid");
assert(
lazyData->originalName != lazyData->closureAlias &&
"Original name must be different from the alias");
// NOTE: the closureAlias target must exist and must be a Variable.
parentVar = cast<Variable>(nameTable_.lookup(lazyData->closureAlias));
// Re-create the alias.
nameTable_.insert(lazyData->originalName, parentVar);
}
assert(
!llvh::isa<ESTree::ArrowFunctionExpressionNode>(node) &&
"lazy compilation not supported for arrow functions");
auto *func = genES5Function(lazyData->originalName, parentVar, node);
addLexicalDebugInfo(func, topLevel, lexicalScopeChain);
return {func, topLevel};
} | 208 | True | 1 |
CVE-2020-1915 | False | False | False | False | AV:N/AC:M/Au:N/C:N/I:N/A:P | NETWORK | MEDIUM | NONE | NONE | NONE | PARTIAL | 4.3 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | NONE | NONE | HIGH | 7.5 | HIGH | 3.9 | 3.6 | False | [{'url': 'https://github.com/facebook/hermes/commit/8cb935cd3b2321c46aa6b7ed8454d95c75a7fca0', 'name': 'https://github.com/facebook/hermes/commit/8cb935cd3b2321c46aa6b7ed8454d95c75a7fca0', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://www.facebook.com/security/advisories/cve-2020-1915', 'name': 'https://www.facebook.com/security/advisories/cve-2020-1915', 'refsource': 'CONFIRM', 'tags': ['Vendor Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:facebook:hermes:*:*:*:*:*:*:*:*', 'versionEndExcluding': '2020-09-25', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'An out-of-bounds read in the JavaScript Interpreter in Facebook Hermes prior to commit 8cb935cd3b2321c46aa6b7ed8454d95c75a7fca0 allows attackers to cause a denial of service attack or possible further memory corruption via crafted JavaScript. Note that this is only exploitable if the application using Hermes permits evaluation of untrusted JavaScript. Hence, most React Native applications are not affected.'}] | 2020-11-02T16:37Z | 2020-10-26T21:15Z | Out-of-bounds Read | The software reads data past the end, or before the beginning, of the intended buffer. | Typically, this can allow attackers to read sensitive information from other memory locations or cause a crash. A crash can occur when the code reads a variable amount of data and assumes that a sentinel exists to stop the read operation, such as a NUL in a string. The expected sentinel might not be located in the out-of-bounds memory, causing excessive data to be read, leading to a segmentation fault or a buffer overflow. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent read operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/125.html | 0 | Marc Horowitz | 2020-09-25 20:52:54-07:00 | Handle set where internalSetter and Proxy are both true
Summary:
If putComputed is called on a proxy whose target's prototype
is an array with a propname of 'length', then internalSetter will be
true, and the receiver will be a proxy. In that case, proxy needs to
win; the behavior may assert or be UB otherwise.
Reviewed By: tmikov
Differential Revision: D23916279
fbshipit-source-id: c760356d48a02ece565fb4bc1acdafd7ccad7c68 | 8cb935cd3b2321c46aa6b7ed8454d95c75a7fca0 | False | facebook/hermes | A JavaScript engine optimized for running React Native. | 2018-10-22 19:13:00 | 2022-08-27 17:16:04 | https://hermesengine.dev/ | facebook | 7427.0 | 453.0 | hermes::vm::JSObject::putComputedWithReceiver_RJS | hermes::vm::JSObject::putComputedWithReceiver_RJS( Handle<JSObject> selfHandle , Runtime * runtime , Handle<> nameValHandle , Handle<> valueHandle , Handle<> receiver , PropOpFlags opFlags) | ['selfHandle', 'runtime', 'nameValHandle', 'valueHandle', 'receiver', 'opFlags'] | CallResult<bool> JSObject::putComputedWithReceiver_RJS(
Handle<JSObject> selfHandle,
Runtime *runtime,
Handle<> nameValHandle,
Handle<> valueHandle,
Handle<> receiver,
PropOpFlags opFlags) {
assert(
!opFlags.getMustExist() &&
"mustExist flag cannot be used with computed properties");
// Try the fast-path first: has "index-like" properties, the "name"
// already is a valid integer index, selfHandle and receiver are the
// same, and it is present in storage.
if (selfHandle->flags_.fastIndexProperties) {
if (auto arrayIndex = toArrayIndexFastPath(*nameValHandle)) {
if (selfHandle.getHermesValue().getRaw() == receiver->getRaw()) {
if (haveOwnIndexed(selfHandle.get(), runtime, *arrayIndex)) {
auto result =
setOwnIndexed(selfHandle, runtime, *arrayIndex, valueHandle);
if (LLVM_UNLIKELY(result == ExecutionStatus::EXCEPTION))
return ExecutionStatus::EXCEPTION;
if (LLVM_LIKELY(*result))
return true;
if (opFlags.getThrowOnError()) {
// TODO: better message.
return runtime->raiseTypeError(
"Cannot assign to read-only property");
}
return false;
}
}
}
}
// If nameValHandle is an object, we should convert it to string now,
// because toString may have side-effect, and we want to do this only
// once.
auto converted = toPropertyKeyIfObject(runtime, nameValHandle);
if (LLVM_UNLIKELY(converted == ExecutionStatus::EXCEPTION)) {
return ExecutionStatus::EXCEPTION;
}
auto nameValPrimitiveHandle = *converted;
ComputedPropertyDescriptor desc;
// Look for the property in this object or along the prototype chain.
MutableHandle<JSObject> propObj{runtime};
if (LLVM_UNLIKELY(
getComputedPrimitiveDescriptor(
selfHandle, runtime, nameValPrimitiveHandle, propObj, desc) ==
ExecutionStatus::EXCEPTION)) {
return ExecutionStatus::EXCEPTION;
}
// If the property exists (or, we hit a proxy/hostobject on the way
// up the chain)
if (propObj) {
// Get the simple case out of the way: If the property already
// exists on selfHandle, is not an accessor, selfHandle and
// receiver are the same, selfHandle is not a host
// object/proxy/internal setter, and the property is writable,
// just write into the same slot.
if (LLVM_LIKELY(
selfHandle == propObj &&
selfHandle.getHermesValue().getRaw() == receiver->getRaw() &&
!desc.flags.accessor && !desc.flags.internalSetter &&
!desc.flags.hostObject && !desc.flags.proxyObject &&
desc.flags.writable)) {
if (LLVM_UNLIKELY(
setComputedSlotValue(selfHandle, runtime, desc, valueHandle) ==
ExecutionStatus::EXCEPTION)) {
return ExecutionStatus::EXCEPTION;
}
return true;
}
// Is it an accessor?
if (LLVM_UNLIKELY(desc.flags.accessor)) {
auto *accessor = vmcast<PropertyAccessor>(
getComputedSlotValue(propObj.get(), runtime, desc));
// If it is a read-only accessor, fail.
if (!accessor->setter) {
if (opFlags.getThrowOnError()) {
return runtime->raiseTypeErrorForValue(
"Cannot assign to property ",
nameValPrimitiveHandle,
" which has only a getter");
}
return false;
}
// Execute the accessor on this object.
if (accessor->setter.get(runtime)->executeCall1(
runtime->makeHandle(accessor->setter),
runtime,
receiver,
valueHandle.get()) == ExecutionStatus::EXCEPTION) {
return ExecutionStatus::EXCEPTION;
}
return true;
}
if (LLVM_UNLIKELY(desc.flags.proxyObject)) {
assert(
!opFlags.getMustExist() &&
"MustExist cannot be used with Proxy objects");
CallResult<Handle<>> key = toPropertyKey(runtime, nameValPrimitiveHandle);
if (key == ExecutionStatus::EXCEPTION)
return ExecutionStatus::EXCEPTION;
CallResult<bool> setRes =
JSProxy::setComputed(propObj, runtime, *key, valueHandle, receiver);
if (LLVM_UNLIKELY(setRes == ExecutionStatus::EXCEPTION)) {
return ExecutionStatus::EXCEPTION;
}
if (!*setRes && opFlags.getThrowOnError()) {
// TODO: better message.
return runtime->raiseTypeError(
TwineChar16("Proxy trap returned false for property"));
}
return setRes;
}
if (LLVM_UNLIKELY(!desc.flags.writable)) {
if (desc.flags.staticBuiltin) {
SymbolID id{};
LAZY_TO_IDENTIFIER(runtime, nameValPrimitiveHandle, id);
return raiseErrorForOverridingStaticBuiltin(
selfHandle, runtime, runtime->makeHandle(id));
}
if (opFlags.getThrowOnError()) {
return runtime->raiseTypeErrorForValue(
"Cannot assign to read-only property ", nameValPrimitiveHandle, "");
}
return false;
}
if (selfHandle == propObj && desc.flags.internalSetter) {
SymbolID id{};
LAZY_TO_IDENTIFIER(runtime, nameValPrimitiveHandle, id);
return internalSetter(
selfHandle,
runtime,
id,
desc.castToNamedPropertyDescriptorRef(),
valueHandle,
opFlags);
}
}
// The property does not exist as an conventional own property on
// this object.
MutableHandle<JSObject> receiverHandle{runtime, *selfHandle};
if (selfHandle.getHermesValue().getRaw() != receiver->getRaw() ||
receiverHandle->isHostObject() || receiverHandle->isProxyObject()) {
if (selfHandle.getHermesValue().getRaw() != receiver->getRaw()) {
receiverHandle = dyn_vmcast<JSObject>(*receiver);
}
if (!receiverHandle) {
return false;
}
CallResult<bool> descDefinedRes = getOwnComputedPrimitiveDescriptor(
receiverHandle, runtime, nameValPrimitiveHandle, IgnoreProxy::No, desc);
if (LLVM_UNLIKELY(descDefinedRes == ExecutionStatus::EXCEPTION)) {
return ExecutionStatus::EXCEPTION;
}
DefinePropertyFlags dpf;
if (*descDefinedRes) {
if (LLVM_UNLIKELY(desc.flags.accessor || !desc.flags.writable)) {
return false;
}
if (LLVM_LIKELY(
!desc.flags.internalSetter && !receiverHandle->isHostObject() &&
!receiverHandle->isProxyObject())) {
if (LLVM_UNLIKELY(
setComputedSlotValue(
receiverHandle, runtime, desc, valueHandle) ==
ExecutionStatus::EXCEPTION)) {
return ExecutionStatus::EXCEPTION;
}
return true;
}
}
if (LLVM_UNLIKELY(
desc.flags.internalSetter || receiverHandle->isHostObject() ||
receiverHandle->isProxyObject())) {
SymbolID id{};
LAZY_TO_IDENTIFIER(runtime, nameValPrimitiveHandle, id);
if (desc.flags.internalSetter) {
return internalSetter(
receiverHandle,
runtime,
id,
desc.castToNamedPropertyDescriptorRef(),
valueHandle,
opFlags);
} else if (receiverHandle->isHostObject()) {
return vmcast<HostObject>(receiverHandle.get())->set(id, *valueHandle);
}
assert(
receiverHandle->isProxyObject() && "descriptor flags are impossible");
if (*descDefinedRes) {
dpf.setValue = 1;
} else {
dpf = DefinePropertyFlags::getDefaultNewPropertyFlags();
}
return JSProxy::defineOwnProperty(
receiverHandle,
runtime,
nameValPrimitiveHandle,
dpf,
valueHandle,
opFlags);
}
}
/// Can we add more properties?
if (LLVM_UNLIKELY(!receiverHandle->isExtensible())) {
if (opFlags.getThrowOnError()) {
return runtime->raiseTypeError(
"cannot add a new property"); // TODO: better message.
}
return false;
}
// If we have indexed storage we must check whether the property is an index,
// and if it is, store it in indexed storage.
if (receiverHandle->flags_.indexedStorage) {
OptValue<uint32_t> arrayIndex;
MutableHandle<StringPrimitive> strPrim{runtime};
TO_ARRAY_INDEX(runtime, nameValPrimitiveHandle, strPrim, arrayIndex);
if (arrayIndex) {
// Check whether we need to update array's ".length" property.
if (auto *array = dyn_vmcast<JSArray>(receiverHandle.get())) {
if (LLVM_UNLIKELY(*arrayIndex >= JSArray::getLength(array))) {
auto cr = putNamed_RJS(
receiverHandle,
runtime,
Predefined::getSymbolID(Predefined::length),
runtime->makeHandle(
HermesValue::encodeNumberValue(*arrayIndex + 1)),
opFlags);
if (LLVM_UNLIKELY(cr == ExecutionStatus::EXCEPTION))
return ExecutionStatus::EXCEPTION;
if (LLVM_UNLIKELY(!*cr))
return false;
}
}
auto result =
setOwnIndexed(receiverHandle, runtime, *arrayIndex, valueHandle);
if (LLVM_UNLIKELY(result == ExecutionStatus::EXCEPTION))
return ExecutionStatus::EXCEPTION;
if (LLVM_LIKELY(*result))
return true;
if (opFlags.getThrowOnError()) {
// TODO: better message.
return runtime->raiseTypeError("Cannot assign to read-only property");
}
return false;
}
}
SymbolID id{};
LAZY_TO_IDENTIFIER(runtime, nameValPrimitiveHandle, id);
// Add a new named property.
return addOwnProperty(
receiverHandle,
runtime,
id,
DefinePropertyFlags::getDefaultNewPropertyFlags(),
valueHandle,
opFlags);
} | 1350 | True | 1 |
CVE-2020-1914 | False | False | False | False | AV:N/AC:L/Au:N/C:P/I:P/A:P | NETWORK | LOW | NONE | PARTIAL | PARTIAL | PARTIAL | 7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | HIGH | HIGH | HIGH | 9.8 | CRITICAL | 3.9 | 5.9 | False | [{'url': 'https://www.facebook.com/security/advisories/cve-2020-1914', 'name': 'https://www.facebook.com/security/advisories/cve-2020-1914', 'refsource': 'CONFIRM', 'tags': ['Vendor Advisory']}, {'url': 'https://github.com/facebook/hermes/commit/b2021df620824627f5a8c96615edbd1eb7fdddfc', 'name': 'https://github.com/facebook/hermes/commit/b2021df620824627f5a8c96615edbd1eb7fdddfc', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-670'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:facebook:hermes:*:*:*:*:*:*:*:*', 'versionEndExcluding': '2020-10-01', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'A logic vulnerability when handling the SaveGeneratorLong instruction in Facebook Hermes prior to commit b2021df620824627f5a8c96615edbd1eb7fdddfc allows attackers to potentially read out of bounds or theoretically execute arbitrary code via crafted JavaScript. Note that this is only exploitable if the application using Hermes permits evaluation of untrusted JavaScript. Hence, most React Native applications are not affected.'}] | 2020-10-20T18:28Z | 2020-10-08T19:15Z | Always-Incorrect Control Flow Implementation | The code contains a control flow path that does not reflect the algorithm that the path is intended to implement, leading to incorrect behavior any time this path is navigated. | This weakness captures cases in which a particular code segment is always incorrect with respect to the algorithm that it is implementing. For example, if a C programmer intends to include multiple statements in a single block but does not include the enclosing braces (CWE-483), then the logic is always incorrect. This issue is in contrast to most weaknesses in which the code usually behaves correctly, except when it is externally manipulated in malicious ways.
| https://cwe.mitre.org/data/definitions/670.html | 0 | Riley Dulin | 2020-10-01 09:38:50-07:00 | Fix CVE-2020-1914 by using NEXTINST for SaveGeneratorLong
Summary:
If `SaveGeneratorLong` was emitted, it would accidentally jump to the
wrong next instruction, based on how long SaveGenerator was.
Make a callout function to handle the common case, and handle the dispatch
within each case of the interpreter loop.
Fixes CVE-2020-1914
Reviewed By: neildhar
Differential Revision: D24024242
fbshipit-source-id: 3bcb88daa740f0d50e91771a49eb212551ce8bd8 | b2021df620824627f5a8c96615edbd1eb7fdddfc | False | facebook/hermes | A JavaScript engine optimized for running React Native. | 2018-10-22 19:13:00 | 2022-08-27 17:16:04 | https://hermesengine.dev/ | facebook | 7427.0 | 453.0 | hermes::vm::Interpreter::interpretFunction | hermes::vm::Interpreter::interpretFunction( Runtime * runtime , InterpreterState & state) | ['runtime', 'state'] | CallResult<HermesValue> Interpreter::interpretFunction(
Runtime *runtime,
InterpreterState &state) {
// The interepter is re-entrant and also saves/restores its IP via the runtime
// whenever a call out is made (see the CAPTURE_IP_* macros). As such, failure
// to preserve the IP across calls to interpeterFunction() disrupt interpreter
// calls further up the C++ callstack. The RAII utility class below makes sure
// we always do this correctly.
//
// TODO: The IPs stored in the C++ callstack via this holder will generally be
// the same as in the JS stack frames via the Saved IP field. We can probably
// get rid of one of these redundant stores. Doing this isn't completely
// trivial as there are currently cases where we re-enter the interpreter
// without calling Runtime::saveCallerIPInStackFrame(), and there are features
// (I think mostly the debugger + stack traces) which implicitly rely on
// this behavior. At least their tests break if this behavior is not
// preserved.
struct IPSaver {
IPSaver(Runtime *runtime)
: ip_(runtime->getCurrentIP()), runtime_(runtime) {}
~IPSaver() {
runtime_->setCurrentIP(ip_);
}
private:
const Inst *ip_;
Runtime *runtime_;
};
IPSaver ipSaver(runtime);
#ifndef HERMES_ENABLE_DEBUGGER
static_assert(!SingleStep, "can't use single-step mode without the debugger");
#endif
// Make sure that the cache can use an optimization by avoiding a branch to
// access the property storage.
static_assert(
HiddenClass::kDictionaryThreshold <=
SegmentedArray::kValueToSegmentThreshold,
"Cannot avoid branches in cache check if the dictionary "
"crossover point is larger than the inline storage");
CodeBlock *curCodeBlock = state.codeBlock;
const Inst *ip = nullptr;
// Holds runtime->currentFrame_.ptr()-1 which is the first local
// register. This eliminates the indirect load from Runtime and the -1 offset.
PinnedHermesValue *frameRegs;
// Strictness of current function.
bool strictMode;
// Default flags when accessing properties.
PropOpFlags defaultPropOpFlags;
// These CAPTURE_IP* macros should wrap around any major calls out of the
// interpeter loop. They stash and retrieve the IP via the current Runtime
// allowing the IP to be externally observed and even altered to change the flow
// of execution. Explicitly saving AND restoring the IP from the Runtime in this
// way means the C++ compiler will keep IP in a register within the rest of the
// interpeter loop.
//
// When assertions are enabled we take the extra step of "invalidating" the IP
// between captures so we can detect if it's erroneously accessed.
//
// In some cases we explicitly don't want to invalidate the IP and instead want
// it to stay set. For this we use the *NO_INVALIDATE variants. This comes up
// when we're performing a call operation which may re-enter the interpeter
// loop, and so need the IP available for the saveCallerIPInStackFrame() call
// when we next enter.
#define CAPTURE_IP_ASSIGN_NO_INVALIDATE(dst, expr) \
runtime->setCurrentIP(ip); \
dst = expr; \
ip = runtime->getCurrentIP();
#ifdef NDEBUG
#define CAPTURE_IP(expr) \
runtime->setCurrentIP(ip); \
(void)expr; \
ip = runtime->getCurrentIP();
#define CAPTURE_IP_ASSIGN(dst, expr) CAPTURE_IP_ASSIGN_NO_INVALIDATE(dst, expr)
#else // !NDEBUG
#define CAPTURE_IP(expr) \
runtime->setCurrentIP(ip); \
(void)expr; \
ip = runtime->getCurrentIP(); \
runtime->invalidateCurrentIP();
#define CAPTURE_IP_ASSIGN(dst, expr) \
runtime->setCurrentIP(ip); \
dst = expr; \
ip = runtime->getCurrentIP(); \
runtime->invalidateCurrentIP();
#endif // NDEBUG
LLVM_DEBUG(dbgs() << "interpretFunction() called\n");
ScopedNativeDepthTracker depthTracker{runtime};
if (LLVM_UNLIKELY(depthTracker.overflowed())) {
return runtime->raiseStackOverflow(Runtime::StackOverflowKind::NativeStack);
}
if (!SingleStep) {
if (auto jitPtr = runtime->jitContext_.compile(runtime, curCodeBlock)) {
return (*jitPtr)(runtime);
}
}
GCScope gcScope(runtime);
// Avoid allocating a handle dynamically by reusing this one.
MutableHandle<> tmpHandle(runtime);
CallResult<HermesValue> res{ExecutionStatus::EXCEPTION};
CallResult<PseudoHandle<>> resPH{ExecutionStatus::EXCEPTION};
CallResult<Handle<Arguments>> resArgs{ExecutionStatus::EXCEPTION};
CallResult<bool> boolRes{ExecutionStatus::EXCEPTION};
// Mark the gcScope so we can clear all allocated handles.
// Remember how many handles the scope has so we can clear them in the loop.
static constexpr unsigned KEEP_HANDLES = 1;
assert(
gcScope.getHandleCountDbg() == KEEP_HANDLES &&
"scope has unexpected number of handles");
INIT_OPCODE_PROFILER;
#if !defined(HERMESVM_PROFILER_EXTERN)
tailCall:
#endif
PROFILER_ENTER_FUNCTION(curCodeBlock);
#ifdef HERMES_ENABLE_DEBUGGER
runtime->getDebugger().willEnterCodeBlock(curCodeBlock);
#endif
runtime->getCodeCoverageProfiler().markExecuted(runtime, curCodeBlock);
// Update function executionCount_ count
curCodeBlock->incrementExecutionCount();
if (!SingleStep) {
auto newFrame = runtime->setCurrentFrameToTopOfStack();
runtime->saveCallerIPInStackFrame();
#ifndef NDEBUG
runtime->invalidateCurrentIP();
#endif
// Point frameRegs to the first register in the new frame. Note that at this
// moment technically it points above the top of the stack, but we are never
// going to access it.
frameRegs = &newFrame.getFirstLocalRef();
#ifndef NDEBUG
LLVM_DEBUG(
dbgs() << "function entry: stackLevel=" << runtime->getStackLevel()
<< ", argCount=" << runtime->getCurrentFrame().getArgCount()
<< ", frameSize=" << curCodeBlock->getFrameSize() << "\n");
LLVM_DEBUG(
dbgs() << " callee "
<< DumpHermesValue(
runtime->getCurrentFrame().getCalleeClosureOrCBRef())
<< "\n");
LLVM_DEBUG(
dbgs() << " this "
<< DumpHermesValue(runtime->getCurrentFrame().getThisArgRef())
<< "\n");
for (uint32_t i = 0; i != runtime->getCurrentFrame()->getArgCount(); ++i) {
LLVM_DEBUG(
dbgs() << " " << llvh::format_decimal(i, 4) << " "
<< DumpHermesValue(runtime->getCurrentFrame().getArgRef(i))
<< "\n");
}
#endif
// Allocate the registers for the new frame.
if (LLVM_UNLIKELY(!runtime->checkAndAllocStack(
curCodeBlock->getFrameSize() +
StackFrameLayout::CalleeExtraRegistersAtStart,
HermesValue::encodeUndefinedValue())))
goto stackOverflow;
ip = (Inst const *)curCodeBlock->begin();
// Check for invalid invocation.
if (LLVM_UNLIKELY(curCodeBlock->getHeaderFlags().isCallProhibited(
newFrame.isConstructorCall()))) {
if (!newFrame.isConstructorCall()) {
CAPTURE_IP(
runtime->raiseTypeError("Class constructor invoked without new"));
} else {
CAPTURE_IP(runtime->raiseTypeError("Function is not a constructor"));
}
goto handleExceptionInParent;
}
} else {
// Point frameRegs to the first register in the frame.
frameRegs = &runtime->getCurrentFrame().getFirstLocalRef();
ip = (Inst const *)(curCodeBlock->begin() + state.offset);
}
assert((const uint8_t *)ip < curCodeBlock->end() && "CodeBlock is empty");
INIT_STATE_FOR_CODEBLOCK(curCodeBlock);
#define BEFORE_OP_CODE \
{ \
UPDATE_OPCODE_TIME_SPENT; \
HERMES_SLOW_ASSERT( \
curCodeBlock->contains(ip) && "curCodeBlock must contain ip"); \
HERMES_SLOW_ASSERT((printDebugInfo(curCodeBlock, frameRegs, ip), true)); \
HERMES_SLOW_ASSERT( \
gcScope.getHandleCountDbg() == KEEP_HANDLES && \
"unaccounted handles were created"); \
HERMES_SLOW_ASSERT(tmpHandle->isUndefined() && "tmpHandle not cleared"); \
RECORD_OPCODE_START_TIME; \
INC_OPCODE_COUNT; \
}
#ifdef HERMESVM_INDIRECT_THREADING
static void *opcodeDispatch[] = {
#define DEFINE_OPCODE(name) &&case_##name,
#include "hermes/BCGen/HBC/BytecodeList.def"
&&case__last};
#define CASE(name) case_##name:
#define DISPATCH \
BEFORE_OP_CODE; \
if (SingleStep) { \
state.codeBlock = curCodeBlock; \
state.offset = CUROFFSET; \
return HermesValue::encodeUndefinedValue(); \
} \
goto *opcodeDispatch[(unsigned)ip->opCode]
#else // HERMESVM_INDIRECT_THREADING
#define CASE(name) case OpCode::name:
#define DISPATCH \
if (SingleStep) { \
state.codeBlock = curCodeBlock; \
state.offset = CUROFFSET; \
return HermesValue::encodeUndefinedValue(); \
} \
continue
#endif // HERMESVM_INDIRECT_THREADING
#define RUN_DEBUGGER_ASYNC_BREAK(flags) \
do { \
CAPTURE_IP_ASSIGN( \
auto dRes, \
runDebuggerUpdatingState( \
(uint8_t)(flags) & \
(uint8_t)Runtime::AsyncBreakReasonBits::DebuggerExplicit \
? Debugger::RunReason::AsyncBreakExplicit \
: Debugger::RunReason::AsyncBreakImplicit, \
runtime, \
curCodeBlock, \
ip, \
frameRegs)); \
if (dRes == ExecutionStatus::EXCEPTION) \
goto exception; \
} while (0)
for (;;) {
BEFORE_OP_CODE;
#ifdef HERMESVM_INDIRECT_THREADING
goto *opcodeDispatch[(unsigned)ip->opCode];
#else
switch (ip->opCode)
#endif
{
const Inst *nextIP;
uint32_t idVal;
bool tryProp;
uint32_t callArgCount;
// This is HermesValue::getRaw(), since HermesValue cannot be assigned
// to. It is meant to be used only for very short durations, in the
// dispatch of call instructions, when there is definitely no possibility
// of a GC.
HermesValue::RawType callNewTarget;
/// Handle an opcode \p name with an out-of-line implementation in a function
/// ExecutionStatus caseName(
/// Runtime *,
/// PinnedHermesValue *frameRegs,
/// Inst *ip)
#define CASE_OUTOFLINE(name) \
CASE(name) { \
CAPTURE_IP_ASSIGN(auto res, case##name(runtime, frameRegs, ip)); \
if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) { \
goto exception; \
} \
gcScope.flushToSmallCount(KEEP_HANDLES); \
ip = NEXTINST(name); \
DISPATCH; \
}
/// Implement a binary arithmetic instruction with a fast path where both
/// operands are numbers.
/// \param name the name of the instruction. The fast path case will have a
/// "n" appended to the name.
/// \param oper the C++ operator to use to actually perform the arithmetic
/// operation.
#define BINOP(name, oper) \
CASE(name) { \
if (LLVM_LIKELY(O2REG(name).isNumber() && O3REG(name).isNumber())) { \
/* Fast-path. */ \
CASE(name##N) { \
O1REG(name) = HermesValue::encodeDoubleValue( \
oper(O2REG(name).getNumber(), O3REG(name).getNumber())); \
ip = NEXTINST(name); \
DISPATCH; \
} \
} \
CAPTURE_IP_ASSIGN(res, toNumber_RJS(runtime, Handle<>(&O2REG(name)))); \
if (res == ExecutionStatus::EXCEPTION) \
goto exception; \
double left = res->getDouble(); \
CAPTURE_IP_ASSIGN(res, toNumber_RJS(runtime, Handle<>(&O3REG(name)))); \
if (res == ExecutionStatus::EXCEPTION) \
goto exception; \
O1REG(name) = \
HermesValue::encodeDoubleValue(oper(left, res->getDouble())); \
gcScope.flushToSmallCount(KEEP_HANDLES); \
ip = NEXTINST(name); \
DISPATCH; \
}
/// Implement a shift instruction with a fast path where both
/// operands are numbers.
/// \param name the name of the instruction.
/// \param oper the C++ operator to use to actually perform the shift
/// operation.
/// \param lConv the conversion function for the LHS of the expression.
/// \param lType the type of the LHS operand.
/// \param returnType the type of the return value.
#define SHIFTOP(name, oper, lConv, lType, returnType) \
CASE(name) { \
if (LLVM_LIKELY( \
O2REG(name).isNumber() && \
O3REG(name).isNumber())) { /* Fast-path. */ \
auto lnum = static_cast<lType>( \
hermes::truncateToInt32(O2REG(name).getNumber())); \
auto rnum = static_cast<uint32_t>( \
hermes::truncateToInt32(O3REG(name).getNumber())) & \
0x1f; \
O1REG(name) = HermesValue::encodeDoubleValue( \
static_cast<returnType>(lnum oper rnum)); \
ip = NEXTINST(name); \
DISPATCH; \
} \
CAPTURE_IP_ASSIGN(res, lConv(runtime, Handle<>(&O2REG(name)))); \
if (res == ExecutionStatus::EXCEPTION) { \
goto exception; \
} \
auto lnum = static_cast<lType>(res->getNumber()); \
CAPTURE_IP_ASSIGN(res, toUInt32_RJS(runtime, Handle<>(&O3REG(name)))); \
if (res == ExecutionStatus::EXCEPTION) { \
goto exception; \
} \
auto rnum = static_cast<uint32_t>(res->getNumber()) & 0x1f; \
gcScope.flushToSmallCount(KEEP_HANDLES); \
O1REG(name) = HermesValue::encodeDoubleValue( \
static_cast<returnType>(lnum oper rnum)); \
ip = NEXTINST(name); \
DISPATCH; \
}
/// Implement a binary bitwise instruction with a fast path where both
/// operands are numbers.
/// \param name the name of the instruction.
/// \param oper the C++ operator to use to actually perform the bitwise
/// operation.
#define BITWISEBINOP(name, oper) \
CASE(name) { \
if (LLVM_LIKELY(O2REG(name).isNumber() && O3REG(name).isNumber())) { \
/* Fast-path. */ \
O1REG(name) = HermesValue::encodeDoubleValue( \
hermes::truncateToInt32(O2REG(name).getNumber()) \
oper hermes::truncateToInt32(O3REG(name).getNumber())); \
ip = NEXTINST(name); \
DISPATCH; \
} \
CAPTURE_IP_ASSIGN(res, toInt32_RJS(runtime, Handle<>(&O2REG(name)))); \
if (res == ExecutionStatus::EXCEPTION) { \
goto exception; \
} \
int32_t left = res->getNumberAs<int32_t>(); \
CAPTURE_IP_ASSIGN(res, toInt32_RJS(runtime, Handle<>(&O3REG(name)))); \
if (res == ExecutionStatus::EXCEPTION) { \
goto exception; \
} \
O1REG(name) = \
HermesValue::encodeNumberValue(left oper res->getNumberAs<int32_t>()); \
gcScope.flushToSmallCount(KEEP_HANDLES); \
ip = NEXTINST(name); \
DISPATCH; \
}
/// Implement a comparison instruction.
/// \param name the name of the instruction.
/// \param oper the C++ operator to use to actually perform the fast arithmetic
/// comparison.
/// \param operFuncName function to call for the slow-path comparison.
#define CONDOP(name, oper, operFuncName) \
CASE(name) { \
if (LLVM_LIKELY(O2REG(name).isNumber() && O3REG(name).isNumber())) { \
/* Fast-path. */ \
O1REG(name) = HermesValue::encodeBoolValue( \
O2REG(name).getNumber() oper O3REG(name).getNumber()); \
ip = NEXTINST(name); \
DISPATCH; \
} \
CAPTURE_IP_ASSIGN( \
boolRes, \
operFuncName( \
runtime, Handle<>(&O2REG(name)), Handle<>(&O3REG(name)))); \
if (boolRes == ExecutionStatus::EXCEPTION) \
goto exception; \
gcScope.flushToSmallCount(KEEP_HANDLES); \
O1REG(name) = HermesValue::encodeBoolValue(boolRes.getValue()); \
ip = NEXTINST(name); \
DISPATCH; \
}
/// Implement a comparison conditional jump with a fast path where both
/// operands are numbers.
/// \param name the name of the instruction. The fast path case will have a
/// "N" appended to the name.
/// \param suffix Optional suffix to be added to the end (e.g. Long)
/// \param oper the C++ operator to use to actually perform the fast arithmetic
/// comparison.
/// \param operFuncName function to call for the slow-path comparison.
/// \param trueDest ip value if the conditional evaluates to true
/// \param falseDest ip value if the conditional evaluates to false
#define JCOND_IMPL(name, suffix, oper, operFuncName, trueDest, falseDest) \
CASE(name##suffix) { \
if (LLVM_LIKELY( \
O2REG(name##suffix).isNumber() && \
O3REG(name##suffix).isNumber())) { \
/* Fast-path. */ \
CASE(name##N##suffix) { \
if (O2REG(name##N##suffix) \
.getNumber() oper O3REG(name##N##suffix) \
.getNumber()) { \
ip = trueDest; \
DISPATCH; \
} \
ip = falseDest; \
DISPATCH; \
} \
} \
CAPTURE_IP_ASSIGN( \
boolRes, \
operFuncName( \
runtime, \
Handle<>(&O2REG(name##suffix)), \
Handle<>(&O3REG(name##suffix)))); \
if (boolRes == ExecutionStatus::EXCEPTION) \
goto exception; \
gcScope.flushToSmallCount(KEEP_HANDLES); \
if (boolRes.getValue()) { \
ip = trueDest; \
DISPATCH; \
} \
ip = falseDest; \
DISPATCH; \
}
/// Implement a strict equality conditional jump
/// \param name the name of the instruction.
/// \param suffix Optional suffix to be added to the end (e.g. Long)
/// \param trueDest ip value if the conditional evaluates to true
/// \param falseDest ip value if the conditional evaluates to false
#define JCOND_STRICT_EQ_IMPL(name, suffix, trueDest, falseDest) \
CASE(name##suffix) { \
if (strictEqualityTest(O2REG(name##suffix), O3REG(name##suffix))) { \
ip = trueDest; \
DISPATCH; \
} \
ip = falseDest; \
DISPATCH; \
}
/// Implement an equality conditional jump
/// \param name the name of the instruction.
/// \param suffix Optional suffix to be added to the end (e.g. Long)
/// \param trueDest ip value if the conditional evaluates to true
/// \param falseDest ip value if the conditional evaluates to false
#define JCOND_EQ_IMPL(name, suffix, trueDest, falseDest) \
CASE(name##suffix) { \
CAPTURE_IP_ASSIGN( \
res, \
abstractEqualityTest_RJS( \
runtime, \
Handle<>(&O2REG(name##suffix)), \
Handle<>(&O3REG(name##suffix)))); \
if (res == ExecutionStatus::EXCEPTION) { \
goto exception; \
} \
gcScope.flushToSmallCount(KEEP_HANDLES); \
if (res->getBool()) { \
ip = trueDest; \
DISPATCH; \
} \
ip = falseDest; \
DISPATCH; \
}
/// Implement the long and short forms of a conditional jump, and its negation.
#define JCOND(name, oper, operFuncName) \
JCOND_IMPL( \
J##name, \
, \
oper, \
operFuncName, \
IPADD(ip->iJ##name.op1), \
NEXTINST(J##name)); \
JCOND_IMPL( \
J##name, \
Long, \
oper, \
operFuncName, \
IPADD(ip->iJ##name##Long.op1), \
NEXTINST(J##name##Long)); \
JCOND_IMPL( \
JNot##name, \
, \
oper, \
operFuncName, \
NEXTINST(JNot##name), \
IPADD(ip->iJNot##name.op1)); \
JCOND_IMPL( \
JNot##name, \
Long, \
oper, \
operFuncName, \
NEXTINST(JNot##name##Long), \
IPADD(ip->iJNot##name##Long.op1));
/// Load a constant.
/// \param value is the value to store in the output register.
#define LOAD_CONST(name, value) \
CASE(name) { \
O1REG(name) = value; \
ip = NEXTINST(name); \
DISPATCH; \
}
#define LOAD_CONST_CAPTURE_IP(name, value) \
CASE(name) { \
CAPTURE_IP_ASSIGN(O1REG(name), value); \
ip = NEXTINST(name); \
DISPATCH; \
}
CASE(Mov) {
O1REG(Mov) = O2REG(Mov);
ip = NEXTINST(Mov);
DISPATCH;
}
CASE(MovLong) {
O1REG(MovLong) = O2REG(MovLong);
ip = NEXTINST(MovLong);
DISPATCH;
}
CASE(LoadParam) {
if (LLVM_LIKELY(ip->iLoadParam.op2 <= FRAME.getArgCount())) {
// index 0 must load 'this'. Index 1 the first argument, etc.
O1REG(LoadParam) = FRAME.getArgRef((int32_t)ip->iLoadParam.op2 - 1);
ip = NEXTINST(LoadParam);
DISPATCH;
}
O1REG(LoadParam) = HermesValue::encodeUndefinedValue();
ip = NEXTINST(LoadParam);
DISPATCH;
}
CASE(LoadParamLong) {
if (LLVM_LIKELY(ip->iLoadParamLong.op2 <= FRAME.getArgCount())) {
// index 0 must load 'this'. Index 1 the first argument, etc.
O1REG(LoadParamLong) =
FRAME.getArgRef((int32_t)ip->iLoadParamLong.op2 - 1);
ip = NEXTINST(LoadParamLong);
DISPATCH;
}
O1REG(LoadParamLong) = HermesValue::encodeUndefinedValue();
ip = NEXTINST(LoadParamLong);
DISPATCH;
}
CASE(CoerceThisNS) {
if (LLVM_LIKELY(O2REG(CoerceThisNS).isObject())) {
O1REG(CoerceThisNS) = O2REG(CoerceThisNS);
} else if (
O2REG(CoerceThisNS).isNull() || O2REG(CoerceThisNS).isUndefined()) {
O1REG(CoerceThisNS) = runtime->global_;
} else {
tmpHandle = O2REG(CoerceThisNS);
nextIP = NEXTINST(CoerceThisNS);
goto coerceThisSlowPath;
}
ip = NEXTINST(CoerceThisNS);
DISPATCH;
}
CASE(LoadThisNS) {
if (LLVM_LIKELY(FRAME.getThisArgRef().isObject())) {
O1REG(LoadThisNS) = FRAME.getThisArgRef();
} else if (
FRAME.getThisArgRef().isNull() ||
FRAME.getThisArgRef().isUndefined()) {
O1REG(LoadThisNS) = runtime->global_;
} else {
tmpHandle = FRAME.getThisArgRef();
nextIP = NEXTINST(LoadThisNS);
goto coerceThisSlowPath;
}
ip = NEXTINST(LoadThisNS);
DISPATCH;
}
coerceThisSlowPath : {
CAPTURE_IP_ASSIGN(res, toObject(runtime, tmpHandle));
if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) {
goto exception;
}
O1REG(CoerceThisNS) = res.getValue();
tmpHandle.clear();
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = nextIP;
DISPATCH;
}
CASE(ConstructLong) {
callArgCount = (uint32_t)ip->iConstructLong.op3;
nextIP = NEXTINST(ConstructLong);
callNewTarget = O2REG(ConstructLong).getRaw();
goto doCall;
}
CASE(CallLong) {
callArgCount = (uint32_t)ip->iCallLong.op3;
nextIP = NEXTINST(CallLong);
callNewTarget = HermesValue::encodeUndefinedValue().getRaw();
goto doCall;
}
// Note in Call1 through Call4, the first argument is 'this' which has
// argument index -1.
// Also note that we are writing to callNewTarget last, to avoid the
// possibility of it being aliased by the arg writes.
CASE(Call1) {
callArgCount = 1;
nextIP = NEXTINST(Call1);
StackFramePtr fr{runtime->stackPointer_};
fr.getArgRefUnsafe(-1) = O3REG(Call1);
callNewTarget = HermesValue::encodeUndefinedValue().getRaw();
goto doCall;
}
CASE(Call2) {
callArgCount = 2;
nextIP = NEXTINST(Call2);
StackFramePtr fr{runtime->stackPointer_};
fr.getArgRefUnsafe(-1) = O3REG(Call2);
fr.getArgRefUnsafe(0) = O4REG(Call2);
callNewTarget = HermesValue::encodeUndefinedValue().getRaw();
goto doCall;
}
CASE(Call3) {
callArgCount = 3;
nextIP = NEXTINST(Call3);
StackFramePtr fr{runtime->stackPointer_};
fr.getArgRefUnsafe(-1) = O3REG(Call3);
fr.getArgRefUnsafe(0) = O4REG(Call3);
fr.getArgRefUnsafe(1) = O5REG(Call3);
callNewTarget = HermesValue::encodeUndefinedValue().getRaw();
goto doCall;
}
CASE(Call4) {
callArgCount = 4;
nextIP = NEXTINST(Call4);
StackFramePtr fr{runtime->stackPointer_};
fr.getArgRefUnsafe(-1) = O3REG(Call4);
fr.getArgRefUnsafe(0) = O4REG(Call4);
fr.getArgRefUnsafe(1) = O5REG(Call4);
fr.getArgRefUnsafe(2) = O6REG(Call4);
callNewTarget = HermesValue::encodeUndefinedValue().getRaw();
goto doCall;
}
CASE(Construct) {
callArgCount = (uint32_t)ip->iConstruct.op3;
nextIP = NEXTINST(Construct);
callNewTarget = O2REG(Construct).getRaw();
goto doCall;
}
CASE(Call) {
callArgCount = (uint32_t)ip->iCall.op3;
nextIP = NEXTINST(Call);
callNewTarget = HermesValue::encodeUndefinedValue().getRaw();
// Fall through.
}
doCall : {
#ifdef HERMES_ENABLE_DEBUGGER
// Check for an async debugger request.
if (uint8_t asyncFlags =
runtime->testAndClearDebuggerAsyncBreakRequest()) {
RUN_DEBUGGER_ASYNC_BREAK(asyncFlags);
gcScope.flushToSmallCount(KEEP_HANDLES);
DISPATCH;
}
#endif
// Subtract 1 from callArgCount as 'this' is considered an argument in the
// instruction, but not in the frame.
CAPTURE_IP_ASSIGN_NO_INVALIDATE(
auto newFrame,
StackFramePtr::initFrame(
runtime->stackPointer_,
FRAME,
ip,
curCodeBlock,
callArgCount - 1,
O2REG(Call),
HermesValue::fromRaw(callNewTarget)));
(void)newFrame;
SLOW_DEBUG(dumpCallArguments(dbgs(), runtime, newFrame));
if (auto *func = dyn_vmcast<JSFunction>(O2REG(Call))) {
assert(!SingleStep && "can't single-step a call");
#ifdef HERMES_ENABLE_ALLOCATION_LOCATION_TRACES
runtime->pushCallStack(curCodeBlock, ip);
#endif
CodeBlock *calleeBlock = func->getCodeBlock();
calleeBlock->lazyCompile(runtime);
#if defined(HERMESVM_PROFILER_EXTERN)
CAPTURE_IP_ASSIGN_NO_INVALIDATE(
res, runtime->interpretFunction(calleeBlock));
if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) {
goto exception;
}
O1REG(Call) = *res;
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = nextIP;
DISPATCH;
#else
if (auto jitPtr = runtime->jitContext_.compile(runtime, calleeBlock)) {
res = (*jitPtr)(runtime);
if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION))
goto exception;
O1REG(Call) = *res;
SLOW_DEBUG(
dbgs() << "JIT return value r" << (unsigned)ip->iCall.op1 << "="
<< DumpHermesValue(O1REG(Call)) << "\n");
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = nextIP;
DISPATCH;
}
curCodeBlock = calleeBlock;
goto tailCall;
#endif
}
CAPTURE_IP_ASSIGN_NO_INVALIDATE(
resPH, Interpreter::handleCallSlowPath(runtime, &O2REG(Call)));
if (LLVM_UNLIKELY(resPH == ExecutionStatus::EXCEPTION)) {
goto exception;
}
O1REG(Call) = std::move(resPH->get());
SLOW_DEBUG(
dbgs() << "native return value r" << (unsigned)ip->iCall.op1 << "="
<< DumpHermesValue(O1REG(Call)) << "\n");
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = nextIP;
DISPATCH;
}
CASE(CallDirect)
CASE(CallDirectLongIndex) {
#ifdef HERMES_ENABLE_DEBUGGER
// Check for an async debugger request.
if (uint8_t asyncFlags =
runtime->testAndClearDebuggerAsyncBreakRequest()) {
RUN_DEBUGGER_ASYNC_BREAK(asyncFlags);
gcScope.flushToSmallCount(KEEP_HANDLES);
DISPATCH;
}
#endif
CAPTURE_IP_ASSIGN(
CodeBlock * calleeBlock,
ip->opCode == OpCode::CallDirect
? curCodeBlock->getRuntimeModule()->getCodeBlockMayAllocate(
ip->iCallDirect.op3)
: curCodeBlock->getRuntimeModule()->getCodeBlockMayAllocate(
ip->iCallDirectLongIndex.op3));
CAPTURE_IP_ASSIGN_NO_INVALIDATE(
auto newFrame,
StackFramePtr::initFrame(
runtime->stackPointer_,
FRAME,
ip,
curCodeBlock,
(uint32_t)ip->iCallDirect.op2 - 1,
HermesValue::encodeNativePointer(calleeBlock),
HermesValue::encodeUndefinedValue()));
(void)newFrame;
LLVM_DEBUG(dumpCallArguments(dbgs(), runtime, newFrame));
assert(!SingleStep && "can't single-step a call");
calleeBlock->lazyCompile(runtime);
#if defined(HERMESVM_PROFILER_EXTERN)
CAPTURE_IP_ASSIGN_NO_INVALIDATE(
res, runtime->interpretFunction(calleeBlock));
if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) {
goto exception;
}
O1REG(CallDirect) = *res;
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = ip->opCode == OpCode::CallDirect ? NEXTINST(CallDirect)
: NEXTINST(CallDirectLongIndex);
DISPATCH;
#else
if (auto jitPtr = runtime->jitContext_.compile(runtime, calleeBlock)) {
res = (*jitPtr)(runtime);
if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION))
goto exception;
O1REG(CallDirect) = *res;
LLVM_DEBUG(
dbgs() << "JIT return value r" << (unsigned)ip->iCallDirect.op1
<< "=" << DumpHermesValue(O1REG(Call)) << "\n");
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = ip->opCode == OpCode::CallDirect ? NEXTINST(CallDirect)
: NEXTINST(CallDirectLongIndex);
DISPATCH;
}
curCodeBlock = calleeBlock;
goto tailCall;
#endif
}
CASE(CallBuiltin) {
NativeFunction *nf =
runtime->getBuiltinNativeFunction(ip->iCallBuiltin.op2);
CAPTURE_IP_ASSIGN(
auto newFrame,
StackFramePtr::initFrame(
runtime->stackPointer_,
FRAME,
ip,
curCodeBlock,
(uint32_t)ip->iCallBuiltin.op3 - 1,
nf,
false));
// "thisArg" is implicitly assumed to "undefined".
newFrame.getThisArgRef() = HermesValue::encodeUndefinedValue();
SLOW_DEBUG(dumpCallArguments(dbgs(), runtime, newFrame));
CAPTURE_IP_ASSIGN(resPH, NativeFunction::_nativeCall(nf, runtime));
if (LLVM_UNLIKELY(resPH == ExecutionStatus::EXCEPTION))
goto exception;
O1REG(CallBuiltin) = std::move(resPH->get());
SLOW_DEBUG(
dbgs() << "native return value r" << (unsigned)ip->iCallBuiltin.op1
<< "=" << DumpHermesValue(O1REG(CallBuiltin)) << "\n");
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = NEXTINST(CallBuiltin);
DISPATCH;
}
CASE(CompleteGenerator) {
auto *innerFn = vmcast<GeneratorInnerFunction>(
runtime->getCurrentFrame().getCalleeClosure());
innerFn->setState(GeneratorInnerFunction::State::Completed);
ip = NEXTINST(CompleteGenerator);
DISPATCH;
}
CASE(SaveGenerator) {
nextIP = IPADD(ip->iSaveGenerator.op1);
goto doSaveGen;
}
CASE(SaveGeneratorLong) {
nextIP = IPADD(ip->iSaveGeneratorLong.op1);
goto doSaveGen;
}
doSaveGen : {
auto *innerFn = vmcast<GeneratorInnerFunction>(
runtime->getCurrentFrame().getCalleeClosure());
innerFn->saveStack(runtime);
innerFn->setNextIP(nextIP);
innerFn->setState(GeneratorInnerFunction::State::SuspendedYield);
ip = NEXTINST(SaveGenerator);
DISPATCH;
}
CASE(StartGenerator) {
auto *innerFn = vmcast<GeneratorInnerFunction>(
runtime->getCurrentFrame().getCalleeClosure());
if (innerFn->getState() ==
GeneratorInnerFunction::State::SuspendedStart) {
nextIP = NEXTINST(StartGenerator);
} else {
nextIP = innerFn->getNextIP();
innerFn->restoreStack(runtime);
}
innerFn->setState(GeneratorInnerFunction::State::Executing);
ip = nextIP;
DISPATCH;
}
CASE(ResumeGenerator) {
auto *innerFn = vmcast<GeneratorInnerFunction>(
runtime->getCurrentFrame().getCalleeClosure());
O1REG(ResumeGenerator) = innerFn->getResult();
O2REG(ResumeGenerator) = HermesValue::encodeBoolValue(
innerFn->getAction() == GeneratorInnerFunction::Action::Return);
innerFn->clearResult(runtime);
if (innerFn->getAction() == GeneratorInnerFunction::Action::Throw) {
runtime->setThrownValue(O1REG(ResumeGenerator));
goto exception;
}
ip = NEXTINST(ResumeGenerator);
DISPATCH;
}
CASE(Ret) {
#ifdef HERMES_ENABLE_DEBUGGER
// Check for an async debugger request.
if (uint8_t asyncFlags =
runtime->testAndClearDebuggerAsyncBreakRequest()) {
RUN_DEBUGGER_ASYNC_BREAK(asyncFlags);
gcScope.flushToSmallCount(KEEP_HANDLES);
DISPATCH;
}
#endif
PROFILER_EXIT_FUNCTION(curCodeBlock);
#ifdef HERMES_ENABLE_ALLOCATION_LOCATION_TRACES
runtime->popCallStack();
#endif
// Store the return value.
res = O1REG(Ret);
ip = FRAME.getSavedIP();
curCodeBlock = FRAME.getSavedCodeBlock();
frameRegs =
&runtime->restoreStackAndPreviousFrame(FRAME).getFirstLocalRef();
SLOW_DEBUG(
dbgs() << "function exit: restored stackLevel="
<< runtime->getStackLevel() << "\n");
// Are we returning to native code?
if (!curCodeBlock) {
SLOW_DEBUG(dbgs() << "function exit: returning to native code\n");
return res;
}
// Return because of recursive calling structure
#if defined(HERMESVM_PROFILER_EXTERN)
return res;
#endif
INIT_STATE_FOR_CODEBLOCK(curCodeBlock);
O1REG(Call) = res.getValue();
ip = nextInstCall(ip);
DISPATCH;
}
CASE(Catch) {
assert(!runtime->thrownValue_.isEmpty() && "Invalid thrown value");
assert(
!isUncatchableError(runtime->thrownValue_) &&
"Uncatchable thrown value was caught");
O1REG(Catch) = runtime->thrownValue_;
runtime->clearThrownValue();
#ifdef HERMES_ENABLE_DEBUGGER
// Signal to the debugger that we're done unwinding an exception,
// and we can resume normal debugging flow.
runtime->debugger_.finishedUnwindingException();
#endif
ip = NEXTINST(Catch);
DISPATCH;
}
CASE(Throw) {
runtime->thrownValue_ = O1REG(Throw);
SLOW_DEBUG(
dbgs() << "Exception thrown: "
<< DumpHermesValue(runtime->thrownValue_) << "\n");
goto exception;
}
CASE(ThrowIfUndefinedInst) {
if (LLVM_UNLIKELY(O1REG(ThrowIfUndefinedInst).isUndefined())) {
SLOW_DEBUG(
dbgs() << "Throwing ReferenceError for undefined variable");
CAPTURE_IP(runtime->raiseReferenceError(
"accessing an uninitialized variable"));
goto exception;
}
ip = NEXTINST(ThrowIfUndefinedInst);
DISPATCH;
}
CASE(Debugger) {
SLOW_DEBUG(dbgs() << "debugger statement executed\n");
#ifdef HERMES_ENABLE_DEBUGGER
{
if (!runtime->debugger_.isDebugging()) {
// Only run the debugger if we're not already debugging.
// Don't want to call it again and mess with its state.
CAPTURE_IP_ASSIGN(
auto res,
runDebuggerUpdatingState(
Debugger::RunReason::Opcode,
runtime,
curCodeBlock,
ip,
frameRegs));
if (res == ExecutionStatus::EXCEPTION) {
// If one of the internal steps threw,
// then handle that here by jumping to where we're supposed to go.
// If we're in mid-step, the breakpoint at the catch point
// will have been set by the debugger.
// We don't want to execute this instruction because it's already
// thrown.
goto exception;
}
}
auto breakpointOpt = runtime->debugger_.getBreakpointLocation(ip);
if (breakpointOpt.hasValue()) {
// We're on a breakpoint but we're supposed to continue.
curCodeBlock->uninstallBreakpointAtOffset(
CUROFFSET, breakpointOpt->opCode);
if (ip->opCode == OpCode::Debugger) {
// Breakpointed a debugger instruction, so move past it
// since we've already called the debugger on this instruction.
ip = NEXTINST(Debugger);
} else {
InterpreterState newState{curCodeBlock, (uint32_t)CUROFFSET};
CAPTURE_IP_ASSIGN(
ExecutionStatus status, runtime->stepFunction(newState));
curCodeBlock->installBreakpointAtOffset(CUROFFSET);
if (status == ExecutionStatus::EXCEPTION) {
goto exception;
}
curCodeBlock = newState.codeBlock;
ip = newState.codeBlock->getOffsetPtr(newState.offset);
INIT_STATE_FOR_CODEBLOCK(curCodeBlock);
// Single-stepping should handle call stack management for us.
frameRegs = &runtime->getCurrentFrame().getFirstLocalRef();
}
} else if (ip->opCode == OpCode::Debugger) {
// No breakpoint here and we've already run the debugger,
// just continue on.
// If the current instruction is no longer a debugger instruction,
// we're just going to keep executing from the current IP.
ip = NEXTINST(Debugger);
}
gcScope.flushToSmallCount(KEEP_HANDLES);
}
DISPATCH;
#else
ip = NEXTINST(Debugger);
DISPATCH;
#endif
}
CASE(AsyncBreakCheck) {
if (LLVM_UNLIKELY(runtime->hasAsyncBreak())) {
#ifdef HERMES_ENABLE_DEBUGGER
if (uint8_t asyncFlags =
runtime->testAndClearDebuggerAsyncBreakRequest()) {
RUN_DEBUGGER_ASYNC_BREAK(asyncFlags);
}
#endif
if (runtime->testAndClearTimeoutAsyncBreakRequest()) {
CAPTURE_IP_ASSIGN(auto nRes, runtime->notifyTimeout());
if (nRes == ExecutionStatus::EXCEPTION) {
goto exception;
}
}
}
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = NEXTINST(AsyncBreakCheck);
DISPATCH;
}
CASE(ProfilePoint) {
#ifdef HERMESVM_PROFILER_BB
auto pointIndex = ip->iProfilePoint.op1;
SLOW_DEBUG(llvh::dbgs() << "ProfilePoint: " << pointIndex << "\n");
CAPTURE_IP(runtime->getBasicBlockExecutionInfo().executeBlock(
curCodeBlock, pointIndex));
#endif
ip = NEXTINST(ProfilePoint);
DISPATCH;
}
CASE(Unreachable) {
llvm_unreachable("Hermes bug: unreachable instruction");
}
CASE(CreateClosure) {
idVal = ip->iCreateClosure.op3;
nextIP = NEXTINST(CreateClosure);
goto createClosure;
}
CASE(CreateClosureLongIndex) {
idVal = ip->iCreateClosureLongIndex.op3;
nextIP = NEXTINST(CreateClosureLongIndex);
goto createClosure;
}
createClosure : {
auto *runtimeModule = curCodeBlock->getRuntimeModule();
CAPTURE_IP_ASSIGN(
O1REG(CreateClosure),
JSFunction::create(
runtime,
runtimeModule->getDomain(runtime),
Handle<JSObject>::vmcast(&runtime->functionPrototype),
Handle<Environment>::vmcast(&O2REG(CreateClosure)),
runtimeModule->getCodeBlockMayAllocate(idVal))
.getHermesValue());
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = nextIP;
DISPATCH;
}
CASE(CreateGeneratorClosure) {
CAPTURE_IP_ASSIGN(
auto res,
createGeneratorClosure(
runtime,
curCodeBlock->getRuntimeModule(),
ip->iCreateClosure.op3,
Handle<Environment>::vmcast(&O2REG(CreateGeneratorClosure))));
if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) {
goto exception;
}
O1REG(CreateGeneratorClosure) = res->getHermesValue();
res->invalidate();
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = NEXTINST(CreateGeneratorClosure);
DISPATCH;
}
CASE(CreateGeneratorClosureLongIndex) {
CAPTURE_IP_ASSIGN(
auto res,
createGeneratorClosure(
runtime,
curCodeBlock->getRuntimeModule(),
ip->iCreateClosureLongIndex.op3,
Handle<Environment>::vmcast(
&O2REG(CreateGeneratorClosureLongIndex))));
if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) {
goto exception;
}
O1REG(CreateGeneratorClosureLongIndex) = res->getHermesValue();
res->invalidate();
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = NEXTINST(CreateGeneratorClosureLongIndex);
DISPATCH;
}
CASE(CreateGenerator) {
CAPTURE_IP_ASSIGN(
auto res,
createGenerator_RJS(
runtime,
curCodeBlock->getRuntimeModule(),
ip->iCreateGenerator.op3,
Handle<Environment>::vmcast(&O2REG(CreateGenerator)),
FRAME.getNativeArgs()));
if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) {
goto exception;
}
O1REG(CreateGenerator) = res->getHermesValue();
res->invalidate();
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = NEXTINST(CreateGenerator);
DISPATCH;
}
CASE(CreateGeneratorLongIndex) {
CAPTURE_IP_ASSIGN(
auto res,
createGenerator_RJS(
runtime,
curCodeBlock->getRuntimeModule(),
ip->iCreateGeneratorLongIndex.op3,
Handle<Environment>::vmcast(&O2REG(CreateGeneratorLongIndex)),
FRAME.getNativeArgs()));
if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) {
goto exception;
}
O1REG(CreateGeneratorLongIndex) = res->getHermesValue();
res->invalidate();
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = NEXTINST(CreateGeneratorLongIndex);
DISPATCH;
}
CASE(GetEnvironment) {
// The currently executing function must exist, so get the environment.
Environment *curEnv =
FRAME.getCalleeClosureUnsafe()->getEnvironment(runtime);
for (unsigned level = ip->iGetEnvironment.op2; level; --level) {
assert(curEnv && "invalid environment relative level");
curEnv = curEnv->getParentEnvironment(runtime);
}
O1REG(GetEnvironment) = HermesValue::encodeObjectValue(curEnv);
ip = NEXTINST(GetEnvironment);
DISPATCH;
}
CASE(CreateEnvironment) {
tmpHandle = HermesValue::encodeObjectValue(
FRAME.getCalleeClosureUnsafe()->getEnvironment(runtime));
CAPTURE_IP_ASSIGN(
res,
Environment::create(
runtime,
tmpHandle->getPointer() ? Handle<Environment>::vmcast(tmpHandle)
: Handle<Environment>::vmcast_or_null(
&runtime->nullPointer_),
curCodeBlock->getEnvironmentSize()));
if (res == ExecutionStatus::EXCEPTION) {
goto exception;
}
O1REG(CreateEnvironment) = *res;
#ifdef HERMES_ENABLE_DEBUGGER
FRAME.getDebugEnvironmentRef() = *res;
#endif
tmpHandle = HermesValue::encodeUndefinedValue();
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = NEXTINST(CreateEnvironment);
DISPATCH;
}
CASE(StoreToEnvironment) {
vmcast<Environment>(O1REG(StoreToEnvironment))
->slot(ip->iStoreToEnvironment.op2)
.set(O3REG(StoreToEnvironment), &runtime->getHeap());
ip = NEXTINST(StoreToEnvironment);
DISPATCH;
}
CASE(StoreToEnvironmentL) {
vmcast<Environment>(O1REG(StoreToEnvironmentL))
->slot(ip->iStoreToEnvironmentL.op2)
.set(O3REG(StoreToEnvironmentL), &runtime->getHeap());
ip = NEXTINST(StoreToEnvironmentL);
DISPATCH;
}
CASE(StoreNPToEnvironment) {
vmcast<Environment>(O1REG(StoreNPToEnvironment))
->slot(ip->iStoreNPToEnvironment.op2)
.setNonPtr(O3REG(StoreNPToEnvironment), &runtime->getHeap());
ip = NEXTINST(StoreNPToEnvironment);
DISPATCH;
}
CASE(StoreNPToEnvironmentL) {
vmcast<Environment>(O1REG(StoreNPToEnvironmentL))
->slot(ip->iStoreNPToEnvironmentL.op2)
.setNonPtr(O3REG(StoreNPToEnvironmentL), &runtime->getHeap());
ip = NEXTINST(StoreNPToEnvironmentL);
DISPATCH;
}
CASE(LoadFromEnvironment) {
O1REG(LoadFromEnvironment) =
vmcast<Environment>(O2REG(LoadFromEnvironment))
->slot(ip->iLoadFromEnvironment.op3);
ip = NEXTINST(LoadFromEnvironment);
DISPATCH;
}
CASE(LoadFromEnvironmentL) {
O1REG(LoadFromEnvironmentL) =
vmcast<Environment>(O2REG(LoadFromEnvironmentL))
->slot(ip->iLoadFromEnvironmentL.op3);
ip = NEXTINST(LoadFromEnvironmentL);
DISPATCH;
}
CASE(GetGlobalObject) {
O1REG(GetGlobalObject) = runtime->global_;
ip = NEXTINST(GetGlobalObject);
DISPATCH;
}
CASE(GetNewTarget) {
O1REG(GetNewTarget) = FRAME.getNewTargetRef();
ip = NEXTINST(GetNewTarget);
DISPATCH;
}
CASE(DeclareGlobalVar) {
DefinePropertyFlags dpf =
DefinePropertyFlags::getDefaultNewPropertyFlags();
dpf.configurable = 0;
// Do not overwrite existing globals with undefined.
dpf.setValue = 0;
CAPTURE_IP_ASSIGN(
auto res,
JSObject::defineOwnProperty(
runtime->getGlobal(),
runtime,
ID(ip->iDeclareGlobalVar.op1),
dpf,
Runtime::getUndefinedValue(),
PropOpFlags().plusThrowOnError()));
if (res == ExecutionStatus::EXCEPTION) {
assert(
!runtime->getGlobal()->isProxyObject() &&
"global can't be a proxy object");
// If the property already exists, this should be a noop.
// Instead of incurring the cost to check every time, do it
// only if an exception is thrown, and swallow the exception
// if it exists, since we didn't want to make the call,
// anyway. This most likely means the property is
// non-configurable.
NamedPropertyDescriptor desc;
CAPTURE_IP_ASSIGN(
auto res,
JSObject::getOwnNamedDescriptor(
runtime->getGlobal(),
runtime,
ID(ip->iDeclareGlobalVar.op1),
desc));
if (!res) {
goto exception;
} else {
runtime->clearThrownValue();
}
// fall through
}
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = NEXTINST(DeclareGlobalVar);
DISPATCH;
}
CASE(TryGetByIdLong) {
tryProp = true;
idVal = ip->iTryGetByIdLong.op4;
nextIP = NEXTINST(TryGetByIdLong);
goto getById;
}
CASE(GetByIdLong) {
tryProp = false;
idVal = ip->iGetByIdLong.op4;
nextIP = NEXTINST(GetByIdLong);
goto getById;
}
CASE(GetByIdShort) {
tryProp = false;
idVal = ip->iGetByIdShort.op4;
nextIP = NEXTINST(GetByIdShort);
goto getById;
}
CASE(TryGetById) {
tryProp = true;
idVal = ip->iTryGetById.op4;
nextIP = NEXTINST(TryGetById);
goto getById;
}
CASE(GetById) {
tryProp = false;
idVal = ip->iGetById.op4;
nextIP = NEXTINST(GetById);
}
getById : {
++NumGetById;
// NOTE: it is safe to use OnREG(GetById) here because all instructions
// have the same layout: opcode, registers, non-register operands, i.e.
// they only differ in the width of the last "identifier" field.
CallResult<HermesValue> propRes{ExecutionStatus::EXCEPTION};
if (LLVM_LIKELY(O2REG(GetById).isObject())) {
auto *obj = vmcast<JSObject>(O2REG(GetById));
auto cacheIdx = ip->iGetById.op3;
auto *cacheEntry = curCodeBlock->getReadCacheEntry(cacheIdx);
#ifdef HERMESVM_PROFILER_BB
{
HERMES_SLOW_ASSERT(
gcScope.getHandleCountDbg() == KEEP_HANDLES &&
"unaccounted handles were created");
auto objHandle = runtime->makeHandle(obj);
auto cacheHCPtr = vmcast_or_null<HiddenClass>(static_cast<GCCell *>(
cacheEntry->clazz.get(runtime, &runtime->getHeap())));
CAPTURE_IP(runtime->recordHiddenClass(
curCodeBlock, ip, ID(idVal), obj->getClass(runtime), cacheHCPtr));
// obj may be moved by GC due to recordHiddenClass
obj = objHandle.get();
}
gcScope.flushToSmallCount(KEEP_HANDLES);
#endif
auto clazzGCPtr = obj->getClassGCPtr();
#ifndef NDEBUG
if (clazzGCPtr.get(runtime)->isDictionary())
++NumGetByIdDict;
#else
(void)NumGetByIdDict;
#endif
// If we have a cache hit, reuse the cached offset and immediately
// return the property.
if (LLVM_LIKELY(cacheEntry->clazz == clazzGCPtr.getStorageType())) {
++NumGetByIdCacheHits;
CAPTURE_IP_ASSIGN(
O1REG(GetById),
JSObject::getNamedSlotValue<PropStorage::Inline::Yes>(
obj, runtime, cacheEntry->slot));
ip = nextIP;
DISPATCH;
}
auto id = ID(idVal);
NamedPropertyDescriptor desc;
CAPTURE_IP_ASSIGN(
OptValue<bool> fastPathResult,
JSObject::tryGetOwnNamedDescriptorFast(obj, runtime, id, desc));
if (LLVM_LIKELY(
fastPathResult.hasValue() && fastPathResult.getValue()) &&
!desc.flags.accessor) {
++NumGetByIdFastPaths;
// cacheIdx == 0 indicates no caching so don't update the cache in
// those cases.
auto *clazz = clazzGCPtr.getNonNull(runtime);
if (LLVM_LIKELY(!clazz->isDictionaryNoCache()) &&
LLVM_LIKELY(cacheIdx != hbc::PROPERTY_CACHING_DISABLED)) {
#ifdef HERMES_SLOW_DEBUG
if (cacheEntry->clazz &&
cacheEntry->clazz != clazzGCPtr.getStorageType())
++NumGetByIdCacheEvicts;
#else
(void)NumGetByIdCacheEvicts;
#endif
// Cache the class, id and property slot.
cacheEntry->clazz = clazzGCPtr.getStorageType();
cacheEntry->slot = desc.slot;
}
CAPTURE_IP_ASSIGN(
O1REG(GetById), JSObject::getNamedSlotValue(obj, runtime, desc));
ip = nextIP;
DISPATCH;
}
// The cache may also be populated via the prototype of the object.
// This value is only reliable if the fast path was a definite
// not-found.
if (fastPathResult.hasValue() && !fastPathResult.getValue() &&
!obj->isProxyObject()) {
CAPTURE_IP_ASSIGN(JSObject * parent, obj->getParent(runtime));
// TODO: This isLazy check is because a lazy object is reported as
// having no properties and therefore cannot contain the property.
// This check does not belong here, it should be merged into
// tryGetOwnNamedDescriptorFast().
if (parent &&
cacheEntry->clazz == parent->getClassGCPtr().getStorageType() &&
LLVM_LIKELY(!obj->isLazy())) {
++NumGetByIdProtoHits;
CAPTURE_IP_ASSIGN(
O1REG(GetById),
JSObject::getNamedSlotValue(parent, runtime, cacheEntry->slot));
ip = nextIP;
DISPATCH;
}
}
#ifdef HERMES_SLOW_DEBUG
CAPTURE_IP_ASSIGN(
JSObject * propObj,
JSObject::getNamedDescriptor(
Handle<JSObject>::vmcast(&O2REG(GetById)), runtime, id, desc));
if (propObj) {
if (desc.flags.accessor)
++NumGetByIdAccessor;
else if (propObj != vmcast<JSObject>(O2REG(GetById)))
++NumGetByIdProto;
} else {
++NumGetByIdNotFound;
}
#else
(void)NumGetByIdAccessor;
(void)NumGetByIdProto;
(void)NumGetByIdNotFound;
#endif
#ifdef HERMES_SLOW_DEBUG
auto *savedClass = cacheIdx != hbc::PROPERTY_CACHING_DISABLED
? cacheEntry->clazz.get(runtime, &runtime->getHeap())
: nullptr;
#endif
++NumGetByIdSlow;
CAPTURE_IP_ASSIGN(
resPH,
JSObject::getNamed_RJS(
Handle<JSObject>::vmcast(&O2REG(GetById)),
runtime,
id,
!tryProp ? defaultPropOpFlags
: defaultPropOpFlags.plusMustExist(),
cacheIdx != hbc::PROPERTY_CACHING_DISABLED ? cacheEntry
: nullptr));
if (LLVM_UNLIKELY(resPH == ExecutionStatus::EXCEPTION)) {
goto exception;
}
#ifdef HERMES_SLOW_DEBUG
if (cacheIdx != hbc::PROPERTY_CACHING_DISABLED && savedClass &&
cacheEntry->clazz.get(runtime, &runtime->getHeap()) != savedClass) {
++NumGetByIdCacheEvicts;
}
#endif
} else {
++NumGetByIdTransient;
assert(!tryProp && "TryGetById can only be used on the global object");
/* Slow path. */
CAPTURE_IP_ASSIGN(
resPH,
Interpreter::getByIdTransient_RJS(
runtime, Handle<>(&O2REG(GetById)), ID(idVal)));
if (LLVM_UNLIKELY(resPH == ExecutionStatus::EXCEPTION)) {
goto exception;
}
}
O1REG(GetById) = resPH->get();
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = nextIP;
DISPATCH;
}
CASE(TryPutByIdLong) {
tryProp = true;
idVal = ip->iTryPutByIdLong.op4;
nextIP = NEXTINST(TryPutByIdLong);
goto putById;
}
CASE(PutByIdLong) {
tryProp = false;
idVal = ip->iPutByIdLong.op4;
nextIP = NEXTINST(PutByIdLong);
goto putById;
}
CASE(TryPutById) {
tryProp = true;
idVal = ip->iTryPutById.op4;
nextIP = NEXTINST(TryPutById);
goto putById;
}
CASE(PutById) {
tryProp = false;
idVal = ip->iPutById.op4;
nextIP = NEXTINST(PutById);
}
putById : {
++NumPutById;
if (LLVM_LIKELY(O1REG(PutById).isObject())) {
auto *obj = vmcast<JSObject>(O1REG(PutById));
auto cacheIdx = ip->iPutById.op3;
auto *cacheEntry = curCodeBlock->getWriteCacheEntry(cacheIdx);
#ifdef HERMESVM_PROFILER_BB
{
HERMES_SLOW_ASSERT(
gcScope.getHandleCountDbg() == KEEP_HANDLES &&
"unaccounted handles were created");
auto objHandle = runtime->makeHandle(obj);
auto cacheHCPtr = vmcast_or_null<HiddenClass>(static_cast<GCCell *>(
cacheEntry->clazz.get(runtime, &runtime->getHeap())));
CAPTURE_IP(runtime->recordHiddenClass(
curCodeBlock, ip, ID(idVal), obj->getClass(runtime), cacheHCPtr));
// obj may be moved by GC due to recordHiddenClass
obj = objHandle.get();
}
gcScope.flushToSmallCount(KEEP_HANDLES);
#endif
auto clazzGCPtr = obj->getClassGCPtr();
// If we have a cache hit, reuse the cached offset and immediately
// return the property.
if (LLVM_LIKELY(cacheEntry->clazz == clazzGCPtr.getStorageType())) {
++NumPutByIdCacheHits;
CAPTURE_IP(JSObject::setNamedSlotValue<PropStorage::Inline::Yes>(
obj, runtime, cacheEntry->slot, O2REG(PutById)));
ip = nextIP;
DISPATCH;
}
auto id = ID(idVal);
NamedPropertyDescriptor desc;
CAPTURE_IP_ASSIGN(
OptValue<bool> hasOwnProp,
JSObject::tryGetOwnNamedDescriptorFast(obj, runtime, id, desc));
if (LLVM_LIKELY(hasOwnProp.hasValue() && hasOwnProp.getValue()) &&
!desc.flags.accessor && desc.flags.writable &&
!desc.flags.internalSetter) {
++NumPutByIdFastPaths;
// cacheIdx == 0 indicates no caching so don't update the cache in
// those cases.
auto *clazz = clazzGCPtr.getNonNull(runtime);
if (LLVM_LIKELY(!clazz->isDictionary()) &&
LLVM_LIKELY(cacheIdx != hbc::PROPERTY_CACHING_DISABLED)) {
#ifdef HERMES_SLOW_DEBUG
if (cacheEntry->clazz &&
cacheEntry->clazz != clazzGCPtr.getStorageType())
++NumPutByIdCacheEvicts;
#else
(void)NumPutByIdCacheEvicts;
#endif
// Cache the class and property slot.
cacheEntry->clazz = clazzGCPtr.getStorageType();
cacheEntry->slot = desc.slot;
}
CAPTURE_IP(JSObject::setNamedSlotValue(
obj, runtime, desc.slot, O2REG(PutById)));
ip = nextIP;
DISPATCH;
}
CAPTURE_IP_ASSIGN(
auto putRes,
JSObject::putNamed_RJS(
Handle<JSObject>::vmcast(&O1REG(PutById)),
runtime,
id,
Handle<>(&O2REG(PutById)),
!tryProp ? defaultPropOpFlags
: defaultPropOpFlags.plusMustExist()));
if (LLVM_UNLIKELY(putRes == ExecutionStatus::EXCEPTION)) {
goto exception;
}
} else {
++NumPutByIdTransient;
assert(!tryProp && "TryPutById can only be used on the global object");
CAPTURE_IP_ASSIGN(
auto retStatus,
Interpreter::putByIdTransient_RJS(
runtime,
Handle<>(&O1REG(PutById)),
ID(idVal),
Handle<>(&O2REG(PutById)),
strictMode));
if (retStatus == ExecutionStatus::EXCEPTION) {
goto exception;
}
}
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = nextIP;
DISPATCH;
}
CASE(GetByVal) {
CallResult<HermesValue> propRes{ExecutionStatus::EXCEPTION};
if (LLVM_LIKELY(O2REG(GetByVal).isObject())) {
CAPTURE_IP_ASSIGN(
resPH,
JSObject::getComputed_RJS(
Handle<JSObject>::vmcast(&O2REG(GetByVal)),
runtime,
Handle<>(&O3REG(GetByVal))));
if (LLVM_UNLIKELY(resPH == ExecutionStatus::EXCEPTION)) {
goto exception;
}
} else {
// This is the "slow path".
CAPTURE_IP_ASSIGN(
resPH,
Interpreter::getByValTransient_RJS(
runtime,
Handle<>(&O2REG(GetByVal)),
Handle<>(&O3REG(GetByVal))));
if (LLVM_UNLIKELY(resPH == ExecutionStatus::EXCEPTION)) {
goto exception;
}
}
gcScope.flushToSmallCount(KEEP_HANDLES);
O1REG(GetByVal) = resPH->get();
ip = NEXTINST(GetByVal);
DISPATCH;
}
CASE(PutByVal) {
if (LLVM_LIKELY(O1REG(PutByVal).isObject())) {
CAPTURE_IP_ASSIGN(
auto putRes,
JSObject::putComputed_RJS(
Handle<JSObject>::vmcast(&O1REG(PutByVal)),
runtime,
Handle<>(&O2REG(PutByVal)),
Handle<>(&O3REG(PutByVal)),
defaultPropOpFlags));
if (LLVM_UNLIKELY(putRes == ExecutionStatus::EXCEPTION)) {
goto exception;
}
} else {
// This is the "slow path".
CAPTURE_IP_ASSIGN(
auto retStatus,
Interpreter::putByValTransient_RJS(
runtime,
Handle<>(&O1REG(PutByVal)),
Handle<>(&O2REG(PutByVal)),
Handle<>(&O3REG(PutByVal)),
strictMode));
if (LLVM_UNLIKELY(retStatus == ExecutionStatus::EXCEPTION)) {
goto exception;
}
}
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = NEXTINST(PutByVal);
DISPATCH;
}
CASE(PutOwnByIndexL) {
nextIP = NEXTINST(PutOwnByIndexL);
idVal = ip->iPutOwnByIndexL.op3;
goto putOwnByIndex;
}
CASE(PutOwnByIndex) {
nextIP = NEXTINST(PutOwnByIndex);
idVal = ip->iPutOwnByIndex.op3;
}
putOwnByIndex : {
tmpHandle = HermesValue::encodeDoubleValue(idVal);
CAPTURE_IP(JSObject::defineOwnComputedPrimitive(
Handle<JSObject>::vmcast(&O1REG(PutOwnByIndex)),
runtime,
tmpHandle,
DefinePropertyFlags::getDefaultNewPropertyFlags(),
Handle<>(&O2REG(PutOwnByIndex))));
gcScope.flushToSmallCount(KEEP_HANDLES);
tmpHandle.clear();
ip = nextIP;
DISPATCH;
}
CASE(GetPNameList) {
CAPTURE_IP_ASSIGN(
auto pRes, handleGetPNameList(runtime, frameRegs, ip));
if (LLVM_UNLIKELY(pRes == ExecutionStatus::EXCEPTION)) {
goto exception;
}
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = NEXTINST(GetPNameList);
DISPATCH;
}
CASE(GetNextPName) {
{
assert(
vmisa<BigStorage>(O2REG(GetNextPName)) &&
"GetNextPName's second op must be BigStorage");
auto obj = Handle<JSObject>::vmcast(&O3REG(GetNextPName));
auto arr = Handle<BigStorage>::vmcast(&O2REG(GetNextPName));
uint32_t idx = O4REG(GetNextPName).getNumber();
uint32_t size = O5REG(GetNextPName).getNumber();
MutableHandle<JSObject> propObj{runtime};
// Loop until we find a property which is present.
while (idx < size) {
tmpHandle = arr->at(idx);
ComputedPropertyDescriptor desc;
CAPTURE_IP(JSObject::getComputedPrimitiveDescriptor(
obj, runtime, tmpHandle, propObj, desc));
if (LLVM_LIKELY(propObj))
break;
++idx;
}
if (idx < size) {
// We must return the property as a string
if (tmpHandle->isNumber()) {
CAPTURE_IP_ASSIGN(auto status, toString_RJS(runtime, tmpHandle));
assert(
status == ExecutionStatus::RETURNED &&
"toString on number cannot fail");
tmpHandle = status->getHermesValue();
}
O1REG(GetNextPName) = tmpHandle.get();
O4REG(GetNextPName) = HermesValue::encodeNumberValue(idx + 1);
} else {
O1REG(GetNextPName) = HermesValue::encodeUndefinedValue();
}
}
gcScope.flushToSmallCount(KEEP_HANDLES);
tmpHandle.clear();
ip = NEXTINST(GetNextPName);
DISPATCH;
}
CASE(ToNumber) {
if (LLVM_LIKELY(O2REG(ToNumber).isNumber())) {
O1REG(ToNumber) = O2REG(ToNumber);
ip = NEXTINST(ToNumber);
} else {
CAPTURE_IP_ASSIGN(
res, toNumber_RJS(runtime, Handle<>(&O2REG(ToNumber))));
if (res == ExecutionStatus::EXCEPTION)
goto exception;
gcScope.flushToSmallCount(KEEP_HANDLES);
O1REG(ToNumber) = res.getValue();
ip = NEXTINST(ToNumber);
}
DISPATCH;
}
CASE(ToInt32) {
CAPTURE_IP_ASSIGN(res, toInt32_RJS(runtime, Handle<>(&O2REG(ToInt32))));
if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION))
goto exception;
gcScope.flushToSmallCount(KEEP_HANDLES);
O1REG(ToInt32) = res.getValue();
ip = NEXTINST(ToInt32);
DISPATCH;
}
CASE(AddEmptyString) {
if (LLVM_LIKELY(O2REG(AddEmptyString).isString())) {
O1REG(AddEmptyString) = O2REG(AddEmptyString);
ip = NEXTINST(AddEmptyString);
} else {
CAPTURE_IP_ASSIGN(
res,
toPrimitive_RJS(
runtime,
Handle<>(&O2REG(AddEmptyString)),
PreferredType::NONE));
if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION))
goto exception;
tmpHandle = res.getValue();
CAPTURE_IP_ASSIGN(auto strRes, toString_RJS(runtime, tmpHandle));
if (LLVM_UNLIKELY(strRes == ExecutionStatus::EXCEPTION))
goto exception;
tmpHandle.clear();
gcScope.flushToSmallCount(KEEP_HANDLES);
O1REG(AddEmptyString) = strRes->getHermesValue();
ip = NEXTINST(AddEmptyString);
}
DISPATCH;
}
CASE(Jmp) {
ip = IPADD(ip->iJmp.op1);
DISPATCH;
}
CASE(JmpLong) {
ip = IPADD(ip->iJmpLong.op1);
DISPATCH;
}
CASE(JmpTrue) {
if (toBoolean(O2REG(JmpTrue)))
ip = IPADD(ip->iJmpTrue.op1);
else
ip = NEXTINST(JmpTrue);
DISPATCH;
}
CASE(JmpTrueLong) {
if (toBoolean(O2REG(JmpTrueLong)))
ip = IPADD(ip->iJmpTrueLong.op1);
else
ip = NEXTINST(JmpTrueLong);
DISPATCH;
}
CASE(JmpFalse) {
if (!toBoolean(O2REG(JmpFalse)))
ip = IPADD(ip->iJmpFalse.op1);
else
ip = NEXTINST(JmpFalse);
DISPATCH;
}
CASE(JmpFalseLong) {
if (!toBoolean(O2REG(JmpFalseLong)))
ip = IPADD(ip->iJmpFalseLong.op1);
else
ip = NEXTINST(JmpFalseLong);
DISPATCH;
}
CASE(JmpUndefined) {
if (O2REG(JmpUndefined).isUndefined())
ip = IPADD(ip->iJmpUndefined.op1);
else
ip = NEXTINST(JmpUndefined);
DISPATCH;
}
CASE(JmpUndefinedLong) {
if (O2REG(JmpUndefinedLong).isUndefined())
ip = IPADD(ip->iJmpUndefinedLong.op1);
else
ip = NEXTINST(JmpUndefinedLong);
DISPATCH;
}
CASE(Add) {
if (LLVM_LIKELY(
O2REG(Add).isNumber() &&
O3REG(Add).isNumber())) { /* Fast-path. */
CASE(AddN) {
O1REG(Add) = HermesValue::encodeDoubleValue(
O2REG(Add).getNumber() + O3REG(Add).getNumber());
ip = NEXTINST(Add);
DISPATCH;
}
}
CAPTURE_IP_ASSIGN(
res,
addOp_RJS(runtime, Handle<>(&O2REG(Add)), Handle<>(&O3REG(Add))));
if (res == ExecutionStatus::EXCEPTION) {
goto exception;
}
gcScope.flushToSmallCount(KEEP_HANDLES);
O1REG(Add) = res.getValue();
ip = NEXTINST(Add);
DISPATCH;
}
CASE(BitNot) {
if (LLVM_LIKELY(O2REG(BitNot).isNumber())) { /* Fast-path. */
O1REG(BitNot) = HermesValue::encodeDoubleValue(
~hermes::truncateToInt32(O2REG(BitNot).getNumber()));
ip = NEXTINST(BitNot);
DISPATCH;
}
CAPTURE_IP_ASSIGN(res, toInt32_RJS(runtime, Handle<>(&O2REG(BitNot))));
if (res == ExecutionStatus::EXCEPTION) {
goto exception;
}
gcScope.flushToSmallCount(KEEP_HANDLES);
O1REG(BitNot) = HermesValue::encodeDoubleValue(
~static_cast<int32_t>(res->getNumber()));
ip = NEXTINST(BitNot);
DISPATCH;
}
CASE(GetArgumentsLength) {
// If the arguments object hasn't been created yet.
if (O2REG(GetArgumentsLength).isUndefined()) {
O1REG(GetArgumentsLength) =
HermesValue::encodeNumberValue(FRAME.getArgCount());
ip = NEXTINST(GetArgumentsLength);
DISPATCH;
}
// The arguments object has been created, so this is a regular property
// get.
assert(
O2REG(GetArgumentsLength).isObject() &&
"arguments lazy register is not an object");
CAPTURE_IP_ASSIGN(
resPH,
JSObject::getNamed_RJS(
Handle<JSObject>::vmcast(&O2REG(GetArgumentsLength)),
runtime,
Predefined::getSymbolID(Predefined::length)));
if (resPH == ExecutionStatus::EXCEPTION) {
goto exception;
}
gcScope.flushToSmallCount(KEEP_HANDLES);
O1REG(GetArgumentsLength) = resPH->get();
ip = NEXTINST(GetArgumentsLength);
DISPATCH;
}
CASE(GetArgumentsPropByVal) {
// If the arguments object hasn't been created yet and we have a
// valid integer index, we use the fast path.
if (O3REG(GetArgumentsPropByVal).isUndefined()) {
// If this is an integer index.
if (auto index = toArrayIndexFastPath(O2REG(GetArgumentsPropByVal))) {
// Is this an existing argument?
if (*index < FRAME.getArgCount()) {
O1REG(GetArgumentsPropByVal) = FRAME.getArgRef(*index);
ip = NEXTINST(GetArgumentsPropByVal);
DISPATCH;
}
}
}
// Slow path.
CAPTURE_IP_ASSIGN(
auto res,
getArgumentsPropByValSlowPath_RJS(
runtime,
&O3REG(GetArgumentsPropByVal),
&O2REG(GetArgumentsPropByVal),
FRAME.getCalleeClosureHandleUnsafe(),
strictMode));
if (res == ExecutionStatus::EXCEPTION) {
goto exception;
}
gcScope.flushToSmallCount(KEEP_HANDLES);
O1REG(GetArgumentsPropByVal) = res->getHermesValue();
ip = NEXTINST(GetArgumentsPropByVal);
DISPATCH;
}
CASE(ReifyArguments) {
// If the arguments object was already created, do nothing.
if (!O1REG(ReifyArguments).isUndefined()) {
assert(
O1REG(ReifyArguments).isObject() &&
"arguments lazy register is not an object");
ip = NEXTINST(ReifyArguments);
DISPATCH;
}
CAPTURE_IP_ASSIGN(
resArgs,
reifyArgumentsSlowPath(
runtime, FRAME.getCalleeClosureHandleUnsafe(), strictMode));
if (LLVM_UNLIKELY(resArgs == ExecutionStatus::EXCEPTION)) {
goto exception;
}
O1REG(ReifyArguments) = resArgs->getHermesValue();
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = NEXTINST(ReifyArguments);
DISPATCH;
}
CASE(NewObject) {
// Create a new object using the built-in constructor. Note that the
// built-in constructor is empty, so we don't actually need to call
// it.
CAPTURE_IP_ASSIGN(
O1REG(NewObject), JSObject::create(runtime).getHermesValue());
assert(
gcScope.getHandleCountDbg() == KEEP_HANDLES &&
"Should not create handles.");
ip = NEXTINST(NewObject);
DISPATCH;
}
CASE(NewObjectWithParent) {
CAPTURE_IP_ASSIGN(
O1REG(NewObjectWithParent),
JSObject::create(
runtime,
O2REG(NewObjectWithParent).isObject()
? Handle<JSObject>::vmcast(&O2REG(NewObjectWithParent))
: O2REG(NewObjectWithParent).isNull()
? Runtime::makeNullHandle<JSObject>()
: Handle<JSObject>::vmcast(&runtime->objectPrototype))
.getHermesValue());
assert(
gcScope.getHandleCountDbg() == KEEP_HANDLES &&
"Should not create handles.");
ip = NEXTINST(NewObjectWithParent);
DISPATCH;
}
CASE(NewObjectWithBuffer) {
CAPTURE_IP_ASSIGN(
resPH,
Interpreter::createObjectFromBuffer(
runtime,
curCodeBlock,
ip->iNewObjectWithBuffer.op3,
ip->iNewObjectWithBuffer.op4,
ip->iNewObjectWithBuffer.op5));
if (LLVM_UNLIKELY(resPH == ExecutionStatus::EXCEPTION)) {
goto exception;
}
O1REG(NewObjectWithBuffer) = resPH->get();
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = NEXTINST(NewObjectWithBuffer);
DISPATCH;
}
CASE(NewObjectWithBufferLong) {
CAPTURE_IP_ASSIGN(
resPH,
Interpreter::createObjectFromBuffer(
runtime,
curCodeBlock,
ip->iNewObjectWithBufferLong.op3,
ip->iNewObjectWithBufferLong.op4,
ip->iNewObjectWithBufferLong.op5));
if (LLVM_UNLIKELY(resPH == ExecutionStatus::EXCEPTION)) {
goto exception;
}
O1REG(NewObjectWithBufferLong) = resPH->get();
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = NEXTINST(NewObjectWithBufferLong);
DISPATCH;
}
CASE(NewArray) {
// Create a new array using the built-in constructor. Note that the
// built-in constructor is empty, so we don't actually need to call
// it.
CAPTURE_IP_ASSIGN(
auto createRes,
JSArray::create(runtime, ip->iNewArray.op2, ip->iNewArray.op2));
if (createRes == ExecutionStatus::EXCEPTION) {
goto exception;
}
O1REG(NewArray) = createRes->getHermesValue();
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = NEXTINST(NewArray);
DISPATCH;
}
CASE(NewArrayWithBuffer) {
CAPTURE_IP_ASSIGN(
resPH,
Interpreter::createArrayFromBuffer(
runtime,
curCodeBlock,
ip->iNewArrayWithBuffer.op2,
ip->iNewArrayWithBuffer.op3,
ip->iNewArrayWithBuffer.op4));
if (LLVM_UNLIKELY(resPH == ExecutionStatus::EXCEPTION)) {
goto exception;
}
O1REG(NewArrayWithBuffer) = resPH->get();
gcScope.flushToSmallCount(KEEP_HANDLES);
tmpHandle.clear();
ip = NEXTINST(NewArrayWithBuffer);
DISPATCH;
}
CASE(NewArrayWithBufferLong) {
CAPTURE_IP_ASSIGN(
resPH,
Interpreter::createArrayFromBuffer(
runtime,
curCodeBlock,
ip->iNewArrayWithBufferLong.op2,
ip->iNewArrayWithBufferLong.op3,
ip->iNewArrayWithBufferLong.op4));
if (LLVM_UNLIKELY(resPH == ExecutionStatus::EXCEPTION)) {
goto exception;
}
O1REG(NewArrayWithBufferLong) = resPH->get();
gcScope.flushToSmallCount(KEEP_HANDLES);
tmpHandle.clear();
ip = NEXTINST(NewArrayWithBufferLong);
DISPATCH;
}
CASE(CreateThis) {
// Registers: output, prototype, closure.
if (LLVM_UNLIKELY(!vmisa<Callable>(O3REG(CreateThis)))) {
CAPTURE_IP(runtime->raiseTypeError("constructor is not callable"));
goto exception;
}
CAPTURE_IP_ASSIGN(
auto res,
Callable::newObject(
Handle<Callable>::vmcast(&O3REG(CreateThis)),
runtime,
Handle<JSObject>::vmcast(
O2REG(CreateThis).isObject() ? &O2REG(CreateThis)
: &runtime->objectPrototype)));
if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) {
goto exception;
}
gcScope.flushToSmallCount(KEEP_HANDLES);
O1REG(CreateThis) = res->getHermesValue();
ip = NEXTINST(CreateThis);
DISPATCH;
}
CASE(SelectObject) {
// Registers: output, thisObject, constructorReturnValue.
O1REG(SelectObject) = O3REG(SelectObject).isObject()
? O3REG(SelectObject)
: O2REG(SelectObject);
ip = NEXTINST(SelectObject);
DISPATCH;
}
CASE(Eq)
CASE(Neq) {
CAPTURE_IP_ASSIGN(
res,
abstractEqualityTest_RJS(
runtime, Handle<>(&O2REG(Eq)), Handle<>(&O3REG(Eq))));
if (res == ExecutionStatus::EXCEPTION) {
goto exception;
}
gcScope.flushToSmallCount(KEEP_HANDLES);
O1REG(Eq) = ip->opCode == OpCode::Eq
? res.getValue()
: HermesValue::encodeBoolValue(!res->getBool());
ip = NEXTINST(Eq);
DISPATCH;
}
CASE(StrictEq) {
O1REG(StrictEq) = HermesValue::encodeBoolValue(
strictEqualityTest(O2REG(StrictEq), O3REG(StrictEq)));
ip = NEXTINST(StrictEq);
DISPATCH;
}
CASE(StrictNeq) {
O1REG(StrictNeq) = HermesValue::encodeBoolValue(
!strictEqualityTest(O2REG(StrictNeq), O3REG(StrictNeq)));
ip = NEXTINST(StrictNeq);
DISPATCH;
}
CASE(Not) {
O1REG(Not) = HermesValue::encodeBoolValue(!toBoolean(O2REG(Not)));
ip = NEXTINST(Not);
DISPATCH;
}
CASE(Negate) {
if (LLVM_LIKELY(O2REG(Negate).isNumber())) {
O1REG(Negate) =
HermesValue::encodeDoubleValue(-O2REG(Negate).getNumber());
} else {
CAPTURE_IP_ASSIGN(
res, toNumber_RJS(runtime, Handle<>(&O2REG(Negate))));
if (res == ExecutionStatus::EXCEPTION)
goto exception;
gcScope.flushToSmallCount(KEEP_HANDLES);
O1REG(Negate) = HermesValue::encodeDoubleValue(-res->getNumber());
}
ip = NEXTINST(Negate);
DISPATCH;
}
CASE(TypeOf) {
CAPTURE_IP_ASSIGN(
O1REG(TypeOf), typeOf(runtime, Handle<>(&O2REG(TypeOf))));
ip = NEXTINST(TypeOf);
DISPATCH;
}
CASE(Mod) {
// We use fmod here for simplicity. Theoretically fmod behaves slightly
// differently than the ECMAScript Spec. fmod applies round-towards-zero
// for the remainder when it's not representable by a double; while the
// spec requires round-to-nearest. As an example, 5 % 0.7 will give
// 0.10000000000000031 using fmod, but using the rounding style
// described
// by the spec, the output should really be 0.10000000000000053.
// Such difference can be ignored in practice.
if (LLVM_LIKELY(O2REG(Mod).isNumber() && O3REG(Mod).isNumber())) {
/* Fast-path. */
O1REG(Mod) = HermesValue::encodeDoubleValue(
std::fmod(O2REG(Mod).getNumber(), O3REG(Mod).getNumber()));
ip = NEXTINST(Mod);
DISPATCH;
}
CAPTURE_IP_ASSIGN(res, toNumber_RJS(runtime, Handle<>(&O2REG(Mod))));
if (res == ExecutionStatus::EXCEPTION)
goto exception;
double left = res->getDouble();
CAPTURE_IP_ASSIGN(res, toNumber_RJS(runtime, Handle<>(&O3REG(Mod))));
if (res == ExecutionStatus::EXCEPTION)
goto exception;
O1REG(Mod) =
HermesValue::encodeDoubleValue(std::fmod(left, res->getDouble()));
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = NEXTINST(Mod);
DISPATCH;
}
CASE(InstanceOf) {
CAPTURE_IP_ASSIGN(
auto result,
instanceOfOperator_RJS(
runtime,
Handle<>(&O2REG(InstanceOf)),
Handle<>(&O3REG(InstanceOf))));
if (LLVM_UNLIKELY(result == ExecutionStatus::EXCEPTION)) {
goto exception;
}
O1REG(InstanceOf) = HermesValue::encodeBoolValue(*result);
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = NEXTINST(InstanceOf);
DISPATCH;
}
CASE(IsIn) {
{
if (LLVM_UNLIKELY(!O3REG(IsIn).isObject())) {
CAPTURE_IP(runtime->raiseTypeError(
"right operand of 'in' is not an object"));
goto exception;
}
CAPTURE_IP_ASSIGN(
auto cr,
JSObject::hasComputed(
Handle<JSObject>::vmcast(&O3REG(IsIn)),
runtime,
Handle<>(&O2REG(IsIn))));
if (cr == ExecutionStatus::EXCEPTION) {
goto exception;
}
O1REG(IsIn) = HermesValue::encodeBoolValue(*cr);
}
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = NEXTINST(IsIn);
DISPATCH;
}
CASE(PutNewOwnByIdShort) {
nextIP = NEXTINST(PutNewOwnByIdShort);
idVal = ip->iPutNewOwnByIdShort.op3;
goto putOwnById;
}
CASE(PutNewOwnNEByIdLong)
CASE(PutNewOwnByIdLong) {
nextIP = NEXTINST(PutNewOwnByIdLong);
idVal = ip->iPutNewOwnByIdLong.op3;
goto putOwnById;
}
CASE(PutNewOwnNEById)
CASE(PutNewOwnById) {
nextIP = NEXTINST(PutNewOwnById);
idVal = ip->iPutNewOwnById.op3;
}
putOwnById : {
assert(
O1REG(PutNewOwnById).isObject() &&
"Object argument of PutNewOwnById must be an object");
CAPTURE_IP_ASSIGN(
auto res,
JSObject::defineNewOwnProperty(
Handle<JSObject>::vmcast(&O1REG(PutNewOwnById)),
runtime,
ID(idVal),
ip->opCode <= OpCode::PutNewOwnByIdLong
? PropertyFlags::defaultNewNamedPropertyFlags()
: PropertyFlags::nonEnumerablePropertyFlags(),
Handle<>(&O2REG(PutNewOwnById))));
if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) {
goto exception;
}
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = nextIP;
DISPATCH;
}
CASE(DelByIdLong) {
idVal = ip->iDelByIdLong.op3;
nextIP = NEXTINST(DelByIdLong);
goto DelById;
}
CASE(DelById) {
idVal = ip->iDelById.op3;
nextIP = NEXTINST(DelById);
}
DelById : {
if (LLVM_LIKELY(O2REG(DelById).isObject())) {
CAPTURE_IP_ASSIGN(
auto status,
JSObject::deleteNamed(
Handle<JSObject>::vmcast(&O2REG(DelById)),
runtime,
ID(idVal),
defaultPropOpFlags));
if (LLVM_UNLIKELY(status == ExecutionStatus::EXCEPTION)) {
goto exception;
}
O1REG(DelById) = HermesValue::encodeBoolValue(status.getValue());
} else {
// This is the "slow path".
CAPTURE_IP_ASSIGN(res, toObject(runtime, Handle<>(&O2REG(DelById))));
if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) {
// If an exception is thrown, likely we are trying to convert
// undefined/null to an object. Passing over the name of the property
// so that we could emit more meaningful error messages.
CAPTURE_IP(amendPropAccessErrorMsgWithPropName(
runtime, Handle<>(&O2REG(DelById)), "delete", ID(idVal)));
goto exception;
}
tmpHandle = res.getValue();
CAPTURE_IP_ASSIGN(
auto status,
JSObject::deleteNamed(
Handle<JSObject>::vmcast(tmpHandle),
runtime,
ID(idVal),
defaultPropOpFlags));
if (LLVM_UNLIKELY(status == ExecutionStatus::EXCEPTION)) {
goto exception;
}
O1REG(DelById) = HermesValue::encodeBoolValue(status.getValue());
tmpHandle.clear();
}
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = nextIP;
DISPATCH;
}
CASE(DelByVal) {
if (LLVM_LIKELY(O2REG(DelByVal).isObject())) {
CAPTURE_IP_ASSIGN(
auto status,
JSObject::deleteComputed(
Handle<JSObject>::vmcast(&O2REG(DelByVal)),
runtime,
Handle<>(&O3REG(DelByVal)),
defaultPropOpFlags));
if (LLVM_UNLIKELY(status == ExecutionStatus::EXCEPTION)) {
goto exception;
}
O1REG(DelByVal) = HermesValue::encodeBoolValue(status.getValue());
} else {
// This is the "slow path".
CAPTURE_IP_ASSIGN(res, toObject(runtime, Handle<>(&O2REG(DelByVal))));
if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) {
goto exception;
}
tmpHandle = res.getValue();
CAPTURE_IP_ASSIGN(
auto status,
JSObject::deleteComputed(
Handle<JSObject>::vmcast(tmpHandle),
runtime,
Handle<>(&O3REG(DelByVal)),
defaultPropOpFlags));
if (LLVM_UNLIKELY(status == ExecutionStatus::EXCEPTION)) {
goto exception;
}
O1REG(DelByVal) = HermesValue::encodeBoolValue(status.getValue());
}
gcScope.flushToSmallCount(KEEP_HANDLES);
tmpHandle.clear();
ip = NEXTINST(DelByVal);
DISPATCH;
}
CASE(CreateRegExp) {
{
// Create the RegExp object.
CAPTURE_IP_ASSIGN(auto re, JSRegExp::create(runtime));
// Initialize the regexp.
CAPTURE_IP_ASSIGN(
auto pattern,
runtime->makeHandle(curCodeBlock->getRuntimeModule()
->getStringPrimFromStringIDMayAllocate(
ip->iCreateRegExp.op2)));
CAPTURE_IP_ASSIGN(
auto flags,
runtime->makeHandle(curCodeBlock->getRuntimeModule()
->getStringPrimFromStringIDMayAllocate(
ip->iCreateRegExp.op3)));
CAPTURE_IP_ASSIGN(
auto bytecode,
curCodeBlock->getRuntimeModule()->getRegExpBytecodeFromRegExpID(
ip->iCreateRegExp.op4));
CAPTURE_IP_ASSIGN(
auto initRes,
JSRegExp::initialize(re, runtime, pattern, flags, bytecode));
if (LLVM_UNLIKELY(initRes == ExecutionStatus::EXCEPTION)) {
goto exception;
}
// Done, return the new object.
O1REG(CreateRegExp) = re.getHermesValue();
}
gcScope.flushToSmallCount(KEEP_HANDLES);
ip = NEXTINST(CreateRegExp);
DISPATCH;
}
CASE(SwitchImm) {
if (LLVM_LIKELY(O1REG(SwitchImm).isNumber())) {
double numVal = O1REG(SwitchImm).getNumber();
uint32_t uintVal = (uint32_t)numVal;
if (LLVM_LIKELY(numVal == uintVal) && // Only integers.
LLVM_LIKELY(uintVal >= ip->iSwitchImm.op4) && // Bounds checking.
LLVM_LIKELY(uintVal <= ip->iSwitchImm.op5)) // Bounds checking.
{
// Calculate the offset into the bytecode where the jump table for
// this SwitchImm starts.
const uint8_t *tablestart = (const uint8_t *)llvh::alignAddr(
(const uint8_t *)ip + ip->iSwitchImm.op2, sizeof(uint32_t));
// Read the offset from the table.
// Must be signed to account for backwards branching.
const int32_t *loc =
(const int32_t *)tablestart + uintVal - ip->iSwitchImm.op4;
ip = IPADD(*loc);
DISPATCH;
}
}
// Wrong type or out of range, jump to default.
ip = IPADD(ip->iSwitchImm.op3);
DISPATCH;
}
LOAD_CONST(
LoadConstUInt8,
HermesValue::encodeDoubleValue(ip->iLoadConstUInt8.op2));
LOAD_CONST(
LoadConstInt, HermesValue::encodeDoubleValue(ip->iLoadConstInt.op2));
LOAD_CONST(
LoadConstDouble,
HermesValue::encodeDoubleValue(ip->iLoadConstDouble.op2));
LOAD_CONST_CAPTURE_IP(
LoadConstString,
HermesValue::encodeStringValue(
curCodeBlock->getRuntimeModule()
->getStringPrimFromStringIDMayAllocate(
ip->iLoadConstString.op2)));
LOAD_CONST_CAPTURE_IP(
LoadConstStringLongIndex,
HermesValue::encodeStringValue(
curCodeBlock->getRuntimeModule()
->getStringPrimFromStringIDMayAllocate(
ip->iLoadConstStringLongIndex.op2)));
LOAD_CONST(LoadConstUndefined, HermesValue::encodeUndefinedValue());
LOAD_CONST(LoadConstNull, HermesValue::encodeNullValue());
LOAD_CONST(LoadConstTrue, HermesValue::encodeBoolValue(true));
LOAD_CONST(LoadConstFalse, HermesValue::encodeBoolValue(false));
LOAD_CONST(LoadConstZero, HermesValue::encodeDoubleValue(0));
BINOP(Sub, doSub);
BINOP(Mul, doMult);
BINOP(Div, doDiv);
BITWISEBINOP(BitAnd, &);
BITWISEBINOP(BitOr, |);
BITWISEBINOP(BitXor, ^);
// For LShift, we need to use toUInt32 first because lshift on negative
// numbers is undefined behavior in theory.
SHIFTOP(LShift, <<, toUInt32_RJS, uint32_t, int32_t);
SHIFTOP(RShift, >>, toInt32_RJS, int32_t, int32_t);
SHIFTOP(URshift, >>, toUInt32_RJS, uint32_t, uint32_t);
CONDOP(Less, <, lessOp_RJS);
CONDOP(LessEq, <=, lessEqualOp_RJS);
CONDOP(Greater, >, greaterOp_RJS);
CONDOP(GreaterEq, >=, greaterEqualOp_RJS);
JCOND(Less, <, lessOp_RJS);
JCOND(LessEqual, <=, lessEqualOp_RJS);
JCOND(Greater, >, greaterOp_RJS);
JCOND(GreaterEqual, >=, greaterEqualOp_RJS);
JCOND_STRICT_EQ_IMPL(
JStrictEqual, , IPADD(ip->iJStrictEqual.op1), NEXTINST(JStrictEqual));
JCOND_STRICT_EQ_IMPL(
JStrictEqual,
Long,
IPADD(ip->iJStrictEqualLong.op1),
NEXTINST(JStrictEqualLong));
JCOND_STRICT_EQ_IMPL(
JStrictNotEqual,
,
NEXTINST(JStrictNotEqual),
IPADD(ip->iJStrictNotEqual.op1));
JCOND_STRICT_EQ_IMPL(
JStrictNotEqual,
Long,
NEXTINST(JStrictNotEqualLong),
IPADD(ip->iJStrictNotEqualLong.op1));
JCOND_EQ_IMPL(JEqual, , IPADD(ip->iJEqual.op1), NEXTINST(JEqual));
JCOND_EQ_IMPL(
JEqual, Long, IPADD(ip->iJEqualLong.op1), NEXTINST(JEqualLong));
JCOND_EQ_IMPL(
JNotEqual, , NEXTINST(JNotEqual), IPADD(ip->iJNotEqual.op1));
JCOND_EQ_IMPL(
JNotEqual,
Long,
NEXTINST(JNotEqualLong),
IPADD(ip->iJNotEqualLong.op1));
CASE_OUTOFLINE(PutOwnByVal);
CASE_OUTOFLINE(PutOwnGetterSetterByVal);
CASE_OUTOFLINE(DirectEval);
CASE_OUTOFLINE(IteratorBegin);
CASE_OUTOFLINE(IteratorNext);
CASE(IteratorClose) {
if (LLVM_UNLIKELY(O1REG(IteratorClose).isObject())) {
// The iterator must be closed if it's still an object.
// That means it was never an index and is not done iterating (a state
// which is indicated by `undefined`).
CAPTURE_IP_ASSIGN(
auto res,
iteratorClose(
runtime,
Handle<JSObject>::vmcast(&O1REG(IteratorClose)),
Runtime::getEmptyValue()));
if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) {
if (ip->iIteratorClose.op2 &&
!isUncatchableError(runtime->thrownValue_)) {
// Ignore inner exception.
runtime->clearThrownValue();
} else {
goto exception;
}
}
gcScope.flushToSmallCount(KEEP_HANDLES);
}
ip = NEXTINST(IteratorClose);
DISPATCH;
}
CASE(_last) {
llvm_unreachable("Invalid opcode _last");
}
}
llvm_unreachable("unreachable");
// We arrive here if we couldn't allocate the registers for the current frame.
stackOverflow:
CAPTURE_IP(runtime->raiseStackOverflow(
Runtime::StackOverflowKind::JSRegisterStack));
// We arrive here when we raised an exception in a callee, but we don't want
// the callee to be able to handle it.
handleExceptionInParent:
// Restore the caller code block and IP.
curCodeBlock = FRAME.getSavedCodeBlock();
ip = FRAME.getSavedIP();
// Pop to the previous frame where technically the error happened.
frameRegs =
&runtime->restoreStackAndPreviousFrame(FRAME).getFirstLocalRef();
// If we are coming from native code, return.
if (!curCodeBlock)
return ExecutionStatus::EXCEPTION;
// Return because of recursive calling structure
#ifdef HERMESVM_PROFILER_EXTERN
return ExecutionStatus::EXCEPTION;
#endif
// Handle the exception.
exception:
UPDATE_OPCODE_TIME_SPENT;
assert(
!runtime->thrownValue_.isEmpty() &&
"thrownValue unavailable at exception");
bool catchable = true;
// If this is an Error object that was thrown internally, it didn't have
// access to the current codeblock and IP, so collect the stack trace here.
if (auto *jsError = dyn_vmcast<JSError>(runtime->thrownValue_)) {
catchable = jsError->catchable();
if (!jsError->getStackTrace()) {
// Temporarily clear the thrown value for following operations.
CAPTURE_IP_ASSIGN(
auto errorHandle,
runtime->makeHandle(vmcast<JSError>(runtime->thrownValue_)));
runtime->clearThrownValue();
CAPTURE_IP(JSError::recordStackTrace(
errorHandle, runtime, false, curCodeBlock, ip));
// Restore the thrown value.
runtime->setThrownValue(errorHandle.getHermesValue());
}
}
gcScope.flushToSmallCount(KEEP_HANDLES);
tmpHandle.clear();
#ifdef HERMES_ENABLE_DEBUGGER
if (SingleStep) {
// If we're single stepping, don't bother with any more checks,
// and simply signal that we should continue execution with an exception.
state.codeBlock = curCodeBlock;
state.offset = CUROFFSET;
return ExecutionStatus::EXCEPTION;
}
using PauseOnThrowMode = facebook::hermes::debugger::PauseOnThrowMode;
auto mode = runtime->debugger_.getPauseOnThrowMode();
if (mode != PauseOnThrowMode::None) {
if (!runtime->debugger_.isDebugging()) {
// Determine whether the PauseOnThrowMode requires us to stop here.
bool caught =
runtime->debugger_
.findCatchTarget(InterpreterState(curCodeBlock, CUROFFSET))
.hasValue();
bool shouldStop = mode == PauseOnThrowMode::All ||
(mode == PauseOnThrowMode::Uncaught && !caught);
if (shouldStop) {
// When runDebugger is invoked after an exception,
// stepping should never happen internally.
// Any step is a step to an exception handler, which we do
// directly here in the interpreter.
// Thus, the result state should be the same as the input state.
InterpreterState tmpState{curCodeBlock, (uint32_t)CUROFFSET};
CAPTURE_IP_ASSIGN(
ExecutionStatus resultStatus,
runtime->debugger_.runDebugger(
Debugger::RunReason::Exception, tmpState));
(void)resultStatus;
assert(
tmpState == InterpreterState(curCodeBlock, CUROFFSET) &&
"not allowed to step internally in a pauseOnThrow");
gcScope.flushToSmallCount(KEEP_HANDLES);
}
}
}
#endif
int32_t handlerOffset = 0;
// If the exception is not catchable, skip found catch blocks.
while (((handlerOffset = curCodeBlock->findCatchTargetOffset(CUROFFSET)) ==
-1) ||
!catchable) {
PROFILER_EXIT_FUNCTION(curCodeBlock);
#ifdef HERMES_ENABLE_ALLOCATION_LOCATION_TRACES
runtime->popCallStack();
#endif
// Restore the code block and IP.
curCodeBlock = FRAME.getSavedCodeBlock();
ip = FRAME.getSavedIP();
// Pop a stack frame.
frameRegs =
&runtime->restoreStackAndPreviousFrame(FRAME).getFirstLocalRef();
SLOW_DEBUG(
dbgs() << "function exit with exception: restored stackLevel="
<< runtime->getStackLevel() << "\n");
// Are we returning to native code?
if (!curCodeBlock) {
SLOW_DEBUG(
dbgs()
<< "function exit with exception: returning to native code\n");
return ExecutionStatus::EXCEPTION;
}
assert(
isCallType(ip->opCode) &&
"return address is not Call-type instruction");
// Return because of recursive calling structure
#ifdef HERMESVM_PROFILER_EXTERN
return ExecutionStatus::EXCEPTION;
#endif
}
INIT_STATE_FOR_CODEBLOCK(curCodeBlock);
ip = IPADD(handlerOffset - CUROFFSET);
}
} | 12017 | True | 1 |
CVE-2020-19858 | False | False | False | False | AV:N/AC:L/Au:N/C:P/I:N/A:N | NETWORK | LOW | NONE | PARTIAL | NONE | NONE | 5.0 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N | NETWORK | LOW | NONE | NONE | UNCHANGED | HIGH | NONE | NONE | 7.5 | HIGH | 3.9 | 3.6 | False | [{'url': 'https://github.com/plutinosoft/Platinum/commit/9a4ceaccb1585ec35c45fd8e2585538fff6a865e', 'name': 'https://github.com/plutinosoft/Platinum/commit/9a4ceaccb1585ec35c45fd8e2585538fff6a865e', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/plutinosoft/Platinum/issues/22', 'name': 'https://github.com/plutinosoft/Platinum/issues/22', 'refsource': 'MISC', 'tags': ['Issue Tracking', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-22'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:plutinosoft:platinum:*:*:*:*:*:*:*:*', 'versionEndIncluding': '1.2.0', 'cpe_name': []}]}] | [{'lang': 'en', 'value': "Platinum Upnp SDK through 1.2.0 has a directory traversal vulnerability. The attack could remote attack victim by sending http://ip:port/../privacy.avi URL to compromise a victim's privacy."}] | 2022-01-27T14:37Z | 2022-01-21T13:15Z | Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') | The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. |
Many file operations are intended to take place within a restricted directory. By using special elements such as ".." and "/" separators, attackers can escape outside of the restricted location to access files or directories that are elsewhere on the system. One of the most common special elements is the "../" sequence, which in most modern operating systems is interpreted as the parent directory of the current location. This is referred to as relative path traversal. Path traversal also covers the use of absolute pathnames such as "/usr/local/bin", which may also be useful in accessing unexpected files. This is referred to as absolute path traversal.
In many programming languages, the injection of a null byte (the 0 or NUL) may allow an attacker to truncate a generated filename to widen the scope of attack. For example, the software may add ".txt" to any pathname, thus limiting the attacker to text files, but a null injection may effectively remove this restriction.
| https://cwe.mitre.org/data/definitions/22.html | 0 | Sylvain Rebaud | 2019-07-22 23:07:31-07:00 | Fix vulnerability around urls crafter as http://host/../secret.foo (#24) | 9a4ceaccb1585ec35c45fd8e2585538fff6a865e | False | plutinosoft/Platinum | UPnP SDK | 2015-04-22 07:00:14 | 2021-03-22 16:02:12 | http://plutinosoft.com/platinum | plutinosoft | 415.0 | 123.0 | PLT_HttpServer::ServeFile | PLT_HttpServer::ServeFile( const NPT_HttpRequest & request , const NPT_HttpRequestContext & context , NPT_HttpResponse & response , NPT_String file_path) | ['request', 'context', 'response', 'file_path'] | PLT_HttpServer::ServeFile(const NPT_HttpRequest& request,
const NPT_HttpRequestContext& context,
NPT_HttpResponse& response,
NPT_String file_path)
{
NPT_InputStreamReference stream;
NPT_File file(file_path);
NPT_FileInfo file_info;
// prevent hackers from accessing files outside of our root
if ((file_path.Find("/..") >= 0) || (file_path.Find("\\..") >= 0) ||
NPT_FAILED(NPT_File::GetInfo(file_path, &file_info))) {
return NPT_ERROR_NO_SUCH_ITEM;
}
// check for range requests
const NPT_String* range_spec = request.GetHeaders().GetHeaderValue(NPT_HTTP_HEADER_RANGE);
// handle potential 304 only if range header not set
NPT_DateTime date;
NPT_TimeStamp timestamp;
if (NPT_SUCCEEDED(PLT_UPnPMessageHelper::GetIfModifiedSince((NPT_HttpMessage&)request, date)) &&
!range_spec) {
date.ToTimeStamp(timestamp);
NPT_LOG_INFO_5("File %s timestamps: request=%d (%s) vs file=%d (%s)",
(const char*)request.GetUrl().GetPath(),
(NPT_UInt32)timestamp.ToSeconds(),
(const char*)date.ToString(),
(NPT_UInt32)file_info.m_ModificationTime,
(const char*)NPT_DateTime(file_info.m_ModificationTime).ToString());
if (timestamp >= file_info.m_ModificationTime) {
// it's a match
NPT_LOG_FINE_1("Returning 304 for %s", request.GetUrl().GetPath().GetChars());
response.SetStatus(304, "Not Modified", NPT_HTTP_PROTOCOL_1_1);
return NPT_SUCCESS;
}
}
// open file
if (NPT_FAILED(file.Open(NPT_FILE_OPEN_MODE_READ)) ||
NPT_FAILED(file.GetInputStream(stream)) ||
stream.IsNull()) {
return NPT_ERROR_NO_SUCH_ITEM;
}
// set Last-Modified and Cache-Control headers
if (file_info.m_ModificationTime) {
NPT_DateTime last_modified = NPT_DateTime(file_info.m_ModificationTime);
response.GetHeaders().SetHeader("Last-Modified", last_modified.ToString(NPT_DateTime::FORMAT_RFC_1123), true);
response.GetHeaders().SetHeader("Cache-Control", "max-age=0,must-revalidate", true);
//response.GetHeaders().SetHeader("Cache-Control", "max-age=1800", true);
}
PLT_HttpRequestContext tmp_context(request, context);
return ServeStream(request, context, response, stream, PLT_MimeType::GetMimeType(file_path, &tmp_context));
} | 353 | True | 1 |
CVE-2020-19860 | False | False | False | True | AV:N/AC:M/Au:N/C:P/I:N/A:N | NETWORK | MEDIUM | NONE | PARTIAL | NONE | NONE | 4.3 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:N | NETWORK | LOW | NONE | REQUIRED | UNCHANGED | HIGH | NONE | NONE | 6.5 | MEDIUM | 2.8 | 3.6 | False | [{'url': 'https://github.com/NLnetLabs/ldns/issues/50', 'name': 'https://github.com/NLnetLabs/ldns/issues/50', 'refsource': 'MISC', 'tags': ['Exploit', 'Issue Tracking', 'Third Party Advisory']}, {'url': 'https://github.com/NLnetLabs/ldns/commit/15d96206996bea969fbc918eb0a4a346f514b9f3', 'name': 'https://github.com/NLnetLabs/ldns/commit/15d96206996bea969fbc918eb0a4a346f514b9f3', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:nlnetlabs:ldns:1.7.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'When ldns version 1.7.1 verifies a zone file, the ldns_rr_new_frm_str_internal function has a heap out of bounds read vulnerability. An attacker can leak information on the heap by constructing a zone file payload.'}] | 2022-01-27T16:36Z | 2022-01-21T14:15Z | Out-of-bounds Read | The software reads data past the end, or before the beginning, of the intended buffer. | Typically, this can allow attackers to read sensitive information from other memory locations or cause a crash. A crash can occur when the code reads a variable amount of data and assumes that a sentinel exists to stop the read operation, such as a NUL in a string. The expected sentinel might not be located in the out-of-bounds memory, causing excessive data to be read, leading to a segmentation fault or a buffer overflow. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent read operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/125.html | 0 | Wouter Wijngaards | 2019-09-24 16:50:27+02:00 | * bugfix #70: heap Out-of-bound Read vulnerability in
rr_frm_str_internal reported by pokerfacett. | 15d96206996bea969fbc918eb0a4a346f514b9f3 | False | NLnetLabs/ldns | LDNS is a DNS library that facilitates DNS tool programming | 2016-11-03 11:57:12 | 2022-08-23 16:47:37 | https://nlnetlabs.nl/ldns | NLnetLabs | 209.0 | 81.0 | ldns_rr_new_frm_str_internal | ldns_rr_new_frm_str_internal( ldns_rr ** newrr , const char * str , uint32_t default_ttl , const ldns_rdf * origin , ldns_rdf ** prev , bool question) | ['newrr', 'str', 'default_ttl', 'origin', 'prev', 'question'] | ldns_rr_new_frm_str_internal(ldns_rr **newrr, const char *str,
uint32_t default_ttl, const ldns_rdf *origin,
ldns_rdf **prev, bool question)
{
ldns_rr *new;
const ldns_rr_descriptor *desc;
ldns_rr_type rr_type;
ldns_buffer *rr_buf = NULL;
ldns_buffer *rd_buf = NULL;
uint32_t ttl_val;
char *owner = NULL;
char *ttl = NULL;
ldns_rr_class clas_val;
char *clas = NULL;
char *type = NULL;
size_t type_sz;
char *rdata = NULL;
char *rd = NULL;
char *xtok = NULL; /* For RDF types with spaces (i.e. extra tokens) */
size_t rd_strlen;
const char *delimiters;
ssize_t c;
ldns_rdf *owner_dname;
const char* endptr;
int was_unknown_rr_format = 0;
ldns_status status = LDNS_STATUS_OK;
/* used for types with unknown number of rdatas */
bool done;
bool quoted;
ldns_rdf *r = NULL;
uint16_t r_cnt;
uint16_t r_min;
uint16_t r_max;
size_t pre_data_pos;
uint16_t hex_data_size;
char *hex_data_str = NULL;
uint16_t cur_hex_data_size;
size_t hex_pos = 0;
uint8_t *hex_data = NULL;
new = ldns_rr_new();
owner = LDNS_XMALLOC(char, LDNS_MAX_DOMAINLEN + 1);
ttl = LDNS_XMALLOC(char, LDNS_TTL_DATALEN);
clas = LDNS_XMALLOC(char, LDNS_SYNTAX_DATALEN);
rdata = LDNS_XMALLOC(char, LDNS_MAX_PACKETLEN + 1);
rr_buf = LDNS_MALLOC(ldns_buffer);
rd_buf = LDNS_MALLOC(ldns_buffer);
rd = LDNS_XMALLOC(char, LDNS_MAX_RDFLEN);
xtok = LDNS_XMALLOC(char, LDNS_MAX_RDFLEN);
if (rr_buf) {
rr_buf->_data = NULL;
}
if (rd_buf) {
rd_buf->_data = NULL;
}
if (!new || !owner || !ttl || !clas || !rdata ||
!rr_buf || !rd_buf || !rd || !xtok) {
goto memerror;
}
ldns_buffer_new_frm_data(rr_buf, (char*)str, strlen(str));
/* split the rr in its parts -1 signals trouble */
if (ldns_bget_token(rr_buf, owner, "\t\n ", LDNS_MAX_DOMAINLEN) == -1){
status = LDNS_STATUS_SYNTAX_ERR;
goto error;
}
if (ldns_bget_token(rr_buf, ttl, "\t\n ", LDNS_TTL_DATALEN) == -1) {
status = LDNS_STATUS_SYNTAX_TTL_ERR;
goto error;
}
ttl_val = (uint32_t) ldns_str2period(ttl, &endptr);
if (strlen(ttl) > 0 && !isdigit((int) ttl[0])) {
/* ah, it's not there or something */
if (default_ttl == 0) {
ttl_val = LDNS_DEFAULT_TTL;
} else {
ttl_val = default_ttl;
}
/* we not ASSUMING the TTL is missing and that
* the rest of the RR is still there. That is
* CLASS TYPE RDATA
* so ttl value we read is actually the class
*/
clas_val = ldns_get_rr_class_by_name(ttl);
/* class can be left out too, assume IN, current
* token must be type
*/
if (clas_val == 0) {
clas_val = LDNS_RR_CLASS_IN;
type_sz = strlen(ttl) + 1;
type = LDNS_XMALLOC(char, type_sz);
if (!type) {
goto memerror;
}
strlcpy(type, ttl, type_sz);
}
} else {
if (-1 == ldns_bget_token(
rr_buf, clas, "\t\n ", LDNS_SYNTAX_DATALEN)) {
status = LDNS_STATUS_SYNTAX_CLASS_ERR;
goto error;
}
clas_val = ldns_get_rr_class_by_name(clas);
/* class can be left out too, assume IN, current
* token must be type
*/
if (clas_val == 0) {
clas_val = LDNS_RR_CLASS_IN;
type_sz = strlen(clas) + 1;
type = LDNS_XMALLOC(char, type_sz);
if (!type) {
goto memerror;
}
strlcpy(type, clas, type_sz);
}
}
/* the rest should still be waiting for us */
if (!type) {
type = LDNS_XMALLOC(char, LDNS_SYNTAX_DATALEN);
if (!type) {
goto memerror;
}
if (-1 == ldns_bget_token(
rr_buf, type, "\t\n ", LDNS_SYNTAX_DATALEN)) {
status = LDNS_STATUS_SYNTAX_TYPE_ERR;
goto error;
}
}
if (ldns_bget_token(rr_buf, rdata, "\0", LDNS_MAX_PACKETLEN) == -1) {
/* apparently we are done, and it's only a question RR
* so do not set status and go to ldnserror here
*/
}
ldns_buffer_new_frm_data(rd_buf, rdata, strlen(rdata));
if (strlen(owner) <= 1 && strncmp(owner, "@", 1) == 0) {
if (origin) {
ldns_rr_set_owner(new, ldns_rdf_clone(origin));
} else if (prev && *prev) {
ldns_rr_set_owner(new, ldns_rdf_clone(*prev));
} else {
/* default to root */
ldns_rr_set_owner(new, ldns_dname_new_frm_str("."));
}
/* @ also overrides prev */
if (prev) {
ldns_rdf_deep_free(*prev);
*prev = ldns_rdf_clone(ldns_rr_owner(new));
if (!*prev) {
goto memerror;
}
}
} else {
if (strlen(owner) == 0) {
/* no ownername was given, try prev, if that fails
* origin, else default to root */
if (prev && *prev) {
ldns_rr_set_owner(new, ldns_rdf_clone(*prev));
} else if (origin) {
ldns_rr_set_owner(new, ldns_rdf_clone(origin));
} else {
ldns_rr_set_owner(new,
ldns_dname_new_frm_str("."));
}
if(!ldns_rr_owner(new)) {
goto memerror;
}
} else {
owner_dname = ldns_dname_new_frm_str(owner);
if (!owner_dname) {
status = LDNS_STATUS_SYNTAX_ERR;
goto error;
}
ldns_rr_set_owner(new, owner_dname);
if (!ldns_dname_str_absolute(owner) && origin) {
if(ldns_dname_cat(ldns_rr_owner(new), origin)
!= LDNS_STATUS_OK) {
status = LDNS_STATUS_SYNTAX_ERR;
goto error;
}
}
if (prev) {
ldns_rdf_deep_free(*prev);
*prev = ldns_rdf_clone(ldns_rr_owner(new));
if (!*prev) {
goto error;
}
}
}
}
LDNS_FREE(owner);
ldns_rr_set_question(new, question);
ldns_rr_set_ttl(new, ttl_val);
LDNS_FREE(ttl);
ldns_rr_set_class(new, clas_val);
LDNS_FREE(clas);
rr_type = ldns_get_rr_type_by_name(type);
LDNS_FREE(type);
desc = ldns_rr_descript((uint16_t)rr_type);
ldns_rr_set_type(new, rr_type);
if (desc) {
/* only the rdata remains */
r_max = ldns_rr_descriptor_maximum(desc);
r_min = ldns_rr_descriptor_minimum(desc);
} else {
r_min = 0;
r_max = 1;
}
for (done = false, r_cnt = 0; !done && r_cnt < r_max; r_cnt++) {
quoted = false;
switch (ldns_rr_descriptor_field_type(desc, r_cnt)) {
case LDNS_RDF_TYPE_B64 :
case LDNS_RDF_TYPE_HEX : /* These rdf types may con- */
case LDNS_RDF_TYPE_LOC : /* tain whitespace, only if */
case LDNS_RDF_TYPE_WKS : /* it is the last rd field. */
case LDNS_RDF_TYPE_IPSECKEY :
case LDNS_RDF_TYPE_AMTRELAY :
case LDNS_RDF_TYPE_NSEC : if (r_cnt == r_max - 1) {
delimiters = "\n";
break;
}
/* fallthrough */
default : delimiters = "\n\t ";
}
if (ldns_rdf_type_maybe_quoted(
ldns_rr_descriptor_field_type(
desc, r_cnt)) &&
ldns_buffer_remaining(rd_buf) > 0){
/* skip spaces */
while (*(ldns_buffer_current(rd_buf)) == ' ') {
ldns_buffer_skip(rd_buf, 1);
}
if (*(ldns_buffer_current(rd_buf)) == '\"') {
delimiters = "\"\0";
ldns_buffer_skip(rd_buf, 1);
quoted = true;
} else if (ldns_rr_descriptor_field_type(desc, r_cnt)
== LDNS_RDF_TYPE_LONG_STR) {
status = LDNS_STATUS_SYNTAX_RDATA_ERR;
goto error;
}
}
/* because number of fields can be variable, we can't rely on
* _maximum() only
*/
/* skip spaces */
while (ldns_buffer_position(rd_buf) < ldns_buffer_limit(rd_buf)
&& *(ldns_buffer_current(rd_buf)) == ' '
&& !quoted) {
ldns_buffer_skip(rd_buf, 1);
}
pre_data_pos = ldns_buffer_position(rd_buf);
if (-1 == (c = ldns_bget_token(
rd_buf, rd, delimiters, LDNS_MAX_RDFLEN))) {
done = true;
(void)done; /* we're breaking, so done not read anymore */
break;
}
/* hmmz, rfc3597 specifies that any type can be represented
* with \# method, which can contain spaces...
* it does specify size though...
*/
rd_strlen = strlen(rd);
/* unknown RR data */
if (strncmp(rd, "\\#", 2) == 0 && !quoted &&
(rd_strlen == 2 || rd[2]==' ')) {
was_unknown_rr_format = 1;
/* go back to before \#
* and skip it while setting delimiters better
*/
ldns_buffer_set_position(rd_buf, pre_data_pos);
delimiters = "\n\t ";
(void)ldns_bget_token(rd_buf, rd,
delimiters, LDNS_MAX_RDFLEN);
/* read rdata octet length */
c = ldns_bget_token(rd_buf, rd,
delimiters, LDNS_MAX_RDFLEN);
if (c == -1) {
/* something goes very wrong here */
status = LDNS_STATUS_SYNTAX_RDATA_ERR;
goto error;
}
hex_data_size = (uint16_t) atoi(rd);
/* copy hex chars into hex str (2 chars per byte) */
hex_data_str = LDNS_XMALLOC(char, 2*hex_data_size + 1);
if (!hex_data_str) {
/* malloc error */
goto memerror;
}
cur_hex_data_size = 0;
while(cur_hex_data_size < 2 * hex_data_size) {
c = ldns_bget_token(rd_buf, rd,
delimiters, LDNS_MAX_RDFLEN);
if (c == -1) {
status = LDNS_STATUS_SYNTAX_RDATA_ERR;
goto error;
}
rd_strlen = strlen(rd);
if ((size_t)cur_hex_data_size + rd_strlen >
2 * (size_t)hex_data_size) {
status = LDNS_STATUS_SYNTAX_RDATA_ERR;
goto error;
}
strlcpy(hex_data_str + cur_hex_data_size, rd,
rd_strlen + 1);
cur_hex_data_size += rd_strlen;
}
hex_data_str[cur_hex_data_size] = '\0';
/* correct the rdf type */
/* if *we* know the type, interpret it as wireformat */
if (desc) {
hex_pos = 0;
hex_data =
LDNS_XMALLOC(uint8_t, hex_data_size+2);
if (!hex_data) {
goto memerror;
}
ldns_write_uint16(hex_data, hex_data_size);
ldns_hexstring_to_data(
hex_data + 2, hex_data_str);
status = ldns_wire2rdf(new, hex_data,
hex_data_size + 2, &hex_pos);
if (status != LDNS_STATUS_OK) {
goto error;
}
LDNS_FREE(hex_data);
} else {
r = ldns_rdf_new_frm_str(LDNS_RDF_TYPE_HEX,
hex_data_str);
if (!r) {
goto memerror;
}
ldns_rdf_set_type(r, LDNS_RDF_TYPE_UNKNOWN);
if (!ldns_rr_push_rdf(new, r)) {
goto memerror;
}
}
LDNS_FREE(hex_data_str);
} else if(rd_strlen > 0 || quoted) {
/* Normal RR */
switch(ldns_rr_descriptor_field_type(desc, r_cnt)) {
case LDNS_RDF_TYPE_HEX:
case LDNS_RDF_TYPE_B64:
/* When this is the last rdata field, then the
* rest should be read in (cause then these
* rdf types may contain spaces).
*/
if (r_cnt == r_max - 1) {
c = ldns_bget_token(rd_buf, xtok,
"\n", LDNS_MAX_RDFLEN);
if (c != -1) {
(void) strncat(rd, xtok,
LDNS_MAX_RDFLEN -
strlen(rd) - 1);
}
}
r = ldns_rdf_new_frm_str(
ldns_rr_descriptor_field_type(
desc, r_cnt), rd);
break;
case LDNS_RDF_TYPE_HIP:
/*
* In presentation format this RDATA type has
* three tokens: An algorithm byte, then a
* variable length HIT (in hexbytes) and then
* a variable length Public Key (in base64).
*
* We have just read the algorithm, so we need
* two more tokens: HIT and Public Key.
*/
do {
/* Read and append HIT */
if (ldns_bget_token(rd_buf,
xtok, delimiters,
LDNS_MAX_RDFLEN) == -1)
break;
(void) strncat(rd, " ",
LDNS_MAX_RDFLEN -
strlen(rd) - 1);
(void) strncat(rd, xtok,
LDNS_MAX_RDFLEN -
strlen(rd) - 1);
/* Read and append Public Key*/
if (ldns_bget_token(rd_buf,
xtok, delimiters,
LDNS_MAX_RDFLEN) == -1)
break;
(void) strncat(rd, " ",
LDNS_MAX_RDFLEN -
strlen(rd) - 1);
(void) strncat(rd, xtok,
LDNS_MAX_RDFLEN -
strlen(rd) - 1);
} while (false);
r = ldns_rdf_new_frm_str(
ldns_rr_descriptor_field_type(
desc, r_cnt), rd);
break;
case LDNS_RDF_TYPE_DNAME:
r = ldns_rdf_new_frm_str(
ldns_rr_descriptor_field_type(
desc, r_cnt), rd);
/* check if the origin should be used
* or concatenated
*/
if (r && ldns_rdf_size(r) > 1 &&
ldns_rdf_data(r)[0] == 1 &&
ldns_rdf_data(r)[1] == '@') {
ldns_rdf_deep_free(r);
r = origin ? ldns_rdf_clone(origin)
: ( rr_type == LDNS_RR_TYPE_SOA ?
ldns_rdf_clone(
ldns_rr_owner(new))
: ldns_rdf_new_frm_str(
LDNS_RDF_TYPE_DNAME, ".")
);
} else if (r && rd_strlen >= 1 && origin &&
!ldns_dname_str_absolute(rd)) {
status = ldns_dname_cat(r, origin);
if (status != LDNS_STATUS_OK) {
goto error;
}
}
break;
default:
r = ldns_rdf_new_frm_str(
ldns_rr_descriptor_field_type(
desc, r_cnt), rd);
break;
}
if (!r) {
status = LDNS_STATUS_SYNTAX_RDATA_ERR;
goto error;
}
ldns_rr_push_rdf(new, r);
}
if (quoted) {
if (ldns_buffer_available(rd_buf, 1)) {
ldns_buffer_skip(rd_buf, 1);
} else {
done = true;
}
}
} /* for (done = false, r_cnt = 0; !done && r_cnt < r_max; r_cnt++) */
LDNS_FREE(rd);
LDNS_FREE(xtok);
ldns_buffer_free(rr_buf);
LDNS_FREE(rdata);
if (ldns_buffer_remaining(rd_buf) > 0) {
ldns_buffer_free(rd_buf);
ldns_rr_free(new);
return LDNS_STATUS_SYNTAX_SUPERFLUOUS_TEXT_ERR;
}
ldns_buffer_free(rd_buf);
if (!question && desc && !was_unknown_rr_format &&
ldns_rr_rd_count(new) < r_min) {
ldns_rr_free(new);
return LDNS_STATUS_SYNTAX_MISSING_VALUE_ERR;
}
if (newrr) {
*newrr = new;
} else {
/* Maybe the caller just wanted to see if it would parse? */
ldns_rr_free(new);
}
return LDNS_STATUS_OK;
memerror:
status = LDNS_STATUS_MEM_ERR;
error:
if (rd_buf && rd_buf->_data) {
ldns_buffer_free(rd_buf);
} else {
LDNS_FREE(rd_buf);
}
if (rr_buf && rr_buf->_data) {
ldns_buffer_free(rr_buf);
} else {
LDNS_FREE(rr_buf);
}
LDNS_FREE(type);
LDNS_FREE(owner);
LDNS_FREE(ttl);
LDNS_FREE(clas);
LDNS_FREE(hex_data);
LDNS_FREE(hex_data_str);
LDNS_FREE(xtok);
LDNS_FREE(rd);
LDNS_FREE(rdata);
ldns_rr_free(new);
return status;
} | 2274 | True | 1 |
CVE-2020-20276 | False | False | False | False | AV:N/AC:L/Au:N/C:P/I:P/A:P | NETWORK | LOW | NONE | PARTIAL | PARTIAL | PARTIAL | 7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | HIGH | HIGH | HIGH | 9.8 | CRITICAL | 3.9 | 5.9 | False | [{'url': 'https://github.com/troglobit/uftpd/commit/0fb2c031ce0ace07cc19cd2cb2143c4b5a63c9dd', 'name': 'https://github.com/troglobit/uftpd/commit/0fb2c031ce0ace07cc19cd2cb2143c4b5a63c9dd', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://arinerron.com/blog/posts/6', 'name': 'https://arinerron.com/blog/posts/6', 'refsource': 'MISC', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-787'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:troglobit:uftpd:*:*:*:*:*:*:*:*', 'versionEndIncluding': '2.10', 'cpe_name': []}]}] | [{'lang': 'en', 'value': "An unauthenticated stack-based buffer overflow vulnerability in common.c's handle_PORT in uftpd FTP server versions 2.10 and earlier can be abused to cause a crash and could potentially lead to remote code execution."}] | 2020-12-22T18:44Z | 2020-12-18T19:15Z | Out-of-bounds Write | The software writes data past the end, or before the beginning, of the intended buffer. | Typically, this can result in corruption of data, a crash, or code execution. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent write operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/787.html | 0 | Joachim Nilsson | 2019-08-31 10:07:39+02:00 | FTP: Fix buffer overflow in PORT parser, reported by Aaron Esau
Signed-off-by: Joachim Nilsson <troglobit@gmail.com> | 0fb2c031ce0ace07cc19cd2cb2143c4b5a63c9dd | False | troglobit/uftpd | FTP/TFTP server for Linux that just works™ | 2014-05-01 20:11:28 | 2022-02-18 07:31:46 | https://troglobit.com/projects/uftpd/ | troglobit | 149.0 | 28.0 | handle_PORT | handle_PORT( ctrl_t * ctrl , char * str) | ['ctrl', 'str'] | static void handle_PORT(ctrl_t *ctrl, char *str)
{
int a, b, c, d, e, f;
char addr[INET_ADDRSTRLEN];
struct sockaddr_in sin;
if (ctrl->data_sd > 0) {
uev_io_stop(&ctrl->data_watcher);
close(ctrl->data_sd);
ctrl->data_sd = -1;
}
/* Convert PORT command's argument to IP address + port */
sscanf(str, "%d,%d,%d,%d,%d,%d", &a, &b, &c, &d, &e, &f);
sprintf(addr, "%d.%d.%d.%d", a, b, c, d);
/* Check IPv4 address using inet_aton(), throw away converted result */
if (!inet_aton(addr, &(sin.sin_addr))) {
ERR(0, "Invalid address '%s' given to PORT command", addr);
send_msg(ctrl->sd, "500 Illegal PORT command.\r\n");
return;
}
strlcpy(ctrl->data_address, addr, sizeof(ctrl->data_address));
ctrl->data_port = e * 256 + f;
DBG("Client PORT command accepted for %s:%d", ctrl->data_address, ctrl->data_port);
send_msg(ctrl->sd, "200 PORT command successful.\r\n");
} | 192 | True | 1 |
CVE-2020-5204 | False | False | False | False | AV:N/AC:L/Au:S/C:P/I:P/A:P | NETWORK | LOW | SINGLE | PARTIAL | PARTIAL | PARTIAL | 6.5 | CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H | NETWORK | LOW | LOW | NONE | UNCHANGED | HIGH | HIGH | HIGH | 8.8 | HIGH | 2.8 | 5.9 | False | [{'url': 'https://github.com/troglobit/uftpd/security/advisories/GHSA-wrpr-xw7q-9wvq', 'name': 'https://github.com/troglobit/uftpd/security/advisories/GHSA-wrpr-xw7q-9wvq', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'https://github.com/troglobit/uftpd/commit/0fb2c031ce0ace07cc19cd2cb2143c4b5a63c9dd', 'name': 'https://github.com/troglobit/uftpd/commit/0fb2c031ce0ace07cc19cd2cb2143c4b5a63c9dd', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://lists.opensuse.org/opensuse-security-announce/2020-01/msg00034.html', 'name': 'openSUSE-SU-2020:0069', 'refsource': 'SUSE', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-120'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:troglobit:uftpd:*:*:*:*:*:*:*:*', 'versionEndExcluding': '2.11', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'In uftpd before 2.11, there is a buffer overflow vulnerability in handle_PORT in ftpcmd.c that is caused by a buffer that is 16 bytes large being filled via sprintf() with user input based on the format specifier string %d.%d.%d.%d. The 16 byte size is correct for valid IPv4 addresses (len('255.255.255.255') == 16), but the format specifier %d allows more than 3 digits. This has been fixed in version 2.11'}] | 2020-01-18T19:15Z | 2020-01-06T20:15Z | Buffer Copy without Checking Size of Input ('Classic Buffer Overflow') | The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow. | A buffer overflow condition exists when a program attempts to put more data in a buffer than it can hold, or when a program attempts to put data in a memory area outside of the boundaries of a buffer. The simplest type of error, and the most common cause of buffer overflows, is the "classic" case in which the program copies the buffer without restricting how much is copied. Other variants exist, but the existence of a classic overflow strongly suggests that the programmer is not considering even the most basic of security protections.
| https://cwe.mitre.org/data/definitions/120.html | 0 | Joachim Nilsson | 2019-08-31 10:07:39+02:00 | FTP: Fix buffer overflow in PORT parser, reported by Aaron Esau
Signed-off-by: Joachim Nilsson <troglobit@gmail.com> | 0fb2c031ce0ace07cc19cd2cb2143c4b5a63c9dd | False | troglobit/uftpd | FTP/TFTP server for Linux that just works™ | 2014-05-01 20:11:28 | 2022-02-18 07:31:46 | https://troglobit.com/projects/uftpd/ | troglobit | 149.0 | 28.0 | handle_PORT | handle_PORT( ctrl_t * ctrl , char * str) | ['ctrl', 'str'] | static void handle_PORT(ctrl_t *ctrl, char *str)
{
int a, b, c, d, e, f;
char addr[INET_ADDRSTRLEN];
struct sockaddr_in sin;
if (ctrl->data_sd > 0) {
uev_io_stop(&ctrl->data_watcher);
close(ctrl->data_sd);
ctrl->data_sd = -1;
}
/* Convert PORT command's argument to IP address + port */
sscanf(str, "%d,%d,%d,%d,%d,%d", &a, &b, &c, &d, &e, &f);
sprintf(addr, "%d.%d.%d.%d", a, b, c, d);
/* Check IPv4 address using inet_aton(), throw away converted result */
if (!inet_aton(addr, &(sin.sin_addr))) {
ERR(0, "Invalid address '%s' given to PORT command", addr);
send_msg(ctrl->sd, "500 Illegal PORT command.\r\n");
return;
}
strlcpy(ctrl->data_address, addr, sizeof(ctrl->data_address));
ctrl->data_port = e * 256 + f;
DBG("Client PORT command accepted for %s:%d", ctrl->data_address, ctrl->data_port);
send_msg(ctrl->sd, "200 PORT command successful.\r\n");
} | 192 | True | 1 |
CVE-2020-20277 | False | False | False | False | AV:N/AC:L/Au:N/C:P/I:P/A:P | NETWORK | LOW | NONE | PARTIAL | PARTIAL | PARTIAL | 7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | HIGH | HIGH | HIGH | 9.8 | CRITICAL | 3.9 | 5.9 | False | [{'url': 'https://arinerron.com/blog/posts/6', 'name': 'https://arinerron.com/blog/posts/6', 'refsource': 'MISC', 'tags': ['Third Party Advisory']}, {'url': 'https://github.com/troglobit/uftpd/commit/455b47d3756aed162d2d0ef7f40b549f3b5b30fe', 'name': 'https://github.com/troglobit/uftpd/commit/455b47d3756aed162d2d0ef7f40b549f3b5b30fe', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://packetstormsecurity.com/files/167908/uftpd-2.10-Directory-Traversal.html', 'name': 'http://packetstormsecurity.com/files/167908/uftpd-2.10-Directory-Traversal.html', 'refsource': 'MISC', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-22'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:troglobit:uftpd:*:*:*:*:*:*:*:*', 'versionStartIncluding': '2.7', 'versionEndIncluding': '2.10', 'cpe_name': []}]}] | [{'lang': 'en', 'value': "There are multiple unauthenticated directory traversal vulnerabilities in different FTP commands in uftpd FTP server versions 2.7 to 2.10 due to improper implementation of a chroot jail in common.c's compose_abspath function that can be abused to read or write to arbitrary files on the filesystem, leak process memory, or potentially lead to remote code execution."}] | 2022-08-02T17:15Z | 2020-12-18T19:15Z | Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') | The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. |
Many file operations are intended to take place within a restricted directory. By using special elements such as ".." and "/" separators, attackers can escape outside of the restricted location to access files or directories that are elsewhere on the system. One of the most common special elements is the "../" sequence, which in most modern operating systems is interpreted as the parent directory of the current location. This is referred to as relative path traversal. Path traversal also covers the use of absolute pathnames such as "/usr/local/bin", which may also be useful in accessing unexpected files. This is referred to as absolute path traversal.
In many programming languages, the injection of a null byte (the 0 or NUL) may allow an attacker to truncate a generated filename to widen the scope of attack. For example, the software may add ".txt" to any pathname, thus limiting the attacker to text files, but a null injection may effectively remove this restriction.
| https://cwe.mitre.org/data/definitions/22.html | 0 | Joachim Nilsson | 2019-08-31 10:08:29+02:00 | FTP/TFTP: Fix directory traversal regression, reported by Aaron Esau
Signed-off-by: Joachim Nilsson <troglobit@gmail.com> | 455b47d3756aed162d2d0ef7f40b549f3b5b30fe | False | troglobit/uftpd | FTP/TFTP server for Linux that just works™ | 2014-05-01 20:11:28 | 2022-02-18 07:31:46 | https://troglobit.com/projects/uftpd/ | troglobit | 149.0 | 28.0 | compose_path | compose_path( ctrl_t * ctrl , char * path) | ['ctrl', 'path'] | char *compose_path(ctrl_t *ctrl, char *path)
{
struct stat st;
static char rpath[PATH_MAX];
char *name, *ptr;
char dir[PATH_MAX] = { 0 };
strlcpy(dir, ctrl->cwd, sizeof(dir));
DBG("Compose path from cwd: %s, arg: %s", ctrl->cwd, path ?: "");
if (!path || !strlen(path))
goto check;
if (path) {
if (path[0] != '/') {
if (dir[strlen(dir) - 1] != '/')
strlcat(dir, "/", sizeof(dir));
}
strlcat(dir, path, sizeof(dir));
}
check:
while ((ptr = strstr(dir, "//")))
memmove(ptr, &ptr[1], strlen(&ptr[1]) + 1);
if (!chrooted) {
size_t len = strlen(home);
DBG("Server path from CWD: %s", dir);
if (len > 0 && home[len - 1] == '/')
len--;
memmove(dir + len, dir, strlen(dir) + 1);
memcpy(dir, home, len);
DBG("Resulting non-chroot path: %s", dir);
}
/*
* Handle directories slightly differently, since dirname() on a
* directory returns the parent directory. So, just squash ..
*/
if (!stat(dir, &st) && S_ISDIR(st.st_mode)) {
if (!realpath(dir, rpath))
return NULL;
} else {
/*
* Check realpath() of directory containing the file, a
* STOR may want to save a new file. Then append the
* file and return it.
*/
name = basename(path);
ptr = dirname(dir);
memset(rpath, 0, sizeof(rpath));
if (!realpath(ptr, rpath)) {
INFO("Failed realpath(%s): %m", ptr);
return NULL;
}
if (rpath[1] != 0)
strlcat(rpath, "/", sizeof(rpath));
strlcat(rpath, name, sizeof(rpath));
}
if (!chrooted && strncmp(dir, home, strlen(home))) {
DBG("Failed non-chroot dir:%s vs home:%s", dir, home);
return NULL;
}
return rpath;
} | 397 | True | 1 |
CVE-2020-5221 | False | False | False | False | AV:N/AC:L/Au:N/C:P/I:P/A:N | NETWORK | LOW | NONE | PARTIAL | PARTIAL | NONE | 6.4 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:L/A:N | NETWORK | LOW | NONE | NONE | CHANGED | LOW | LOW | NONE | 7.2 | HIGH | 3.9 | 2.7 | False | [{'url': 'https://github.com/troglobit/uftpd/security/advisories/GHSA-wmx8-v7mx-6x9h', 'name': 'https://github.com/troglobit/uftpd/security/advisories/GHSA-wmx8-v7mx-6x9h', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/troglobit/uftpd/commit/455b47d3756aed162d2d0ef7f40b549f3b5b30fe', 'name': 'https://github.com/troglobit/uftpd/commit/455b47d3756aed162d2d0ef7f40b549f3b5b30fe', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-22'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:troglobit:uftpd:*:*:*:*:*:*:*:*', 'versionEndExcluding': '2.11', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'In uftpd before 2.11, it is possible for an unauthenticated user to perform a directory traversal attack using multiple different FTP commands and read and write to arbitrary locations on the filesystem due to the lack of a well-written chroot jail in compose_abspath(). This has been fixed in version 2.11'}] | 2020-01-30T16:36Z | 2020-01-22T19:15Z | Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') | The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. |
Many file operations are intended to take place within a restricted directory. By using special elements such as ".." and "/" separators, attackers can escape outside of the restricted location to access files or directories that are elsewhere on the system. One of the most common special elements is the "../" sequence, which in most modern operating systems is interpreted as the parent directory of the current location. This is referred to as relative path traversal. Path traversal also covers the use of absolute pathnames such as "/usr/local/bin", which may also be useful in accessing unexpected files. This is referred to as absolute path traversal.
In many programming languages, the injection of a null byte (the 0 or NUL) may allow an attacker to truncate a generated filename to widen the scope of attack. For example, the software may add ".txt" to any pathname, thus limiting the attacker to text files, but a null injection may effectively remove this restriction.
| https://cwe.mitre.org/data/definitions/22.html | 0 | Joachim Nilsson | 2019-08-31 10:08:29+02:00 | FTP/TFTP: Fix directory traversal regression, reported by Aaron Esau
Signed-off-by: Joachim Nilsson <troglobit@gmail.com> | 455b47d3756aed162d2d0ef7f40b549f3b5b30fe | False | troglobit/uftpd | FTP/TFTP server for Linux that just works™ | 2014-05-01 20:11:28 | 2022-02-18 07:31:46 | https://troglobit.com/projects/uftpd/ | troglobit | 149.0 | 28.0 | compose_path | compose_path( ctrl_t * ctrl , char * path) | ['ctrl', 'path'] | char *compose_path(ctrl_t *ctrl, char *path)
{
struct stat st;
static char rpath[PATH_MAX];
char *name, *ptr;
char dir[PATH_MAX] = { 0 };
strlcpy(dir, ctrl->cwd, sizeof(dir));
DBG("Compose path from cwd: %s, arg: %s", ctrl->cwd, path ?: "");
if (!path || !strlen(path))
goto check;
if (path) {
if (path[0] != '/') {
if (dir[strlen(dir) - 1] != '/')
strlcat(dir, "/", sizeof(dir));
}
strlcat(dir, path, sizeof(dir));
}
check:
while ((ptr = strstr(dir, "//")))
memmove(ptr, &ptr[1], strlen(&ptr[1]) + 1);
if (!chrooted) {
size_t len = strlen(home);
DBG("Server path from CWD: %s", dir);
if (len > 0 && home[len - 1] == '/')
len--;
memmove(dir + len, dir, strlen(dir) + 1);
memcpy(dir, home, len);
DBG("Resulting non-chroot path: %s", dir);
}
/*
* Handle directories slightly differently, since dirname() on a
* directory returns the parent directory. So, just squash ..
*/
if (!stat(dir, &st) && S_ISDIR(st.st_mode)) {
if (!realpath(dir, rpath))
return NULL;
} else {
/*
* Check realpath() of directory containing the file, a
* STOR may want to save a new file. Then append the
* file and return it.
*/
name = basename(path);
ptr = dirname(dir);
memset(rpath, 0, sizeof(rpath));
if (!realpath(ptr, rpath)) {
INFO("Failed realpath(%s): %m", ptr);
return NULL;
}
if (rpath[1] != 0)
strlcat(rpath, "/", sizeof(rpath));
strlcat(rpath, name, sizeof(rpath));
}
if (!chrooted && strncmp(dir, home, strlen(home))) {
DBG("Failed non-chroot dir:%s vs home:%s", dir, home);
return NULL;
}
return rpath;
} | 397 | True | 1 |
CVE-2020-21050 | False | False | False | True | AV:N/AC:M/Au:N/C:N/I:N/A:P | NETWORK | MEDIUM | NONE | NONE | NONE | PARTIAL | 4.3 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H | NETWORK | LOW | NONE | REQUIRED | UNCHANGED | NONE | NONE | HIGH | 6.5 | MEDIUM | 2.8 | 3.6 | False | [{'url': 'https://github.com/saitoha/libsixel/issues/75', 'name': 'https://github.com/saitoha/libsixel/issues/75', 'refsource': 'MISC', 'tags': ['Exploit', 'Issue Tracking', 'Patch', 'Third Party Advisory']}, {'url': 'https://github.com/saitoha/libsixel/releases/tag/v1.8.5', 'name': 'https://github.com/saitoha/libsixel/releases/tag/v1.8.5', 'refsource': 'MISC', 'tags': ['Release Notes', 'Third Party Advisory']}, {'url': 'https://github.com/saitoha/libsixel/blob/master/ChangeLog', 'name': 'https://github.com/saitoha/libsixel/blob/master/ChangeLog', 'refsource': 'MISC', 'tags': ['Release Notes', 'Third Party Advisory']}, {'url': 'https://github.com/saitoha/libsixel/commit/7808a06b88c11dbc502318cdd51fa374f8cd47ee', 'name': 'https://github.com/saitoha/libsixel/commit/7808a06b88c11dbc502318cdd51fa374f8cd47ee', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://bitbucket.org/netbsd/pkgsrc/commits/a27113e21179cbfbfae0c35f6a9edd6aa498faae', 'name': 'https://bitbucket.org/netbsd/pkgsrc/commits/a27113e21179cbfbfae0c35f6a9edd6aa498faae', 'refsource': 'MISC', 'tags': ['Broken Link']}, {'url': 'https://cwe.mitre.org/data/definitions/121.html', 'name': 'https://cwe.mitre.org/data/definitions/121.html', 'refsource': 'MISC', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-787'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:libsixel_project:libsixel:*:*:*:*:*:*:*:*', 'versionEndExcluding': '1.8.3', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Libsixel prior to v1.8.3 contains a stack buffer overflow in the function gif_process_raster at fromgif.c.'}] | 2022-07-10T21:15Z | 2021-09-14T16:15Z | Out-of-bounds Write | The software writes data past the end, or before the beginning, of the intended buffer. | Typically, this can result in corruption of data, a crash, or code execution. The software may modify an index or perform pointer arithmetic that references a memory location that is outside of the boundaries of the buffer. A subsequent write operation then produces undefined or unexpected results.
| https://cwe.mitre.org/data/definitions/787.html | 0 | Hayaki Saito | 2018-08-02 01:59:41+09:00 | gif loader: check LZW code size (Issue #75) | 7808a06b88c11dbc502318cdd51fa374f8cd47ee | False | saitoha/libsixel | A SIXEL encoder/decoder implementation derived from kmiya's sixel (https://github.com/saitoha/sixel). | 2013-08-20 15:52:45 | 2022-01-01 10:32:54 | saitoha | 1939.0 | 67.0 | gif_process_raster | gif_process_raster( gif_context_t * s , gif_t * g) | ['s', 'g'] | gif_process_raster(
gif_context_t /* in */ *s,
gif_t /* in */ *g
)
{
SIXELSTATUS status = SIXEL_FALSE;
unsigned char lzw_cs;
signed int len, code;
unsigned int first;
signed int codesize, codemask, avail, oldcode, bits, valid_bits, clear;
gif_lzw *p;
lzw_cs = gif_get8(s);
clear = 1 << lzw_cs;
first = 1;
codesize = lzw_cs + 1;
codemask = (1 << codesize) - 1;
bits = 0;
valid_bits = 0;
for (code = 0; code < clear; code++) {
g->codes[code].prefix = -1;
g->codes[code].first = (unsigned char) code;
g->codes[code].suffix = (unsigned char) code;
}
/* support no starting clear code */
avail = clear + 2;
oldcode = (-1);
len = 0;
for(;;) {
if (valid_bits < codesize) {
if (len == 0) {
len = gif_get8(s); /* start new block */
if (len == 0) {
return SIXEL_OK;
}
}
--len;
bits |= (signed int) gif_get8(s) << valid_bits;
valid_bits += 8;
} else {
code = bits & codemask;
bits >>= codesize;
valid_bits -= codesize;
/* @OPTIMIZE: is there some way we can accelerate the non-clear path? */
if (code == clear) { /* clear code */
codesize = lzw_cs + 1;
codemask = (1 << codesize) - 1;
avail = clear + 2;
oldcode = -1;
first = 0;
} else if (code == clear + 1) { /* end of stream code */
s->img_buffer += len;
while ((len = gif_get8(s)) > 0) {
s->img_buffer += len;
}
return SIXEL_OK;
} else if (code <= avail) {
if (first) {
sixel_helper_set_additional_message(
"corrupt GIF (reason: no clear code).");
status = SIXEL_RUNTIME_ERROR;
goto end;
}
if (oldcode >= 0) {
if (avail < 4096) {
p = &g->codes[avail++];
p->prefix = (signed short) oldcode;
p->first = g->codes[oldcode].first;
p->suffix = (code == avail) ? p->first : g->codes[code].first;
}
} else if (code == avail) {
sixel_helper_set_additional_message(
"corrupt GIF (reason: illegal code in raster).");
status = SIXEL_RUNTIME_ERROR;
goto end;
}
gif_out_code(g, (unsigned short) code);
if ((avail & codemask) == 0 && avail <= 0x0FFF) {
codesize++;
codemask = (1 << codesize) - 1;
}
oldcode = code;
} else {
sixel_helper_set_additional_message(
"corrupt GIF (reason: illegal code in raster).");
status = SIXEL_RUNTIME_ERROR;
goto end;
}
}
}
status = SIXEL_OK;
end:
return status;
} | 518 | True | 1 |
|
CVE-2020-21048 | False | False | False | True | AV:N/AC:M/Au:N/C:N/I:N/A:P | NETWORK | MEDIUM | NONE | NONE | NONE | PARTIAL | 4.3 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H | NETWORK | LOW | NONE | REQUIRED | UNCHANGED | NONE | NONE | HIGH | 6.5 | MEDIUM | 2.8 | 3.6 | False | [{'url': 'https://github.com/saitoha/libsixel/releases/tag/v1.8.4', 'name': 'https://github.com/saitoha/libsixel/releases/tag/v1.8.4', 'refsource': 'MISC', 'tags': ['Release Notes', 'Third Party Advisory']}, {'url': 'https://github.com/saitoha/libsixel/blob/master/ChangeLog', 'name': 'https://github.com/saitoha/libsixel/blob/master/ChangeLog', 'refsource': 'MISC', 'tags': ['Release Notes', 'Third Party Advisory']}, {'url': 'https://github.com/saitoha/libsixel/commit/cb373ab6614c910407c5e5a93ab935144e62b037', 'name': 'https://github.com/saitoha/libsixel/commit/cb373ab6614c910407c5e5a93ab935144e62b037', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://bitbucket.org/netbsd/pkgsrc/commits/6f0c011cbfccdffa635d04c84433b1a02687adad', 'name': 'https://bitbucket.org/netbsd/pkgsrc/commits/6f0c011cbfccdffa635d04c84433b1a02687adad', 'refsource': 'MISC', 'tags': ['Broken Link']}, {'url': 'https://github.com/saitoha/libsixel/issues/73', 'name': 'https://github.com/saitoha/libsixel/issues/73', 'refsource': 'MISC', 'tags': ['Exploit', 'Issue Tracking', 'Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'NVD-CWE-noinfo'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:libsixel_project:libsixel:*:*:*:*:*:*:*:*', 'versionEndExcluding': '1.8.4', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'An issue in the dither.c component of libsixel prior to v1.8.4 allows attackers to cause a denial of service (DOS) via a crafted PNG file.'}] | 2021-09-24T17:05Z | 2021-09-14T16:15Z | Insufficient Information | There is insufficient information about the issue to classify it; details are unkown or unspecified. | Insufficient Information | https://nvd.nist.gov/vuln/categories | 0 | Hayaki Saito | 2019-12-15 21:56:23+09:00 | Avoid illegal memory access problem with 1 color paletted png(#73),
Thanks to HongxuChen. | cb373ab6614c910407c5e5a93ab935144e62b037 | False | saitoha/libsixel | A SIXEL encoder/decoder implementation derived from kmiya's sixel (https://github.com/saitoha/sixel). | 2013-08-20 15:52:45 | 2022-01-01 10:32:54 | saitoha | 1939.0 | 67.0 | sixel_dither_new | sixel_dither_new( sixel_dither_t ** ppdither , int ncolors , sixel_allocator_t * allocator) | ['ppdither', 'ncolors', 'allocator'] | sixel_dither_new(
sixel_dither_t /* out */ **ppdither, /* dither object to be created */
int /* in */ ncolors, /* required colors */
sixel_allocator_t /* in */ *allocator) /* allocator, null if you use
default allocator */
{
SIXELSTATUS status = SIXEL_FALSE;
size_t headsize;
size_t datasize;
size_t wholesize;
int quality_mode;
if (ppdither == NULL) {
sixel_helper_set_additional_message(
"sixel_dither_new: ppdither is null.");
status = SIXEL_BAD_ARGUMENT;
goto end;
}
if (allocator == NULL) {
status = sixel_allocator_new(&allocator, NULL, NULL, NULL, NULL);
if (SIXEL_FAILED(status)) {
*ppdither = NULL;
goto end;
}
} else {
sixel_allocator_ref(allocator);
}
if (ncolors < 0) {
ncolors = 256;
quality_mode = SIXEL_QUALITY_HIGHCOLOR;
} else {
if (ncolors > SIXEL_PALETTE_MAX) {
ncolors = 256;
} else if (ncolors < 2) {
ncolors = 2;
}
quality_mode = SIXEL_QUALITY_LOW;
}
headsize = sizeof(sixel_dither_t);
datasize = (size_t)(ncolors * 3);
wholesize = headsize + datasize;
*ppdither = (sixel_dither_t *)sixel_allocator_malloc(allocator, wholesize);
if (*ppdither == NULL) {
sixel_allocator_unref(allocator);
sixel_helper_set_additional_message(
"sixel_dither_new: sixel_allocator_malloc() failed.");
status = SIXEL_BAD_ALLOCATION;
goto end;
}
(*ppdither)->ref = 1;
(*ppdither)->palette = (unsigned char*)(*ppdither + 1);
(*ppdither)->cachetable = NULL;
(*ppdither)->reqcolors = ncolors;
(*ppdither)->ncolors = ncolors;
(*ppdither)->origcolors = (-1);
(*ppdither)->keycolor = (-1);
(*ppdither)->optimized = 0;
(*ppdither)->optimize_palette = 0;
(*ppdither)->complexion = 1;
(*ppdither)->bodyonly = 0;
(*ppdither)->method_for_largest = SIXEL_LARGE_NORM;
(*ppdither)->method_for_rep = SIXEL_REP_CENTER_BOX;
(*ppdither)->method_for_diffuse = SIXEL_DIFFUSE_FS;
(*ppdither)->quality_mode = quality_mode;
(*ppdither)->pixelformat = SIXEL_PIXELFORMAT_RGB888;
(*ppdither)->allocator = allocator;
status = SIXEL_OK;
end:
return status;
} | 391 | True | 1 |
|
CVE-2020-21572 | False | False | False | False | AV:N/AC:L/Au:N/C:N/I:N/A:P | NETWORK | LOW | NONE | NONE | NONE | PARTIAL | 5.0 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | NONE | NONE | HIGH | 7.5 | HIGH | 3.9 | 3.6 | False | [{'url': 'https://github.com/trgil/gilcc/issues/1', 'name': 'https://github.com/trgil/gilcc/issues/1', 'refsource': 'MISC', 'tags': ['Issue Tracking', 'Third Party Advisory']}, {'url': 'https://github.com/trgil/gilcc/commit/803969389ca9c06237075a7f8eeb1a19e6651759', 'name': 'https://github.com/trgil/gilcc/commit/803969389ca9c06237075a7f8eeb1a19e6651759', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-120'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gilcc_project:gilcc:*:*:*:*:*:*:*:*', 'versionEndExcluding': '2019-12-22', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Buffer overflow vulnerability in function src_parser_trans_stage_1_2_3 trgil gilcc before commit 803969389ca9c06237075a7f8eeb1a19e6651759, allows attackers to cause a denial of service.'}] | 2021-11-04T14:00Z | 2021-11-02T18:15Z | Buffer Copy without Checking Size of Input ('Classic Buffer Overflow') | The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow. | A buffer overflow condition exists when a program attempts to put more data in a buffer than it can hold, or when a program attempts to put data in a memory area outside of the boundaries of a buffer. The simplest type of error, and the most common cause of buffer overflows, is the "classic" case in which the program copies the buffer without restricting how much is copied. Other variants exist, but the existence of a classic overflow strongly suggests that the programmer is not considering even the most basic of security protections.
| https://cwe.mitre.org/data/definitions/120.html | 0 | gil | 2019-12-22 13:47:09-08:00 | Fix parser tmp-buffer overflow issue | 803969389ca9c06237075a7f8eeb1a19e6651759 | False | trgil/gilcc | C code analysis tool. | 2018-12-21 12:32:09 | 2020-04-04 19:58:32 | null | trgil | 0.0 | 0.0 | src_parser_trans_stage_1_2_3 | src_parser_trans_stage_1_2_3( const int tmp_fd , const char * src , const struct trans_config cfg) | ['tmp_fd', 'src', 'cfg'] | static int src_parser_trans_stage_1_2_3(const int tmp_fd, const char *src, const struct trans_config cfg)
{
struct parser_buf pbuf = {
.f_indx = 0,
.tmp_indx = 0,
.f_read_size = 0
};
int write_count = 0;
int src_fd;
int p_state = P_STATE_CODE;
src_fd = open(src, O_RDONLY);
if (src_fd == -1) {
fprintf(stderr, "**Error: Could not open source file: %s.\n", src);
return -1;
}
while (p_buf_refill(&pbuf, src_fd) > 0) {
while (PBUF_F_REMD(pbuf)) {
switch (p_state) {
case P_STATE_COMMENT_C:
switch (PBUF_F_CHAR(pbuf)) {
case '*':
p_buf_push_tmp_char(&pbuf, '*');
continue;
case '/':
if (pbuf.tmp_indx && (PBUF_TMP_PREV_CHAR(pbuf) == '*')) {
pbuf.tmp_indx--;
p_state = P_STATE_CODE;
}
break;
default:
if (pbuf.tmp_indx && (PBUF_TMP_PREV_CHAR(pbuf) == '*'))
pbuf.tmp_indx--;
break;
}
pbuf.f_indx++;
case P_STATE_CODE:
default:
/* TODO: add trigraph support */
switch (PBUF_F_CHAR(pbuf)) {
case ' ':
case '\t':
if (pbuf.tmp_indx &&
(PBUF_TMP_PREV_CHAR(pbuf) == ' ' || PBUF_TMP_PREV_CHAR(pbuf) == '\t' ||
PBUF_TMP_PREV_CHAR(pbuf) == '\n'))
pbuf.f_indx++;
else
p_buf_push_tmp_char(&pbuf, ' ');
continue;
case '\r':
case '\n':
if (pbuf.tmp_indx &&
(PBUF_TMP_PREV_CHAR(pbuf) == ' ' || PBUF_TMP_PREV_CHAR(pbuf) == '\t' ||
PBUF_TMP_PREV_CHAR(pbuf) == '\n')) {
pbuf.f_indx++;
} else if (pbuf.tmp_indx &&
(PBUF_TMP_PREV_CHAR(pbuf) == '\\')) {
pbuf.tmp_indx--;
pbuf.f_indx++;
} else {
p_buf_push_tmp_char(&pbuf, '\n');
}
continue;
case '\\':
p_buf_push_tmp_char(&pbuf, '\\');
continue;
case '/':
p_buf_push_tmp_char(&pbuf, '/');
continue;
case '*':
if (pbuf.tmp_indx &&
(PBUF_TMP_PREV_CHAR(pbuf) == '/')) {
pbuf.tmp_indx--;
pbuf.f_indx++;
p_state = P_STATE_COMMENT_C;
continue;
}
default:
break;
}
/* TODO: check return values */
p_buf_write_tmp(&pbuf, tmp_fd);
p_buf_write_f_char(&pbuf, tmp_fd);
}
}
}
p_buf_write_tmp(&pbuf, tmp_fd);
return 0;
} | 438 | True | 1 |
CVE-2020-22617 | False | False | False | False | AV:N/AC:L/Au:N/C:P/I:P/A:P | NETWORK | LOW | NONE | PARTIAL | PARTIAL | PARTIAL | 7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | HIGH | HIGH | HIGH | 9.8 | CRITICAL | 3.9 | 5.9 | False | [{'url': 'https://github.com/Ardour/ardour/commit/96daa4036a', 'name': 'https://github.com/Ardour/ardour/commit/96daa4036a', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://tracker.ardour.org/view.php?id=7926', 'name': 'https://tracker.ardour.org/view.php?id=7926', 'refsource': 'MISC', 'tags': ['Vendor Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-416'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:ardour:ardour:5.12:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Ardour v5.12 contains a use-after-free vulnerability in the component ardour/libs/pbd/xml++.cc when using xmlFreeDoc and xmlXPathFreeContext.'}] | 2021-10-15T16:17Z | 2021-10-08T20:15Z | Use After Free | Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code. |
The use of previously-freed memory can have any number of adverse consequences, ranging from the corruption of valid data to the execution of arbitrary code, depending on the instantiation and timing of the flaw. The simplest way data corruption may occur involves the system's reuse of the freed memory. Use-after-free errors have two common and sometimes overlapping causes:
Error conditions and other exceptional circumstances.
Confusion over which part of the program is responsible for freeing the memory.
In this scenario, the memory in question is allocated to another pointer validly at some point after it has been freed. The original pointer to the freed memory is used again and points to somewhere within the new allocation. As the data is changed, it corrupts the validly used memory; this induces undefined behavior in the process.
If the newly allocated data chances to hold a class, in C++ for example, various function pointers may be scattered within the heap data. If one of these function pointers is overwritten with an address to valid shellcode, execution of arbitrary code can be achieved.
| https://cwe.mitre.org/data/definitions/416.html | 0 | Paul Davis | 2020-03-11 08:49:42-06:00 | fix apparent free-ordering issue reported in #7926 | 96daa4036a425ff3f23a7dfcba57bfb0f942bec6 | False | Ardour/ardour | Mirror of Ardour Source Code | 2013-03-13 17:23:57 | 2022-08-27 22:25:15 | http://ardour.org | Ardour | 2620.0 | 540.0 | find_impl | find_impl( xmlXPathContext * ctxt , const string & xpath) | ['ctxt', 'xpath'] | static XMLSharedNodeList* find_impl(xmlXPathContext* ctxt, const string& xpath)
{
xmlXPathObject* result = xmlXPathEval((const xmlChar*)xpath.c_str(), ctxt);
if (!result) {
xmlXPathFreeContext(ctxt);
xmlFreeDoc(ctxt->doc);
throw XMLException("Invalid XPath: " + xpath);
}
if (result->type != XPATH_NODESET) {
xmlXPathFreeObject(result);
xmlXPathFreeContext(ctxt);
xmlFreeDoc(ctxt->doc);
throw XMLException("Only nodeset result types are supported.");
}
xmlNodeSet* nodeset = result->nodesetval;
XMLSharedNodeList* nodes = new XMLSharedNodeList();
if (nodeset) {
for (int i = 0; i < nodeset->nodeNr; ++i) {
XMLNode* node = readnode(nodeset->nodeTab[i]);
nodes->push_back(boost::shared_ptr<XMLNode>(node));
}
} else {
// return empty set
}
xmlXPathFreeObject(result);
return nodes;
} | 174 | True | 1 |
CVE-2020-22875 | False | False | False | False | AV:N/AC:L/Au:N/C:P/I:P/A:P | NETWORK | LOW | NONE | PARTIAL | PARTIAL | PARTIAL | 7.5 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H | NETWORK | LOW | NONE | NONE | UNCHANGED | HIGH | HIGH | HIGH | 9.8 | CRITICAL | 3.9 | 5.9 | False | [{'url': 'https://github.com/pcmacdon/jsish/commit/5408a6d93f45bf1f7acd9ae5d44e0ebd77379e98', 'name': 'https://github.com/pcmacdon/jsish/commit/5408a6d93f45bf1f7acd9ae5d44e0ebd77379e98', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/pcmacdon/jsish/issues/10', 'name': 'https://github.com/pcmacdon/jsish/issues/10', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-190'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:jsish:jsish:*:*:*:*:*:*:*:*', 'versionEndExcluding': '3.0.6', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Integer overflow vulnerability in function Jsi_ObjSetLength in jsish before 3.0.6, allows remote attackers to execute arbitrary code.'}] | 2021-07-15T18:49Z | 2021-07-13T15:15Z | Integer Overflow or Wraparound | The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | An integer overflow or wraparound occurs when an integer value is incremented to a value that is too large to store in the associated representation. When this occurs, the value may wrap to become a very small or negative number. While this may be intended behavior in circumstances that rely on wrapping, it can have security consequences if the wrap is unexpected. This is especially the case if the integer overflow can be triggered using user-supplied inputs. This becomes security-critical when the result is used to control looping, make a security decision, or determine the offset or size in behaviors such as memory allocation, copying, concatenation, etc.
| https://cwe.mitre.org/data/definitions/190.html | 0 | pmacdona | 2020-04-13 16:07:27+00:00 | Release "3.0.6": Fix crashes in Array for "integer overflow #10"
FossilOrigin-Name: 50642d64b8f0a4e62df68e59fcb2ef0923c3dbec8fc8a15d38b1ddbe655c38d6 | 5408a6d93f45bf1f7acd9ae5d44e0ebd77379e98 | False | pcmacdon/jsish | Jsi is a small, C-embeddable javascript interpreter with tightly woven Web and DB support. | 2016-07-08 13:28:40 | 2022-08-23 14:47:21 | https://jsish.org/ | pcmacdon | 29.0 | 5.0 | Jsi_ValueArrayShift | Jsi_ValueArrayShift( Jsi_Interp * interp , Jsi_Value * v) | ['interp', 'v'] | void Jsi_ValueArrayShift(Jsi_Interp *interp, Jsi_Value *v)
{
if (v->vt != JSI_VT_OBJECT) {
Jsi_LogBug("Jsi_ValueArrayShift, target is not object");
return;
}
Jsi_Obj *o = v->d.obj;
if (o->isarrlist) {
uint i;
if (!o->arrCnt)
return;
if (o->arr[0])
Jsi_DecrRefCount(interp, o->arr[0]);
for (i=1; i<o->arrCnt; i++) {
o->arr[i-1] = o->arr[i];
}
o->arr[o->arrCnt--] = NULL;
return;
}
int len = Jsi_ObjGetLength(interp, v->d.obj);
if (len <= 0) return;
Jsi_Value *v0 = Jsi_ValueArrayIndex(interp, v, 0);
if (!v0) return;
Jsi_ValueReset(interp, &v0);
int i;
Jsi_Value *last = v0;
for (i = 1; i < len; ++i) {
Jsi_Value *t = Jsi_ValueArrayIndex(interp, v, i);
if (!t) return;
Jsi_ValueCopy(interp, last, t);
Jsi_ValueReset(interp, &t);
last = t;
}
Jsi_ObjSetLength(interp, v->d.obj, len - 1);
} | 257 | True | 1 |
Subsets and Splits