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-2019-1010315 | 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.0/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/dbry/WavPack/issues/65', 'name': 'https://github.com/dbry/WavPack/issues/65', 'refsource': 'MISC', 'tags': ['Exploit', 'Issue Tracking', 'Third Party Advisory']}, {'url': 'https://github.com/dbry/WavPack/commit/4c0faba32fddbd0745cbfaf1e1aeb3da5d35b9fc', 'name': 'https://github.com/dbry/WavPack/commit/4c0faba32fddbd0745cbfaf1e1aeb3da5d35b9fc', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://usn.ubuntu.com/4062-1/', 'name': 'USN-4062-1', 'refsource': 'UBUNTU', 'tags': []}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/6CFFFWIWALGQPKINRDW3PRGRD5LOLGZA/', 'name': 'FEDORA-2020-e55567b6be', 'refsource': 'FEDORA', 'tags': []}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/BRWQNE3TH5UF64IKHKKHVCHJHUOVKJUH/', 'name': 'FEDORA-2020-73274c9df4', 'refsource': 'FEDORA', 'tags': []}, {'url': 'https://lists.debian.org/debian-lts-announce/2021/01/msg00013.html', 'name': '[debian-lts-announce] 20210115 [SECURITY] [DLA 2525-1] wavpack security update', 'refsource': 'MLIST', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-369'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:wavpack:wavpack:*:*:*:*:*:*:*:*', 'versionEndIncluding': '5.1.0', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'WavPack 5.1 and earlier is affected by: CWE 369: Divide by Zero. The impact is: Divide by zero can lead to sudden crash of a software/service that tries to parse a .wav file. The component is: ParseDsdiffHeaderConfig (dsdiff.c:282). The attack vector is: Maliciously crafted .wav file. The fixed version is: After commit https://github.com/dbry/WavPack/commit/4c0faba32fddbd0745cbfaf1e1aeb3da5d35b9fc.'}] | 2021-01-15T13:15Z | 2019-07-11T20:15Z | Divide By Zero | The product divides a value by zero. | This weakness typically occurs when an unexpected value is provided to the product, or if an error occurs that is not properly detected. It frequently occurs in calculations involving physical dimensions such as size, length, width, and height.
| https://cwe.mitre.org/data/definitions/369.html | 0 | David Bryant | 2019-03-02 18:37:14-08:00 | issue #65: make sure DSDIFF files have a valid channel count | 4c0faba32fddbd0745cbfaf1e1aeb3da5d35b9fc | False | dbry/WavPack | WavPack encode/decode library, command-line programs, and several plugins | 2013-09-25 01:18:11 | 2022-08-17 05:32:09 | dbry | 224.0 | 54.0 | ParseDsdiffHeaderConfig | ParseDsdiffHeaderConfig( FILE * infile , char * infilename , char * fourcc , WavpackContext * wpc , WavpackConfig * config) | ['infile', 'infilename', 'fourcc', 'wpc', 'config'] | int ParseDsdiffHeaderConfig (FILE *infile, char *infilename, char *fourcc, WavpackContext *wpc, WavpackConfig *config)
{
int64_t infilesize, total_samples;
DFFFileHeader dff_file_header;
DFFChunkHeader dff_chunk_header;
uint32_t bcount;
infilesize = DoGetFileSize (infile);
memcpy (&dff_file_header, fourcc, 4);
if ((!DoReadFile (infile, ((char *) &dff_file_header) + 4, sizeof (DFFFileHeader) - 4, &bcount) ||
bcount != sizeof (DFFFileHeader) - 4) || strncmp (dff_file_header.formType, "DSD ", 4)) {
error_line ("%s is not a valid .DFF file!", infilename);
return WAVPACK_SOFT_ERROR;
}
else if (!(config->qmode & QMODE_NO_STORE_WRAPPER) &&
!WavpackAddWrapper (wpc, &dff_file_header, sizeof (DFFFileHeader))) {
error_line ("%s", WavpackGetErrorMessage (wpc));
return WAVPACK_SOFT_ERROR;
}
#if 1 // this might be a little too picky...
WavpackBigEndianToNative (&dff_file_header, DFFFileHeaderFormat);
if (infilesize && !(config->qmode & QMODE_IGNORE_LENGTH) &&
dff_file_header.ckDataSize && dff_file_header.ckDataSize + 1 && dff_file_header.ckDataSize + 12 != infilesize) {
error_line ("%s is not a valid .DFF file (by total size)!", infilename);
return WAVPACK_SOFT_ERROR;
}
if (debug_logging_mode)
error_line ("file header indicated length = %lld", dff_file_header.ckDataSize);
#endif
// loop through all elements of the DSDIFF header
// (until the data chuck) and copy them to the output file
while (1) {
if (!DoReadFile (infile, &dff_chunk_header, sizeof (DFFChunkHeader), &bcount) ||
bcount != sizeof (DFFChunkHeader)) {
error_line ("%s is not a valid .DFF file!", infilename);
return WAVPACK_SOFT_ERROR;
}
else if (!(config->qmode & QMODE_NO_STORE_WRAPPER) &&
!WavpackAddWrapper (wpc, &dff_chunk_header, sizeof (DFFChunkHeader))) {
error_line ("%s", WavpackGetErrorMessage (wpc));
return WAVPACK_SOFT_ERROR;
}
WavpackBigEndianToNative (&dff_chunk_header, DFFChunkHeaderFormat);
if (debug_logging_mode)
error_line ("chunk header indicated length = %lld", dff_chunk_header.ckDataSize);
if (!strncmp (dff_chunk_header.ckID, "FVER", 4)) {
uint32_t version;
if (dff_chunk_header.ckDataSize != sizeof (version) ||
!DoReadFile (infile, &version, sizeof (version), &bcount) ||
bcount != sizeof (version)) {
error_line ("%s is not a valid .DFF file!", infilename);
return WAVPACK_SOFT_ERROR;
}
else if (!(config->qmode & QMODE_NO_STORE_WRAPPER) &&
!WavpackAddWrapper (wpc, &version, sizeof (version))) {
error_line ("%s", WavpackGetErrorMessage (wpc));
return WAVPACK_SOFT_ERROR;
}
WavpackBigEndianToNative (&version, "L");
if (debug_logging_mode)
error_line ("dsdiff file version = 0x%08x", version);
}
else if (!strncmp (dff_chunk_header.ckID, "PROP", 4)) {
char *prop_chunk;
if (dff_chunk_header.ckDataSize < 4 || dff_chunk_header.ckDataSize > 1024) {
error_line ("%s is not a valid .DFF file!", infilename);
return WAVPACK_SOFT_ERROR;
}
if (debug_logging_mode)
error_line ("got PROP chunk of %d bytes total", (int) dff_chunk_header.ckDataSize);
prop_chunk = malloc ((size_t) dff_chunk_header.ckDataSize);
if (!DoReadFile (infile, prop_chunk, (uint32_t) dff_chunk_header.ckDataSize, &bcount) ||
bcount != dff_chunk_header.ckDataSize) {
error_line ("%s is not a valid .DFF file!", infilename);
free (prop_chunk);
return WAVPACK_SOFT_ERROR;
}
else if (!(config->qmode & QMODE_NO_STORE_WRAPPER) &&
!WavpackAddWrapper (wpc, prop_chunk, (uint32_t) dff_chunk_header.ckDataSize)) {
error_line ("%s", WavpackGetErrorMessage (wpc));
free (prop_chunk);
return WAVPACK_SOFT_ERROR;
}
if (!strncmp (prop_chunk, "SND ", 4)) {
char *cptr = prop_chunk + 4, *eptr = prop_chunk + dff_chunk_header.ckDataSize;
uint16_t numChannels, chansSpecified, chanMask = 0;
uint32_t sampleRate;
while (eptr - cptr >= sizeof (dff_chunk_header)) {
memcpy (&dff_chunk_header, cptr, sizeof (dff_chunk_header));
cptr += sizeof (dff_chunk_header);
WavpackBigEndianToNative (&dff_chunk_header, DFFChunkHeaderFormat);
if (dff_chunk_header.ckDataSize > 0 && dff_chunk_header.ckDataSize <= eptr - cptr) {
if (!strncmp (dff_chunk_header.ckID, "FS ", 4) && dff_chunk_header.ckDataSize == 4) {
memcpy (&sampleRate, cptr, sizeof (sampleRate));
WavpackBigEndianToNative (&sampleRate, "L");
cptr += dff_chunk_header.ckDataSize;
if (debug_logging_mode)
error_line ("got sample rate of %u Hz", sampleRate);
}
else if (!strncmp (dff_chunk_header.ckID, "CHNL", 4) && dff_chunk_header.ckDataSize >= 2) {
memcpy (&numChannels, cptr, sizeof (numChannels));
WavpackBigEndianToNative (&numChannels, "S");
cptr += sizeof (numChannels);
chansSpecified = (int)(dff_chunk_header.ckDataSize - sizeof (numChannels)) / 4;
if (numChannels < chansSpecified || numChannels < 1) {
error_line ("%s is not a valid .DFF file!", infilename);
free (prop_chunk);
return WAVPACK_SOFT_ERROR;
}
while (chansSpecified--) {
if (!strncmp (cptr, "SLFT", 4) || !strncmp (cptr, "MLFT", 4))
chanMask |= 0x1;
else if (!strncmp (cptr, "SRGT", 4) || !strncmp (cptr, "MRGT", 4))
chanMask |= 0x2;
else if (!strncmp (cptr, "LS ", 4))
chanMask |= 0x10;
else if (!strncmp (cptr, "RS ", 4))
chanMask |= 0x20;
else if (!strncmp (cptr, "C ", 4))
chanMask |= 0x4;
else if (!strncmp (cptr, "LFE ", 4))
chanMask |= 0x8;
else
if (debug_logging_mode)
error_line ("undefined channel ID %c%c%c%c", cptr [0], cptr [1], cptr [2], cptr [3]);
cptr += 4;
}
if (debug_logging_mode)
error_line ("%d channels, mask = 0x%08x", numChannels, chanMask);
}
else if (!strncmp (dff_chunk_header.ckID, "CMPR", 4) && dff_chunk_header.ckDataSize >= 4) {
if (strncmp (cptr, "DSD ", 4)) {
error_line ("DSDIFF files must be uncompressed, not \"%c%c%c%c\"!",
cptr [0], cptr [1], cptr [2], cptr [3]);
free (prop_chunk);
return WAVPACK_SOFT_ERROR;
}
cptr += dff_chunk_header.ckDataSize;
}
else {
if (debug_logging_mode)
error_line ("got PROP/SND chunk type \"%c%c%c%c\" of %d bytes", dff_chunk_header.ckID [0],
dff_chunk_header.ckID [1], dff_chunk_header.ckID [2], dff_chunk_header.ckID [3], dff_chunk_header.ckDataSize);
cptr += dff_chunk_header.ckDataSize;
}
}
else {
error_line ("%s is not a valid .DFF file!", infilename);
free (prop_chunk);
return WAVPACK_SOFT_ERROR;
}
}
if (chanMask && (config->channel_mask || (config->qmode & QMODE_CHANS_UNASSIGNED))) {
error_line ("this DSDIFF file already has channel order information!");
free (prop_chunk);
return WAVPACK_SOFT_ERROR;
}
else if (chanMask)
config->channel_mask = chanMask;
config->bits_per_sample = 8;
config->bytes_per_sample = 1;
config->num_channels = numChannels;
config->sample_rate = sampleRate / 8;
config->qmode |= QMODE_DSD_MSB_FIRST;
}
else if (debug_logging_mode)
error_line ("got unknown PROP chunk type \"%c%c%c%c\" of %d bytes",
prop_chunk [0], prop_chunk [1], prop_chunk [2], prop_chunk [3], dff_chunk_header.ckDataSize);
free (prop_chunk);
}
else if (!strncmp (dff_chunk_header.ckID, "DSD ", 4)) {
total_samples = dff_chunk_header.ckDataSize / config->num_channels;
break;
}
else { // just copy unknown chunks to output file
int bytes_to_copy = (int)(((dff_chunk_header.ckDataSize) + 1) & ~(int64_t)1);
char *buff;
if (bytes_to_copy < 0 || bytes_to_copy > 4194304) {
error_line ("%s is not a valid .DFF file!", infilename);
return WAVPACK_SOFT_ERROR;
}
buff = malloc (bytes_to_copy);
if (debug_logging_mode)
error_line ("extra unknown chunk \"%c%c%c%c\" of %d bytes",
dff_chunk_header.ckID [0], dff_chunk_header.ckID [1], dff_chunk_header.ckID [2],
dff_chunk_header.ckID [3], dff_chunk_header.ckDataSize);
if (!DoReadFile (infile, buff, bytes_to_copy, &bcount) ||
bcount != bytes_to_copy ||
(!(config->qmode & QMODE_NO_STORE_WRAPPER) &&
!WavpackAddWrapper (wpc, buff, bytes_to_copy))) {
error_line ("%s", WavpackGetErrorMessage (wpc));
free (buff);
return WAVPACK_SOFT_ERROR;
}
free (buff);
}
}
if (debug_logging_mode)
error_line ("setting configuration with %lld samples", total_samples);
if (!WavpackSetConfiguration64 (wpc, config, total_samples, NULL)) {
error_line ("%s: %s", infilename, WavpackGetErrorMessage (wpc));
return WAVPACK_SOFT_ERROR;
}
return WAVPACK_NO_ERROR;
} | 1550 | True | 1 |
|
CVE-2019-1010317 | 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/dbry/WavPack/issues/66', 'name': 'https://github.com/dbry/WavPack/issues/66', 'refsource': 'MISC', 'tags': ['Exploit', 'Issue Tracking', 'Third Party Advisory']}, {'url': 'https://github.com/dbry/WavPack/commit/f68a9555b548306c5b1ee45199ccdc4a16a6101b', 'name': 'https://github.com/dbry/WavPack/commit/f68a9555b548306c5b1ee45199ccdc4a16a6101b', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://usn.ubuntu.com/4062-1/', 'name': 'USN-4062-1', 'refsource': 'UBUNTU', 'tags': ['Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/PYESOAZ6Z6IG4BQBURL6OUY6P4YB6SKS/', 'name': 'FEDORA-2019-c72f5f6361', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/IX3J2JML5A7KC2BLGBEFTIIZR3EM7LVJ/', 'name': 'FEDORA-2019-8eeb8f9d3f', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/6CFFFWIWALGQPKINRDW3PRGRD5LOLGZA/', 'name': 'FEDORA-2020-e55567b6be', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/BRWQNE3TH5UF64IKHKKHVCHJHUOVKJUH/', 'name': 'FEDORA-2020-73274c9df4', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2021/01/msg00013.html', 'name': '[debian-lts-announce] 20210115 [SECURITY] [DLA 2525-1] wavpack security update', 'refsource': 'MLIST', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-908'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:wavpack:wavpack:*:*:*:*:*:*:*:*', 'versionEndIncluding': '5.1.0', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:fedoraproject:fedora:29:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:fedoraproject:fedora:30:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:fedoraproject:fedora:31:*:*:*:*:*:*:*', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:canonical:ubuntu_linux:18.04:*:*:*:lts:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:canonical:ubuntu_linux:19.04:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'WavPack 5.1.0 and earlier is affected by: CWE-457: Use of Uninitialized Variable. The impact is: Unexpected control flow, crashes, and segfaults. The component is: ParseCaffHeaderConfig (caff.c:486). The attack vector is: Maliciously crafted .wav file. The fixed version is: After commit https://github.com/dbry/WavPack/commit/f68a9555b548306c5b1ee45199ccdc4a16a6101b.'}] | 2021-01-15T13:15Z | 2019-07-11T20:15Z | Use of Uninitialized Resource | The software uses or accesses a resource that has not been initialized. | When a resource has not been properly initialized, the software may behave unexpectedly. This may lead to a crash or invalid memory access, but the consequences vary depending on the type of resource and how it is used within the software.
| https://cwe.mitre.org/data/definitions/908.html | 0 | David Bryant | 2019-03-04 21:09:41-08:00 | issue #66: make sure CAF files have a "desc" chunk | f68a9555b548306c5b1ee45199ccdc4a16a6101b | False | dbry/WavPack | WavPack encode/decode library, command-line programs, and several plugins | 2013-09-25 01:18:11 | 2022-08-17 05:32:09 | dbry | 224.0 | 54.0 | ParseCaffHeaderConfig | ParseCaffHeaderConfig( FILE * infile , char * infilename , char * fourcc , WavpackContext * wpc , WavpackConfig * config) | ['infile', 'infilename', 'fourcc', 'wpc', 'config'] | int ParseCaffHeaderConfig (FILE *infile, char *infilename, char *fourcc, WavpackContext *wpc, WavpackConfig *config)
{
uint32_t chan_chunk = 0, channel_layout = 0, bcount;
unsigned char *channel_identities = NULL;
unsigned char *channel_reorder = NULL;
int64_t total_samples = 0, infilesize;
CAFFileHeader caf_file_header;
CAFChunkHeader caf_chunk_header;
CAFAudioFormat caf_audio_format;
int i;
infilesize = DoGetFileSize (infile);
memcpy (&caf_file_header, fourcc, 4);
if ((!DoReadFile (infile, ((char *) &caf_file_header) + 4, sizeof (CAFFileHeader) - 4, &bcount) ||
bcount != sizeof (CAFFileHeader) - 4)) {
error_line ("%s is not a valid .CAF file!", infilename);
return WAVPACK_SOFT_ERROR;
}
else if (!(config->qmode & QMODE_NO_STORE_WRAPPER) &&
!WavpackAddWrapper (wpc, &caf_file_header, sizeof (CAFFileHeader))) {
error_line ("%s", WavpackGetErrorMessage (wpc));
return WAVPACK_SOFT_ERROR;
}
WavpackBigEndianToNative (&caf_file_header, CAFFileHeaderFormat);
if (caf_file_header.mFileVersion != 1) {
error_line ("%s: can't handle version %d .CAF files!", infilename, caf_file_header.mFileVersion);
return WAVPACK_SOFT_ERROR;
}
// loop through all elements of the RIFF wav header
// (until the data chuck) and copy them to the output file
while (1) {
if (!DoReadFile (infile, &caf_chunk_header, sizeof (CAFChunkHeader), &bcount) ||
bcount != sizeof (CAFChunkHeader)) {
error_line ("%s is not a valid .CAF file!", infilename);
return WAVPACK_SOFT_ERROR;
}
else if (!(config->qmode & QMODE_NO_STORE_WRAPPER) &&
!WavpackAddWrapper (wpc, &caf_chunk_header, sizeof (CAFChunkHeader))) {
error_line ("%s", WavpackGetErrorMessage (wpc));
return WAVPACK_SOFT_ERROR;
}
WavpackBigEndianToNative (&caf_chunk_header, CAFChunkHeaderFormat);
// if it's the format chunk, we want to get some info out of there and
// make sure it's a .caf file we can handle
if (!strncmp (caf_chunk_header.mChunkType, "desc", 4)) {
int supported = TRUE;
if (caf_chunk_header.mChunkSize != sizeof (CAFAudioFormat) ||
!DoReadFile (infile, &caf_audio_format, (uint32_t) caf_chunk_header.mChunkSize, &bcount) ||
bcount != caf_chunk_header.mChunkSize) {
error_line ("%s is not a valid .CAF file!", infilename);
return WAVPACK_SOFT_ERROR;
}
else if (!(config->qmode & QMODE_NO_STORE_WRAPPER) &&
!WavpackAddWrapper (wpc, &caf_audio_format, (uint32_t) caf_chunk_header.mChunkSize)) {
error_line ("%s", WavpackGetErrorMessage (wpc));
return WAVPACK_SOFT_ERROR;
}
WavpackBigEndianToNative (&caf_audio_format, CAFAudioFormatFormat);
if (debug_logging_mode) {
char formatstr [5];
memcpy (formatstr, caf_audio_format.mFormatID, 4);
formatstr [4] = 0;
error_line ("format = %s, flags = %x, sampling rate = %g",
formatstr, caf_audio_format.mFormatFlags, caf_audio_format.mSampleRate);
error_line ("packet = %d bytes and %d frames",
caf_audio_format.mBytesPerPacket, caf_audio_format.mFramesPerPacket);
error_line ("channels per frame = %d, bits per channel = %d",
caf_audio_format.mChannelsPerFrame, caf_audio_format.mBitsPerChannel);
}
if (strncmp (caf_audio_format.mFormatID, "lpcm", 4) || (caf_audio_format.mFormatFlags & ~3))
supported = FALSE;
else if (caf_audio_format.mSampleRate < 1.0 || caf_audio_format.mSampleRate > 16777215.0 ||
caf_audio_format.mSampleRate != floor (caf_audio_format.mSampleRate))
supported = FALSE;
else if (!caf_audio_format.mChannelsPerFrame || caf_audio_format.mChannelsPerFrame > 256)
supported = FALSE;
else if (caf_audio_format.mBitsPerChannel < 1 || caf_audio_format.mBitsPerChannel > 32 ||
((caf_audio_format.mFormatFlags & CAF_FORMAT_FLOAT) && caf_audio_format.mBitsPerChannel != 32))
supported = FALSE;
else if (caf_audio_format.mFramesPerPacket != 1 ||
caf_audio_format.mBytesPerPacket / caf_audio_format.mChannelsPerFrame < (caf_audio_format.mBitsPerChannel + 7) / 8 ||
caf_audio_format.mBytesPerPacket / caf_audio_format.mChannelsPerFrame > 4 ||
caf_audio_format.mBytesPerPacket % caf_audio_format.mChannelsPerFrame)
supported = FALSE;
if (!supported) {
error_line ("%s is an unsupported .CAF format!", infilename);
return WAVPACK_SOFT_ERROR;
}
config->bytes_per_sample = caf_audio_format.mBytesPerPacket / caf_audio_format.mChannelsPerFrame;
config->float_norm_exp = (caf_audio_format.mFormatFlags & CAF_FORMAT_FLOAT) ? 127 : 0;
config->bits_per_sample = caf_audio_format.mBitsPerChannel;
config->num_channels = caf_audio_format.mChannelsPerFrame;
config->sample_rate = (int) caf_audio_format.mSampleRate;
if (!(caf_audio_format.mFormatFlags & CAF_FORMAT_LITTLE_ENDIAN) && config->bytes_per_sample > 1)
config->qmode |= QMODE_BIG_ENDIAN;
if (config->bytes_per_sample == 1)
config->qmode |= QMODE_SIGNED_BYTES;
if (debug_logging_mode) {
if (config->float_norm_exp == 127)
error_line ("data format: 32-bit %s-endian floating point", (config->qmode & QMODE_BIG_ENDIAN) ? "big" : "little");
else
error_line ("data format: %d-bit %s-endian integers stored in %d byte(s)",
config->bits_per_sample, (config->qmode & QMODE_BIG_ENDIAN) ? "big" : "little", config->bytes_per_sample);
}
}
else if (!strncmp (caf_chunk_header.mChunkType, "chan", 4)) {
CAFChannelLayout *caf_channel_layout;
if (caf_chunk_header.mChunkSize < 0 || caf_chunk_header.mChunkSize > 1024 ||
caf_chunk_header.mChunkSize < sizeof (CAFChannelLayout)) {
error_line ("this .CAF file has an invalid 'chan' chunk!");
return WAVPACK_SOFT_ERROR;
}
if (debug_logging_mode)
error_line ("'chan' chunk is %d bytes", (int) caf_chunk_header.mChunkSize);
caf_channel_layout = malloc ((size_t) caf_chunk_header.mChunkSize);
if (!DoReadFile (infile, caf_channel_layout, (uint32_t) caf_chunk_header.mChunkSize, &bcount) ||
bcount != caf_chunk_header.mChunkSize) {
error_line ("%s is not a valid .CAF file!", infilename);
free (caf_channel_layout);
return WAVPACK_SOFT_ERROR;
}
else if (!(config->qmode & QMODE_NO_STORE_WRAPPER) &&
!WavpackAddWrapper (wpc, caf_channel_layout, (uint32_t) caf_chunk_header.mChunkSize)) {
error_line ("%s", WavpackGetErrorMessage (wpc));
free (caf_channel_layout);
return WAVPACK_SOFT_ERROR;
}
WavpackBigEndianToNative (caf_channel_layout, CAFChannelLayoutFormat);
chan_chunk = 1;
if (config->channel_mask || (config->qmode & QMODE_CHANS_UNASSIGNED)) {
error_line ("this CAF file already has channel order information!");
free (caf_channel_layout);
return WAVPACK_SOFT_ERROR;
}
switch (caf_channel_layout->mChannelLayoutTag) {
case kCAFChannelLayoutTag_UseChannelDescriptions:
{
CAFChannelDescription *descriptions = (CAFChannelDescription *) (caf_channel_layout + 1);
int num_descriptions = caf_channel_layout->mNumberChannelDescriptions;
int label, cindex = 0, idents = 0;
if (caf_chunk_header.mChunkSize != sizeof (CAFChannelLayout) + sizeof (CAFChannelDescription) * num_descriptions ||
num_descriptions != config->num_channels) {
error_line ("channel descriptions in 'chan' chunk are the wrong size!");
free (caf_channel_layout);
return WAVPACK_SOFT_ERROR;
}
if (num_descriptions >= 256) {
error_line ("%d channel descriptions is more than we can handle...ignoring!");
break;
}
// we allocate (and initialize to invalid values) a channel reorder array
// (even though we might not end up doing any reordering) and a string for
// any non-Microsoft channels we encounter
channel_reorder = malloc (num_descriptions);
memset (channel_reorder, -1, num_descriptions);
channel_identities = malloc (num_descriptions+1);
// convert the descriptions array to our native endian so it's easy to access
for (i = 0; i < num_descriptions; ++i) {
WavpackBigEndianToNative (descriptions + i, CAFChannelDescriptionFormat);
if (debug_logging_mode)
error_line ("chan %d --> %d", i + 1, descriptions [i].mChannelLabel);
}
// first, we go though and find any MS channels present, and move those to the beginning
for (label = 1; label <= 18; ++label)
for (i = 0; i < num_descriptions; ++i)
if (descriptions [i].mChannelLabel == label) {
config->channel_mask |= 1 << (label - 1);
channel_reorder [i] = cindex++;
break;
}
// next, we go though the channels again assigning any we haven't done
for (i = 0; i < num_descriptions; ++i)
if (channel_reorder [i] == (unsigned char) -1) {
uint32_t clabel = descriptions [i].mChannelLabel;
if (clabel == 0 || clabel == 0xffffffff || clabel == 100)
channel_identities [idents++] = 0xff;
else if ((clabel >= 33 && clabel <= 44) || (clabel >= 200 && clabel <= 207) || (clabel >= 301 && clabel <= 305))
channel_identities [idents++] = clabel >= 301 ? clabel - 80 : clabel;
else {
error_line ("warning: unknown channel descriptions label: %d", clabel);
channel_identities [idents++] = 0xff;
}
channel_reorder [i] = cindex++;
}
// then, go through the reordering array and see if we really have to reorder
for (i = 0; i < num_descriptions; ++i)
if (channel_reorder [i] != i)
break;
if (i == num_descriptions) {
free (channel_reorder); // no reordering required, so don't
channel_reorder = NULL;
}
else {
config->qmode |= QMODE_REORDERED_CHANS; // reordering required, put channel count into layout
channel_layout = num_descriptions;
}
if (!idents) { // if no non-MS channels, free the identities string
free (channel_identities);
channel_identities = NULL;
}
else
channel_identities [idents] = 0; // otherwise NULL terminate it
if (debug_logging_mode) {
error_line ("layout_tag = 0x%08x, so generated bitmap of 0x%08x from %d descriptions, %d non-MS",
caf_channel_layout->mChannelLayoutTag, config->channel_mask,
caf_channel_layout->mNumberChannelDescriptions, idents);
// if debugging, display the reordering as a string (but only little ones)
if (channel_reorder && num_descriptions <= 8) {
char reorder_string [] = "12345678";
for (i = 0; i < num_descriptions; ++i)
reorder_string [i] = channel_reorder [i] + '1';
reorder_string [i] = 0;
error_line ("reordering string = \"%s\"\n", reorder_string);
}
}
}
break;
case kCAFChannelLayoutTag_UseChannelBitmap:
config->channel_mask = caf_channel_layout->mChannelBitmap;
if (debug_logging_mode)
error_line ("layout_tag = 0x%08x, so using supplied bitmap of 0x%08x",
caf_channel_layout->mChannelLayoutTag, caf_channel_layout->mChannelBitmap);
break;
default:
for (i = 0; i < NUM_LAYOUTS; ++i)
if (caf_channel_layout->mChannelLayoutTag == layouts [i].mChannelLayoutTag) {
config->channel_mask = layouts [i].mChannelBitmap;
channel_layout = layouts [i].mChannelLayoutTag;
if (layouts [i].mChannelReorder) {
channel_reorder = (unsigned char *) strdup (layouts [i].mChannelReorder);
config->qmode |= QMODE_REORDERED_CHANS;
}
if (layouts [i].mChannelIdentities)
channel_identities = (unsigned char *) strdup (layouts [i].mChannelIdentities);
if (debug_logging_mode)
error_line ("layout_tag 0x%08x found in table, bitmap = 0x%08x, reorder = %s, identities = %s",
channel_layout, config->channel_mask, channel_reorder ? "yes" : "no", channel_identities ? "yes" : "no");
break;
}
if (i == NUM_LAYOUTS && debug_logging_mode)
error_line ("layout_tag 0x%08x not found in table...all channels unassigned",
caf_channel_layout->mChannelLayoutTag);
break;
}
free (caf_channel_layout);
}
else if (!strncmp (caf_chunk_header.mChunkType, "data", 4)) { // on the data chunk, get size and exit loop
uint32_t mEditCount;
if (!DoReadFile (infile, &mEditCount, sizeof (mEditCount), &bcount) ||
bcount != sizeof (mEditCount)) {
error_line ("%s is not a valid .CAF file!", infilename);
return WAVPACK_SOFT_ERROR;
}
else if (!(config->qmode & QMODE_NO_STORE_WRAPPER) &&
!WavpackAddWrapper (wpc, &mEditCount, sizeof (mEditCount))) {
error_line ("%s", WavpackGetErrorMessage (wpc));
return WAVPACK_SOFT_ERROR;
}
if ((config->qmode & QMODE_IGNORE_LENGTH) || caf_chunk_header.mChunkSize == -1) {
config->qmode |= QMODE_IGNORE_LENGTH;
if (infilesize && DoGetFilePosition (infile) != -1)
total_samples = (infilesize - DoGetFilePosition (infile)) / caf_audio_format.mBytesPerPacket;
else
total_samples = -1;
}
else {
if (infilesize && infilesize - caf_chunk_header.mChunkSize > 16777216) {
error_line (".CAF file %s has over 16 MB of extra CAFF data, probably is corrupt!", infilename);
return WAVPACK_SOFT_ERROR;
}
if ((caf_chunk_header.mChunkSize - 4) % caf_audio_format.mBytesPerPacket) {
error_line (".CAF file %s has an invalid data chunk size, probably is corrupt!", infilename);
return WAVPACK_SOFT_ERROR;
}
total_samples = (caf_chunk_header.mChunkSize - 4) / caf_audio_format.mBytesPerPacket;
if (!total_samples) {
error_line ("this .CAF file has no audio samples, probably is corrupt!");
return WAVPACK_SOFT_ERROR;
}
if (total_samples > MAX_WAVPACK_SAMPLES) {
error_line ("%s has too many samples for WavPack!", infilename);
return WAVPACK_SOFT_ERROR;
}
}
break;
}
else { // just copy unknown chunks to output file
uint32_t bytes_to_copy = (uint32_t) caf_chunk_header.mChunkSize;
char *buff;
if (caf_chunk_header.mChunkSize < 0 || caf_chunk_header.mChunkSize > 1048576) {
error_line ("%s is not a valid .CAF file!", infilename);
return WAVPACK_SOFT_ERROR;
}
buff = malloc (bytes_to_copy);
if (debug_logging_mode)
error_line ("extra unknown chunk \"%c%c%c%c\" of %d bytes",
caf_chunk_header.mChunkType [0], caf_chunk_header.mChunkType [1], caf_chunk_header.mChunkType [2],
caf_chunk_header.mChunkType [3], caf_chunk_header.mChunkSize);
if (!DoReadFile (infile, buff, bytes_to_copy, &bcount) ||
bcount != bytes_to_copy ||
(!(config->qmode & QMODE_NO_STORE_WRAPPER) &&
!WavpackAddWrapper (wpc, buff, bytes_to_copy))) {
error_line ("%s", WavpackGetErrorMessage (wpc));
free (buff);
return WAVPACK_SOFT_ERROR;
}
free (buff);
}
}
if (!chan_chunk && !config->channel_mask && config->num_channels <= 2 && !(config->qmode & QMODE_CHANS_UNASSIGNED))
config->channel_mask = 0x5 - config->num_channels;
if (!WavpackSetConfiguration64 (wpc, config, total_samples, channel_identities)) {
error_line ("%s", WavpackGetErrorMessage (wpc));
return WAVPACK_SOFT_ERROR;
}
if (channel_identities)
free (channel_identities);
if (channel_layout || channel_reorder) {
if (!WavpackSetChannelLayout (wpc, channel_layout, channel_reorder)) {
error_line ("problem with setting channel layout (should not happen)");
return WAVPACK_SOFT_ERROR;
}
if (channel_reorder)
free (channel_reorder);
}
return WAVPACK_NO_ERROR;
} | 2284 | True | 1 |
|
CVE-2019-11498 | 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.0/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/dbry/WavPack/issues/67', 'name': 'https://github.com/dbry/WavPack/issues/67', 'refsource': 'MISC', 'tags': ['Exploit', 'Issue Tracking', 'Third Party Advisory']}, {'url': 'https://github.com/dbry/WavPack/commit/bc6cba3f552c44565f7f1e66dc1580189addb2b4', 'name': 'https://github.com/dbry/WavPack/commit/bc6cba3f552c44565f7f1e66dc1580189addb2b4', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://usn.ubuntu.com/3960-1/', 'name': 'USN-3960-1', 'refsource': 'UBUNTU', 'tags': ['Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/NZDKXGA2ZNSSM64ZYDHOWCO4Q4VAKAON/', 'name': 'FEDORA-2019-52145aa7ca', 'refsource': 'FEDORA', 'tags': []}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/SCK2YJXY6V5CKGKSF2PPN7RL2DXVOC6G/', 'name': 'FEDORA-2019-b8a704ff4b', 'refsource': 'FEDORA', 'tags': []}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/6CFFFWIWALGQPKINRDW3PRGRD5LOLGZA/', 'name': 'FEDORA-2020-e55567b6be', 'refsource': 'FEDORA', 'tags': []}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/BRWQNE3TH5UF64IKHKKHVCHJHUOVKJUH/', 'name': 'FEDORA-2020-73274c9df4', 'refsource': 'FEDORA', 'tags': []}, {'url': 'https://security.gentoo.org/glsa/202007-19', 'name': 'GLSA-202007-19', 'refsource': 'GENTOO', 'tags': []}, {'url': 'https://lists.debian.org/debian-lts-announce/2021/01/msg00013.html', 'name': '[debian-lts-announce] 20210115 [SECURITY] [DLA 2525-1] wavpack security update', 'refsource': 'MLIST', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-824'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:wavpack:wavpack:*:*:*:*:*:*:*:*', 'versionEndIncluding': '5.1.0', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:canonical:ubuntu_linux:18.04:*:*:*:lts:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:canonical:ubuntu_linux:18.10:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:canonical:ubuntu_linux:19.04:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'WavpackSetConfiguration64 in pack_utils.c in libwavpack.a in WavPack through 5.1.0 has a "Conditional jump or move depends on uninitialised value" condition, which might allow attackers to cause a denial of service (application crash) via a DFF file that lacks valid sample-rate data.'}] | 2021-01-15T13:15Z | 2019-04-24T05:29Z | Access of Uninitialized Pointer | The program accesses or uses a pointer that has not been initialized. |
If the pointer contains an uninitialized value, then the value might not point to a valid memory location. This could cause the program to read from or write to unexpected memory locations, leading to a denial of service. If the uninitialized pointer is used as a function call, then arbitrary functions could be invoked. If an attacker can influence the portion of uninitialized memory that is contained in the pointer, this weakness could be leveraged to execute code or perform other attacks.
Depending on memory layout, associated memory management behaviors, and program operation, the attacker might be able to influence the contents of the uninitialized pointer, thus gaining more fine-grained control of the memory location to be accessed.
| https://cwe.mitre.org/data/definitions/824.html | 0 | David Bryant | 2019-03-05 21:32:27-08:00 | issue #67: make sure sample rate is specified and non-zero in DFF files | bc6cba3f552c44565f7f1e66dc1580189addb2b4 | False | dbry/WavPack | WavPack encode/decode library, command-line programs, and several plugins | 2013-09-25 01:18:11 | 2022-08-17 05:32:09 | dbry | 224.0 | 54.0 | ParseDsdiffHeaderConfig | ParseDsdiffHeaderConfig( FILE * infile , char * infilename , char * fourcc , WavpackContext * wpc , WavpackConfig * config) | ['infile', 'infilename', 'fourcc', 'wpc', 'config'] | int ParseDsdiffHeaderConfig (FILE *infile, char *infilename, char *fourcc, WavpackContext *wpc, WavpackConfig *config)
{
int64_t infilesize, total_samples;
DFFFileHeader dff_file_header;
DFFChunkHeader dff_chunk_header;
uint32_t bcount;
infilesize = DoGetFileSize (infile);
memcpy (&dff_file_header, fourcc, 4);
if ((!DoReadFile (infile, ((char *) &dff_file_header) + 4, sizeof (DFFFileHeader) - 4, &bcount) ||
bcount != sizeof (DFFFileHeader) - 4) || strncmp (dff_file_header.formType, "DSD ", 4)) {
error_line ("%s is not a valid .DFF file!", infilename);
return WAVPACK_SOFT_ERROR;
}
else if (!(config->qmode & QMODE_NO_STORE_WRAPPER) &&
!WavpackAddWrapper (wpc, &dff_file_header, sizeof (DFFFileHeader))) {
error_line ("%s", WavpackGetErrorMessage (wpc));
return WAVPACK_SOFT_ERROR;
}
#if 1 // this might be a little too picky...
WavpackBigEndianToNative (&dff_file_header, DFFFileHeaderFormat);
if (infilesize && !(config->qmode & QMODE_IGNORE_LENGTH) &&
dff_file_header.ckDataSize && dff_file_header.ckDataSize + 1 && dff_file_header.ckDataSize + 12 != infilesize) {
error_line ("%s is not a valid .DFF file (by total size)!", infilename);
return WAVPACK_SOFT_ERROR;
}
if (debug_logging_mode)
error_line ("file header indicated length = %lld", dff_file_header.ckDataSize);
#endif
// loop through all elements of the DSDIFF header
// (until the data chuck) and copy them to the output file
while (1) {
if (!DoReadFile (infile, &dff_chunk_header, sizeof (DFFChunkHeader), &bcount) ||
bcount != sizeof (DFFChunkHeader)) {
error_line ("%s is not a valid .DFF file!", infilename);
return WAVPACK_SOFT_ERROR;
}
else if (!(config->qmode & QMODE_NO_STORE_WRAPPER) &&
!WavpackAddWrapper (wpc, &dff_chunk_header, sizeof (DFFChunkHeader))) {
error_line ("%s", WavpackGetErrorMessage (wpc));
return WAVPACK_SOFT_ERROR;
}
WavpackBigEndianToNative (&dff_chunk_header, DFFChunkHeaderFormat);
if (debug_logging_mode)
error_line ("chunk header indicated length = %lld", dff_chunk_header.ckDataSize);
if (!strncmp (dff_chunk_header.ckID, "FVER", 4)) {
uint32_t version;
if (dff_chunk_header.ckDataSize != sizeof (version) ||
!DoReadFile (infile, &version, sizeof (version), &bcount) ||
bcount != sizeof (version)) {
error_line ("%s is not a valid .DFF file!", infilename);
return WAVPACK_SOFT_ERROR;
}
else if (!(config->qmode & QMODE_NO_STORE_WRAPPER) &&
!WavpackAddWrapper (wpc, &version, sizeof (version))) {
error_line ("%s", WavpackGetErrorMessage (wpc));
return WAVPACK_SOFT_ERROR;
}
WavpackBigEndianToNative (&version, "L");
if (debug_logging_mode)
error_line ("dsdiff file version = 0x%08x", version);
}
else if (!strncmp (dff_chunk_header.ckID, "PROP", 4)) {
char *prop_chunk;
if (dff_chunk_header.ckDataSize < 4 || dff_chunk_header.ckDataSize > 1024) {
error_line ("%s is not a valid .DFF file!", infilename);
return WAVPACK_SOFT_ERROR;
}
if (debug_logging_mode)
error_line ("got PROP chunk of %d bytes total", (int) dff_chunk_header.ckDataSize);
prop_chunk = malloc ((size_t) dff_chunk_header.ckDataSize);
if (!DoReadFile (infile, prop_chunk, (uint32_t) dff_chunk_header.ckDataSize, &bcount) ||
bcount != dff_chunk_header.ckDataSize) {
error_line ("%s is not a valid .DFF file!", infilename);
free (prop_chunk);
return WAVPACK_SOFT_ERROR;
}
else if (!(config->qmode & QMODE_NO_STORE_WRAPPER) &&
!WavpackAddWrapper (wpc, prop_chunk, (uint32_t) dff_chunk_header.ckDataSize)) {
error_line ("%s", WavpackGetErrorMessage (wpc));
free (prop_chunk);
return WAVPACK_SOFT_ERROR;
}
if (!strncmp (prop_chunk, "SND ", 4)) {
char *cptr = prop_chunk + 4, *eptr = prop_chunk + dff_chunk_header.ckDataSize;
uint16_t numChannels = 0, chansSpecified, chanMask = 0;
uint32_t sampleRate;
while (eptr - cptr >= sizeof (dff_chunk_header)) {
memcpy (&dff_chunk_header, cptr, sizeof (dff_chunk_header));
cptr += sizeof (dff_chunk_header);
WavpackBigEndianToNative (&dff_chunk_header, DFFChunkHeaderFormat);
if (dff_chunk_header.ckDataSize > 0 && dff_chunk_header.ckDataSize <= eptr - cptr) {
if (!strncmp (dff_chunk_header.ckID, "FS ", 4) && dff_chunk_header.ckDataSize == 4) {
memcpy (&sampleRate, cptr, sizeof (sampleRate));
WavpackBigEndianToNative (&sampleRate, "L");
cptr += dff_chunk_header.ckDataSize;
if (debug_logging_mode)
error_line ("got sample rate of %u Hz", sampleRate);
}
else if (!strncmp (dff_chunk_header.ckID, "CHNL", 4) && dff_chunk_header.ckDataSize >= 2) {
memcpy (&numChannels, cptr, sizeof (numChannels));
WavpackBigEndianToNative (&numChannels, "S");
cptr += sizeof (numChannels);
chansSpecified = (int)(dff_chunk_header.ckDataSize - sizeof (numChannels)) / 4;
if (numChannels < chansSpecified || numChannels < 1 || numChannels > 256) {
error_line ("%s is not a valid .DFF file!", infilename);
free (prop_chunk);
return WAVPACK_SOFT_ERROR;
}
while (chansSpecified--) {
if (!strncmp (cptr, "SLFT", 4) || !strncmp (cptr, "MLFT", 4))
chanMask |= 0x1;
else if (!strncmp (cptr, "SRGT", 4) || !strncmp (cptr, "MRGT", 4))
chanMask |= 0x2;
else if (!strncmp (cptr, "LS ", 4))
chanMask |= 0x10;
else if (!strncmp (cptr, "RS ", 4))
chanMask |= 0x20;
else if (!strncmp (cptr, "C ", 4))
chanMask |= 0x4;
else if (!strncmp (cptr, "LFE ", 4))
chanMask |= 0x8;
else
if (debug_logging_mode)
error_line ("undefined channel ID %c%c%c%c", cptr [0], cptr [1], cptr [2], cptr [3]);
cptr += 4;
}
if (debug_logging_mode)
error_line ("%d channels, mask = 0x%08x", numChannels, chanMask);
}
else if (!strncmp (dff_chunk_header.ckID, "CMPR", 4) && dff_chunk_header.ckDataSize >= 4) {
if (strncmp (cptr, "DSD ", 4)) {
error_line ("DSDIFF files must be uncompressed, not \"%c%c%c%c\"!",
cptr [0], cptr [1], cptr [2], cptr [3]);
free (prop_chunk);
return WAVPACK_SOFT_ERROR;
}
cptr += dff_chunk_header.ckDataSize;
}
else {
if (debug_logging_mode)
error_line ("got PROP/SND chunk type \"%c%c%c%c\" of %d bytes", dff_chunk_header.ckID [0],
dff_chunk_header.ckID [1], dff_chunk_header.ckID [2], dff_chunk_header.ckID [3], dff_chunk_header.ckDataSize);
cptr += dff_chunk_header.ckDataSize;
}
}
else {
error_line ("%s is not a valid .DFF file!", infilename);
free (prop_chunk);
return WAVPACK_SOFT_ERROR;
}
}
if (chanMask && (config->channel_mask || (config->qmode & QMODE_CHANS_UNASSIGNED))) {
error_line ("this DSDIFF file already has channel order information!");
free (prop_chunk);
return WAVPACK_SOFT_ERROR;
}
else if (chanMask)
config->channel_mask = chanMask;
config->bits_per_sample = 8;
config->bytes_per_sample = 1;
config->num_channels = numChannels;
config->sample_rate = sampleRate / 8;
config->qmode |= QMODE_DSD_MSB_FIRST;
}
else if (debug_logging_mode)
error_line ("got unknown PROP chunk type \"%c%c%c%c\" of %d bytes",
prop_chunk [0], prop_chunk [1], prop_chunk [2], prop_chunk [3], dff_chunk_header.ckDataSize);
free (prop_chunk);
}
else if (!strncmp (dff_chunk_header.ckID, "DSD ", 4)) {
if (!config->num_channels) {
error_line ("%s is not a valid .DFF file!", infilename);
return WAVPACK_SOFT_ERROR;
}
total_samples = dff_chunk_header.ckDataSize / config->num_channels;
break;
}
else { // just copy unknown chunks to output file
int bytes_to_copy = (int)(((dff_chunk_header.ckDataSize) + 1) & ~(int64_t)1);
char *buff;
if (bytes_to_copy < 0 || bytes_to_copy > 4194304) {
error_line ("%s is not a valid .DFF file!", infilename);
return WAVPACK_SOFT_ERROR;
}
buff = malloc (bytes_to_copy);
if (debug_logging_mode)
error_line ("extra unknown chunk \"%c%c%c%c\" of %d bytes",
dff_chunk_header.ckID [0], dff_chunk_header.ckID [1], dff_chunk_header.ckID [2],
dff_chunk_header.ckID [3], dff_chunk_header.ckDataSize);
if (!DoReadFile (infile, buff, bytes_to_copy, &bcount) ||
bcount != bytes_to_copy ||
(!(config->qmode & QMODE_NO_STORE_WRAPPER) &&
!WavpackAddWrapper (wpc, buff, bytes_to_copy))) {
error_line ("%s", WavpackGetErrorMessage (wpc));
free (buff);
return WAVPACK_SOFT_ERROR;
}
free (buff);
}
}
if (debug_logging_mode)
error_line ("setting configuration with %lld samples", total_samples);
if (!WavpackSetConfiguration64 (wpc, config, total_samples, NULL)) {
error_line ("%s: %s", infilename, WavpackGetErrorMessage (wpc));
return WAVPACK_SOFT_ERROR;
}
return WAVPACK_NO_ERROR;
} | 1575 | True | 1 |
|
CVE-2016-10189 | 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.0/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/bitlbee/bitlbee/commit/701ab8129ba9ea64f569daedca9a8603abad740f', 'name': 'https://github.com/bitlbee/bitlbee/commit/701ab8129ba9ea64f569daedca9a8603abad740f', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://bugs.bitlbee.org/ticket/1282', 'name': 'https://bugs.bitlbee.org/ticket/1282', 'refsource': 'CONFIRM', 'tags': ['Issue Tracking', 'Patch', 'Vendor Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2017/01/31/11', 'name': '[oss-security] 20170131 Re: CVE Request - Remote DoS vulnerabilities in BitlBee', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Patch', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2017/01/30/4', 'name': '[oss-security] 20170130 CVE Request - Remote DoS vulnerabilities in BitlBee', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Patch', 'Third Party Advisory']}, {'url': 'http://www.securityfocus.com/bid/95931', 'name': '95931', 'refsource': 'BID', 'tags': []}, {'url': 'http://www.debian.org/security/2017/dsa-3853', 'name': 'DSA-3853', 'refsource': 'DEBIAN', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-476'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:bitlbee:bitlbee-libpurple:*:*:*:*:*:*:*:*', 'versionEndIncluding': '3.5', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:bitlbee:bitlbee:*:*:*:*:*:*:*:*', 'versionEndIncluding': '3.4.2', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'BitlBee before 3.5 allows remote attackers to cause a denial of service (NULL pointer dereference and crash) and possibly execute arbitrary code via a file transfer request for a contact that is not in the contact list.'}] | 2017-11-04T01:29Z | 2017-03-14T14:59Z | 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 | dequis | 2016-11-13 16:52:43-03:00 | imcb_file_send_start: handle ft attempts from non-existing users | 701ab8129ba9ea64f569daedca9a8603abad740f | False | bitlbee/bitlbee | An IRC to other chat networks gateway :bee: | 2015-01-24 21:21:23 | 2022-08-22 14:48:16 | https://www.bitlbee.org/ | bitlbee | 551.0 | 114.0 | imcb_file_send_start | imcb_file_send_start( struct im_connection * ic , char * handle , char * file_name , size_t file_size) | ['ic', 'handle', 'file_name', 'file_size'] | file_transfer_t *imcb_file_send_start(struct im_connection *ic, char *handle, char *file_name, size_t file_size)
{
bee_t *bee = ic->bee;
bee_user_t *bu = bee_user_by_handle(bee, ic, handle);
if (bee->ui->ft_in_start) {
return bee->ui->ft_in_start(bee, bu, file_name, file_size);
} else {
return NULL;
}
} | 73 | True | 1 |
CVE-2016-10196 | 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 | True | [{'url': 'https://github.com/libevent/libevent/issues/318', 'name': 'https://github.com/libevent/libevent/issues/318', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Issue Tracking', 'Third Party Advisory']}, {'url': 'https://github.com/libevent/libevent/commit/329acc18a0768c21ba22522f01a5c7f46cacc4d5', 'name': 'https://github.com/libevent/libevent/commit/329acc18a0768c21ba22522f01a5c7f46cacc4d5', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/libevent/libevent/blob/release-2.1.6-beta/ChangeLog', 'name': 'https://github.com/libevent/libevent/blob/release-2.1.6-beta/ChangeLog', 'refsource': 'CONFIRM', 'tags': ['Release Notes', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2017/02/02/7', 'name': '[oss-security] 20170202 Re: Bugs fixed in libevent 2.1.6', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2017/01/31/17', 'name': '[oss-security] 20170131 Bugs fixed in libevent 2.1.6', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'http://www.debian.org/security/2017/dsa-3789', 'name': 'DSA-3789', 'refsource': 'DEBIAN', 'tags': ['Third Party Advisory']}, {'url': 'http://www.securityfocus.com/bid/96014', 'name': '96014', 'refsource': 'BID', 'tags': ['Third Party Advisory', 'VDB Entry']}, {'url': 'https://security.gentoo.org/glsa/201705-01', 'name': 'GLSA-201705-01', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}, {'url': 'http://www.securitytracker.com/id/1038320', 'name': '1038320', 'refsource': 'SECTRACK', 'tags': ['Broken Link', 'Third Party Advisory', 'VDB Entry']}, {'url': 'https://access.redhat.com/errata/RHSA-2017:1201', 'name': 'RHSA-2017:1201', 'refsource': 'REDHAT', 'tags': ['Third Party Advisory']}, {'url': 'https://access.redhat.com/errata/RHSA-2017:1106', 'name': 'RHSA-2017:1106', 'refsource': 'REDHAT', 'tags': ['Third Party Advisory']}, {'url': 'https://access.redhat.com/errata/RHSA-2017:1104', 'name': 'RHSA-2017:1104', 'refsource': 'REDHAT', 'tags': ['Third Party Advisory']}, {'url': 'https://www.mozilla.org/security/advisories/mfsa2017-13/', 'name': 'https://www.mozilla.org/security/advisories/mfsa2017-13/', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'https://www.mozilla.org/security/advisories/mfsa2017-12/', 'name': 'https://www.mozilla.org/security/advisories/mfsa2017-12/', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'https://www.mozilla.org/security/advisories/mfsa2017-11/', 'name': 'https://www.mozilla.org/security/advisories/mfsa2017-11/', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'https://www.mozilla.org/security/advisories/mfsa2017-10/', 'name': 'https://www.mozilla.org/security/advisories/mfsa2017-10/', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'https://bugzilla.mozilla.org/show_bug.cgi?id=1343453', 'name': 'https://bugzilla.mozilla.org/show_bug.cgi?id=1343453', 'refsource': 'CONFIRM', 'tags': ['Issue Tracking', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-787'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:debian:debian_linux:8.0:*:*:*:*:*:*:*', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:libevent_project:libevent:*:*:*:*:*:*:*:*', 'versionEndIncluding': '2.1.5', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:mozilla:thunderbird:*:*:*:*:*:*:*:*', 'versionEndExcluding': '52.1.0', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:mozilla:firefox:*:*:*:*:*:*:*:*', 'versionEndExcluding': '53.0', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:mozilla:firefox_esr:*:*:*:*:*:*:*:*', 'versionEndExcluding': '45.9.0', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:mozilla:firefox_esr:52.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Stack-based buffer overflow in the evutil_parse_sockaddr_port function in evutil.c in libevent before 2.1.6-beta allows attackers to cause a denial of service (segmentation fault) via vectors involving a long string in brackets in the ip_as_string argument.'}] | 2022-01-31T17:38Z | 2017-03-15T15:59Z | 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 | Azat Khuzhin | 2016-01-31 00:57:16+03:00 | evutil_parse_sockaddr_port(): fix buffer overflow
@asn-the-goblin-slayer:
"Length between '[' and ']' is cast to signed 32 bit integer on line 1815. Is
the length is more than 2<<31 (INT_MAX), len will hold a negative value.
Consequently, it will pass the check at line 1816. Segfault happens at line
1819.
Generate a resolv.conf with generate-resolv.conf, then compile and run
poc.c. See entry-functions.txt for functions in tor that might be
vulnerable.
Please credit 'Guido Vranken' for this discovery through the Tor bug bounty
program."
Reproducer for gdb (https://gist.github.com/azat/be2b0d5e9417ba0dfe2c):
start
p (1ULL<<31)+1ULL
# $1 = 2147483649
p malloc(sizeof(struct sockaddr))
# $2 = (void *) 0x646010
p malloc(sizeof(int))
# $3 = (void *) 0x646030
p malloc($1)
# $4 = (void *) 0x7fff76a2a010
p memset($4, 1, $1)
# $5 = 1990369296
p (char *)$4
# $6 = 0x7fff76a2a010 '\001' <repeats 200 times>...
set $6[0]='['
set $6[$1]=']'
p evutil_parse_sockaddr_port($4, $2, $3)
# $7 = -1
Before:
$ gdb bin/http-connect < gdb
(gdb) $1 = 2147483649
(gdb) (gdb) $2 = (void *) 0x646010
(gdb) (gdb) $3 = (void *) 0x646030
(gdb) (gdb) $4 = (void *) 0x7fff76a2a010
(gdb) (gdb) $5 = 1990369296
(gdb) (gdb) $6 = 0x7fff76a2a010 '\001' <repeats 200 times>...
(gdb) (gdb) (gdb) (gdb)
Program received signal SIGSEGV, Segmentation fault.
__memcpy_sse2_unaligned () at memcpy-sse2-unaligned.S:36
After:
$ gdb bin/http-connect < gdb
(gdb) $1 = 2147483649
(gdb) (gdb) $2 = (void *) 0x646010
(gdb) (gdb) $3 = (void *) 0x646030
(gdb) (gdb) $4 = (void *) 0x7fff76a2a010
(gdb) (gdb) $5 = 1990369296
(gdb) (gdb) $6 = 0x7fff76a2a010 '\001' <repeats 200 times>...
(gdb) (gdb) (gdb) (gdb) $7 = -1
(gdb) (gdb) quit
Fixes: #318 | 329acc18a0768c21ba22522f01a5c7f46cacc4d5 | False | libevent/libevent | Event notification library | 2011-06-06 21:42:50 | 2022-08-27 13:50:10 | https://libevent.org | libevent | 9097.0 | 3099.0 | evutil_parse_sockaddr_port | evutil_parse_sockaddr_port( const char * ip_as_string , struct sockaddr * out , int * outlen) | ['ip_as_string', 'out', 'outlen'] | evutil_parse_sockaddr_port(const char *ip_as_string, struct sockaddr *out, int *outlen)
{
int port;
char buf[128];
const char *cp, *addr_part, *port_part;
int is_ipv6;
/* recognized formats are:
* [ipv6]:port
* ipv6
* [ipv6]
* ipv4:port
* ipv4
*/
cp = strchr(ip_as_string, ':');
if (*ip_as_string == '[') {
int len;
if (!(cp = strchr(ip_as_string, ']'))) {
return -1;
}
len = (int) ( cp-(ip_as_string + 1) );
if (len > (int)sizeof(buf)-1) {
return -1;
}
memcpy(buf, ip_as_string+1, len);
buf[len] = '\0';
addr_part = buf;
if (cp[1] == ':')
port_part = cp+2;
else
port_part = NULL;
is_ipv6 = 1;
} else if (cp && strchr(cp+1, ':')) {
is_ipv6 = 1;
addr_part = ip_as_string;
port_part = NULL;
} else if (cp) {
is_ipv6 = 0;
if (cp - ip_as_string > (int)sizeof(buf)-1) {
return -1;
}
memcpy(buf, ip_as_string, cp-ip_as_string);
buf[cp-ip_as_string] = '\0';
addr_part = buf;
port_part = cp+1;
} else {
addr_part = ip_as_string;
port_part = NULL;
is_ipv6 = 0;
}
if (port_part == NULL) {
port = 0;
} else {
port = atoi(port_part);
if (port <= 0 || port > 65535) {
return -1;
}
}
if (!addr_part)
return -1; /* Should be impossible. */
#ifdef AF_INET6
if (is_ipv6)
{
struct sockaddr_in6 sin6;
memset(&sin6, 0, sizeof(sin6));
#ifdef EVENT__HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN
sin6.sin6_len = sizeof(sin6);
#endif
sin6.sin6_family = AF_INET6;
sin6.sin6_port = htons(port);
if (1 != evutil_inet_pton(AF_INET6, addr_part, &sin6.sin6_addr))
return -1;
if ((int)sizeof(sin6) > *outlen)
return -1;
memset(out, 0, *outlen);
memcpy(out, &sin6, sizeof(sin6));
*outlen = sizeof(sin6);
return 0;
}
else
#endif
{
struct sockaddr_in sin;
memset(&sin, 0, sizeof(sin));
#ifdef EVENT__HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
sin.sin_len = sizeof(sin);
#endif
sin.sin_family = AF_INET;
sin.sin_port = htons(port);
if (1 != evutil_inet_pton(AF_INET, addr_part, &sin.sin_addr))
return -1;
if ((int)sizeof(sin) > *outlen)
return -1;
memset(out, 0, *outlen);
memcpy(out, &sin, sizeof(sin));
*outlen = sizeof(sin);
return 0;
}
} | 549 | True | 1 |
CVE-2016-10195 | 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 | True | [{'url': 'https://github.com/libevent/libevent/issues/317', 'name': 'https://github.com/libevent/libevent/issues/317', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Issue Tracking', 'Patch', 'Third Party Advisory']}, {'url': 'https://github.com/libevent/libevent/commit/96f64a022014a208105ead6c8a7066018449d86d', 'name': 'https://github.com/libevent/libevent/commit/96f64a022014a208105ead6c8a7066018449d86d', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/libevent/libevent/blob/release-2.1.6-beta/ChangeLog', 'name': 'https://github.com/libevent/libevent/blob/release-2.1.6-beta/ChangeLog', 'refsource': 'CONFIRM', 'tags': ['Release Notes', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2017/02/02/7', 'name': '[oss-security] 20170202 Re: Bugs fixed in libevent 2.1.6', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Patch', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2017/01/31/17', 'name': '[oss-security] 20170131 Bugs fixed in libevent 2.1.6', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Patch', 'Third Party Advisory']}, {'url': 'http://www.debian.org/security/2017/dsa-3789', 'name': 'DSA-3789', 'refsource': 'DEBIAN', 'tags': ['Third Party Advisory']}, {'url': 'http://www.securityfocus.com/bid/96014', 'name': '96014', 'refsource': 'BID', 'tags': ['Third Party Advisory', 'VDB Entry']}, {'url': 'https://security.gentoo.org/glsa/201705-01', 'name': 'GLSA-201705-01', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}, {'url': 'http://www.securitytracker.com/id/1038320', 'name': '1038320', 'refsource': 'SECTRACK', 'tags': ['Broken Link', 'Third Party Advisory', 'VDB Entry']}, {'url': 'https://access.redhat.com/errata/RHSA-2017:1201', 'name': 'RHSA-2017:1201', 'refsource': 'REDHAT', 'tags': ['Third Party Advisory']}, {'url': 'https://access.redhat.com/errata/RHSA-2017:1106', 'name': 'RHSA-2017:1106', 'refsource': 'REDHAT', 'tags': ['Third Party Advisory']}, {'url': 'https://access.redhat.com/errata/RHSA-2017:1104', 'name': 'RHSA-2017:1104', 'refsource': 'REDHAT', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:libevent_project:libevent:*:*:*:*:*:*:*:*', 'versionEndIncluding': '2.1.5', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:debian:debian_linux:8.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'The name_parse function in evdns.c in libevent before 2.1.6-beta allows remote attackers to have unspecified impact via vectors involving the label_len variable, which triggers an out-of-bounds stack read.'}] | 2022-01-31T17:39Z | 2017-03-15T15:59Z | 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 | Azat Khuzhin | 2016-02-01 17:32:09+03:00 | evdns: name_parse(): fix remote stack overread
@asn-the-goblin-slayer:
"the name_parse() function in libevent's DNS code is vulnerable to a buffer overread.
971 if (cp != name_out) {
972 if (cp + 1 >= end) return -1;
973 *cp++ = '.';
974 }
975 if (cp + label_len >= end) return -1;
976 memcpy(cp, packet + j, label_len);
977 cp += label_len;
978 j += label_len;
No check is made against length before the memcpy occurs.
This was found through the Tor bug bounty program and the discovery should be credited to 'Guido Vranken'."
Reproducer for gdb (https://gist.github.com/azat/e4fcf540e9b89ab86d02):
set $PROT_NONE=0x0
set $PROT_READ=0x1
set $PROT_WRITE=0x2
set $MAP_ANONYMOUS=0x20
set $MAP_SHARED=0x01
set $MAP_FIXED=0x10
set $MAP_32BIT=0x40
start
set $length=202
# overread
set $length=2
# allocate with mmap to have a seg fault on page boundary
set $l=(1<<20)*2
p mmap(0, $l, $PROT_READ|$PROT_WRITE, $MAP_ANONYMOUS|$MAP_SHARED|$MAP_32BIT, -1, 0)
set $packet=(char *)$1+$l-$length
# hack the packet
set $packet[0]=63
set $packet[1]='/'
p malloc(sizeof(int))
set $idx=(int *)$2
set $idx[0]=0
set $name_out_len=202
p malloc($name_out_len)
set $name_out=$3
# have WRITE only mapping to fail on read
set $end=$1+$l
p (void *)mmap($end, 1<<12, $PROT_NONE, $MAP_ANONYMOUS|$MAP_SHARED|$MAP_FIXED|$MAP_32BIT, -1, 0)
set $m=$4
p name_parse($packet, $length, $idx, $name_out, $name_out_len)
x/2s (char *)$name_out
Before this patch:
$ gdb -ex 'source gdb' dns-example
$1 = 1073741824
$2 = (void *) 0x633010
$3 = (void *) 0x633030
$4 = (void *) 0x40200000
Program received signal SIGSEGV, Segmentation fault.
__memcpy_sse2_unaligned () at memcpy-sse2-unaligned.S:33
After this patch:
$ gdb -ex 'source gdb' dns-example
$1 = 1073741824
$2 = (void *) 0x633010
$3 = (void *) 0x633030
$4 = (void *) 0x40200000
$5 = -1
0x633030: "/"
0x633032: ""
(gdb) p $m
$6 = (void *) 0x40200000
(gdb) p $1
$7 = 1073741824
(gdb) p/x $1
$8 = 0x40000000
(gdb) quit
P.S. plus drop one condition duplicate.
Fixes: #317 | 96f64a022014a208105ead6c8a7066018449d86d | False | libevent/libevent | Event notification library | 2011-06-06 21:42:50 | 2022-08-27 13:50:10 | https://libevent.org | libevent | 9097.0 | 3099.0 | name_parse | name_parse( u8 * packet , int length , int * idx , char * name_out , int name_out_len) | ['packet', 'length', 'idx', 'name_out', 'name_out_len'] | name_parse(u8 *packet, int length, int *idx, char *name_out, int name_out_len) {
int name_end = -1;
int j = *idx;
int ptr_count = 0;
#define GET32(x) do { if (j + 4 > length) goto err; memcpy(&t32_, packet + j, 4); j += 4; x = ntohl(t32_); } while (0)
#define GET16(x) do { if (j + 2 > length) goto err; memcpy(&t_, packet + j, 2); j += 2; x = ntohs(t_); } while (0)
#define GET8(x) do { if (j >= length) goto err; x = packet[j++]; } while (0)
char *cp = name_out;
const char *const end = name_out + name_out_len;
/* Normally, names are a series of length prefixed strings terminated */
/* with a length of 0 (the lengths are u8's < 63). */
/* However, the length can start with a pair of 1 bits and that */
/* means that the next 14 bits are a pointer within the current */
/* packet. */
for (;;) {
u8 label_len;
if (j >= length) return -1;
GET8(label_len);
if (!label_len) break;
if (label_len & 0xc0) {
u8 ptr_low;
GET8(ptr_low);
if (name_end < 0) name_end = j;
j = (((int)label_len & 0x3f) << 8) + ptr_low;
/* Make sure that the target offset is in-bounds. */
if (j < 0 || j >= length) return -1;
/* If we've jumped more times than there are characters in the
* message, we must have a loop. */
if (++ptr_count > length) return -1;
continue;
}
if (label_len > 63) return -1;
if (cp != name_out) {
if (cp + 1 >= end) return -1;
*cp++ = '.';
}
if (cp + label_len >= end) return -1;
memcpy(cp, packet + j, label_len);
cp += label_len;
j += label_len;
}
if (cp >= end) return -1;
*cp = '\0';
if (name_end < 0)
*idx = j;
else
*idx = name_end;
return 0;
err:
return -1;
} | 266 | True | 1 |
CVE-2016-10197 | 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 | nan | [{'url': 'https://github.com/libevent/libevent/issues/332', 'name': 'https://github.com/libevent/libevent/issues/332', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Issue Tracking', 'Third Party Advisory']}, {'url': 'https://github.com/libevent/libevent/commit/ec65c42052d95d2c23d1d837136d1cf1d9ecef9e', 'name': 'https://github.com/libevent/libevent/commit/ec65c42052d95d2c23d1d837136d1cf1d9ecef9e', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/libevent/libevent/blob/release-2.1.6-beta/ChangeLog', 'name': 'https://github.com/libevent/libevent/blob/release-2.1.6-beta/ChangeLog', 'refsource': 'CONFIRM', 'tags': ['Release Notes', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2017/02/02/7', 'name': '[oss-security] 20170202 Re: Bugs fixed in libevent 2.1.6', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2017/01/31/17', 'name': '[oss-security] 20170131 Bugs fixed in libevent 2.1.6', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'http://www.debian.org/security/2017/dsa-3789', 'name': 'DSA-3789', 'refsource': 'DEBIAN', 'tags': ['Third Party Advisory']}, {'url': 'http://www.securityfocus.com/bid/96014', 'name': '96014', 'refsource': 'BID', 'tags': ['Third Party Advisory', 'VDB Entry']}, {'url': 'https://security.gentoo.org/glsa/201705-01', 'name': 'GLSA-201705-01', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}, {'url': 'http://www.securitytracker.com/id/1038320', 'name': '1038320', 'refsource': 'SECTRACK', 'tags': ['Broken Link', 'Third Party Advisory', 'VDB Entry']}, {'url': 'https://access.redhat.com/errata/RHSA-2017:1201', 'name': 'RHSA-2017:1201', 'refsource': 'REDHAT', 'tags': ['Third Party Advisory']}, {'url': 'https://access.redhat.com/errata/RHSA-2017:1106', 'name': 'RHSA-2017:1106', 'refsource': 'REDHAT', 'tags': ['Third Party Advisory']}, {'url': 'https://access.redhat.com/errata/RHSA-2017:1104', 'name': 'RHSA-2017:1104', 'refsource': 'REDHAT', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:debian:debian_linux:8.0:*:*:*:*:*:*:*', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:libevent_project:libevent:*:*:*:*:*:*:*:*', 'versionEndIncluding': '2.1.5', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'The search_make_new function in evdns.c in libevent before 2.1.6-beta allows attackers to cause a denial of service (out-of-bounds read) via an empty hostname.'}] | 2022-01-31T17:38Z | 2017-03-15T15:59Z | 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 | Azat Khuzhin | 2016-03-25 00:33:47+03:00 | evdns: fix searching empty hostnames
From #332:
Here follows a bug report by **Guido Vranken** via the _Tor bug bounty program_. Please credit Guido accordingly.
## Bug report
The DNS code of Libevent contains this rather obvious OOB read:
```c
static char *
search_make_new(const struct search_state *const state, int n, const char *const base_name) {
const size_t base_len = strlen(base_name);
const char need_to_append_dot = base_name[base_len - 1] == '.' ? 0 : 1;
```
If the length of ```base_name``` is 0, then line 3125 reads 1 byte before the buffer. This will trigger a crash on ASAN-protected builds.
To reproduce:
Build libevent with ASAN:
```
$ CFLAGS='-fomit-frame-pointer -fsanitize=address' ./configure && make -j4
```
Put the attached ```resolv.conf``` and ```poc.c``` in the source directory and then do:
```
$ gcc -fsanitize=address -fomit-frame-pointer poc.c .libs/libevent.a
$ ./a.out
=================================================================
==22201== ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60060000efdf at pc 0x4429da bp 0x7ffe1ed47300 sp 0x7ffe1ed472f8
READ of size 1 at 0x60060000efdf thread T0
```
P.S. we can add a check earlier, but since this is very uncommon, I didn't add it.
Fixes: #332 | ec65c42052d95d2c23d1d837136d1cf1d9ecef9e | False | libevent/libevent | Event notification library | 2011-06-06 21:42:50 | 2022-08-27 13:50:10 | https://libevent.org | libevent | 9097.0 | 3099.0 | search_make_new | search_make_new( const struct search_state * const state , int n , const char * const base_name) | ['state', 'n', 'base_name'] | search_make_new(const struct search_state *const state, int n, const char *const base_name) {
const size_t base_len = strlen(base_name);
const char need_to_append_dot = base_name[base_len - 1] == '.' ? 0 : 1;
struct search_domain *dom;
for (dom = state->head; dom; dom = dom->next) {
if (!n--) {
/* this is the postfix we want */
/* the actual postfix string is kept at the end of the structure */
const u8 *const postfix = ((u8 *) dom) + sizeof(struct search_domain);
const int postfix_len = dom->len;
char *const newname = (char *) mm_malloc(base_len + need_to_append_dot + postfix_len + 1);
if (!newname) return NULL;
memcpy(newname, base_name, base_len);
if (need_to_append_dot) newname[base_len] = '.';
memcpy(newname + base_len + need_to_append_dot, postfix, postfix_len);
newname[base_len + need_to_append_dot + postfix_len] = 0;
return newname;
}
}
/* we ran off the end of the list and still didn't find the requested string */
EVUTIL_ASSERT(0);
return NULL; /* unreachable; stops warnings in some compilers. */
} | 188 | True | 1 |
CVE-2016-10207 | 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.0/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/TigerVNC/tigervnc/commit/8aa4bc53206c2430bbf0c8f4b642f59a379ee649', 'name': 'https://github.com/TigerVNC/tigervnc/commit/8aa4bc53206c2430bbf0c8f4b642f59a379ee649', 'refsource': 'CONFIRM', 'tags': ['Patch']}, {'url': 'https://bugzilla.suse.com/show_bug.cgi?id=1023012', 'name': 'https://bugzilla.suse.com/show_bug.cgi?id=1023012', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Issue Tracking', 'Third Party Advisory', 'VDB Entry']}, {'url': 'http://www.securityfocus.com/bid/96012', 'name': '96012', 'refsource': 'BID', 'tags': ['Third Party Advisory', 'VDB Entry']}, {'url': 'http://www.openwall.com/lists/oss-security/2017/02/05/2', 'name': '[oss-security] 20170204 Re: CVE request tigervnc: vnc server can crash when TLS handshake terminates early', 'refsource': 'MLIST', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2017/02/02/22', 'name': '[oss-security] 20170202 CVE request tigervnc: vnc server can crash when TLS handshake terminates early', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'http://lists.opensuse.org/opensuse-security-announce/2017-02/msg00020.html', 'name': 'openSUSE-SU-2017:0444', 'refsource': 'SUSE', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://access.redhat.com/errata/RHSA-2017:2000', 'name': 'RHSA-2017:2000', 'refsource': 'REDHAT', 'tags': ['Third Party Advisory']}, {'url': 'http://rhn.redhat.com/errata/RHSA-2017-0630.html', 'name': 'RHSA-2017:0630', 'refsource': 'REDHAT', 'tags': ['Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/201801-13', 'name': 'GLSA-201801-13', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-119'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:opensuse:leap:42.2:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:opensuse:leap:42.1:*:*:*:*:*:*:*', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:0.0.90:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:1.3:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:0.0.91:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:1.0:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:1.1.0:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:1.7:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:1.3.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'The Xvnc server in TigerVNC allows remote attackers to cause a denial of service (invalid memory access and crash) by terminating a TLS handshake early.'}] | 2018-02-01T17:05Z | 2017-02-28T18:59Z | 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 | Pierre Ossman | 2016-08-23 17:02:58+02:00 | Proper global init/deinit of GnuTLS
These are reference counted so it is important to retain symmetry
between the calls. Failure to do so will result in bad memory access
and crashes. | 8aa4bc53206c2430bbf0c8f4b642f59a379ee649 | False | TigerVNC/tigervnc | High performance, multi-platform VNC client and server | 2014-06-25 12:48:26 | 2022-08-26 00:49:49 | https://tigervnc.org | TigerVNC | 3517.0 | 756.0 | CSecurityTLS::initGlobal | CSecurityTLS::initGlobal() | [] | void CSecurityTLS::initGlobal()
{
static bool globalInitDone = false;
if (!globalInitDone) {
gnutls_global_init();
globalInitDone = true;
}
} | 28 | True | 1 |
CVE-2016-10207 | 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.0/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/TigerVNC/tigervnc/commit/8aa4bc53206c2430bbf0c8f4b642f59a379ee649', 'name': 'https://github.com/TigerVNC/tigervnc/commit/8aa4bc53206c2430bbf0c8f4b642f59a379ee649', 'refsource': 'CONFIRM', 'tags': ['Patch']}, {'url': 'https://bugzilla.suse.com/show_bug.cgi?id=1023012', 'name': 'https://bugzilla.suse.com/show_bug.cgi?id=1023012', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Issue Tracking', 'Third Party Advisory', 'VDB Entry']}, {'url': 'http://www.securityfocus.com/bid/96012', 'name': '96012', 'refsource': 'BID', 'tags': ['Third Party Advisory', 'VDB Entry']}, {'url': 'http://www.openwall.com/lists/oss-security/2017/02/05/2', 'name': '[oss-security] 20170204 Re: CVE request tigervnc: vnc server can crash when TLS handshake terminates early', 'refsource': 'MLIST', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2017/02/02/22', 'name': '[oss-security] 20170202 CVE request tigervnc: vnc server can crash when TLS handshake terminates early', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'http://lists.opensuse.org/opensuse-security-announce/2017-02/msg00020.html', 'name': 'openSUSE-SU-2017:0444', 'refsource': 'SUSE', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://access.redhat.com/errata/RHSA-2017:2000', 'name': 'RHSA-2017:2000', 'refsource': 'REDHAT', 'tags': ['Third Party Advisory']}, {'url': 'http://rhn.redhat.com/errata/RHSA-2017-0630.html', 'name': 'RHSA-2017:0630', 'refsource': 'REDHAT', 'tags': ['Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/201801-13', 'name': 'GLSA-201801-13', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-119'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:opensuse:leap:42.2:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:opensuse:leap:42.1:*:*:*:*:*:*:*', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:0.0.90:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:1.3:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:0.0.91:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:1.0:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:1.1.0:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:1.7:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:1.3.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'The Xvnc server in TigerVNC allows remote attackers to cause a denial of service (invalid memory access and crash) by terminating a TLS handshake early.'}] | 2018-02-01T17:05Z | 2017-02-28T18:59Z | 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 | Pierre Ossman | 2016-08-23 17:02:58+02:00 | Proper global init/deinit of GnuTLS
These are reference counted so it is important to retain symmetry
between the calls. Failure to do so will result in bad memory access
and crashes. | 8aa4bc53206c2430bbf0c8f4b642f59a379ee649 | False | TigerVNC/tigervnc | High performance, multi-platform VNC client and server | 2014-06-25 12:48:26 | 2022-08-26 00:49:49 | https://tigervnc.org | TigerVNC | 3517.0 | 756.0 | CSecurityTLS::processMsg | CSecurityTLS::processMsg( CConnection * cc) | ['cc'] | bool CSecurityTLS::processMsg(CConnection* cc)
{
rdr::InStream* is = cc->getInStream();
rdr::OutStream* os = cc->getOutStream();
client = cc;
initGlobal();
if (!session) {
if (!is->checkNoWait(1))
return false;
if (is->readU8() == 0) {
rdr::U32 result = is->readU32();
CharArray reason;
if (result == secResultFailed || result == secResultTooMany)
reason.buf = is->readString();
else
reason.buf = strDup("Authentication failure (protocol error)");
throw AuthFailureException(reason.buf);
}
if (gnutls_init(&session, GNUTLS_CLIENT) != GNUTLS_E_SUCCESS)
throw AuthFailureException("gnutls_init failed");
if (gnutls_set_default_priority(session) != GNUTLS_E_SUCCESS)
throw AuthFailureException("gnutls_set_default_priority failed");
setParam();
}
rdr::TLSInStream *tlsis = new rdr::TLSInStream(is, session);
rdr::TLSOutStream *tlsos = new rdr::TLSOutStream(os, session);
int err;
err = gnutls_handshake(session);
if (err != GNUTLS_E_SUCCESS) {
delete tlsis;
delete tlsos;
if (!gnutls_error_is_fatal(err))
return false;
vlog.error("TLS Handshake failed: %s\n", gnutls_strerror (err));
shutdown(false);
throw AuthFailureException("TLS Handshake failed");
}
checkSession();
cc->setStreams(fis = tlsis, fos = tlsos);
return true;
} | 273 | True | 1 |
CVE-2016-10207 | 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.0/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/TigerVNC/tigervnc/commit/8aa4bc53206c2430bbf0c8f4b642f59a379ee649', 'name': 'https://github.com/TigerVNC/tigervnc/commit/8aa4bc53206c2430bbf0c8f4b642f59a379ee649', 'refsource': 'CONFIRM', 'tags': ['Patch']}, {'url': 'https://bugzilla.suse.com/show_bug.cgi?id=1023012', 'name': 'https://bugzilla.suse.com/show_bug.cgi?id=1023012', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Issue Tracking', 'Third Party Advisory', 'VDB Entry']}, {'url': 'http://www.securityfocus.com/bid/96012', 'name': '96012', 'refsource': 'BID', 'tags': ['Third Party Advisory', 'VDB Entry']}, {'url': 'http://www.openwall.com/lists/oss-security/2017/02/05/2', 'name': '[oss-security] 20170204 Re: CVE request tigervnc: vnc server can crash when TLS handshake terminates early', 'refsource': 'MLIST', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2017/02/02/22', 'name': '[oss-security] 20170202 CVE request tigervnc: vnc server can crash when TLS handshake terminates early', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'http://lists.opensuse.org/opensuse-security-announce/2017-02/msg00020.html', 'name': 'openSUSE-SU-2017:0444', 'refsource': 'SUSE', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://access.redhat.com/errata/RHSA-2017:2000', 'name': 'RHSA-2017:2000', 'refsource': 'REDHAT', 'tags': ['Third Party Advisory']}, {'url': 'http://rhn.redhat.com/errata/RHSA-2017-0630.html', 'name': 'RHSA-2017:0630', 'refsource': 'REDHAT', 'tags': ['Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/201801-13', 'name': 'GLSA-201801-13', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-119'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:opensuse:leap:42.2:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:opensuse:leap:42.1:*:*:*:*:*:*:*', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:0.0.90:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:1.3:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:0.0.91:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:1.0:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:1.1.0:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:1.7:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:1.3.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'The Xvnc server in TigerVNC allows remote attackers to cause a denial of service (invalid memory access and crash) by terminating a TLS handshake early.'}] | 2018-02-01T17:05Z | 2017-02-28T18:59Z | 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 | Pierre Ossman | 2016-08-23 17:02:58+02:00 | Proper global init/deinit of GnuTLS
These are reference counted so it is important to retain symmetry
between the calls. Failure to do so will result in bad memory access
and crashes. | 8aa4bc53206c2430bbf0c8f4b642f59a379ee649 | False | TigerVNC/tigervnc | High performance, multi-platform VNC client and server | 2014-06-25 12:48:26 | 2022-08-26 00:49:49 | https://tigervnc.org | TigerVNC | 3517.0 | 756.0 | CSecurityTLS::shutdown | CSecurityTLS::shutdown( bool needbye) | ['needbye'] | void CSecurityTLS::shutdown(bool needbye)
{
if (session && needbye)
if (gnutls_bye(session, GNUTLS_SHUT_RDWR) != GNUTLS_E_SUCCESS)
vlog.error("gnutls_bye failed");
if (anon_cred) {
gnutls_anon_free_client_credentials(anon_cred);
anon_cred = 0;
}
if (cert_cred) {
gnutls_certificate_free_credentials(cert_cred);
cert_cred = 0;
}
if (session) {
gnutls_deinit(session);
session = 0;
gnutls_global_deinit();
}
} | 82 | True | 1 |
CVE-2016-10207 | 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.0/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/TigerVNC/tigervnc/commit/8aa4bc53206c2430bbf0c8f4b642f59a379ee649', 'name': 'https://github.com/TigerVNC/tigervnc/commit/8aa4bc53206c2430bbf0c8f4b642f59a379ee649', 'refsource': 'CONFIRM', 'tags': ['Patch']}, {'url': 'https://bugzilla.suse.com/show_bug.cgi?id=1023012', 'name': 'https://bugzilla.suse.com/show_bug.cgi?id=1023012', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Issue Tracking', 'Third Party Advisory', 'VDB Entry']}, {'url': 'http://www.securityfocus.com/bid/96012', 'name': '96012', 'refsource': 'BID', 'tags': ['Third Party Advisory', 'VDB Entry']}, {'url': 'http://www.openwall.com/lists/oss-security/2017/02/05/2', 'name': '[oss-security] 20170204 Re: CVE request tigervnc: vnc server can crash when TLS handshake terminates early', 'refsource': 'MLIST', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2017/02/02/22', 'name': '[oss-security] 20170202 CVE request tigervnc: vnc server can crash when TLS handshake terminates early', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'http://lists.opensuse.org/opensuse-security-announce/2017-02/msg00020.html', 'name': 'openSUSE-SU-2017:0444', 'refsource': 'SUSE', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://access.redhat.com/errata/RHSA-2017:2000', 'name': 'RHSA-2017:2000', 'refsource': 'REDHAT', 'tags': ['Third Party Advisory']}, {'url': 'http://rhn.redhat.com/errata/RHSA-2017-0630.html', 'name': 'RHSA-2017:0630', 'refsource': 'REDHAT', 'tags': ['Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/201801-13', 'name': 'GLSA-201801-13', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-119'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:opensuse:leap:42.2:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:opensuse:leap:42.1:*:*:*:*:*:*:*', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:0.0.90:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:1.3:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:0.0.91:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:1.0:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:1.1.0:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:1.7:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:1.3.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'The Xvnc server in TigerVNC allows remote attackers to cause a denial of service (invalid memory access and crash) by terminating a TLS handshake early.'}] | 2018-02-01T17:05Z | 2017-02-28T18:59Z | 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 | Pierre Ossman | 2016-08-23 17:02:58+02:00 | Proper global init/deinit of GnuTLS
These are reference counted so it is important to retain symmetry
between the calls. Failure to do so will result in bad memory access
and crashes. | 8aa4bc53206c2430bbf0c8f4b642f59a379ee649 | False | TigerVNC/tigervnc | High performance, multi-platform VNC client and server | 2014-06-25 12:48:26 | 2022-08-26 00:49:49 | https://tigervnc.org | TigerVNC | 3517.0 | 756.0 | SSecurityTLS::initGlobal | SSecurityTLS::initGlobal() | [] | void SSecurityTLS::initGlobal()
{
static bool globalInitDone = false;
if (!globalInitDone) {
if (gnutls_global_init() != GNUTLS_E_SUCCESS)
throw AuthFailureException("gnutls_global_init failed");
globalInitDone = true;
}
} | 38 | True | 1 |
CVE-2016-10207 | 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.0/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/TigerVNC/tigervnc/commit/8aa4bc53206c2430bbf0c8f4b642f59a379ee649', 'name': 'https://github.com/TigerVNC/tigervnc/commit/8aa4bc53206c2430bbf0c8f4b642f59a379ee649', 'refsource': 'CONFIRM', 'tags': ['Patch']}, {'url': 'https://bugzilla.suse.com/show_bug.cgi?id=1023012', 'name': 'https://bugzilla.suse.com/show_bug.cgi?id=1023012', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Issue Tracking', 'Third Party Advisory', 'VDB Entry']}, {'url': 'http://www.securityfocus.com/bid/96012', 'name': '96012', 'refsource': 'BID', 'tags': ['Third Party Advisory', 'VDB Entry']}, {'url': 'http://www.openwall.com/lists/oss-security/2017/02/05/2', 'name': '[oss-security] 20170204 Re: CVE request tigervnc: vnc server can crash when TLS handshake terminates early', 'refsource': 'MLIST', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2017/02/02/22', 'name': '[oss-security] 20170202 CVE request tigervnc: vnc server can crash when TLS handshake terminates early', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'http://lists.opensuse.org/opensuse-security-announce/2017-02/msg00020.html', 'name': 'openSUSE-SU-2017:0444', 'refsource': 'SUSE', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://access.redhat.com/errata/RHSA-2017:2000', 'name': 'RHSA-2017:2000', 'refsource': 'REDHAT', 'tags': ['Third Party Advisory']}, {'url': 'http://rhn.redhat.com/errata/RHSA-2017-0630.html', 'name': 'RHSA-2017:0630', 'refsource': 'REDHAT', 'tags': ['Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/201801-13', 'name': 'GLSA-201801-13', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-119'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:opensuse:leap:42.2:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:opensuse:leap:42.1:*:*:*:*:*:*:*', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:0.0.90:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:1.3:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:0.0.91:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:1.0:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:1.1.0:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:1.7:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:1.3.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'The Xvnc server in TigerVNC allows remote attackers to cause a denial of service (invalid memory access and crash) by terminating a TLS handshake early.'}] | 2018-02-01T17:05Z | 2017-02-28T18:59Z | 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 | Pierre Ossman | 2016-08-23 17:02:58+02:00 | Proper global init/deinit of GnuTLS
These are reference counted so it is important to retain symmetry
between the calls. Failure to do so will result in bad memory access
and crashes. | 8aa4bc53206c2430bbf0c8f4b642f59a379ee649 | False | TigerVNC/tigervnc | High performance, multi-platform VNC client and server | 2014-06-25 12:48:26 | 2022-08-26 00:49:49 | https://tigervnc.org | TigerVNC | 3517.0 | 756.0 | SSecurityTLS::processMsg | SSecurityTLS::processMsg( SConnection * sc) | ['sc'] | bool SSecurityTLS::processMsg(SConnection *sc)
{
rdr::InStream* is = sc->getInStream();
rdr::OutStream* os = sc->getOutStream();
vlog.debug("Process security message (session %p)", session);
if (!session) {
initGlobal();
if (gnutls_init(&session, GNUTLS_SERVER) != GNUTLS_E_SUCCESS)
throw AuthFailureException("gnutls_init failed");
if (gnutls_set_default_priority(session) != GNUTLS_E_SUCCESS)
throw AuthFailureException("gnutls_set_default_priority failed");
try {
setParams(session);
}
catch(...) {
os->writeU8(0);
throw;
}
os->writeU8(1);
os->flush();
}
rdr::TLSInStream *tlsis = new rdr::TLSInStream(is, session);
rdr::TLSOutStream *tlsos = new rdr::TLSOutStream(os, session);
int err;
err = gnutls_handshake(session);
if (err != GNUTLS_E_SUCCESS) {
delete tlsis;
delete tlsos;
if (!gnutls_error_is_fatal(err)) {
vlog.debug("Deferring completion of TLS handshake: %s", gnutls_strerror(err));
return false;
}
vlog.error("TLS Handshake failed: %s", gnutls_strerror (err));
shutdown();
throw AuthFailureException("TLS Handshake failed");
}
vlog.debug("Handshake completed");
sc->setStreams(fis = tlsis, fos = tlsos);
return true;
} | 249 | True | 1 |
CVE-2016-10207 | 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.0/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/TigerVNC/tigervnc/commit/8aa4bc53206c2430bbf0c8f4b642f59a379ee649', 'name': 'https://github.com/TigerVNC/tigervnc/commit/8aa4bc53206c2430bbf0c8f4b642f59a379ee649', 'refsource': 'CONFIRM', 'tags': ['Patch']}, {'url': 'https://bugzilla.suse.com/show_bug.cgi?id=1023012', 'name': 'https://bugzilla.suse.com/show_bug.cgi?id=1023012', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Issue Tracking', 'Third Party Advisory', 'VDB Entry']}, {'url': 'http://www.securityfocus.com/bid/96012', 'name': '96012', 'refsource': 'BID', 'tags': ['Third Party Advisory', 'VDB Entry']}, {'url': 'http://www.openwall.com/lists/oss-security/2017/02/05/2', 'name': '[oss-security] 20170204 Re: CVE request tigervnc: vnc server can crash when TLS handshake terminates early', 'refsource': 'MLIST', 'tags': ['Exploit', 'Mailing List', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2017/02/02/22', 'name': '[oss-security] 20170202 CVE request tigervnc: vnc server can crash when TLS handshake terminates early', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'http://lists.opensuse.org/opensuse-security-announce/2017-02/msg00020.html', 'name': 'openSUSE-SU-2017:0444', 'refsource': 'SUSE', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://access.redhat.com/errata/RHSA-2017:2000', 'name': 'RHSA-2017:2000', 'refsource': 'REDHAT', 'tags': ['Third Party Advisory']}, {'url': 'http://rhn.redhat.com/errata/RHSA-2017-0630.html', 'name': 'RHSA-2017:0630', 'refsource': 'REDHAT', 'tags': ['Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/201801-13', 'name': 'GLSA-201801-13', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-119'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:opensuse:leap:42.2:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:opensuse:leap:42.1:*:*:*:*:*:*:*', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:0.0.90:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:1.3:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:0.0.91:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:1.0:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:1.1.0:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:1.7:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:1.3.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'The Xvnc server in TigerVNC allows remote attackers to cause a denial of service (invalid memory access and crash) by terminating a TLS handshake early.'}] | 2018-02-01T17:05Z | 2017-02-28T18:59Z | 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 | Pierre Ossman | 2016-08-23 17:02:58+02:00 | Proper global init/deinit of GnuTLS
These are reference counted so it is important to retain symmetry
between the calls. Failure to do so will result in bad memory access
and crashes. | 8aa4bc53206c2430bbf0c8f4b642f59a379ee649 | False | TigerVNC/tigervnc | High performance, multi-platform VNC client and server | 2014-06-25 12:48:26 | 2022-08-26 00:49:49 | https://tigervnc.org | TigerVNC | 3517.0 | 756.0 | SSecurityTLS::shutdown | SSecurityTLS::shutdown() | [] | void SSecurityTLS::shutdown()
{
if (session) {
if (gnutls_bye(session, GNUTLS_SHUT_RDWR) != GNUTLS_E_SUCCESS) {
/* FIXME: Treat as non-fatal error */
vlog.error("TLS session wasn't terminated gracefully");
}
}
if (dh_params) {
gnutls_dh_params_deinit(dh_params);
dh_params = 0;
}
if (anon_cred) {
gnutls_anon_free_server_credentials(anon_cred);
anon_cred = 0;
}
if (cert_cred) {
gnutls_certificate_free_credentials(cert_cred);
cert_cred = 0;
}
if (session) {
gnutls_deinit(session);
session = 0;
gnutls_global_deinit();
}
} | 97 | True | 1 |
CVE-2017-5581 | 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.0/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 | nan | [{'url': 'https://github.com/TigerVNC/tigervnc/releases/tag/v1.7.1', 'name': 'https://github.com/TigerVNC/tigervnc/releases/tag/v1.7.1', 'refsource': 'CONFIRM', 'tags': ['Release Notes', 'Third Party Advisory']}, {'url': 'https://github.com/TigerVNC/tigervnc/pull/399', 'name': 'https://github.com/TigerVNC/tigervnc/pull/399', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/TigerVNC/tigervnc/commit/18c020124ff1b2441f714da2017f63dba50720ba', 'name': 'https://github.com/TigerVNC/tigervnc/commit/18c020124ff1b2441f714da2017f63dba50720ba', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://www.securityfocus.com/bid/95789', 'name': '95789', 'refsource': 'BID', 'tags': ['Third Party Advisory', 'VDB Entry']}, {'url': 'http://www.openwall.com/lists/oss-security/2017/01/25/6', 'name': '[oss-security] 20170125 Re: [tigervnc-announce] TigerVNC 1.7.1', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Patch', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2017/01/22/1', 'name': '[oss-security] 20170121 Re: [tigervnc-announce] TigerVNC 1.7.1', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Patch', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/201702-19', 'name': 'GLSA-201702-19', 'refsource': 'GENTOO', 'tags': []}, {'url': 'https://access.redhat.com/errata/RHSA-2017:2000', 'name': 'RHSA-2017:2000', 'refsource': 'REDHAT', 'tags': []}, {'url': 'http://rhn.redhat.com/errata/RHSA-2017-0630.html', 'name': 'RHSA-2017:0630', 'refsource': 'REDHAT', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-119'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:*:*:*:*:*:*:*:*', 'versionEndIncluding': '1.7', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Buffer overflow in the ModifiablePixelBuffer::fillRect function in TigerVNC before 1.7.1 allows remote servers to execute arbitrary code via an RRE message with subrectangle outside framebuffer boundaries.'}] | 2018-01-05T02:31Z | 2017-02-28T18:59Z | 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 | Michal Srb | 2017-01-13 16:32:23+02:00 | Fix buffer overflow in ModifiablePixelBuffer::fillRect.
It can be triggered by RRE message with subrectangle out of framebuffer
boundaries. It may prevent the same kind of issue caused by evil message
from another encoding too. | 18c020124ff1b2441f714da2017f63dba50720ba | False | TigerVNC/tigervnc | High performance, multi-platform VNC client and server | 2014-06-25 12:48:26 | 2022-08-26 00:49:49 | https://tigervnc.org | TigerVNC | 3517.0 | 756.0 | ModifiablePixelBuffer::fillRect | ModifiablePixelBuffer::fillRect( const Rect & r , const void * pix) | ['r', 'pix'] | void ModifiablePixelBuffer::fillRect(const Rect& r, const void* pix)
{
int stride;
U8 *buf;
int w, h, b;
w = r.width();
h = r.height();
b = format.bpp/8;
if (h == 0)
return;
buf = getBufferRW(r, &stride);
if (b == 1) {
while (h--) {
memset(buf, *(const U8*)pix, w);
buf += stride * b;
}
} else {
U8 *start;
int w1;
start = buf;
w1 = w;
while (w1--) {
memcpy(buf, pix, b);
buf += b;
}
buf += (stride - w) * b;
h--;
while (h--) {
memcpy(buf, start, w * b);
buf += stride * b;
}
}
commitBufferRW(r);
} | 188 | True | 1 |
CVE-2020-26117 | False | False | False | True | AV:N/AC:M/Au:N/C:P/I:P/A:N | NETWORK | MEDIUM | NONE | PARTIAL | PARTIAL | NONE | 5.8 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:N | NETWORK | LOW | NONE | REQUIRED | UNCHANGED | HIGH | HIGH | NONE | 8.1 | HIGH | 2.8 | 5.2 | False | [{'url': 'https://github.com/TigerVNC/tigervnc/commit/20dea801e747318525a5859fe4f37c52b05310cb', 'name': 'https://github.com/TigerVNC/tigervnc/commit/20dea801e747318525a5859fe4f37c52b05310cb', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/TigerVNC/tigervnc/commit/b30f10c681ec87720cff85d490f67098568a9cba', 'name': 'https://github.com/TigerVNC/tigervnc/commit/b30f10c681ec87720cff85d490f67098568a9cba', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/TigerVNC/tigervnc/releases/tag/v1.11.0', 'name': 'https://github.com/TigerVNC/tigervnc/releases/tag/v1.11.0', 'refsource': 'MISC', 'tags': ['Release Notes', 'Third Party Advisory']}, {'url': 'https://github.com/TigerVNC/tigervnc/commit/f029745f63ac7d22fb91639b2cb5b3ab56134d6e', 'name': 'https://github.com/TigerVNC/tigervnc/commit/f029745f63ac7d22fb91639b2cb5b3ab56134d6e', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://bugzilla.opensuse.org/show_bug.cgi?id=1176733', 'name': 'https://bugzilla.opensuse.org/show_bug.cgi?id=1176733', 'refsource': 'MISC', 'tags': ['Issue Tracking', 'Third Party Advisory']}, {'url': 'https://github.com/TigerVNC/tigervnc/commit/7399eab79a4365434d26494fa1628ce1eb91562b', 'name': 'https://github.com/TigerVNC/tigervnc/commit/7399eab79a4365434d26494fa1628ce1eb91562b', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2020/10/msg00007.html', 'name': '[debian-lts-announce] 20201006 [SECURITY] [DLA 2396-1] tigervnc security update', 'refsource': 'MLIST', 'tags': ['Third Party Advisory']}, {'url': 'http://lists.opensuse.org/opensuse-security-announce/2020-10/msg00025.html', 'name': 'openSUSE-SU-2020:1666', 'refsource': 'SUSE', 'tags': ['Third Party Advisory']}, {'url': 'http://lists.opensuse.org/opensuse-security-announce/2020-11/msg00024.html', 'name': 'openSUSE-SU-2020:1841', 'refsource': 'SUSE', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-295'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:*:*:*:*:*:*:*:*', 'versionEndExcluding': '1.11.0', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:debian:debian_linux:9.0:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:opensuse:leap:15.2:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'In rfb/CSecurityTLS.cxx and rfb/CSecurityTLS.java in TigerVNC before 1.11.0, viewers mishandle TLS certificate exceptions. They store the certificates as authorities, meaning that the owner of a certificate could impersonate any server after a client had added an exception.'}] | 2020-11-06T01:15Z | 2020-09-27T04:15Z | Improper Certificate Validation | The software does not validate, or incorrectly validates, a certificate. | When a certificate is invalid or malicious, it might allow an attacker to spoof a trusted entity by interfering in the communication path between the host and client. The software might connect to a malicious host while believing it is a trusted host, or the software might be deceived into accepting spoofed data that appears to originate from a trusted host.
| https://cwe.mitre.org/data/definitions/295.html | 0 | Pierre Ossman | 2020-05-21 21:10:38+02:00 | Properly store certificate exceptions
The previous method stored the certificates as authorities, meaning that
the owner of that certificate could impersonate any server it wanted
after a client had added an exception.
Handle this more properly by only storing exceptions for specific
hostname/certificate combinations, the same way browsers or SSH does
things. | b30f10c681ec87720cff85d490f67098568a9cba | False | TigerVNC/tigervnc | High performance, multi-platform VNC client and server | 2014-06-25 12:48:26 | 2022-08-26 00:49:49 | https://tigervnc.org | TigerVNC | 3517.0 | 756.0 | CSecurityTLS::checkSession | CSecurityTLS::checkSession() | [] | void CSecurityTLS::checkSession()
{
const unsigned allowed_errors = GNUTLS_CERT_INVALID |
GNUTLS_CERT_SIGNER_NOT_FOUND |
GNUTLS_CERT_SIGNER_NOT_CA;
unsigned int status;
const gnutls_datum_t *cert_list;
unsigned int cert_list_size = 0;
int err;
gnutls_datum_t info;
if (anon)
return;
if (gnutls_certificate_type_get(session) != GNUTLS_CRT_X509)
throw AuthFailureException("unsupported certificate type");
err = gnutls_certificate_verify_peers2(session, &status);
if (err != 0) {
vlog.error("server certificate verification failed: %s", gnutls_strerror(err));
throw AuthFailureException("server certificate verification failed");
}
if (status & GNUTLS_CERT_REVOKED)
throw AuthFailureException("server certificate has been revoked");
#ifndef WITHOUT_X509_TIMES
if (status & GNUTLS_CERT_NOT_ACTIVATED)
throw AuthFailureException("server certificate has not been activated");
if (status & GNUTLS_CERT_EXPIRED) {
vlog.debug("server certificate has expired");
if (!msg->showMsgBox(UserMsgBox::M_YESNO, "certificate has expired",
"The certificate of the server has expired, "
"do you want to continue?"))
throw AuthFailureException("server certificate has expired");
}
#endif
/* Process other errors later */
cert_list = gnutls_certificate_get_peers(session, &cert_list_size);
if (!cert_list_size)
throw AuthFailureException("empty certificate chain");
/* Process only server's certificate, not issuer's certificate */
gnutls_x509_crt_t crt;
gnutls_x509_crt_init(&crt);
if (gnutls_x509_crt_import(crt, &cert_list[0], GNUTLS_X509_FMT_DER) < 0)
throw AuthFailureException("decoding of certificate failed");
if (gnutls_x509_crt_check_hostname(crt, client->getServerName()) == 0) {
char buf[255];
vlog.debug("hostname mismatch");
snprintf(buf, sizeof(buf), "Hostname (%s) does not match any certificate, "
"do you want to continue?", client->getServerName());
buf[sizeof(buf) - 1] = '\0';
if (!msg->showMsgBox(UserMsgBox::M_YESNO, "hostname mismatch", buf))
throw AuthFailureException("hostname mismatch");
}
if (status == 0) {
/* Everything is fine (hostname + verification) */
gnutls_x509_crt_deinit(crt);
return;
}
if (status & GNUTLS_CERT_INVALID)
vlog.debug("server certificate invalid");
if (status & GNUTLS_CERT_SIGNER_NOT_FOUND)
vlog.debug("server cert signer not found");
if (status & GNUTLS_CERT_SIGNER_NOT_CA)
vlog.debug("server cert signer not CA");
if (status & GNUTLS_CERT_INSECURE_ALGORITHM)
throw AuthFailureException("The server certificate uses an insecure algorithm");
if ((status & (~allowed_errors)) != 0) {
/* No other errors are allowed */
vlog.debug("GNUTLS status of certificate verification: %u", status);
throw AuthFailureException("Invalid status of server certificate verification");
}
vlog.debug("Saved server certificates don't match");
if (gnutls_x509_crt_print(crt, GNUTLS_CRT_PRINT_ONELINE, &info)) {
/*
* GNUTLS doesn't correctly export gnutls_free symbol which is
* a function pointer. Linking with Visual Studio 2008 Express will
* fail when you call gnutls_free().
*/
#if WIN32
free(info.data);
#else
gnutls_free(info.data);
#endif
throw AuthFailureException("Could not find certificate to display");
}
size_t out_size = 0;
char *out_buf = NULL;
char *certinfo = NULL;
int len = 0;
vlog.debug("certificate issuer unknown");
len = snprintf(NULL, 0, "This certificate has been signed by an unknown "
"authority:\n\n%s\n\nDo you want to save it and "
"continue?\n ", info.data);
if (len < 0)
throw AuthFailureException("certificate decoding error");
vlog.debug("%s", info.data);
certinfo = new char[len];
snprintf(certinfo, len, "This certificate has been signed by an unknown "
"authority:\n\n%s\n\nDo you want to save it and "
"continue? ", info.data);
for (int i = 0; i < len - 1; i++)
if (certinfo[i] == ',' && certinfo[i + 1] == ' ')
certinfo[i] = '\n';
if (!msg->showMsgBox(UserMsgBox::M_YESNO, "certificate issuer unknown",
certinfo)) {
delete [] certinfo;
throw AuthFailureException("certificate issuer unknown");
}
delete [] certinfo;
if (gnutls_x509_crt_export(crt, GNUTLS_X509_FMT_PEM, NULL, &out_size)
!= GNUTLS_E_SHORT_MEMORY_BUFFER)
throw AuthFailureException("certificate issuer unknown, and certificate "
"export failed");
// Save cert
out_buf = new char[out_size];
if (gnutls_x509_crt_export(crt, GNUTLS_X509_FMT_PEM, out_buf, &out_size) < 0)
throw AuthFailureException("certificate issuer unknown, and certificate "
"export failed");
char *homeDir = NULL;
if (getvnchomedir(&homeDir) == -1)
vlog.error("Could not obtain VNC home directory path");
else {
FILE *f;
CharArray caSave(strlen(homeDir) + 1 + 19);
sprintf(caSave.buf, "%sx509_savedcerts.pem", homeDir);
delete [] homeDir;
f = fopen(caSave.buf, "a+");
if (!f)
msg->showMsgBox(UserMsgBox::M_OK, "certificate save failed",
"Could not save the certificate");
else {
fprintf(f, "%s\n", out_buf);
fclose(f);
}
}
delete [] out_buf;
gnutls_x509_crt_deinit(crt);
/*
* GNUTLS doesn't correctly export gnutls_free symbol which is
* a function pointer. Linking with Visual Studio 2008 Express will
* fail when you call gnutls_free().
*/
#if WIN32
free(info.data);
#else
gnutls_free(info.data);
#endif
} | 780 | True | 1 |
CVE-2020-26117 | False | False | False | True | AV:N/AC:M/Au:N/C:P/I:P/A:N | NETWORK | MEDIUM | NONE | PARTIAL | PARTIAL | NONE | 5.8 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:N | NETWORK | LOW | NONE | REQUIRED | UNCHANGED | HIGH | HIGH | NONE | 8.1 | HIGH | 2.8 | 5.2 | False | [{'url': 'https://github.com/TigerVNC/tigervnc/commit/20dea801e747318525a5859fe4f37c52b05310cb', 'name': 'https://github.com/TigerVNC/tigervnc/commit/20dea801e747318525a5859fe4f37c52b05310cb', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/TigerVNC/tigervnc/commit/b30f10c681ec87720cff85d490f67098568a9cba', 'name': 'https://github.com/TigerVNC/tigervnc/commit/b30f10c681ec87720cff85d490f67098568a9cba', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/TigerVNC/tigervnc/releases/tag/v1.11.0', 'name': 'https://github.com/TigerVNC/tigervnc/releases/tag/v1.11.0', 'refsource': 'MISC', 'tags': ['Release Notes', 'Third Party Advisory']}, {'url': 'https://github.com/TigerVNC/tigervnc/commit/f029745f63ac7d22fb91639b2cb5b3ab56134d6e', 'name': 'https://github.com/TigerVNC/tigervnc/commit/f029745f63ac7d22fb91639b2cb5b3ab56134d6e', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://bugzilla.opensuse.org/show_bug.cgi?id=1176733', 'name': 'https://bugzilla.opensuse.org/show_bug.cgi?id=1176733', 'refsource': 'MISC', 'tags': ['Issue Tracking', 'Third Party Advisory']}, {'url': 'https://github.com/TigerVNC/tigervnc/commit/7399eab79a4365434d26494fa1628ce1eb91562b', 'name': 'https://github.com/TigerVNC/tigervnc/commit/7399eab79a4365434d26494fa1628ce1eb91562b', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2020/10/msg00007.html', 'name': '[debian-lts-announce] 20201006 [SECURITY] [DLA 2396-1] tigervnc security update', 'refsource': 'MLIST', 'tags': ['Third Party Advisory']}, {'url': 'http://lists.opensuse.org/opensuse-security-announce/2020-10/msg00025.html', 'name': 'openSUSE-SU-2020:1666', 'refsource': 'SUSE', 'tags': ['Third Party Advisory']}, {'url': 'http://lists.opensuse.org/opensuse-security-announce/2020-11/msg00024.html', 'name': 'openSUSE-SU-2020:1841', 'refsource': 'SUSE', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-295'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:tigervnc:tigervnc:*:*:*:*:*:*:*:*', 'versionEndExcluding': '1.11.0', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:debian:debian_linux:9.0:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:opensuse:leap:15.2:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'In rfb/CSecurityTLS.cxx and rfb/CSecurityTLS.java in TigerVNC before 1.11.0, viewers mishandle TLS certificate exceptions. They store the certificates as authorities, meaning that the owner of a certificate could impersonate any server after a client had added an exception.'}] | 2020-11-06T01:15Z | 2020-09-27T04:15Z | Improper Certificate Validation | The software does not validate, or incorrectly validates, a certificate. | When a certificate is invalid or malicious, it might allow an attacker to spoof a trusted entity by interfering in the communication path between the host and client. The software might connect to a malicious host while believing it is a trusted host, or the software might be deceived into accepting spoofed data that appears to originate from a trusted host.
| https://cwe.mitre.org/data/definitions/295.html | 0 | Pierre Ossman | 2020-05-21 21:10:38+02:00 | Properly store certificate exceptions
The previous method stored the certificates as authorities, meaning that
the owner of that certificate could impersonate any server it wanted
after a client had added an exception.
Handle this more properly by only storing exceptions for specific
hostname/certificate combinations, the same way browsers or SSH does
things. | b30f10c681ec87720cff85d490f67098568a9cba | False | TigerVNC/tigervnc | High performance, multi-platform VNC client and server | 2014-06-25 12:48:26 | 2022-08-26 00:49:49 | https://tigervnc.org | TigerVNC | 3517.0 | 756.0 | CSecurityTLS::setParam | CSecurityTLS::setParam() | [] | void CSecurityTLS::setParam()
{
static const char kx_anon_priority[] = ":+ANON-ECDH:+ANON-DH";
int ret;
char *prio;
const char *err;
prio = (char*)malloc(strlen(Security::GnuTLSPriority) +
strlen(kx_anon_priority) + 1);
if (prio == NULL)
throw AuthFailureException("Not enough memory for GnuTLS priority string");
strcpy(prio, Security::GnuTLSPriority);
if (anon)
strcat(prio, kx_anon_priority);
ret = gnutls_priority_set_direct(session, prio, &err);
free(prio);
if (ret != GNUTLS_E_SUCCESS) {
if (ret == GNUTLS_E_INVALID_REQUEST)
vlog.error("GnuTLS priority syntax error at: %s", err);
throw AuthFailureException("gnutls_set_priority_direct failed");
}
if (anon) {
if (gnutls_anon_allocate_client_credentials(&anon_cred) != GNUTLS_E_SUCCESS)
throw AuthFailureException("gnutls_anon_allocate_client_credentials failed");
if (gnutls_credentials_set(session, GNUTLS_CRD_ANON, anon_cred) != GNUTLS_E_SUCCESS)
throw AuthFailureException("gnutls_credentials_set failed");
vlog.debug("Anonymous session has been set");
} else {
if (gnutls_certificate_allocate_credentials(&cert_cred) != GNUTLS_E_SUCCESS)
throw AuthFailureException("gnutls_certificate_allocate_credentials failed");
if (gnutls_certificate_set_x509_system_trust(cert_cred) != GNUTLS_E_SUCCESS)
vlog.error("Could not load system certificate trust store");
if (*cafile && gnutls_certificate_set_x509_trust_file(cert_cred,cafile,GNUTLS_X509_FMT_PEM) < 0)
throw AuthFailureException("load of CA cert failed");
/* Load previously saved certs */
char *homeDir = NULL;
int err;
if (getvnchomedir(&homeDir) == -1)
vlog.error("Could not obtain VNC home directory path");
else {
CharArray caSave(strlen(homeDir) + 19 + 1);
sprintf(caSave.buf, "%sx509_savedcerts.pem", homeDir);
delete [] homeDir;
err = gnutls_certificate_set_x509_trust_file(cert_cred, caSave.buf,
GNUTLS_X509_FMT_PEM);
if (err < 0)
vlog.debug("Failed to load saved server certificates from %s", caSave.buf);
}
if (*crlfile && gnutls_certificate_set_x509_crl_file(cert_cred,crlfile,GNUTLS_X509_FMT_PEM) < 0)
throw AuthFailureException("load of CRL failed");
if (gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, cert_cred) != GNUTLS_E_SUCCESS)
throw AuthFailureException("gnutls_credentials_set failed");
if (gnutls_server_name_set(session, GNUTLS_NAME_DNS,
client->getServerName(),
strlen(client->getServerName())) != GNUTLS_E_SUCCESS)
vlog.error("Failed to configure the server name for TLS handshake");
vlog.debug("X509 session has been set");
}
} | 404 | True | 1 |
CVE-2016-10211 | 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.0/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/VirusTotal/yara/issues/575', 'name': 'https://github.com/VirusTotal/yara/issues/575', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Issue Tracking', 'Patch']}, {'url': 'https://github.com/VirusTotal/yara/commit/890c3f850293176c0e996a602ffa88b315f4e98f', 'name': 'https://github.com/VirusTotal/yara/commit/890c3f850293176c0e996a602ffa88b315f4e98f', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Vendor Advisory']}, {'url': 'http://www.securityfocus.com/bid/98078', 'name': '98078', 'refsource': 'BID', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-416'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:virustotal:yara:3.5.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'libyara/grammar.y in YARA 3.5.0 allows remote attackers to cause a denial of service (use-after-free and application crash) via a crafted rule that is mishandled in the yr_parser_lookup_loop_variable function.'}] | 2017-05-02T01:59Z | 2017-04-03T05:59Z | 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 | plusvic | 2017-01-04 17:09:35+01:00 | Fix issue #575 | 890c3f850293176c0e996a602ffa88b315f4e98f | False | VirusTotal/yara | The pattern matching swiss knife | 2012-12-06 15:33:08 | 2022-08-26 10:13:14 | https://virustotal.github.io/yara/ | VirusTotal | 5938.0 | 1229.0 | yyparse | yyparse( void * yyscanner , YR_COMPILER * compiler) | ['yyscanner', 'compiler'] | int
yyparse (void *yyscanner, YR_COMPILER* compiler)
{
/* The lookahead symbol. */
int yychar;
/* The semantic value of the lookahead symbol. */
/* Default value used for initialization, for pacifying older GCCs
or non-GCC compilers. */
YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
/* Number of syntax errors so far. */
int yynerrs;
int yystate;
/* Number of tokens to shift before error messages enabled. */
int yyerrstatus;
/* The stacks and their tools:
'yyss': related to states.
'yyvs': related to semantic values.
Refer to the stacks through separate pointers, to allow yyoverflow
to reallocate them elsewhere. */
/* The state stack. */
yytype_int16 yyssa[YYINITDEPTH];
yytype_int16 *yyss;
yytype_int16 *yyssp;
/* The semantic value stack. */
YYSTYPE yyvsa[YYINITDEPTH];
YYSTYPE *yyvs;
YYSTYPE *yyvsp;
YYSIZE_T yystacksize;
int yyn;
int yyresult;
/* Lookahead token as an internal (translated) token number. */
int yytoken = 0;
/* The variables used to return semantic value and location from the
action routines. */
YYSTYPE yyval;
#if YYERROR_VERBOSE
/* Buffer for error messages, and its allocated size. */
char yymsgbuf[128];
char *yymsg = yymsgbuf;
YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
#endif
#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
/* The number of symbols on the RHS of the reduced rule.
Keep to zero when no symbol should be popped. */
int yylen = 0;
yyssp = yyss = yyssa;
yyvsp = yyvs = yyvsa;
yystacksize = YYINITDEPTH;
YYDPRINTF ((stderr, "Starting parse\n"));
yystate = 0;
yyerrstatus = 0;
yynerrs = 0;
yychar = YYEMPTY; /* Cause a token to be read. */
goto yysetstate;
/*------------------------------------------------------------.
| yynewstate -- Push a new state, which is found in yystate. |
`------------------------------------------------------------*/
yynewstate:
/* In all cases, when you get here, the value and location stacks
have just been pushed. So pushing a state here evens the stacks. */
yyssp++;
yysetstate:
*yyssp = yystate;
if (yyss + yystacksize - 1 <= yyssp)
{
/* Get the current used size of the three stacks, in elements. */
YYSIZE_T yysize = yyssp - yyss + 1;
#ifdef yyoverflow
{
/* Give user a chance to reallocate the stack. Use copies of
these so that the &'s don't force the real ones into
memory. */
YYSTYPE *yyvs1 = yyvs;
yytype_int16 *yyss1 = yyss;
/* Each stack pointer address is followed by the size of the
data in use in that stack, in bytes. This used to be a
conditional around just the two extra args, but that might
be undefined if yyoverflow is a macro. */
yyoverflow (YY_("memory exhausted"),
&yyss1, yysize * sizeof (*yyssp),
&yyvs1, yysize * sizeof (*yyvsp),
&yystacksize);
yyss = yyss1;
yyvs = yyvs1;
}
#else /* no yyoverflow */
# ifndef YYSTACK_RELOCATE
goto yyexhaustedlab;
# else
/* Extend the stack our own way. */
if (YYMAXDEPTH <= yystacksize)
goto yyexhaustedlab;
yystacksize *= 2;
if (YYMAXDEPTH < yystacksize)
yystacksize = YYMAXDEPTH;
{
yytype_int16 *yyss1 = yyss;
union yyalloc *yyptr =
(union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
if (! yyptr)
goto yyexhaustedlab;
YYSTACK_RELOCATE (yyss_alloc, yyss);
YYSTACK_RELOCATE (yyvs_alloc, yyvs);
# undef YYSTACK_RELOCATE
if (yyss1 != yyssa)
YYSTACK_FREE (yyss1);
}
# endif
#endif /* no yyoverflow */
yyssp = yyss + yysize - 1;
yyvsp = yyvs + yysize - 1;
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
(unsigned long int) yystacksize));
if (yyss + yystacksize - 1 <= yyssp)
YYABORT;
}
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
if (yystate == YYFINAL)
YYACCEPT;
goto yybackup;
/*-----------.
| yybackup. |
`-----------*/
yybackup:
/* Do appropriate processing given the current state. Read a
lookahead token if we need one and don't already have one. */
/* First try to decide what to do without reference to lookahead token. */
yyn = yypact[yystate];
if (yypact_value_is_default (yyn))
goto yydefault;
/* Not known => get a lookahead token if don't already have one. */
/* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
if (yychar == YYEMPTY)
{
YYDPRINTF ((stderr, "Reading a token: "));
yychar = yylex (&yylval, yyscanner, compiler);
}
if (yychar <= YYEOF)
{
yychar = yytoken = YYEOF;
YYDPRINTF ((stderr, "Now at end of input.\n"));
}
else
{
yytoken = YYTRANSLATE (yychar);
YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
}
/* If the proper action on seeing token YYTOKEN is to reduce or to
detect an error, take that action. */
yyn += yytoken;
if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
goto yydefault;
yyn = yytable[yyn];
if (yyn <= 0)
{
if (yytable_value_is_error (yyn))
goto yyerrlab;
yyn = -yyn;
goto yyreduce;
}
/* Count tokens shifted since error; after three, turn off error
status. */
if (yyerrstatus)
yyerrstatus--;
/* Shift the lookahead token. */
YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
/* Discard the shifted token. */
yychar = YYEMPTY;
yystate = yyn;
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
*++yyvsp = yylval;
YY_IGNORE_MAYBE_UNINITIALIZED_END
goto yynewstate;
/*-----------------------------------------------------------.
| yydefault -- do the default action for the current state. |
`-----------------------------------------------------------*/
yydefault:
yyn = yydefact[yystate];
if (yyn == 0)
goto yyerrlab;
goto yyreduce;
/*-----------------------------.
| yyreduce -- Do a reduction. |
`-----------------------------*/
yyreduce:
/* yyn is the number of a rule to reduce with. */
yylen = yyr2[yyn];
/* If YYLEN is nonzero, implement the default value of the action:
'$$ = $1'.
Otherwise, the following line sets YYVAL to garbage.
This behavior is undocumented and Bison
users should not rely upon it. Assigning to YYVAL
unconditionally makes the parser a bit smaller, and it avoids a
GCC warning that YYVAL may be used uninitialized. */
yyval = yyvsp[1-yylen];
YY_REDUCE_PRINT (yyn);
switch (yyn)
{
case 8:
#line 230 "grammar.y" /* yacc.c:1646 */
{
int result = yr_parser_reduce_import(yyscanner, (yyvsp[0].sized_string));
yr_free((yyvsp[0].sized_string));
ERROR_IF(result != ERROR_SUCCESS);
}
#line 1661 "grammar.c" /* yacc.c:1646 */
break;
case 9:
#line 242 "grammar.y" /* yacc.c:1646 */
{
YR_RULE* rule = yr_parser_reduce_rule_declaration_phase_1(
yyscanner, (int32_t) (yyvsp[-2].integer), (yyvsp[0].c_string));
ERROR_IF(rule == NULL);
(yyval.rule) = rule;
}
#line 1674 "grammar.c" /* yacc.c:1646 */
break;
case 10:
#line 251 "grammar.y" /* yacc.c:1646 */
{
YR_RULE* rule = (yyvsp[-4].rule); // rule created in phase 1
rule->tags = (yyvsp[-3].c_string);
rule->metas = (yyvsp[-1].meta);
rule->strings = (yyvsp[0].string);
}
#line 1686 "grammar.c" /* yacc.c:1646 */
break;
case 11:
#line 259 "grammar.y" /* yacc.c:1646 */
{
YR_RULE* rule = (yyvsp[-7].rule); // rule created in phase 1
compiler->last_result = yr_parser_reduce_rule_declaration_phase_2(
yyscanner, rule);
yr_free((yyvsp[-8].c_string));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
}
#line 1701 "grammar.c" /* yacc.c:1646 */
break;
case 12:
#line 274 "grammar.y" /* yacc.c:1646 */
{
(yyval.meta) = NULL;
}
#line 1709 "grammar.c" /* yacc.c:1646 */
break;
case 13:
#line 278 "grammar.y" /* yacc.c:1646 */
{
// Each rule have a list of meta-data info, consisting in a
// sequence of YR_META structures. The last YR_META structure does
// not represent a real meta-data, it's just a end-of-list marker
// identified by a specific type (META_TYPE_NULL). Here we
// write the end-of-list marker.
YR_META null_meta;
memset(&null_meta, 0xFF, sizeof(YR_META));
null_meta.type = META_TYPE_NULL;
compiler->last_result = yr_arena_write_data(
compiler->metas_arena,
&null_meta,
sizeof(YR_META),
NULL);
(yyval.meta) = (yyvsp[0].meta);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
}
#line 1736 "grammar.c" /* yacc.c:1646 */
break;
case 14:
#line 305 "grammar.y" /* yacc.c:1646 */
{
(yyval.string) = NULL;
}
#line 1744 "grammar.c" /* yacc.c:1646 */
break;
case 15:
#line 309 "grammar.y" /* yacc.c:1646 */
{
// Each rule have a list of strings, consisting in a sequence
// of YR_STRING structures. The last YR_STRING structure does not
// represent a real string, it's just a end-of-list marker
// identified by a specific flag (STRING_FLAGS_NULL). Here we
// write the end-of-list marker.
YR_STRING null_string;
memset(&null_string, 0xFF, sizeof(YR_STRING));
null_string.g_flags = STRING_GFLAGS_NULL;
compiler->last_result = yr_arena_write_data(
compiler->strings_arena,
&null_string,
sizeof(YR_STRING),
NULL);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.string) = (yyvsp[0].string);
}
#line 1771 "grammar.c" /* yacc.c:1646 */
break;
case 17:
#line 340 "grammar.y" /* yacc.c:1646 */
{ (yyval.integer) = 0; }
#line 1777 "grammar.c" /* yacc.c:1646 */
break;
case 18:
#line 341 "grammar.y" /* yacc.c:1646 */
{ (yyval.integer) = (yyvsp[-1].integer) | (yyvsp[0].integer); }
#line 1783 "grammar.c" /* yacc.c:1646 */
break;
case 19:
#line 346 "grammar.y" /* yacc.c:1646 */
{ (yyval.integer) = RULE_GFLAGS_PRIVATE; }
#line 1789 "grammar.c" /* yacc.c:1646 */
break;
case 20:
#line 347 "grammar.y" /* yacc.c:1646 */
{ (yyval.integer) = RULE_GFLAGS_GLOBAL; }
#line 1795 "grammar.c" /* yacc.c:1646 */
break;
case 21:
#line 353 "grammar.y" /* yacc.c:1646 */
{
(yyval.c_string) = NULL;
}
#line 1803 "grammar.c" /* yacc.c:1646 */
break;
case 22:
#line 357 "grammar.y" /* yacc.c:1646 */
{
// Tags list is represented in the arena as a sequence
// of null-terminated strings, the sequence ends with an
// additional null character. Here we write the ending null
//character. Example: tag1\0tag2\0tag3\0\0
compiler->last_result = yr_arena_write_string(
yyget_extra(yyscanner)->sz_arena, "", NULL);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.c_string) = (yyvsp[0].c_string);
}
#line 1821 "grammar.c" /* yacc.c:1646 */
break;
case 23:
#line 375 "grammar.y" /* yacc.c:1646 */
{
char* identifier;
compiler->last_result = yr_arena_write_string(
yyget_extra(yyscanner)->sz_arena, (yyvsp[0].c_string), &identifier);
yr_free((yyvsp[0].c_string));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.c_string) = identifier;
}
#line 1838 "grammar.c" /* yacc.c:1646 */
break;
case 24:
#line 388 "grammar.y" /* yacc.c:1646 */
{
char* tag_name = (yyvsp[-1].c_string);
size_t tag_length = tag_name != NULL ? strlen(tag_name) : 0;
while (tag_length > 0)
{
if (strcmp(tag_name, (yyvsp[0].c_string)) == 0)
{
yr_compiler_set_error_extra_info(compiler, tag_name);
compiler->last_result = ERROR_DUPLICATED_TAG_IDENTIFIER;
break;
}
tag_name = (char*) yr_arena_next_address(
yyget_extra(yyscanner)->sz_arena,
tag_name,
tag_length + 1);
tag_length = tag_name != NULL ? strlen(tag_name) : 0;
}
if (compiler->last_result == ERROR_SUCCESS)
compiler->last_result = yr_arena_write_string(
yyget_extra(yyscanner)->sz_arena, (yyvsp[0].c_string), NULL);
yr_free((yyvsp[0].c_string));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.c_string) = (yyvsp[-1].c_string);
}
#line 1874 "grammar.c" /* yacc.c:1646 */
break;
case 25:
#line 424 "grammar.y" /* yacc.c:1646 */
{ (yyval.meta) = (yyvsp[0].meta); }
#line 1880 "grammar.c" /* yacc.c:1646 */
break;
case 26:
#line 425 "grammar.y" /* yacc.c:1646 */
{ (yyval.meta) = (yyvsp[-1].meta); }
#line 1886 "grammar.c" /* yacc.c:1646 */
break;
case 27:
#line 431 "grammar.y" /* yacc.c:1646 */
{
SIZED_STRING* sized_string = (yyvsp[0].sized_string);
(yyval.meta) = yr_parser_reduce_meta_declaration(
yyscanner,
META_TYPE_STRING,
(yyvsp[-2].c_string),
sized_string->c_string,
0);
yr_free((yyvsp[-2].c_string));
yr_free((yyvsp[0].sized_string));
ERROR_IF((yyval.meta) == NULL);
}
#line 1906 "grammar.c" /* yacc.c:1646 */
break;
case 28:
#line 447 "grammar.y" /* yacc.c:1646 */
{
(yyval.meta) = yr_parser_reduce_meta_declaration(
yyscanner,
META_TYPE_INTEGER,
(yyvsp[-2].c_string),
NULL,
(yyvsp[0].integer));
yr_free((yyvsp[-2].c_string));
ERROR_IF((yyval.meta) == NULL);
}
#line 1923 "grammar.c" /* yacc.c:1646 */
break;
case 29:
#line 460 "grammar.y" /* yacc.c:1646 */
{
(yyval.meta) = yr_parser_reduce_meta_declaration(
yyscanner,
META_TYPE_INTEGER,
(yyvsp[-3].c_string),
NULL,
-(yyvsp[0].integer));
yr_free((yyvsp[-3].c_string));
ERROR_IF((yyval.meta) == NULL);
}
#line 1940 "grammar.c" /* yacc.c:1646 */
break;
case 30:
#line 473 "grammar.y" /* yacc.c:1646 */
{
(yyval.meta) = yr_parser_reduce_meta_declaration(
yyscanner,
META_TYPE_BOOLEAN,
(yyvsp[-2].c_string),
NULL,
TRUE);
yr_free((yyvsp[-2].c_string));
ERROR_IF((yyval.meta) == NULL);
}
#line 1957 "grammar.c" /* yacc.c:1646 */
break;
case 31:
#line 486 "grammar.y" /* yacc.c:1646 */
{
(yyval.meta) = yr_parser_reduce_meta_declaration(
yyscanner,
META_TYPE_BOOLEAN,
(yyvsp[-2].c_string),
NULL,
FALSE);
yr_free((yyvsp[-2].c_string));
ERROR_IF((yyval.meta) == NULL);
}
#line 1974 "grammar.c" /* yacc.c:1646 */
break;
case 32:
#line 502 "grammar.y" /* yacc.c:1646 */
{ (yyval.string) = (yyvsp[0].string); }
#line 1980 "grammar.c" /* yacc.c:1646 */
break;
case 33:
#line 503 "grammar.y" /* yacc.c:1646 */
{ (yyval.string) = (yyvsp[-1].string); }
#line 1986 "grammar.c" /* yacc.c:1646 */
break;
case 34:
#line 509 "grammar.y" /* yacc.c:1646 */
{
compiler->error_line = yyget_lineno(yyscanner);
}
#line 1994 "grammar.c" /* yacc.c:1646 */
break;
case 35:
#line 513 "grammar.y" /* yacc.c:1646 */
{
(yyval.string) = yr_parser_reduce_string_declaration(
yyscanner, (int32_t) (yyvsp[0].integer), (yyvsp[-4].c_string), (yyvsp[-1].sized_string));
yr_free((yyvsp[-4].c_string));
yr_free((yyvsp[-1].sized_string));
ERROR_IF((yyval.string) == NULL);
compiler->error_line = 0;
}
#line 2009 "grammar.c" /* yacc.c:1646 */
break;
case 36:
#line 524 "grammar.y" /* yacc.c:1646 */
{
compiler->error_line = yyget_lineno(yyscanner);
}
#line 2017 "grammar.c" /* yacc.c:1646 */
break;
case 37:
#line 528 "grammar.y" /* yacc.c:1646 */
{
(yyval.string) = yr_parser_reduce_string_declaration(
yyscanner, (int32_t) (yyvsp[0].integer) | STRING_GFLAGS_REGEXP, (yyvsp[-4].c_string), (yyvsp[-1].sized_string));
yr_free((yyvsp[-4].c_string));
yr_free((yyvsp[-1].sized_string));
ERROR_IF((yyval.string) == NULL);
compiler->error_line = 0;
}
#line 2033 "grammar.c" /* yacc.c:1646 */
break;
case 38:
#line 540 "grammar.y" /* yacc.c:1646 */
{
(yyval.string) = yr_parser_reduce_string_declaration(
yyscanner, STRING_GFLAGS_HEXADECIMAL, (yyvsp[-2].c_string), (yyvsp[0].sized_string));
yr_free((yyvsp[-2].c_string));
yr_free((yyvsp[0].sized_string));
ERROR_IF((yyval.string) == NULL);
}
#line 2047 "grammar.c" /* yacc.c:1646 */
break;
case 39:
#line 553 "grammar.y" /* yacc.c:1646 */
{ (yyval.integer) = 0; }
#line 2053 "grammar.c" /* yacc.c:1646 */
break;
case 40:
#line 554 "grammar.y" /* yacc.c:1646 */
{ (yyval.integer) = (yyvsp[-1].integer) | (yyvsp[0].integer); }
#line 2059 "grammar.c" /* yacc.c:1646 */
break;
case 41:
#line 559 "grammar.y" /* yacc.c:1646 */
{ (yyval.integer) = STRING_GFLAGS_WIDE; }
#line 2065 "grammar.c" /* yacc.c:1646 */
break;
case 42:
#line 560 "grammar.y" /* yacc.c:1646 */
{ (yyval.integer) = STRING_GFLAGS_ASCII; }
#line 2071 "grammar.c" /* yacc.c:1646 */
break;
case 43:
#line 561 "grammar.y" /* yacc.c:1646 */
{ (yyval.integer) = STRING_GFLAGS_NO_CASE; }
#line 2077 "grammar.c" /* yacc.c:1646 */
break;
case 44:
#line 562 "grammar.y" /* yacc.c:1646 */
{ (yyval.integer) = STRING_GFLAGS_FULL_WORD; }
#line 2083 "grammar.c" /* yacc.c:1646 */
break;
case 45:
#line 568 "grammar.y" /* yacc.c:1646 */
{
int var_index = yr_parser_lookup_loop_variable(yyscanner, (yyvsp[0].c_string));
if (var_index >= 0)
{
compiler->last_result = yr_parser_emit_with_arg(
yyscanner,
OP_PUSH_M,
LOOP_LOCAL_VARS * var_index,
NULL,
NULL);
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
(yyval.expression).value.integer = UNDEFINED;
(yyval.expression).identifier = compiler->loop_identifier[var_index];
}
else
{
// Search for identifier within the global namespace, where the
// externals variables reside.
YR_OBJECT* object = (YR_OBJECT*) yr_hash_table_lookup(
compiler->objects_table, (yyvsp[0].c_string), NULL);
if (object == NULL)
{
// If not found, search within the current namespace.
char* ns = compiler->current_namespace->name;
object = (YR_OBJECT*) yr_hash_table_lookup(
compiler->objects_table, (yyvsp[0].c_string), ns);
}
if (object != NULL)
{
char* id;
compiler->last_result = yr_arena_write_string(
compiler->sz_arena, (yyvsp[0].c_string), &id);
if (compiler->last_result == ERROR_SUCCESS)
compiler->last_result = yr_parser_emit_with_arg_reloc(
yyscanner,
OP_OBJ_LOAD,
id,
NULL,
NULL);
(yyval.expression).type = EXPRESSION_TYPE_OBJECT;
(yyval.expression).value.object = object;
(yyval.expression).identifier = object->identifier;
}
else
{
YR_RULE* rule = (YR_RULE*) yr_hash_table_lookup(
compiler->rules_table,
(yyvsp[0].c_string),
compiler->current_namespace->name);
if (rule != NULL)
{
compiler->last_result = yr_parser_emit_with_arg_reloc(
yyscanner,
OP_PUSH_RULE,
rule,
NULL,
NULL);
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
(yyval.expression).value.integer = UNDEFINED;
(yyval.expression).identifier = rule->identifier;
}
else
{
yr_compiler_set_error_extra_info(compiler, (yyvsp[0].c_string));
compiler->last_result = ERROR_UNDEFINED_IDENTIFIER;
}
}
}
yr_free((yyvsp[0].c_string));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
}
#line 2172 "grammar.c" /* yacc.c:1646 */
break;
case 46:
#line 653 "grammar.y" /* yacc.c:1646 */
{
YR_OBJECT* field = NULL;
if ((yyvsp[-2].expression).type == EXPRESSION_TYPE_OBJECT &&
(yyvsp[-2].expression).value.object->type == OBJECT_TYPE_STRUCTURE)
{
field = yr_object_lookup_field((yyvsp[-2].expression).value.object, (yyvsp[0].c_string));
if (field != NULL)
{
char* ident;
compiler->last_result = yr_arena_write_string(
compiler->sz_arena, (yyvsp[0].c_string), &ident);
if (compiler->last_result == ERROR_SUCCESS)
compiler->last_result = yr_parser_emit_with_arg_reloc(
yyscanner,
OP_OBJ_FIELD,
ident,
NULL,
NULL);
(yyval.expression).type = EXPRESSION_TYPE_OBJECT;
(yyval.expression).value.object = field;
(yyval.expression).identifier = field->identifier;
}
else
{
yr_compiler_set_error_extra_info(compiler, (yyvsp[0].c_string));
compiler->last_result = ERROR_INVALID_FIELD_NAME;
}
}
else
{
yr_compiler_set_error_extra_info(
compiler, (yyvsp[-2].expression).identifier);
compiler->last_result = ERROR_NOT_A_STRUCTURE;
}
yr_free((yyvsp[0].c_string));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
}
#line 2222 "grammar.c" /* yacc.c:1646 */
break;
case 47:
#line 699 "grammar.y" /* yacc.c:1646 */
{
YR_OBJECT_ARRAY* array;
YR_OBJECT_DICTIONARY* dict;
if ((yyvsp[-3].expression).type == EXPRESSION_TYPE_OBJECT &&
(yyvsp[-3].expression).value.object->type == OBJECT_TYPE_ARRAY)
{
if ((yyvsp[-1].expression).type != EXPRESSION_TYPE_INTEGER)
{
yr_compiler_set_error_extra_info(
compiler, "array indexes must be of integer type");
compiler->last_result = ERROR_WRONG_TYPE;
}
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
compiler->last_result = yr_parser_emit(
yyscanner, OP_INDEX_ARRAY, NULL);
array = (YR_OBJECT_ARRAY*) (yyvsp[-3].expression).value.object;
(yyval.expression).type = EXPRESSION_TYPE_OBJECT;
(yyval.expression).value.object = array->prototype_item;
(yyval.expression).identifier = array->identifier;
}
else if ((yyvsp[-3].expression).type == EXPRESSION_TYPE_OBJECT &&
(yyvsp[-3].expression).value.object->type == OBJECT_TYPE_DICTIONARY)
{
if ((yyvsp[-1].expression).type != EXPRESSION_TYPE_STRING)
{
yr_compiler_set_error_extra_info(
compiler, "dictionary keys must be of string type");
compiler->last_result = ERROR_WRONG_TYPE;
}
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
compiler->last_result = yr_parser_emit(
yyscanner, OP_LOOKUP_DICT, NULL);
dict = (YR_OBJECT_DICTIONARY*) (yyvsp[-3].expression).value.object;
(yyval.expression).type = EXPRESSION_TYPE_OBJECT;
(yyval.expression).value.object = dict->prototype_item;
(yyval.expression).identifier = dict->identifier;
}
else
{
yr_compiler_set_error_extra_info(
compiler, (yyvsp[-3].expression).identifier);
compiler->last_result = ERROR_NOT_INDEXABLE;
}
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
}
#line 2283 "grammar.c" /* yacc.c:1646 */
break;
case 48:
#line 757 "grammar.y" /* yacc.c:1646 */
{
YR_OBJECT_FUNCTION* function;
char* args_fmt;
if ((yyvsp[-3].expression).type == EXPRESSION_TYPE_OBJECT &&
(yyvsp[-3].expression).value.object->type == OBJECT_TYPE_FUNCTION)
{
compiler->last_result = yr_parser_check_types(
compiler, (YR_OBJECT_FUNCTION*) (yyvsp[-3].expression).value.object, (yyvsp[-1].c_string));
if (compiler->last_result == ERROR_SUCCESS)
compiler->last_result = yr_arena_write_string(
compiler->sz_arena, (yyvsp[-1].c_string), &args_fmt);
if (compiler->last_result == ERROR_SUCCESS)
compiler->last_result = yr_parser_emit_with_arg_reloc(
yyscanner,
OP_CALL,
args_fmt,
NULL,
NULL);
function = (YR_OBJECT_FUNCTION*) (yyvsp[-3].expression).value.object;
(yyval.expression).type = EXPRESSION_TYPE_OBJECT;
(yyval.expression).value.object = function->return_obj;
(yyval.expression).identifier = function->identifier;
}
else
{
yr_compiler_set_error_extra_info(
compiler, (yyvsp[-3].expression).identifier);
compiler->last_result = ERROR_NOT_A_FUNCTION;
}
yr_free((yyvsp[-1].c_string));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
}
#line 2328 "grammar.c" /* yacc.c:1646 */
break;
case 49:
#line 801 "grammar.y" /* yacc.c:1646 */
{ (yyval.c_string) = yr_strdup(""); }
#line 2334 "grammar.c" /* yacc.c:1646 */
break;
case 50:
#line 802 "grammar.y" /* yacc.c:1646 */
{ (yyval.c_string) = (yyvsp[0].c_string); }
#line 2340 "grammar.c" /* yacc.c:1646 */
break;
case 51:
#line 807 "grammar.y" /* yacc.c:1646 */
{
(yyval.c_string) = (char*) yr_malloc(MAX_FUNCTION_ARGS + 1);
switch((yyvsp[0].expression).type)
{
case EXPRESSION_TYPE_INTEGER:
strlcpy((yyval.c_string), "i", MAX_FUNCTION_ARGS);
break;
case EXPRESSION_TYPE_FLOAT:
strlcpy((yyval.c_string), "f", MAX_FUNCTION_ARGS);
break;
case EXPRESSION_TYPE_BOOLEAN:
strlcpy((yyval.c_string), "b", MAX_FUNCTION_ARGS);
break;
case EXPRESSION_TYPE_STRING:
strlcpy((yyval.c_string), "s", MAX_FUNCTION_ARGS);
break;
case EXPRESSION_TYPE_REGEXP:
strlcpy((yyval.c_string), "r", MAX_FUNCTION_ARGS);
break;
}
ERROR_IF((yyval.c_string) == NULL);
}
#line 2369 "grammar.c" /* yacc.c:1646 */
break;
case 52:
#line 832 "grammar.y" /* yacc.c:1646 */
{
if (strlen((yyvsp[-2].c_string)) == MAX_FUNCTION_ARGS)
{
compiler->last_result = ERROR_TOO_MANY_ARGUMENTS;
}
else
{
switch((yyvsp[0].expression).type)
{
case EXPRESSION_TYPE_INTEGER:
strlcat((yyvsp[-2].c_string), "i", MAX_FUNCTION_ARGS);
break;
case EXPRESSION_TYPE_FLOAT:
strlcat((yyvsp[-2].c_string), "f", MAX_FUNCTION_ARGS);
break;
case EXPRESSION_TYPE_BOOLEAN:
strlcat((yyvsp[-2].c_string), "b", MAX_FUNCTION_ARGS);
break;
case EXPRESSION_TYPE_STRING:
strlcat((yyvsp[-2].c_string), "s", MAX_FUNCTION_ARGS);
break;
case EXPRESSION_TYPE_REGEXP:
strlcat((yyvsp[-2].c_string), "r", MAX_FUNCTION_ARGS);
break;
}
}
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.c_string) = (yyvsp[-2].c_string);
}
#line 2405 "grammar.c" /* yacc.c:1646 */
break;
case 53:
#line 868 "grammar.y" /* yacc.c:1646 */
{
SIZED_STRING* sized_string = (yyvsp[0].sized_string);
RE* re;
RE_ERROR error;
int re_flags = 0;
if (sized_string->flags & SIZED_STRING_FLAGS_NO_CASE)
re_flags |= RE_FLAGS_NO_CASE;
if (sized_string->flags & SIZED_STRING_FLAGS_DOT_ALL)
re_flags |= RE_FLAGS_DOT_ALL;
compiler->last_result = yr_re_compile(
sized_string->c_string,
re_flags,
compiler->re_code_arena,
&re,
&error);
yr_free((yyvsp[0].sized_string));
if (compiler->last_result == ERROR_INVALID_REGULAR_EXPRESSION)
yr_compiler_set_error_extra_info(compiler, error.message);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
if (compiler->last_result == ERROR_SUCCESS)
compiler->last_result = yr_parser_emit_with_arg_reloc(
yyscanner,
OP_PUSH,
re->root_node->forward_code,
NULL,
NULL);
yr_re_destroy(re);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_REGEXP;
}
#line 2451 "grammar.c" /* yacc.c:1646 */
break;
case 54:
#line 914 "grammar.y" /* yacc.c:1646 */
{
if ((yyvsp[0].expression).type == EXPRESSION_TYPE_STRING)
{
if ((yyvsp[0].expression).value.sized_string != NULL)
{
yywarning(yyscanner,
"Using literal string \"%s\" in a boolean operation.",
(yyvsp[0].expression).value.sized_string->c_string);
}
compiler->last_result = yr_parser_emit(
yyscanner, OP_STR_TO_BOOL, NULL);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
}
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
}
#line 2474 "grammar.c" /* yacc.c:1646 */
break;
case 55:
#line 936 "grammar.y" /* yacc.c:1646 */
{
compiler->last_result = yr_parser_emit_with_arg(
yyscanner, OP_PUSH, 1, NULL, NULL);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
}
#line 2487 "grammar.c" /* yacc.c:1646 */
break;
case 56:
#line 945 "grammar.y" /* yacc.c:1646 */
{
compiler->last_result = yr_parser_emit_with_arg(
yyscanner, OP_PUSH, 0, NULL, NULL);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
}
#line 2500 "grammar.c" /* yacc.c:1646 */
break;
case 57:
#line 954 "grammar.y" /* yacc.c:1646 */
{
CHECK_TYPE((yyvsp[-2].expression), EXPRESSION_TYPE_STRING, "matches");
CHECK_TYPE((yyvsp[0].expression), EXPRESSION_TYPE_REGEXP, "matches");
if (compiler->last_result == ERROR_SUCCESS)
compiler->last_result = yr_parser_emit(
yyscanner,
OP_MATCHES,
NULL);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
}
#line 2519 "grammar.c" /* yacc.c:1646 */
break;
case 58:
#line 969 "grammar.y" /* yacc.c:1646 */
{
CHECK_TYPE((yyvsp[-2].expression), EXPRESSION_TYPE_STRING, "contains");
CHECK_TYPE((yyvsp[0].expression), EXPRESSION_TYPE_STRING, "contains");
compiler->last_result = yr_parser_emit(
yyscanner, OP_CONTAINS, NULL);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
}
#line 2535 "grammar.c" /* yacc.c:1646 */
break;
case 59:
#line 981 "grammar.y" /* yacc.c:1646 */
{
int result = yr_parser_reduce_string_identifier(
yyscanner,
(yyvsp[0].c_string),
OP_FOUND,
UNDEFINED);
yr_free((yyvsp[0].c_string));
ERROR_IF(result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
}
#line 2553 "grammar.c" /* yacc.c:1646 */
break;
case 60:
#line 995 "grammar.y" /* yacc.c:1646 */
{
CHECK_TYPE((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "at");
compiler->last_result = yr_parser_reduce_string_identifier(
yyscanner, (yyvsp[-2].c_string), OP_FOUND_AT, (yyvsp[0].expression).value.integer);
yr_free((yyvsp[-2].c_string));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
}
#line 2570 "grammar.c" /* yacc.c:1646 */
break;
case 61:
#line 1008 "grammar.y" /* yacc.c:1646 */
{
compiler->last_result = yr_parser_reduce_string_identifier(
yyscanner, (yyvsp[-2].c_string), OP_FOUND_IN, UNDEFINED);
yr_free((yyvsp[-2].c_string));
ERROR_IF(compiler->last_result!= ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
}
#line 2585 "grammar.c" /* yacc.c:1646 */
break;
case 62:
#line 1019 "grammar.y" /* yacc.c:1646 */
{
int var_index;
if (compiler->loop_depth == MAX_LOOP_NESTING)
compiler->last_result = \
ERROR_LOOP_NESTING_LIMIT_EXCEEDED;
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
var_index = yr_parser_lookup_loop_variable(
yyscanner, (yyvsp[-1].c_string));
if (var_index >= 0)
{
yr_compiler_set_error_extra_info(
compiler, (yyvsp[-1].c_string));
compiler->last_result = \
ERROR_DUPLICATED_LOOP_IDENTIFIER;
}
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
// Push end-of-list marker
compiler->last_result = yr_parser_emit_with_arg(
yyscanner, OP_PUSH, UNDEFINED, NULL, NULL);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
}
#line 2619 "grammar.c" /* yacc.c:1646 */
break;
case 63:
#line 1049 "grammar.y" /* yacc.c:1646 */
{
int mem_offset = LOOP_LOCAL_VARS * compiler->loop_depth;
uint8_t* addr;
// Clear counter for number of expressions evaluating
// to TRUE.
yr_parser_emit_with_arg(
yyscanner, OP_CLEAR_M, mem_offset + 1, NULL, NULL);
// Clear iterations counter
yr_parser_emit_with_arg(
yyscanner, OP_CLEAR_M, mem_offset + 2, NULL, NULL);
if ((yyvsp[-1].integer) == INTEGER_SET_ENUMERATION)
{
// Pop the first integer
yr_parser_emit_with_arg(
yyscanner, OP_POP_M, mem_offset, &addr, NULL);
}
else // INTEGER_SET_RANGE
{
// Pop higher bound of set range
yr_parser_emit_with_arg(
yyscanner, OP_POP_M, mem_offset + 3, &addr, NULL);
// Pop lower bound of set range
yr_parser_emit_with_arg(
yyscanner, OP_POP_M, mem_offset, NULL, NULL);
}
compiler->loop_address[compiler->loop_depth] = addr;
compiler->loop_identifier[compiler->loop_depth] = (yyvsp[-4].c_string);
compiler->loop_depth++;
}
#line 2658 "grammar.c" /* yacc.c:1646 */
break;
case 64:
#line 1084 "grammar.y" /* yacc.c:1646 */
{
int mem_offset;
compiler->loop_depth--;
mem_offset = LOOP_LOCAL_VARS * compiler->loop_depth;
// The value at the top of the stack is the result of
// evaluating the boolean expression, so it could be
// 0, 1 or UNDEFINED. Add this value to a counter
// keeping the number of expressions evaluating to true.
// If the value is UNDEFINED instruction OP_ADD_M
// does nothing.
yr_parser_emit_with_arg(
yyscanner, OP_ADD_M, mem_offset + 1, NULL, NULL);
// Increment iterations counter
yr_parser_emit_with_arg(
yyscanner, OP_INCR_M, mem_offset + 2, NULL, NULL);
if ((yyvsp[-5].integer) == INTEGER_SET_ENUMERATION)
{
yr_parser_emit_with_arg_reloc(
yyscanner,
OP_JNUNDEF,
compiler->loop_address[compiler->loop_depth],
NULL,
NULL);
}
else // INTEGER_SET_RANGE
{
// Increment lower bound of integer set
yr_parser_emit_with_arg(
yyscanner, OP_INCR_M, mem_offset, NULL, NULL);
// Push lower bound of integer set
yr_parser_emit_with_arg(
yyscanner, OP_PUSH_M, mem_offset, NULL, NULL);
// Push higher bound of integer set
yr_parser_emit_with_arg(
yyscanner, OP_PUSH_M, mem_offset + 3, NULL, NULL);
// Compare higher bound with lower bound, do loop again
// if lower bound is still lower or equal than higher bound
yr_parser_emit_with_arg_reloc(
yyscanner,
OP_JLE,
compiler->loop_address[compiler->loop_depth],
NULL,
NULL);
yr_parser_emit(yyscanner, OP_POP, NULL);
yr_parser_emit(yyscanner, OP_POP, NULL);
}
// Pop end-of-list marker.
yr_parser_emit(yyscanner, OP_POP, NULL);
// At this point the loop quantifier (any, all, 1, 2,..)
// is at the top of the stack. Check if the quantifier
// is undefined (meaning "all") and replace it with the
// iterations counter in that case.
yr_parser_emit_with_arg(
yyscanner, OP_SWAPUNDEF, mem_offset + 2, NULL, NULL);
// Compare the loop quantifier with the number of
// expressions evaluating to TRUE.
yr_parser_emit_with_arg(
yyscanner, OP_PUSH_M, mem_offset + 1, NULL, NULL);
yr_parser_emit(yyscanner, OP_INT_LE, NULL);
compiler->loop_identifier[compiler->loop_depth] = NULL;
yr_free((yyvsp[-8].c_string));
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
}
#line 2741 "grammar.c" /* yacc.c:1646 */
break;
case 65:
#line 1163 "grammar.y" /* yacc.c:1646 */
{
int mem_offset = LOOP_LOCAL_VARS * compiler->loop_depth;
uint8_t* addr;
if (compiler->loop_depth == MAX_LOOP_NESTING)
compiler->last_result = \
ERROR_LOOP_NESTING_LIMIT_EXCEEDED;
if (compiler->loop_for_of_mem_offset != -1)
compiler->last_result = \
ERROR_NESTED_FOR_OF_LOOP;
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
yr_parser_emit_with_arg(
yyscanner, OP_CLEAR_M, mem_offset + 1, NULL, NULL);
yr_parser_emit_with_arg(
yyscanner, OP_CLEAR_M, mem_offset + 2, NULL, NULL);
// Pop the first string.
yr_parser_emit_with_arg(
yyscanner, OP_POP_M, mem_offset, &addr, NULL);
compiler->loop_for_of_mem_offset = mem_offset;
compiler->loop_address[compiler->loop_depth] = addr;
compiler->loop_identifier[compiler->loop_depth] = NULL;
compiler->loop_depth++;
}
#line 2775 "grammar.c" /* yacc.c:1646 */
break;
case 66:
#line 1193 "grammar.y" /* yacc.c:1646 */
{
int mem_offset;
compiler->loop_depth--;
compiler->loop_for_of_mem_offset = -1;
mem_offset = LOOP_LOCAL_VARS * compiler->loop_depth;
// Increment counter by the value returned by the
// boolean expression (0 or 1). If the boolean expression
// returned UNDEFINED the OP_ADD_M won't do anything.
yr_parser_emit_with_arg(
yyscanner, OP_ADD_M, mem_offset + 1, NULL, NULL);
// Increment iterations counter.
yr_parser_emit_with_arg(
yyscanner, OP_INCR_M, mem_offset + 2, NULL, NULL);
// If next string is not undefined, go back to the
// beginning of the loop.
yr_parser_emit_with_arg_reloc(
yyscanner,
OP_JNUNDEF,
compiler->loop_address[compiler->loop_depth],
NULL,
NULL);
// Pop end-of-list marker.
yr_parser_emit(yyscanner, OP_POP, NULL);
// At this point the loop quantifier (any, all, 1, 2,..)
// is at top of the stack. Check if the quantifier is
// undefined (meaning "all") and replace it with the
// iterations counter in that case.
yr_parser_emit_with_arg(
yyscanner, OP_SWAPUNDEF, mem_offset + 2, NULL, NULL);
// Compare the loop quantifier with the number of
// expressions evaluating to TRUE.
yr_parser_emit_with_arg(
yyscanner, OP_PUSH_M, mem_offset + 1, NULL, NULL);
yr_parser_emit(yyscanner, OP_INT_LE, NULL);
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
}
#line 2828 "grammar.c" /* yacc.c:1646 */
break;
case 67:
#line 1242 "grammar.y" /* yacc.c:1646 */
{
yr_parser_emit(yyscanner, OP_OF, NULL);
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
}
#line 2838 "grammar.c" /* yacc.c:1646 */
break;
case 68:
#line 1248 "grammar.y" /* yacc.c:1646 */
{
yr_parser_emit(yyscanner, OP_NOT, NULL);
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
}
#line 2848 "grammar.c" /* yacc.c:1646 */
break;
case 69:
#line 1254 "grammar.y" /* yacc.c:1646 */
{
YR_FIXUP* fixup;
void* jmp_destination_addr;
compiler->last_result = yr_parser_emit_with_arg_reloc(
yyscanner,
OP_JFALSE,
0, // still don't know the jump destination
NULL,
&jmp_destination_addr);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
// create a fixup entry for the jump and push it in the stack
fixup = (YR_FIXUP*) yr_malloc(sizeof(YR_FIXUP));
if (fixup == NULL)
compiler->last_error = ERROR_INSUFFICIENT_MEMORY;
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
fixup->address = jmp_destination_addr;
fixup->next = compiler->fixup_stack_head;
compiler->fixup_stack_head = fixup;
}
#line 2878 "grammar.c" /* yacc.c:1646 */
break;
case 70:
#line 1280 "grammar.y" /* yacc.c:1646 */
{
YR_FIXUP* fixup;
uint8_t* and_addr;
// Ensure that we have at least two consecutive bytes in the arena's
// current page, one for the AND opcode and one for opcode following the
// AND. This is necessary because we need to compute the address for the
// opcode following the AND, and we don't want the AND in one page and
// the following opcode in another page.
compiler->last_result = yr_arena_reserve_memory(
compiler->code_arena, 2);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
compiler->last_result = yr_parser_emit(yyscanner, OP_AND, &and_addr);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
// Now we know the jump destination, which is the address of the
// instruction following the AND. Let's fixup the jump address.
fixup = compiler->fixup_stack_head;
// We know that the AND opcode and the following one are within the same
// page, so we can compute the address for the opcode following the AND
// by simply adding one to its address.
*(void**)(fixup->address) = (void*)(and_addr + 1);
compiler->fixup_stack_head = fixup->next;
yr_free(fixup);
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
}
#line 2918 "grammar.c" /* yacc.c:1646 */
break;
case 71:
#line 1316 "grammar.y" /* yacc.c:1646 */
{
YR_FIXUP* fixup;
void* jmp_destination_addr;
compiler->last_result = yr_parser_emit_with_arg_reloc(
yyscanner,
OP_JTRUE,
0, // still don't know the jump destination
NULL,
&jmp_destination_addr);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
fixup = (YR_FIXUP*) yr_malloc(sizeof(YR_FIXUP));
if (fixup == NULL)
compiler->last_error = ERROR_INSUFFICIENT_MEMORY;
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
fixup->address = jmp_destination_addr;
fixup->next = compiler->fixup_stack_head;
compiler->fixup_stack_head = fixup;
}
#line 2947 "grammar.c" /* yacc.c:1646 */
break;
case 72:
#line 1341 "grammar.y" /* yacc.c:1646 */
{
YR_FIXUP* fixup;
uint8_t* or_addr;
// Ensure that we have at least two consecutive bytes in the arena's
// current page, one for the OR opcode and one for opcode following the
// OR. This is necessary because we need to compute the address for the
// opcode following the OR, and we don't want the OR in one page and
// the following opcode in another page.
compiler->last_result = yr_arena_reserve_memory(
compiler->code_arena, 2);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
compiler->last_result = yr_parser_emit(yyscanner, OP_OR, &or_addr);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
// Now we know the jump destination, which is the address of the
// instruction following the OP_OR. Let's fixup the jump address.
fixup = compiler->fixup_stack_head;
// We know that the OR opcode and the following one are within the same
// page, so we can compute the address for the opcode following the OR
// by simply adding one to its address.
*(void**)(fixup->address) = (void*)(or_addr + 1);
compiler->fixup_stack_head = fixup->next;
yr_free(fixup);
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
}
#line 2987 "grammar.c" /* yacc.c:1646 */
break;
case 73:
#line 1377 "grammar.y" /* yacc.c:1646 */
{
compiler->last_result = yr_parser_reduce_operation(
yyscanner, "<", (yyvsp[-2].expression), (yyvsp[0].expression));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
}
#line 3000 "grammar.c" /* yacc.c:1646 */
break;
case 74:
#line 1386 "grammar.y" /* yacc.c:1646 */
{
compiler->last_result = yr_parser_reduce_operation(
yyscanner, ">", (yyvsp[-2].expression), (yyvsp[0].expression));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
}
#line 3013 "grammar.c" /* yacc.c:1646 */
break;
case 75:
#line 1395 "grammar.y" /* yacc.c:1646 */
{
compiler->last_result = yr_parser_reduce_operation(
yyscanner, "<=", (yyvsp[-2].expression), (yyvsp[0].expression));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
}
#line 3026 "grammar.c" /* yacc.c:1646 */
break;
case 76:
#line 1404 "grammar.y" /* yacc.c:1646 */
{
compiler->last_result = yr_parser_reduce_operation(
yyscanner, ">=", (yyvsp[-2].expression), (yyvsp[0].expression));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
}
#line 3039 "grammar.c" /* yacc.c:1646 */
break;
case 77:
#line 1413 "grammar.y" /* yacc.c:1646 */
{
compiler->last_result = yr_parser_reduce_operation(
yyscanner, "==", (yyvsp[-2].expression), (yyvsp[0].expression));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
}
#line 3052 "grammar.c" /* yacc.c:1646 */
break;
case 78:
#line 1422 "grammar.y" /* yacc.c:1646 */
{
compiler->last_result = yr_parser_reduce_operation(
yyscanner, "!=", (yyvsp[-2].expression), (yyvsp[0].expression));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
}
#line 3065 "grammar.c" /* yacc.c:1646 */
break;
case 79:
#line 1431 "grammar.y" /* yacc.c:1646 */
{
(yyval.expression) = (yyvsp[0].expression);
}
#line 3073 "grammar.c" /* yacc.c:1646 */
break;
case 80:
#line 1435 "grammar.y" /* yacc.c:1646 */
{
(yyval.expression) = (yyvsp[-1].expression);
}
#line 3081 "grammar.c" /* yacc.c:1646 */
break;
case 81:
#line 1442 "grammar.y" /* yacc.c:1646 */
{ (yyval.integer) = INTEGER_SET_ENUMERATION; }
#line 3087 "grammar.c" /* yacc.c:1646 */
break;
case 82:
#line 1443 "grammar.y" /* yacc.c:1646 */
{ (yyval.integer) = INTEGER_SET_RANGE; }
#line 3093 "grammar.c" /* yacc.c:1646 */
break;
case 83:
#line 1449 "grammar.y" /* yacc.c:1646 */
{
if ((yyvsp[-3].expression).type != EXPRESSION_TYPE_INTEGER)
{
yr_compiler_set_error_extra_info(
compiler, "wrong type for range's lower bound");
compiler->last_result = ERROR_WRONG_TYPE;
}
if ((yyvsp[-1].expression).type != EXPRESSION_TYPE_INTEGER)
{
yr_compiler_set_error_extra_info(
compiler, "wrong type for range's upper bound");
compiler->last_result = ERROR_WRONG_TYPE;
}
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
}
#line 3115 "grammar.c" /* yacc.c:1646 */
break;
case 84:
#line 1471 "grammar.y" /* yacc.c:1646 */
{
if ((yyvsp[0].expression).type != EXPRESSION_TYPE_INTEGER)
{
yr_compiler_set_error_extra_info(
compiler, "wrong type for enumeration item");
compiler->last_result = ERROR_WRONG_TYPE;
}
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
}
#line 3131 "grammar.c" /* yacc.c:1646 */
break;
case 85:
#line 1483 "grammar.y" /* yacc.c:1646 */
{
if ((yyvsp[0].expression).type != EXPRESSION_TYPE_INTEGER)
{
yr_compiler_set_error_extra_info(
compiler, "wrong type for enumeration item");
compiler->last_result = ERROR_WRONG_TYPE;
}
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
}
#line 3146 "grammar.c" /* yacc.c:1646 */
break;
case 86:
#line 1498 "grammar.y" /* yacc.c:1646 */
{
// Push end-of-list marker
yr_parser_emit_with_arg(yyscanner, OP_PUSH, UNDEFINED, NULL, NULL);
}
#line 3155 "grammar.c" /* yacc.c:1646 */
break;
case 88:
#line 1504 "grammar.y" /* yacc.c:1646 */
{
yr_parser_emit_with_arg(yyscanner, OP_PUSH, UNDEFINED, NULL, NULL);
yr_parser_emit_pushes_for_strings(yyscanner, "$*");
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
}
#line 3166 "grammar.c" /* yacc.c:1646 */
break;
case 91:
#line 1521 "grammar.y" /* yacc.c:1646 */
{
yr_parser_emit_pushes_for_strings(yyscanner, (yyvsp[0].c_string));
yr_free((yyvsp[0].c_string));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
}
#line 3177 "grammar.c" /* yacc.c:1646 */
break;
case 92:
#line 1528 "grammar.y" /* yacc.c:1646 */
{
yr_parser_emit_pushes_for_strings(yyscanner, (yyvsp[0].c_string));
yr_free((yyvsp[0].c_string));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
}
#line 3188 "grammar.c" /* yacc.c:1646 */
break;
case 94:
#line 1540 "grammar.y" /* yacc.c:1646 */
{
yr_parser_emit_with_arg(yyscanner, OP_PUSH, UNDEFINED, NULL, NULL);
}
#line 3196 "grammar.c" /* yacc.c:1646 */
break;
case 95:
#line 1544 "grammar.y" /* yacc.c:1646 */
{
yr_parser_emit_with_arg(yyscanner, OP_PUSH, 1, NULL, NULL);
}
#line 3204 "grammar.c" /* yacc.c:1646 */
break;
case 96:
#line 1552 "grammar.y" /* yacc.c:1646 */
{
(yyval.expression) = (yyvsp[-1].expression);
}
#line 3212 "grammar.c" /* yacc.c:1646 */
break;
case 97:
#line 1556 "grammar.y" /* yacc.c:1646 */
{
compiler->last_result = yr_parser_emit(
yyscanner, OP_FILESIZE, NULL);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
(yyval.expression).value.integer = UNDEFINED;
}
#line 3226 "grammar.c" /* yacc.c:1646 */
break;
case 98:
#line 1566 "grammar.y" /* yacc.c:1646 */
{
yywarning(yyscanner,
"Using deprecated \"entrypoint\" keyword. Use the \"entry_point\" "
"function from PE module instead.");
compiler->last_result = yr_parser_emit(
yyscanner, OP_ENTRYPOINT, NULL);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
(yyval.expression).value.integer = UNDEFINED;
}
#line 3244 "grammar.c" /* yacc.c:1646 */
break;
case 99:
#line 1580 "grammar.y" /* yacc.c:1646 */
{
CHECK_TYPE((yyvsp[-1].expression), EXPRESSION_TYPE_INTEGER, "intXXXX or uintXXXX");
// _INTEGER_FUNCTION_ could be any of int8, int16, int32, uint8,
// uint32, etc. $1 contains an index that added to OP_READ_INT results
// in the proper OP_INTXX opcode.
compiler->last_result = yr_parser_emit(
yyscanner, (uint8_t) (OP_READ_INT + (yyvsp[-3].integer)), NULL);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
(yyval.expression).value.integer = UNDEFINED;
}
#line 3264 "grammar.c" /* yacc.c:1646 */
break;
case 100:
#line 1596 "grammar.y" /* yacc.c:1646 */
{
compiler->last_result = yr_parser_emit_with_arg(
yyscanner, OP_PUSH, (yyvsp[0].integer), NULL, NULL);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
(yyval.expression).value.integer = (yyvsp[0].integer);
}
#line 3278 "grammar.c" /* yacc.c:1646 */
break;
case 101:
#line 1606 "grammar.y" /* yacc.c:1646 */
{
compiler->last_result = yr_parser_emit_with_arg_double(
yyscanner, OP_PUSH, (yyvsp[0].double_), NULL, NULL);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_FLOAT;
}
#line 3291 "grammar.c" /* yacc.c:1646 */
break;
case 102:
#line 1615 "grammar.y" /* yacc.c:1646 */
{
SIZED_STRING* sized_string;
compiler->last_result = yr_arena_write_data(
compiler->sz_arena,
(yyvsp[0].sized_string),
(yyvsp[0].sized_string)->length + sizeof(SIZED_STRING),
(void**) &sized_string);
yr_free((yyvsp[0].sized_string));
if (compiler->last_result == ERROR_SUCCESS)
compiler->last_result = yr_parser_emit_with_arg_reloc(
yyscanner,
OP_PUSH,
sized_string,
NULL,
NULL);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_STRING;
(yyval.expression).value.sized_string = sized_string;
}
#line 3320 "grammar.c" /* yacc.c:1646 */
break;
case 103:
#line 1640 "grammar.y" /* yacc.c:1646 */
{
compiler->last_result = yr_parser_reduce_string_identifier(
yyscanner, (yyvsp[0].c_string), OP_COUNT, UNDEFINED);
yr_free((yyvsp[0].c_string));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
(yyval.expression).value.integer = UNDEFINED;
}
#line 3336 "grammar.c" /* yacc.c:1646 */
break;
case 104:
#line 1652 "grammar.y" /* yacc.c:1646 */
{
compiler->last_result = yr_parser_reduce_string_identifier(
yyscanner, (yyvsp[-3].c_string), OP_OFFSET, UNDEFINED);
yr_free((yyvsp[-3].c_string));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
(yyval.expression).value.integer = UNDEFINED;
}
#line 3352 "grammar.c" /* yacc.c:1646 */
break;
case 105:
#line 1664 "grammar.y" /* yacc.c:1646 */
{
compiler->last_result = yr_parser_emit_with_arg(
yyscanner, OP_PUSH, 1, NULL, NULL);
if (compiler->last_result == ERROR_SUCCESS)
compiler->last_result = yr_parser_reduce_string_identifier(
yyscanner, (yyvsp[0].c_string), OP_OFFSET, UNDEFINED);
yr_free((yyvsp[0].c_string));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
(yyval.expression).value.integer = UNDEFINED;
}
#line 3372 "grammar.c" /* yacc.c:1646 */
break;
case 106:
#line 1680 "grammar.y" /* yacc.c:1646 */
{
compiler->last_result = yr_parser_reduce_string_identifier(
yyscanner, (yyvsp[-3].c_string), OP_LENGTH, UNDEFINED);
yr_free((yyvsp[-3].c_string));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
(yyval.expression).value.integer = UNDEFINED;
}
#line 3388 "grammar.c" /* yacc.c:1646 */
break;
case 107:
#line 1692 "grammar.y" /* yacc.c:1646 */
{
compiler->last_result = yr_parser_emit_with_arg(
yyscanner, OP_PUSH, 1, NULL, NULL);
if (compiler->last_result == ERROR_SUCCESS)
compiler->last_result = yr_parser_reduce_string_identifier(
yyscanner, (yyvsp[0].c_string), OP_LENGTH, UNDEFINED);
yr_free((yyvsp[0].c_string));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
(yyval.expression).value.integer = UNDEFINED;
}
#line 3408 "grammar.c" /* yacc.c:1646 */
break;
case 108:
#line 1708 "grammar.y" /* yacc.c:1646 */
{
if ((yyvsp[0].expression).type == EXPRESSION_TYPE_INTEGER) // loop identifier
{
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
(yyval.expression).value.integer = UNDEFINED;
}
else if ((yyvsp[0].expression).type == EXPRESSION_TYPE_BOOLEAN) // rule identifier
{
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
(yyval.expression).value.integer = UNDEFINED;
}
else if ((yyvsp[0].expression).type == EXPRESSION_TYPE_OBJECT)
{
compiler->last_result = yr_parser_emit(
yyscanner, OP_OBJ_VALUE, NULL);
switch((yyvsp[0].expression).value.object->type)
{
case OBJECT_TYPE_INTEGER:
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
(yyval.expression).value.integer = UNDEFINED;
break;
case OBJECT_TYPE_FLOAT:
(yyval.expression).type = EXPRESSION_TYPE_FLOAT;
break;
case OBJECT_TYPE_STRING:
(yyval.expression).type = EXPRESSION_TYPE_STRING;
(yyval.expression).value.sized_string = NULL;
break;
default:
yr_compiler_set_error_extra_info_fmt(
compiler,
"wrong usage of identifier \"%s\"",
(yyvsp[0].expression).identifier);
compiler->last_result = ERROR_WRONG_TYPE;
}
}
else
{
assert(FALSE);
}
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
}
#line 3457 "grammar.c" /* yacc.c:1646 */
break;
case 109:
#line 1753 "grammar.y" /* yacc.c:1646 */
{
CHECK_TYPE((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER | EXPRESSION_TYPE_FLOAT, "-");
if ((yyvsp[0].expression).type == EXPRESSION_TYPE_INTEGER)
{
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
(yyval.expression).value.integer = ((yyvsp[0].expression).value.integer == UNDEFINED) ?
UNDEFINED : -((yyvsp[0].expression).value.integer);
compiler->last_result = yr_parser_emit(yyscanner, OP_INT_MINUS, NULL);
}
else if ((yyvsp[0].expression).type == EXPRESSION_TYPE_FLOAT)
{
(yyval.expression).type = EXPRESSION_TYPE_FLOAT;
compiler->last_result = yr_parser_emit(yyscanner, OP_DBL_MINUS, NULL);
}
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
}
#line 3480 "grammar.c" /* yacc.c:1646 */
break;
case 110:
#line 1772 "grammar.y" /* yacc.c:1646 */
{
compiler->last_result = yr_parser_reduce_operation(
yyscanner, "+", (yyvsp[-2].expression), (yyvsp[0].expression));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
if ((yyvsp[-2].expression).type == EXPRESSION_TYPE_INTEGER &&
(yyvsp[0].expression).type == EXPRESSION_TYPE_INTEGER)
{
(yyval.expression).value.integer = OPERATION(+, (yyvsp[-2].expression).value.integer, (yyvsp[0].expression).value.integer);
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
}
else
{
(yyval.expression).type = EXPRESSION_TYPE_FLOAT;
}
}
#line 3502 "grammar.c" /* yacc.c:1646 */
break;
case 111:
#line 1790 "grammar.y" /* yacc.c:1646 */
{
compiler->last_result = yr_parser_reduce_operation(
yyscanner, "-", (yyvsp[-2].expression), (yyvsp[0].expression));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
if ((yyvsp[-2].expression).type == EXPRESSION_TYPE_INTEGER &&
(yyvsp[0].expression).type == EXPRESSION_TYPE_INTEGER)
{
(yyval.expression).value.integer = OPERATION(-, (yyvsp[-2].expression).value.integer, (yyvsp[0].expression).value.integer);
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
}
else
{
(yyval.expression).type = EXPRESSION_TYPE_FLOAT;
}
}
#line 3524 "grammar.c" /* yacc.c:1646 */
break;
case 112:
#line 1808 "grammar.y" /* yacc.c:1646 */
{
compiler->last_result = yr_parser_reduce_operation(
yyscanner, "*", (yyvsp[-2].expression), (yyvsp[0].expression));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
if ((yyvsp[-2].expression).type == EXPRESSION_TYPE_INTEGER &&
(yyvsp[0].expression).type == EXPRESSION_TYPE_INTEGER)
{
(yyval.expression).value.integer = OPERATION(*, (yyvsp[-2].expression).value.integer, (yyvsp[0].expression).value.integer);
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
}
else
{
(yyval.expression).type = EXPRESSION_TYPE_FLOAT;
}
}
#line 3546 "grammar.c" /* yacc.c:1646 */
break;
case 113:
#line 1826 "grammar.y" /* yacc.c:1646 */
{
compiler->last_result = yr_parser_reduce_operation(
yyscanner, "\\", (yyvsp[-2].expression), (yyvsp[0].expression));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
if ((yyvsp[-2].expression).type == EXPRESSION_TYPE_INTEGER &&
(yyvsp[0].expression).type == EXPRESSION_TYPE_INTEGER)
{
if ((yyvsp[0].expression).value.integer != 0)
{
(yyval.expression).value.integer = OPERATION(/, (yyvsp[-2].expression).value.integer, (yyvsp[0].expression).value.integer);
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
}
else
{
compiler->last_result = ERROR_DIVISION_BY_ZERO;
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
}
}
else
{
(yyval.expression).type = EXPRESSION_TYPE_FLOAT;
}
}
#line 3576 "grammar.c" /* yacc.c:1646 */
break;
case 114:
#line 1852 "grammar.y" /* yacc.c:1646 */
{
CHECK_TYPE((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "%");
CHECK_TYPE((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "%");
yr_parser_emit(yyscanner, OP_MOD, NULL);
if ((yyvsp[0].expression).value.integer != 0)
{
(yyval.expression).value.integer = OPERATION(%, (yyvsp[-2].expression).value.integer, (yyvsp[0].expression).value.integer);
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
}
else
{
compiler->last_result = ERROR_DIVISION_BY_ZERO;
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
}
}
#line 3598 "grammar.c" /* yacc.c:1646 */
break;
case 115:
#line 1870 "grammar.y" /* yacc.c:1646 */
{
CHECK_TYPE((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "^");
CHECK_TYPE((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "^");
yr_parser_emit(yyscanner, OP_BITWISE_XOR, NULL);
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
(yyval.expression).value.integer = OPERATION(^, (yyvsp[-2].expression).value.integer, (yyvsp[0].expression).value.integer);
}
#line 3612 "grammar.c" /* yacc.c:1646 */
break;
case 116:
#line 1880 "grammar.y" /* yacc.c:1646 */
{
CHECK_TYPE((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "^");
CHECK_TYPE((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "^");
yr_parser_emit(yyscanner, OP_BITWISE_AND, NULL);
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
(yyval.expression).value.integer = OPERATION(&, (yyvsp[-2].expression).value.integer, (yyvsp[0].expression).value.integer);
}
#line 3626 "grammar.c" /* yacc.c:1646 */
break;
case 117:
#line 1890 "grammar.y" /* yacc.c:1646 */
{
CHECK_TYPE((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "|");
CHECK_TYPE((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "|");
yr_parser_emit(yyscanner, OP_BITWISE_OR, NULL);
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
(yyval.expression).value.integer = OPERATION(|, (yyvsp[-2].expression).value.integer, (yyvsp[0].expression).value.integer);
}
#line 3640 "grammar.c" /* yacc.c:1646 */
break;
case 118:
#line 1900 "grammar.y" /* yacc.c:1646 */
{
CHECK_TYPE((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "~");
yr_parser_emit(yyscanner, OP_BITWISE_NOT, NULL);
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
(yyval.expression).value.integer = ((yyvsp[0].expression).value.integer == UNDEFINED) ?
UNDEFINED : ~((yyvsp[0].expression).value.integer);
}
#line 3654 "grammar.c" /* yacc.c:1646 */
break;
case 119:
#line 1910 "grammar.y" /* yacc.c:1646 */
{
CHECK_TYPE((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "<<");
CHECK_TYPE((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "<<");
yr_parser_emit(yyscanner, OP_SHL, NULL);
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
(yyval.expression).value.integer = OPERATION(<<, (yyvsp[-2].expression).value.integer, (yyvsp[0].expression).value.integer);
}
#line 3668 "grammar.c" /* yacc.c:1646 */
break;
case 120:
#line 1920 "grammar.y" /* yacc.c:1646 */
{
CHECK_TYPE((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, ">>");
CHECK_TYPE((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, ">>");
yr_parser_emit(yyscanner, OP_SHR, NULL);
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
(yyval.expression).value.integer = OPERATION(>>, (yyvsp[-2].expression).value.integer, (yyvsp[0].expression).value.integer);
}
#line 3682 "grammar.c" /* yacc.c:1646 */
break;
case 121:
#line 1930 "grammar.y" /* yacc.c:1646 */
{
(yyval.expression) = (yyvsp[0].expression);
}
#line 3690 "grammar.c" /* yacc.c:1646 */
break;
#line 3694 "grammar.c" /* yacc.c:1646 */
default: break;
}
/* User semantic actions sometimes alter yychar, and that requires
that yytoken be updated with the new translation. We take the
approach of translating immediately before every use of yytoken.
One alternative is translating here after every semantic action,
but that translation would be missed if the semantic action invokes
YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
incorrect destructor might then be invoked immediately. In the
case of YYERROR or YYBACKUP, subsequent parser actions might lead
to an incorrect destructor call or verbose syntax error message
before the lookahead is translated. */
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
YYPOPSTACK (yylen);
yylen = 0;
YY_STACK_PRINT (yyss, yyssp);
*++yyvsp = yyval;
/* Now 'shift' the result of the reduction. Determine what state
that goes to, based on the state we popped back to and the rule
number reduced by. */
yyn = yyr1[yyn];
yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
yystate = yytable[yystate];
else
yystate = yydefgoto[yyn - YYNTOKENS];
goto yynewstate;
/*--------------------------------------.
| yyerrlab -- here on detecting error. |
`--------------------------------------*/
yyerrlab:
/* Make sure we have latest lookahead translation. See comments at
user semantic actions for why this is necessary. */
yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
/* If not already recovering from an error, report this error. */
if (!yyerrstatus)
{
++yynerrs;
#if ! YYERROR_VERBOSE
yyerror (yyscanner, compiler, YY_("syntax error"));
#else
# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
yyssp, yytoken)
{
char const *yymsgp = YY_("syntax error");
int yysyntax_error_status;
yysyntax_error_status = YYSYNTAX_ERROR;
if (yysyntax_error_status == 0)
yymsgp = yymsg;
else if (yysyntax_error_status == 1)
{
if (yymsg != yymsgbuf)
YYSTACK_FREE (yymsg);
yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
if (!yymsg)
{
yymsg = yymsgbuf;
yymsg_alloc = sizeof yymsgbuf;
yysyntax_error_status = 2;
}
else
{
yysyntax_error_status = YYSYNTAX_ERROR;
yymsgp = yymsg;
}
}
yyerror (yyscanner, compiler, yymsgp);
if (yysyntax_error_status == 2)
goto yyexhaustedlab;
}
# undef YYSYNTAX_ERROR
#endif
}
if (yyerrstatus == 3)
{
/* If just tried and failed to reuse lookahead token after an
error, discard it. */
if (yychar <= YYEOF)
{
/* Return failure if at end of input. */
if (yychar == YYEOF)
YYABORT;
}
else
{
yydestruct ("Error: discarding",
yytoken, &yylval, yyscanner, compiler);
yychar = YYEMPTY;
}
}
/* Else will try to reuse lookahead token after shifting the error
token. */
goto yyerrlab1;
/*---------------------------------------------------.
| yyerrorlab -- error raised explicitly by YYERROR. |
`---------------------------------------------------*/
yyerrorlab:
/* Pacify compilers like GCC when the user code never invokes
YYERROR and the label yyerrorlab therefore never appears in user
code. */
if (/*CONSTCOND*/ 0)
goto yyerrorlab;
/* Do not reclaim the symbols of the rule whose action triggered
this YYERROR. */
YYPOPSTACK (yylen);
yylen = 0;
YY_STACK_PRINT (yyss, yyssp);
yystate = *yyssp;
goto yyerrlab1;
/*-------------------------------------------------------------.
| yyerrlab1 -- common code for both syntax error and YYERROR. |
`-------------------------------------------------------------*/
yyerrlab1:
yyerrstatus = 3; /* Each real token shifted decrements this. */
for (;;)
{
yyn = yypact[yystate];
if (!yypact_value_is_default (yyn))
{
yyn += YYTERROR;
if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
{
yyn = yytable[yyn];
if (0 < yyn)
break;
}
}
/* Pop the current state because it cannot handle the error token. */
if (yyssp == yyss)
YYABORT;
yydestruct ("Error: popping",
yystos[yystate], yyvsp, yyscanner, compiler);
YYPOPSTACK (1);
yystate = *yyssp;
YY_STACK_PRINT (yyss, yyssp);
}
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
*++yyvsp = yylval;
YY_IGNORE_MAYBE_UNINITIALIZED_END
/* Shift the error token. */
YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
yystate = yyn;
goto yynewstate;
/*-------------------------------------.
| yyacceptlab -- YYACCEPT comes here. |
`-------------------------------------*/
yyacceptlab:
yyresult = 0;
goto yyreturn;
/*-----------------------------------.
| yyabortlab -- YYABORT comes here. |
`-----------------------------------*/
yyabortlab:
yyresult = 1;
goto yyreturn;
#if !defined yyoverflow || YYERROR_VERBOSE
/*-------------------------------------------------.
| yyexhaustedlab -- memory exhaustion comes here. |
`-------------------------------------------------*/
yyexhaustedlab:
yyerror (yyscanner, compiler, YY_("memory exhausted"));
yyresult = 2;
/* Fall through. */
#endif
yyreturn:
if (yychar != YYEMPTY)
{
/* Make sure we have latest lookahead translation. See comments at
user semantic actions for why this is necessary. */
yytoken = YYTRANSLATE (yychar);
yydestruct ("Cleanup: discarding lookahead",
yytoken, &yylval, yyscanner, compiler);
}
/* Do not reclaim the symbols of the rule whose action triggered
this YYABORT or YYACCEPT. */
YYPOPSTACK (yylen);
YY_STACK_PRINT (yyss, yyssp);
while (yyssp != yyss)
{
yydestruct ("Cleanup: popping",
yystos[*yyssp], yyvsp, yyscanner, compiler);
YYPOPSTACK (1);
}
#ifndef yyoverflow
if (yyss != yyssa)
YYSTACK_FREE (yyss);
#endif
#if YYERROR_VERBOSE
if (yymsg != yymsgbuf)
YYSTACK_FREE (yymsg);
#endif
return yyresult; | 9786 | True | 1 |
CVE-2016-10210 | 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.0/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/VirusTotal/yara/issues/576', 'name': 'https://github.com/VirusTotal/yara/issues/576', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Issue Tracking', 'Patch']}, {'url': 'https://github.com/VirusTotal/yara/commit/3119b232c9c453c98d8fa8b6ae4e37ba18117cd4', 'name': 'https://github.com/VirusTotal/yara/commit/3119b232c9c453c98d8fa8b6ae4e37ba18117cd4', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Vendor Advisory']}, {'url': 'http://www.securityfocus.com/bid/98077', 'name': '98077', 'refsource': 'BID', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-476'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:virustotal:yara:3.5.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'libyara/lexer.l in YARA 3.5.0 allows remote attackers to cause a denial of service (NULL pointer dereference and application crash) via a crafted rule that is mishandled in the yy_get_next_buffer function.'}] | 2017-05-02T01:59Z | 2017-04-03T05:59Z | 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 | Hilko Bengen | 2017-01-17 17:07:02+01:00 | re_lexer: Make reading escape sequences more robust (#586)
* Add test for issue #503
* re_lexer: Make reading escape sequences more robust
This commit fixes parsing incomplete escape sequences at the end of a
regular expression and parsing things like \xxy (invalid hex digits)
which before were silently turned into (char)255.
Close #503
* Update re_lexer.c | 3119b232c9c453c98d8fa8b6ae4e37ba18117cd4 | False | VirusTotal/yara | The pattern matching swiss knife | 2012-12-06 15:33:08 | 2022-08-26 10:13:14 | https://virustotal.github.io/yara/ | VirusTotal | 5938.0 | 1229.0 | input | input( yyscan_t yyscanner) | ['yyscanner'] | #else
static int input (yyscan_t yyscanner)
#endif
{
int c;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
*yyg->yy_c_buf_p = yyg->yy_hold_char;
if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
{
/* yy_c_buf_p now points to the character we want to return.
* If this occurs *before* the EOB characters, then it's a
* valid NUL; if not, then we've hit the end of the buffer.
*/
if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
/* This was really a NUL. */
*yyg->yy_c_buf_p = '\0';
else
{ /* need more input */
yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
++yyg->yy_c_buf_p;
switch ( yy_get_next_buffer( yyscanner ) )
{
case EOB_ACT_LAST_MATCH:
/* This happens because yy_g_n_b()
* sees that we've accumulated a
* token and flags that we need to
* try matching the token before
* proceeding. But for input(),
* there's no matching to consider.
* So convert the EOB_ACT_LAST_MATCH
* to EOB_ACT_END_OF_FILE.
*/
/* Reset buffer status. */
re_yyrestart(yyin ,yyscanner);
/*FALLTHROUGH*/
case EOB_ACT_END_OF_FILE:
{
if ( re_yywrap(yyscanner ) )
return EOF;
if ( ! yyg->yy_did_buffer_switch_on_eof )
YY_NEW_FILE;
#ifdef __cplusplus
return yyinput(yyscanner);
#else
return input(yyscanner);
#endif
}
case EOB_ACT_CONTINUE_SCAN:
yyg->yy_c_buf_p = yyg->yytext_ptr + offset;
break;
}
}
}
c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */
*yyg->yy_c_buf_p = '\0'; /* preserve yytext */
yyg->yy_hold_char = *++yyg->yy_c_buf_p;
if ( c == '\n' )
do{ yylineno++;
yycolumn=0;
}while(0)
;
return c; | 206 | True | 1 |
CVE-2016-10210 | 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.0/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/VirusTotal/yara/issues/576', 'name': 'https://github.com/VirusTotal/yara/issues/576', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Issue Tracking', 'Patch']}, {'url': 'https://github.com/VirusTotal/yara/commit/3119b232c9c453c98d8fa8b6ae4e37ba18117cd4', 'name': 'https://github.com/VirusTotal/yara/commit/3119b232c9c453c98d8fa8b6ae4e37ba18117cd4', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Vendor Advisory']}, {'url': 'http://www.securityfocus.com/bid/98077', 'name': '98077', 'refsource': 'BID', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-476'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:virustotal:yara:3.5.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'libyara/lexer.l in YARA 3.5.0 allows remote attackers to cause a denial of service (NULL pointer dereference and application crash) via a crafted rule that is mishandled in the yy_get_next_buffer function.'}] | 2017-05-02T01:59Z | 2017-04-03T05:59Z | 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 | Hilko Bengen | 2017-01-17 17:07:02+01:00 | re_lexer: Make reading escape sequences more robust (#586)
* Add test for issue #503
* re_lexer: Make reading escape sequences more robust
This commit fixes parsing incomplete escape sequences at the end of a
regular expression and parsing things like \xxy (invalid hex digits)
which before were silently turned into (char)255.
Close #503
* Update re_lexer.c | 3119b232c9c453c98d8fa8b6ae4e37ba18117cd4 | False | VirusTotal/yara | The pattern matching swiss knife | 2012-12-06 15:33:08 | 2022-08-26 10:13:14 | https://virustotal.github.io/yara/ | VirusTotal | 5938.0 | 1229.0 | re_yyensure_buffer_stack | re_yyensure_buffer_stack( yyscan_t yyscanner) | ['yyscanner'] | */
static void re_yyensure_buffer_stack (yyscan_t yyscanner)
{
yy_size_t num_to_alloc;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if (!yyg->yy_buffer_stack) {
/* First allocation is just for 2 elements, since we don't know if this
* scanner will even need a stack. We use 2 instead of 1 to avoid an
* immediate realloc on the next call.
*/
num_to_alloc = 1; // After all that talk, this was set to 1 anyways...
yyg->yy_buffer_stack = (struct yy_buffer_state**)re_yyalloc
(num_to_alloc * sizeof(struct yy_buffer_state*)
, yyscanner);
if ( ! yyg->yy_buffer_stack )
YY_FATAL_ERROR( "out of dynamic memory in re_yyensure_buffer_stack()" );
memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
yyg->yy_buffer_stack_max = num_to_alloc;
yyg->yy_buffer_stack_top = 0;
return;
}
if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){
/* Increase the buffer to prepare for a possible push. */
yy_size_t grow_size = 8 /* arbitrary grow size */;
num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
yyg->yy_buffer_stack = (struct yy_buffer_state**)re_yyrealloc
(yyg->yy_buffer_stack,
num_to_alloc * sizeof(struct yy_buffer_state*)
, yyscanner);
if ( ! yyg->yy_buffer_stack )
YY_FATAL_ERROR( "out of dynamic memory in re_yyensure_buffer_stack()" );
/* zero only the new slots.*/
memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
yyg->yy_buffer_stack_max = num_to_alloc;
} | 198 | True | 1 |
CVE-2016-10210 | 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.0/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/VirusTotal/yara/issues/576', 'name': 'https://github.com/VirusTotal/yara/issues/576', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Issue Tracking', 'Patch']}, {'url': 'https://github.com/VirusTotal/yara/commit/3119b232c9c453c98d8fa8b6ae4e37ba18117cd4', 'name': 'https://github.com/VirusTotal/yara/commit/3119b232c9c453c98d8fa8b6ae4e37ba18117cd4', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Vendor Advisory']}, {'url': 'http://www.securityfocus.com/bid/98077', 'name': '98077', 'refsource': 'BID', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-476'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:virustotal:yara:3.5.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'libyara/lexer.l in YARA 3.5.0 allows remote attackers to cause a denial of service (NULL pointer dereference and application crash) via a crafted rule that is mishandled in the yy_get_next_buffer function.'}] | 2017-05-02T01:59Z | 2017-04-03T05:59Z | 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 | Hilko Bengen | 2017-01-17 17:07:02+01:00 | re_lexer: Make reading escape sequences more robust (#586)
* Add test for issue #503
* re_lexer: Make reading escape sequences more robust
This commit fixes parsing incomplete escape sequences at the end of a
regular expression and parsing things like \xxy (invalid hex digits)
which before were silently turned into (char)255.
Close #503
* Update re_lexer.c | 3119b232c9c453c98d8fa8b6ae4e37ba18117cd4 | False | VirusTotal/yara | The pattern matching swiss knife | 2012-12-06 15:33:08 | 2022-08-26 10:13:14 | https://virustotal.github.io/yara/ | VirusTotal | 5938.0 | 1229.0 | re_yyget_column | re_yyget_column( yyscan_t yyscanner) | ['yyscanner'] | */
int re_yyget_column (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if (! YY_CURRENT_BUFFER)
return 0;
return yycolumn; | 30 | True | 1 |
CVE-2016-10210 | 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.0/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/VirusTotal/yara/issues/576', 'name': 'https://github.com/VirusTotal/yara/issues/576', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Issue Tracking', 'Patch']}, {'url': 'https://github.com/VirusTotal/yara/commit/3119b232c9c453c98d8fa8b6ae4e37ba18117cd4', 'name': 'https://github.com/VirusTotal/yara/commit/3119b232c9c453c98d8fa8b6ae4e37ba18117cd4', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Vendor Advisory']}, {'url': 'http://www.securityfocus.com/bid/98077', 'name': '98077', 'refsource': 'BID', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-476'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:virustotal:yara:3.5.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'libyara/lexer.l in YARA 3.5.0 allows remote attackers to cause a denial of service (NULL pointer dereference and application crash) via a crafted rule that is mishandled in the yy_get_next_buffer function.'}] | 2017-05-02T01:59Z | 2017-04-03T05:59Z | 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 | Hilko Bengen | 2017-01-17 17:07:02+01:00 | re_lexer: Make reading escape sequences more robust (#586)
* Add test for issue #503
* re_lexer: Make reading escape sequences more robust
This commit fixes parsing incomplete escape sequences at the end of a
regular expression and parsing things like \xxy (invalid hex digits)
which before were silently turned into (char)255.
Close #503
* Update re_lexer.c | 3119b232c9c453c98d8fa8b6ae4e37ba18117cd4 | False | VirusTotal/yara | The pattern matching swiss knife | 2012-12-06 15:33:08 | 2022-08-26 10:13:14 | https://virustotal.github.io/yara/ | VirusTotal | 5938.0 | 1229.0 | re_yyget_lineno | re_yyget_lineno( yyscan_t yyscanner) | ['yyscanner'] | */
int re_yyget_lineno (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if (! YY_CURRENT_BUFFER)
return 0;
return yylineno; | 30 | True | 1 |
CVE-2016-10210 | 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.0/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/VirusTotal/yara/issues/576', 'name': 'https://github.com/VirusTotal/yara/issues/576', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Issue Tracking', 'Patch']}, {'url': 'https://github.com/VirusTotal/yara/commit/3119b232c9c453c98d8fa8b6ae4e37ba18117cd4', 'name': 'https://github.com/VirusTotal/yara/commit/3119b232c9c453c98d8fa8b6ae4e37ba18117cd4', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Vendor Advisory']}, {'url': 'http://www.securityfocus.com/bid/98077', 'name': '98077', 'refsource': 'BID', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-476'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:virustotal:yara:3.5.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'libyara/lexer.l in YARA 3.5.0 allows remote attackers to cause a denial of service (NULL pointer dereference and application crash) via a crafted rule that is mishandled in the yy_get_next_buffer function.'}] | 2017-05-02T01:59Z | 2017-04-03T05:59Z | 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 | Hilko Bengen | 2017-01-17 17:07:02+01:00 | re_lexer: Make reading escape sequences more robust (#586)
* Add test for issue #503
* re_lexer: Make reading escape sequences more robust
This commit fixes parsing incomplete escape sequences at the end of a
regular expression and parsing things like \xxy (invalid hex digits)
which before were silently turned into (char)255.
Close #503
* Update re_lexer.c | 3119b232c9c453c98d8fa8b6ae4e37ba18117cd4 | False | VirusTotal/yara | The pattern matching swiss knife | 2012-12-06 15:33:08 | 2022-08-26 10:13:14 | https://virustotal.github.io/yara/ | VirusTotal | 5938.0 | 1229.0 | re_yylex_init_extra | re_yylex_init_extra( YY_EXTRA_TYPE yy_user_defined , yyscan_t * ptr_yy_globals) | ['yy_user_defined', 'ptr_yy_globals'] |
int re_yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals )
{
struct yyguts_t dummy_yyguts;
re_yyset_extra (yy_user_defined, &dummy_yyguts);
if (ptr_yy_globals == NULL){
errno = EINVAL;
return 1;
}
*ptr_yy_globals = (yyscan_t) re_yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
if (*ptr_yy_globals == NULL){
errno = ENOMEM;
return 1;
}
/* By setting to 0xAA, we expose bugs in
yy_init_globals. Leave at 0x00 for releases. */
memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
re_yyset_extra (yy_user_defined, *ptr_yy_globals);
return yy_init_globals ( *ptr_yy_globals ); | 101 | True | 1 |
CVE-2016-10210 | 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.0/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/VirusTotal/yara/issues/576', 'name': 'https://github.com/VirusTotal/yara/issues/576', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Issue Tracking', 'Patch']}, {'url': 'https://github.com/VirusTotal/yara/commit/3119b232c9c453c98d8fa8b6ae4e37ba18117cd4', 'name': 'https://github.com/VirusTotal/yara/commit/3119b232c9c453c98d8fa8b6ae4e37ba18117cd4', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Vendor Advisory']}, {'url': 'http://www.securityfocus.com/bid/98077', 'name': '98077', 'refsource': 'BID', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-476'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:virustotal:yara:3.5.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'libyara/lexer.l in YARA 3.5.0 allows remote attackers to cause a denial of service (NULL pointer dereference and application crash) via a crafted rule that is mishandled in the yy_get_next_buffer function.'}] | 2017-05-02T01:59Z | 2017-04-03T05:59Z | 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 | Hilko Bengen | 2017-01-17 17:07:02+01:00 | re_lexer: Make reading escape sequences more robust (#586)
* Add test for issue #503
* re_lexer: Make reading escape sequences more robust
This commit fixes parsing incomplete escape sequences at the end of a
regular expression and parsing things like \xxy (invalid hex digits)
which before were silently turned into (char)255.
Close #503
* Update re_lexer.c | 3119b232c9c453c98d8fa8b6ae4e37ba18117cd4 | False | VirusTotal/yara | The pattern matching swiss knife | 2012-12-06 15:33:08 | 2022-08-26 10:13:14 | https://virustotal.github.io/yara/ | VirusTotal | 5938.0 | 1229.0 | read_escaped_char | read_escaped_char( yyscan_t yyscanner , uint8_t * escaped_char) | ['yyscanner', 'escaped_char'] |
int read_escaped_char(
yyscan_t yyscanner,
uint8_t* escaped_char)
{
char text[4] = {0, 0, 0, 0};
text[0] = '\\';
text[1] = RE_YY_INPUT(yyscanner);
if (text[1] == EOF)
return 0;
if (text[1] == 'x')
{
text[2] = RE_YY_INPUT(yyscanner);
if (text[2] == EOF)
return 0;
text[3] = RE_YY_INPUT(yyscanner);
if (text[3] == EOF)
return 0;
}
*escaped_char = escaped_char_value(text);
return 1; | 122 | True | 1 |
CVE-2016-10210 | 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.0/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/VirusTotal/yara/issues/576', 'name': 'https://github.com/VirusTotal/yara/issues/576', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Issue Tracking', 'Patch']}, {'url': 'https://github.com/VirusTotal/yara/commit/3119b232c9c453c98d8fa8b6ae4e37ba18117cd4', 'name': 'https://github.com/VirusTotal/yara/commit/3119b232c9c453c98d8fa8b6ae4e37ba18117cd4', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Vendor Advisory']}, {'url': 'http://www.securityfocus.com/bid/98077', 'name': '98077', 'refsource': 'BID', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-476'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:virustotal:yara:3.5.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'libyara/lexer.l in YARA 3.5.0 allows remote attackers to cause a denial of service (NULL pointer dereference and application crash) via a crafted rule that is mishandled in the yy_get_next_buffer function.'}] | 2017-05-02T01:59Z | 2017-04-03T05:59Z | 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 | Hilko Bengen | 2017-01-17 17:07:02+01:00 | re_lexer: Make reading escape sequences more robust (#586)
* Add test for issue #503
* re_lexer: Make reading escape sequences more robust
This commit fixes parsing incomplete escape sequences at the end of a
regular expression and parsing things like \xxy (invalid hex digits)
which before were silently turned into (char)255.
Close #503
* Update re_lexer.c | 3119b232c9c453c98d8fa8b6ae4e37ba18117cd4 | False | VirusTotal/yara | The pattern matching swiss knife | 2012-12-06 15:33:08 | 2022-08-26 10:13:14 | https://virustotal.github.io/yara/ | VirusTotal | 5938.0 | 1229.0 | while | while( 1) | ['1'] |
while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
{
yy_cp = yyg->yy_c_buf_p;
/* Support of yytext. */
*yy_cp = yyg->yy_hold_char;
/* yy_bp points to the position in yy_ch_buf of the start of
* the current run.
*/
yy_bp = yy_cp;
yy_current_state = yyg->yy_start;
yy_match:
do
{
YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
if ( yy_accept[yy_current_state] )
{
yyg->yy_last_accepting_state = yy_current_state;
yyg->yy_last_accepting_cpos = yy_cp;
}
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 45 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
++yy_cp;
}
while ( yy_current_state != 44 );
yy_cp = yyg->yy_last_accepting_cpos;
yy_current_state = yyg->yy_last_accepting_state;
yy_find_action:
yy_act = yy_accept[yy_current_state];
YY_DO_BEFORE_ACTION;
if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )
{
yy_size_t yyl;
for ( yyl = 0; yyl < yyleng; ++yyl )
if ( yytext[yyl] == '\n' )
do{ yylineno++;
yycolumn=0;
}while(0)
;
}
do_action: /* This label is used only to access EOF actions. */
switch ( yy_act )
{ /* beginning of action switch */
case 0: /* must back up */
/* undo the effects of YY_DO_BEFORE_ACTION */
*yy_cp = yyg->yy_hold_char;
yy_cp = yyg->yy_last_accepting_cpos;
yy_current_state = yyg->yy_last_accepting_state;
goto yy_find_action;
case 1:
YY_RULE_SETUP
#line 101 "re_lexer.l"
{
// Examples: {3,8} {0,5} {,5} {7,}
int hi_bound;
int lo_bound = atoi(yytext + 1);
char* comma = strchr(yytext, ',');
if (comma - yytext == strlen(yytext) - 2)
// if comma is followed by the closing curly bracket
// (example: {2,}) set high bound value to maximum.
hi_bound = INT16_MAX;
else
hi_bound = atoi(comma + 1);
if (hi_bound > INT16_MAX)
{
yyerror(yyscanner, lex_env, "repeat interval too large");
yyterminate();
}
if (hi_bound < lo_bound || hi_bound < 0 || lo_bound < 0)
{
yyerror(yyscanner, lex_env, "bad repeat interval");
yyterminate();
}
yylval->range = (hi_bound << 16) | lo_bound;
return _RANGE_;
}
YY_BREAK
case 2:
YY_RULE_SETUP
#line 135 "re_lexer.l"
{
// Example: {10}
int value = atoi(yytext + 1);
if (value > INT16_MAX)
{
yyerror(yyscanner, lex_env, "repeat interval too large");
yyterminate();
}
yylval->range = (value << 16) | value;
return _RANGE_;
}
YY_BREAK
case 3:
YY_RULE_SETUP
#line 153 "re_lexer.l"
{
// Start of a negated character class. Example: [^abcd]
BEGIN(char_class);
memset(LEX_ENV->class_vector, 0, 32);
LEX_ENV->negated_class = TRUE;
}
YY_BREAK
case 4:
YY_RULE_SETUP
#line 162 "re_lexer.l"
{
// Start of character negated class containing a ].
// Example: [^]abc] this must be interpreted as a class
// not matching ], a, b, nor c
BEGIN(char_class);
memset(LEX_ENV->class_vector, 0, 32);
LEX_ENV->negated_class = TRUE;
LEX_ENV->class_vector[']' / 8] |= 1 << ']' % 8;
}
YY_BREAK
case 5:
YY_RULE_SETUP
#line 175 "re_lexer.l"
{
// Start of character class containing a ].
// Example: []abc] this must be interpreted as a class
// matching ], a, b, or c.
BEGIN(char_class);
memset(LEX_ENV->class_vector, 0, 32);
LEX_ENV->negated_class = FALSE;
LEX_ENV->class_vector[']' / 8] |= 1 << ']' % 8;
}
YY_BREAK
case 6:
YY_RULE_SETUP
#line 188 "re_lexer.l"
{
// Start of character class. Example: [abcd]
BEGIN(char_class);
memset(LEX_ENV->class_vector, 0, 32);
LEX_ENV->negated_class = FALSE;
}
YY_BREAK
case 7:
/* rule 7 can match eol */
YY_RULE_SETUP
#line 198 "re_lexer.l"
{
// Any non-special character is passed as a CHAR token to the scanner.
yylval->integer = yytext[0];
return _CHAR_;
}
YY_BREAK
case 8:
YY_RULE_SETUP
#line 207 "re_lexer.l"
{
return _WORD_CHAR_;
}
YY_BREAK
case 9:
YY_RULE_SETUP
#line 212 "re_lexer.l"
{
return _NON_WORD_CHAR_;
}
YY_BREAK
case 10:
YY_RULE_SETUP
#line 217 "re_lexer.l"
{
return _SPACE_;
}
YY_BREAK
case 11:
YY_RULE_SETUP
#line 222 "re_lexer.l"
{
return _NON_SPACE_;
}
YY_BREAK
case 12:
YY_RULE_SETUP
#line 227 "re_lexer.l"
{
return _DIGIT_;
}
YY_BREAK
case 13:
YY_RULE_SETUP
#line 232 "re_lexer.l"
{
return _NON_DIGIT_;
}
YY_BREAK
case 14:
YY_RULE_SETUP
#line 237 "re_lexer.l"
{
return _WORD_BOUNDARY_;
}
YY_BREAK
case 15:
YY_RULE_SETUP
#line 241 "re_lexer.l"
{
return _NON_WORD_BOUNDARY_;
}
YY_BREAK
case 16:
YY_RULE_SETUP
#line 246 "re_lexer.l"
{
yyerror(yyscanner, lex_env, "backreferences are not allowed");
yyterminate();
}
YY_BREAK
case 17:
YY_RULE_SETUP
#line 253 "re_lexer.l"
{
uint8_t c;
if (read_escaped_char(yyscanner, &c))
{
yylval->integer = c;
return _CHAR_;
}
else
{
yyerror(yyscanner, lex_env, "unexpected end of buffer");
yyterminate();
}
}
YY_BREAK
case 18:
YY_RULE_SETUP
#line 270 "re_lexer.l"
{
// End of character class.
int i;
yylval->class_vector = (uint8_t*) yr_malloc(32);
memcpy(yylval->class_vector, LEX_ENV->class_vector, 32);
if (LEX_ENV->negated_class)
{
for(i = 0; i < 32; i++)
yylval->class_vector[i] = ~yylval->class_vector[i];
}
BEGIN(INITIAL);
return _CLASS_;
}
YY_BREAK
case 19:
/* rule 19 can match eol */
YY_RULE_SETUP
#line 291 "re_lexer.l"
{
// A range inside a character class.
// [abc0-9]
// ^- matching here
uint16_t c;
uint8_t start = yytext[0];
uint8_t end = yytext[2];
if (start == '\\')
{
start = escaped_char_value(yytext);
if (yytext[1] == 'x')
end = yytext[5];
else
end = yytext[3];
}
if (end == '\\')
{
if (!read_escaped_char(yyscanner, &end))
{
yyerror(yyscanner, lex_env, "unexpected end of buffer");
yyterminate();
}
}
if (end < start)
{
yyerror(yyscanner, lex_env, "bad character range");
yyterminate();
}
for (c = start; c <= end; c++)
{
LEX_ENV->class_vector[c / 8] |= 1 << c % 8;
}
}
YY_BREAK
case 20:
YY_RULE_SETUP
#line 333 "re_lexer.l"
{
int i;
for (i = 0; i < 32; i++)
LEX_ENV->class_vector[i] |= word_chars[i];
}
YY_BREAK
case 21:
YY_RULE_SETUP
#line 342 "re_lexer.l"
{
int i;
for (i = 0; i < 32; i++)
LEX_ENV->class_vector[i] |= ~word_chars[i];
}
YY_BREAK
case 22:
YY_RULE_SETUP
#line 351 "re_lexer.l"
{
LEX_ENV->class_vector[' ' / 8] |= 1 << ' ' % 8;
LEX_ENV->class_vector['\t' / 8] |= 1 << '\t' % 8;
}
YY_BREAK
case 23:
YY_RULE_SETUP
#line 358 "re_lexer.l"
{
int i;
for (i = 0; i < 32; i++)
{
if (i == ' ' / 8)
LEX_ENV->class_vector[i] |= ~(1 << ' ' % 8);
else if (i == '\t' / 8)
LEX_ENV->class_vector[i] |= ~(1 << '\t' % 8);
else
LEX_ENV->class_vector[i] = 0xFF;
}
}
YY_BREAK
case 24:
YY_RULE_SETUP
#line 374 "re_lexer.l"
{
char c;
for (c = '0'; c <= '9'; c++)
LEX_ENV->class_vector[c / 8] |= 1 << c % 8;
}
YY_BREAK
case 25:
YY_RULE_SETUP
#line 383 "re_lexer.l"
{
int i;
for (i = 0; i < 32; i++)
{
// digits 0-7 are in the sixth byte of the vector, let that byte alone
if (i == 6)
continue;
// digits 8 and 9 are the lowest two bits in the seventh byte of the
// vector, let those bits alone.
if (i == 7)
LEX_ENV->class_vector[i] |= 0xFC;
else
LEX_ENV->class_vector[i] = 0xFF;
}
}
YY_BREAK
case 26:
YY_RULE_SETUP
#line 403 "re_lexer.l"
{
uint8_t c;
if (read_escaped_char(yyscanner, &c))
{
LEX_ENV->class_vector[c / 8] |= 1 << c % 8;
}
else
{
yyerror(yyscanner, lex_env, "unexpected end of buffer");
yyterminate();
}
}
YY_BREAK
case 27:
YY_RULE_SETUP
#line 419 "re_lexer.l"
{
if (yytext[0] >= 32 && yytext[0] < 127)
{
// A character class (i.e: [0-9a-f]) is represented by a 256-bits vector,
// here we set to 1 the vector's bit corresponding to the input character.
LEX_ENV->class_vector[yytext[0] / 8] |= 1 << yytext[0] % 8;
}
else
{
yyerror(yyscanner, lex_env, "non-ascii character");
yyterminate();
}
}
YY_BREAK
case YY_STATE_EOF(char_class):
#line 436 "re_lexer.l"
{
// End of regexp reached while scanning a character class.
yyerror(yyscanner, lex_env, "missing terminating ] for character class");
yyterminate();
}
YY_BREAK
case 28:
YY_RULE_SETUP
#line 445 "re_lexer.l"
{
if (yytext[0] >= 32 && yytext[0] < 127)
{
return yytext[0];
}
else
{
yyerror(yyscanner, lex_env, "non-ascii character");
yyterminate();
}
}
YY_BREAK
case YY_STATE_EOF(INITIAL):
#line 459 "re_lexer.l"
{
yyterminate();
}
YY_BREAK
case 29:
YY_RULE_SETUP
#line 464 "re_lexer.l"
ECHO;
YY_BREAK
#line 1358 "re_lexer.c"
case YY_END_OF_BUFFER:
{
/* Amount of text matched not including the EOB char. */
int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1;
/* Undo the effects of YY_DO_BEFORE_ACTION. */
*yy_cp = yyg->yy_hold_char;
YY_RESTORE_YY_MORE_OFFSET
if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
{
/* We're scanning a new file or input source. It's
* possible that this happened because the user
* just pointed yyin at a new source and called
* re_yylex(). If so, then we have to assure
* consistency between YY_CURRENT_BUFFER and our
* globals. Here is the right place to do so, because
* this is the first action (other than possibly a
* back-up) that will match for the new input source.
*/
yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
}
/* Note that here we test for yy_c_buf_p "<=" to the position
* of the first EOB in the buffer, since yy_c_buf_p will
* already have been incremented past the NUL character
* (since all states make transitions on EOB to the
* end-of-buffer state). Contrast this with the test
* in input().
*/
if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
{ /* This was really a NUL. */
yy_state_type yy_next_state;
yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;
yy_current_state = yy_get_previous_state( yyscanner );
/* Okay, we're now positioned to make the NUL
* transition. We couldn't have
* yy_get_previous_state() go ahead and do it
* for us because it doesn't know how to deal
* with the possibility of jamming (and we don't
* want to build jamming into it because then it
* will run more slowly).
*/
yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner);
yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
if ( yy_next_state )
{
/* Consume the NUL. */
yy_cp = ++yyg->yy_c_buf_p;
yy_current_state = yy_next_state;
goto yy_match;
}
else
{
yy_cp = yyg->yy_last_accepting_cpos;
yy_current_state = yyg->yy_last_accepting_state;
goto yy_find_action;
}
}
else switch ( yy_get_next_buffer( yyscanner ) )
{
case EOB_ACT_END_OF_FILE:
{
yyg->yy_did_buffer_switch_on_eof = 0;
if ( re_yywrap(yyscanner ) )
{
/* Note: because we've taken care in
* yy_get_next_buffer() to have set up
* yytext, we can now set up
* yy_c_buf_p so that if some total
* hoser (like flex itself) wants to
* call the scanner after we return the
* YY_NULL, it'll still work - another
* YY_NULL will get returned.
*/
yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ;
yy_act = YY_STATE_EOF(YY_START);
goto do_action;
}
else
{
if ( ! yyg->yy_did_buffer_switch_on_eof )
YY_NEW_FILE;
}
break;
}
case EOB_ACT_CONTINUE_SCAN:
yyg->yy_c_buf_p =
yyg->yytext_ptr + yy_amount_of_matched_text;
yy_current_state = yy_get_previous_state( yyscanner );
yy_cp = yyg->yy_c_buf_p;
yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
goto yy_match;
case EOB_ACT_LAST_MATCH:
yyg->yy_c_buf_p =
&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars];
yy_current_state = yy_get_previous_state( yyscanner );
yy_cp = yyg->yy_c_buf_p;
yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
goto yy_find_action;
}
break;
}
default:
YY_FATAL_ERROR(
"fatal flex scanner internal error--no action found" );
} /* end of action switch */ | 1766 | True | 1 |
CVE-2017-5923 | 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.0/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/VirusTotal/yara/issues/597', 'name': 'https://github.com/VirusTotal/yara/issues/597', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Issue Tracking', 'Patch']}, {'url': 'https://github.com/VirusTotal/yara/commit/ab906da53ff2a68c6fd6d1fa73f2b7c7bf0bc636', 'name': 'https://github.com/VirusTotal/yara/commit/ab906da53ff2a68c6fd6d1fa73f2b7c7bf0bc636', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Vendor Advisory']}, {'url': 'http://www.securityfocus.com/bid/98080', 'name': '98080', 'refsource': 'BID', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:virustotal:yara:3.5.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'libyara/grammar.y in YARA 3.5.0 allows remote attackers to cause a denial of service (heap-based out-of-bounds read and application crash) via a crafted rule that is mishandled in the yara_yyparse function.'}] | 2017-05-02T01:59Z | 2017-04-03T05:59Z | 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 | plusvic | 2017-01-23 18:08:51+01:00 | Fix issue #597 | ab906da53ff2a68c6fd6d1fa73f2b7c7bf0bc636 | False | VirusTotal/yara | The pattern matching swiss knife | 2012-12-06 15:33:08 | 2022-08-26 10:13:14 | https://virustotal.github.io/yara/ | VirusTotal | 5938.0 | 1229.0 | yyparse | yyparse( void * yyscanner , YR_COMPILER * compiler) | ['yyscanner', 'compiler'] | int
yyparse (void *yyscanner, YR_COMPILER* compiler)
{
/* The lookahead symbol. */
int yychar;
/* The semantic value of the lookahead symbol. */
/* Default value used for initialization, for pacifying older GCCs
or non-GCC compilers. */
YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
/* Number of syntax errors so far. */
int yynerrs;
int yystate;
/* Number of tokens to shift before error messages enabled. */
int yyerrstatus;
/* The stacks and their tools:
'yyss': related to states.
'yyvs': related to semantic values.
Refer to the stacks through separate pointers, to allow yyoverflow
to reallocate them elsewhere. */
/* The state stack. */
yytype_int16 yyssa[YYINITDEPTH];
yytype_int16 *yyss;
yytype_int16 *yyssp;
/* The semantic value stack. */
YYSTYPE yyvsa[YYINITDEPTH];
YYSTYPE *yyvs;
YYSTYPE *yyvsp;
YYSIZE_T yystacksize;
int yyn;
int yyresult;
/* Lookahead token as an internal (translated) token number. */
int yytoken = 0;
/* The variables used to return semantic value and location from the
action routines. */
YYSTYPE yyval;
#if YYERROR_VERBOSE
/* Buffer for error messages, and its allocated size. */
char yymsgbuf[128];
char *yymsg = yymsgbuf;
YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
#endif
#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
/* The number of symbols on the RHS of the reduced rule.
Keep to zero when no symbol should be popped. */
int yylen = 0;
yyssp = yyss = yyssa;
yyvsp = yyvs = yyvsa;
yystacksize = YYINITDEPTH;
YYDPRINTF ((stderr, "Starting parse\n"));
yystate = 0;
yyerrstatus = 0;
yynerrs = 0;
yychar = YYEMPTY; /* Cause a token to be read. */
goto yysetstate;
/*------------------------------------------------------------.
| yynewstate -- Push a new state, which is found in yystate. |
`------------------------------------------------------------*/
yynewstate:
/* In all cases, when you get here, the value and location stacks
have just been pushed. So pushing a state here evens the stacks. */
yyssp++;
yysetstate:
*yyssp = yystate;
if (yyss + yystacksize - 1 <= yyssp)
{
/* Get the current used size of the three stacks, in elements. */
YYSIZE_T yysize = yyssp - yyss + 1;
#ifdef yyoverflow
{
/* Give user a chance to reallocate the stack. Use copies of
these so that the &'s don't force the real ones into
memory. */
YYSTYPE *yyvs1 = yyvs;
yytype_int16 *yyss1 = yyss;
/* Each stack pointer address is followed by the size of the
data in use in that stack, in bytes. This used to be a
conditional around just the two extra args, but that might
be undefined if yyoverflow is a macro. */
yyoverflow (YY_("memory exhausted"),
&yyss1, yysize * sizeof (*yyssp),
&yyvs1, yysize * sizeof (*yyvsp),
&yystacksize);
yyss = yyss1;
yyvs = yyvs1;
}
#else /* no yyoverflow */
# ifndef YYSTACK_RELOCATE
goto yyexhaustedlab;
# else
/* Extend the stack our own way. */
if (YYMAXDEPTH <= yystacksize)
goto yyexhaustedlab;
yystacksize *= 2;
if (YYMAXDEPTH < yystacksize)
yystacksize = YYMAXDEPTH;
{
yytype_int16 *yyss1 = yyss;
union yyalloc *yyptr =
(union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
if (! yyptr)
goto yyexhaustedlab;
YYSTACK_RELOCATE (yyss_alloc, yyss);
YYSTACK_RELOCATE (yyvs_alloc, yyvs);
# undef YYSTACK_RELOCATE
if (yyss1 != yyssa)
YYSTACK_FREE (yyss1);
}
# endif
#endif /* no yyoverflow */
yyssp = yyss + yysize - 1;
yyvsp = yyvs + yysize - 1;
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
(unsigned long int) yystacksize));
if (yyss + yystacksize - 1 <= yyssp)
YYABORT;
}
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
if (yystate == YYFINAL)
YYACCEPT;
goto yybackup;
/*-----------.
| yybackup. |
`-----------*/
yybackup:
/* Do appropriate processing given the current state. Read a
lookahead token if we need one and don't already have one. */
/* First try to decide what to do without reference to lookahead token. */
yyn = yypact[yystate];
if (yypact_value_is_default (yyn))
goto yydefault;
/* Not known => get a lookahead token if don't already have one. */
/* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
if (yychar == YYEMPTY)
{
YYDPRINTF ((stderr, "Reading a token: "));
yychar = yylex (&yylval, yyscanner, compiler);
}
if (yychar <= YYEOF)
{
yychar = yytoken = YYEOF;
YYDPRINTF ((stderr, "Now at end of input.\n"));
}
else
{
yytoken = YYTRANSLATE (yychar);
YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
}
/* If the proper action on seeing token YYTOKEN is to reduce or to
detect an error, take that action. */
yyn += yytoken;
if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
goto yydefault;
yyn = yytable[yyn];
if (yyn <= 0)
{
if (yytable_value_is_error (yyn))
goto yyerrlab;
yyn = -yyn;
goto yyreduce;
}
/* Count tokens shifted since error; after three, turn off error
status. */
if (yyerrstatus)
yyerrstatus--;
/* Shift the lookahead token. */
YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
/* Discard the shifted token. */
yychar = YYEMPTY;
yystate = yyn;
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
*++yyvsp = yylval;
YY_IGNORE_MAYBE_UNINITIALIZED_END
goto yynewstate;
/*-----------------------------------------------------------.
| yydefault -- do the default action for the current state. |
`-----------------------------------------------------------*/
yydefault:
yyn = yydefact[yystate];
if (yyn == 0)
goto yyerrlab;
goto yyreduce;
/*-----------------------------.
| yyreduce -- Do a reduction. |
`-----------------------------*/
yyreduce:
/* yyn is the number of a rule to reduce with. */
yylen = yyr2[yyn];
/* If YYLEN is nonzero, implement the default value of the action:
'$$ = $1'.
Otherwise, the following line sets YYVAL to garbage.
This behavior is undocumented and Bison
users should not rely upon it. Assigning to YYVAL
unconditionally makes the parser a bit smaller, and it avoids a
GCC warning that YYVAL may be used uninitialized. */
yyval = yyvsp[1-yylen];
YY_REDUCE_PRINT (yyn);
switch (yyn)
{
case 8:
#line 230 "grammar.y" /* yacc.c:1646 */
{
int result = yr_parser_reduce_import(yyscanner, (yyvsp[0].sized_string));
yr_free((yyvsp[0].sized_string));
ERROR_IF(result != ERROR_SUCCESS);
}
#line 1661 "grammar.c" /* yacc.c:1646 */
break;
case 9:
#line 242 "grammar.y" /* yacc.c:1646 */
{
YR_RULE* rule = yr_parser_reduce_rule_declaration_phase_1(
yyscanner, (int32_t) (yyvsp[-2].integer), (yyvsp[0].c_string));
ERROR_IF(rule == NULL);
(yyval.rule) = rule;
}
#line 1674 "grammar.c" /* yacc.c:1646 */
break;
case 10:
#line 251 "grammar.y" /* yacc.c:1646 */
{
YR_RULE* rule = (yyvsp[-4].rule); // rule created in phase 1
rule->tags = (yyvsp[-3].c_string);
rule->metas = (yyvsp[-1].meta);
rule->strings = (yyvsp[0].string);
}
#line 1686 "grammar.c" /* yacc.c:1646 */
break;
case 11:
#line 259 "grammar.y" /* yacc.c:1646 */
{
YR_RULE* rule = (yyvsp[-7].rule); // rule created in phase 1
compiler->last_result = yr_parser_reduce_rule_declaration_phase_2(
yyscanner, rule);
yr_free((yyvsp[-8].c_string));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
}
#line 1701 "grammar.c" /* yacc.c:1646 */
break;
case 12:
#line 274 "grammar.y" /* yacc.c:1646 */
{
(yyval.meta) = NULL;
}
#line 1709 "grammar.c" /* yacc.c:1646 */
break;
case 13:
#line 278 "grammar.y" /* yacc.c:1646 */
{
// Each rule have a list of meta-data info, consisting in a
// sequence of YR_META structures. The last YR_META structure does
// not represent a real meta-data, it's just a end-of-list marker
// identified by a specific type (META_TYPE_NULL). Here we
// write the end-of-list marker.
YR_META null_meta;
memset(&null_meta, 0xFF, sizeof(YR_META));
null_meta.type = META_TYPE_NULL;
compiler->last_result = yr_arena_write_data(
compiler->metas_arena,
&null_meta,
sizeof(YR_META),
NULL);
(yyval.meta) = (yyvsp[0].meta);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
}
#line 1736 "grammar.c" /* yacc.c:1646 */
break;
case 14:
#line 305 "grammar.y" /* yacc.c:1646 */
{
(yyval.string) = NULL;
}
#line 1744 "grammar.c" /* yacc.c:1646 */
break;
case 15:
#line 309 "grammar.y" /* yacc.c:1646 */
{
// Each rule have a list of strings, consisting in a sequence
// of YR_STRING structures. The last YR_STRING structure does not
// represent a real string, it's just a end-of-list marker
// identified by a specific flag (STRING_FLAGS_NULL). Here we
// write the end-of-list marker.
YR_STRING null_string;
memset(&null_string, 0xFF, sizeof(YR_STRING));
null_string.g_flags = STRING_GFLAGS_NULL;
compiler->last_result = yr_arena_write_data(
compiler->strings_arena,
&null_string,
sizeof(YR_STRING),
NULL);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.string) = (yyvsp[0].string);
}
#line 1771 "grammar.c" /* yacc.c:1646 */
break;
case 17:
#line 340 "grammar.y" /* yacc.c:1646 */
{ (yyval.integer) = 0; }
#line 1777 "grammar.c" /* yacc.c:1646 */
break;
case 18:
#line 341 "grammar.y" /* yacc.c:1646 */
{ (yyval.integer) = (yyvsp[-1].integer) | (yyvsp[0].integer); }
#line 1783 "grammar.c" /* yacc.c:1646 */
break;
case 19:
#line 346 "grammar.y" /* yacc.c:1646 */
{ (yyval.integer) = RULE_GFLAGS_PRIVATE; }
#line 1789 "grammar.c" /* yacc.c:1646 */
break;
case 20:
#line 347 "grammar.y" /* yacc.c:1646 */
{ (yyval.integer) = RULE_GFLAGS_GLOBAL; }
#line 1795 "grammar.c" /* yacc.c:1646 */
break;
case 21:
#line 353 "grammar.y" /* yacc.c:1646 */
{
(yyval.c_string) = NULL;
}
#line 1803 "grammar.c" /* yacc.c:1646 */
break;
case 22:
#line 357 "grammar.y" /* yacc.c:1646 */
{
// Tags list is represented in the arena as a sequence
// of null-terminated strings, the sequence ends with an
// additional null character. Here we write the ending null
//character. Example: tag1\0tag2\0tag3\0\0
compiler->last_result = yr_arena_write_string(
yyget_extra(yyscanner)->sz_arena, "", NULL);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.c_string) = (yyvsp[0].c_string);
}
#line 1821 "grammar.c" /* yacc.c:1646 */
break;
case 23:
#line 375 "grammar.y" /* yacc.c:1646 */
{
char* identifier;
compiler->last_result = yr_arena_write_string(
yyget_extra(yyscanner)->sz_arena, (yyvsp[0].c_string), &identifier);
yr_free((yyvsp[0].c_string));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.c_string) = identifier;
}
#line 1838 "grammar.c" /* yacc.c:1646 */
break;
case 24:
#line 388 "grammar.y" /* yacc.c:1646 */
{
char* tag_name = (yyvsp[-1].c_string);
size_t tag_length = tag_name != NULL ? strlen(tag_name) : 0;
while (tag_length > 0)
{
if (strcmp(tag_name, (yyvsp[0].c_string)) == 0)
{
yr_compiler_set_error_extra_info(compiler, tag_name);
compiler->last_result = ERROR_DUPLICATED_TAG_IDENTIFIER;
break;
}
tag_name = (char*) yr_arena_next_address(
yyget_extra(yyscanner)->sz_arena,
tag_name,
tag_length + 1);
tag_length = tag_name != NULL ? strlen(tag_name) : 0;
}
if (compiler->last_result == ERROR_SUCCESS)
compiler->last_result = yr_arena_write_string(
yyget_extra(yyscanner)->sz_arena, (yyvsp[0].c_string), NULL);
yr_free((yyvsp[0].c_string));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.c_string) = (yyvsp[-1].c_string);
}
#line 1874 "grammar.c" /* yacc.c:1646 */
break;
case 25:
#line 424 "grammar.y" /* yacc.c:1646 */
{ (yyval.meta) = (yyvsp[0].meta); }
#line 1880 "grammar.c" /* yacc.c:1646 */
break;
case 26:
#line 425 "grammar.y" /* yacc.c:1646 */
{ (yyval.meta) = (yyvsp[-1].meta); }
#line 1886 "grammar.c" /* yacc.c:1646 */
break;
case 27:
#line 431 "grammar.y" /* yacc.c:1646 */
{
SIZED_STRING* sized_string = (yyvsp[0].sized_string);
(yyval.meta) = yr_parser_reduce_meta_declaration(
yyscanner,
META_TYPE_STRING,
(yyvsp[-2].c_string),
sized_string->c_string,
0);
yr_free((yyvsp[-2].c_string));
yr_free((yyvsp[0].sized_string));
ERROR_IF((yyval.meta) == NULL);
}
#line 1906 "grammar.c" /* yacc.c:1646 */
break;
case 28:
#line 447 "grammar.y" /* yacc.c:1646 */
{
(yyval.meta) = yr_parser_reduce_meta_declaration(
yyscanner,
META_TYPE_INTEGER,
(yyvsp[-2].c_string),
NULL,
(yyvsp[0].integer));
yr_free((yyvsp[-2].c_string));
ERROR_IF((yyval.meta) == NULL);
}
#line 1923 "grammar.c" /* yacc.c:1646 */
break;
case 29:
#line 460 "grammar.y" /* yacc.c:1646 */
{
(yyval.meta) = yr_parser_reduce_meta_declaration(
yyscanner,
META_TYPE_INTEGER,
(yyvsp[-3].c_string),
NULL,
-(yyvsp[0].integer));
yr_free((yyvsp[-3].c_string));
ERROR_IF((yyval.meta) == NULL);
}
#line 1940 "grammar.c" /* yacc.c:1646 */
break;
case 30:
#line 473 "grammar.y" /* yacc.c:1646 */
{
(yyval.meta) = yr_parser_reduce_meta_declaration(
yyscanner,
META_TYPE_BOOLEAN,
(yyvsp[-2].c_string),
NULL,
TRUE);
yr_free((yyvsp[-2].c_string));
ERROR_IF((yyval.meta) == NULL);
}
#line 1957 "grammar.c" /* yacc.c:1646 */
break;
case 31:
#line 486 "grammar.y" /* yacc.c:1646 */
{
(yyval.meta) = yr_parser_reduce_meta_declaration(
yyscanner,
META_TYPE_BOOLEAN,
(yyvsp[-2].c_string),
NULL,
FALSE);
yr_free((yyvsp[-2].c_string));
ERROR_IF((yyval.meta) == NULL);
}
#line 1974 "grammar.c" /* yacc.c:1646 */
break;
case 32:
#line 502 "grammar.y" /* yacc.c:1646 */
{ (yyval.string) = (yyvsp[0].string); }
#line 1980 "grammar.c" /* yacc.c:1646 */
break;
case 33:
#line 503 "grammar.y" /* yacc.c:1646 */
{ (yyval.string) = (yyvsp[-1].string); }
#line 1986 "grammar.c" /* yacc.c:1646 */
break;
case 34:
#line 509 "grammar.y" /* yacc.c:1646 */
{
compiler->error_line = yyget_lineno(yyscanner);
}
#line 1994 "grammar.c" /* yacc.c:1646 */
break;
case 35:
#line 513 "grammar.y" /* yacc.c:1646 */
{
(yyval.string) = yr_parser_reduce_string_declaration(
yyscanner, (int32_t) (yyvsp[0].integer), (yyvsp[-4].c_string), (yyvsp[-1].sized_string));
yr_free((yyvsp[-4].c_string));
yr_free((yyvsp[-1].sized_string));
ERROR_IF((yyval.string) == NULL);
compiler->error_line = 0;
}
#line 2009 "grammar.c" /* yacc.c:1646 */
break;
case 36:
#line 524 "grammar.y" /* yacc.c:1646 */
{
compiler->error_line = yyget_lineno(yyscanner);
}
#line 2017 "grammar.c" /* yacc.c:1646 */
break;
case 37:
#line 528 "grammar.y" /* yacc.c:1646 */
{
(yyval.string) = yr_parser_reduce_string_declaration(
yyscanner, (int32_t) (yyvsp[0].integer) | STRING_GFLAGS_REGEXP, (yyvsp[-4].c_string), (yyvsp[-1].sized_string));
yr_free((yyvsp[-4].c_string));
yr_free((yyvsp[-1].sized_string));
ERROR_IF((yyval.string) == NULL);
compiler->error_line = 0;
}
#line 2033 "grammar.c" /* yacc.c:1646 */
break;
case 38:
#line 540 "grammar.y" /* yacc.c:1646 */
{
(yyval.string) = yr_parser_reduce_string_declaration(
yyscanner, STRING_GFLAGS_HEXADECIMAL, (yyvsp[-2].c_string), (yyvsp[0].sized_string));
yr_free((yyvsp[-2].c_string));
yr_free((yyvsp[0].sized_string));
ERROR_IF((yyval.string) == NULL);
}
#line 2047 "grammar.c" /* yacc.c:1646 */
break;
case 39:
#line 553 "grammar.y" /* yacc.c:1646 */
{ (yyval.integer) = 0; }
#line 2053 "grammar.c" /* yacc.c:1646 */
break;
case 40:
#line 554 "grammar.y" /* yacc.c:1646 */
{ (yyval.integer) = (yyvsp[-1].integer) | (yyvsp[0].integer); }
#line 2059 "grammar.c" /* yacc.c:1646 */
break;
case 41:
#line 559 "grammar.y" /* yacc.c:1646 */
{ (yyval.integer) = STRING_GFLAGS_WIDE; }
#line 2065 "grammar.c" /* yacc.c:1646 */
break;
case 42:
#line 560 "grammar.y" /* yacc.c:1646 */
{ (yyval.integer) = STRING_GFLAGS_ASCII; }
#line 2071 "grammar.c" /* yacc.c:1646 */
break;
case 43:
#line 561 "grammar.y" /* yacc.c:1646 */
{ (yyval.integer) = STRING_GFLAGS_NO_CASE; }
#line 2077 "grammar.c" /* yacc.c:1646 */
break;
case 44:
#line 562 "grammar.y" /* yacc.c:1646 */
{ (yyval.integer) = STRING_GFLAGS_FULL_WORD; }
#line 2083 "grammar.c" /* yacc.c:1646 */
break;
case 45:
#line 568 "grammar.y" /* yacc.c:1646 */
{
int var_index = yr_parser_lookup_loop_variable(yyscanner, (yyvsp[0].c_string));
if (var_index >= 0)
{
compiler->last_result = yr_parser_emit_with_arg(
yyscanner,
OP_PUSH_M,
LOOP_LOCAL_VARS * var_index,
NULL,
NULL);
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
(yyval.expression).value.integer = UNDEFINED;
(yyval.expression).identifier = compiler->loop_identifier[var_index];
}
else
{
// Search for identifier within the global namespace, where the
// externals variables reside.
YR_OBJECT* object = (YR_OBJECT*) yr_hash_table_lookup(
compiler->objects_table, (yyvsp[0].c_string), NULL);
if (object == NULL)
{
// If not found, search within the current namespace.
char* ns = compiler->current_namespace->name;
object = (YR_OBJECT*) yr_hash_table_lookup(
compiler->objects_table, (yyvsp[0].c_string), ns);
}
if (object != NULL)
{
char* id;
compiler->last_result = yr_arena_write_string(
compiler->sz_arena, (yyvsp[0].c_string), &id);
if (compiler->last_result == ERROR_SUCCESS)
compiler->last_result = yr_parser_emit_with_arg_reloc(
yyscanner,
OP_OBJ_LOAD,
id,
NULL,
NULL);
(yyval.expression).type = EXPRESSION_TYPE_OBJECT;
(yyval.expression).value.object = object;
(yyval.expression).identifier = object->identifier;
}
else
{
YR_RULE* rule = (YR_RULE*) yr_hash_table_lookup(
compiler->rules_table,
(yyvsp[0].c_string),
compiler->current_namespace->name);
if (rule != NULL)
{
compiler->last_result = yr_parser_emit_with_arg_reloc(
yyscanner,
OP_PUSH_RULE,
rule,
NULL,
NULL);
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
(yyval.expression).value.integer = UNDEFINED;
(yyval.expression).identifier = rule->identifier;
}
else
{
yr_compiler_set_error_extra_info(compiler, (yyvsp[0].c_string));
compiler->last_result = ERROR_UNDEFINED_IDENTIFIER;
}
}
}
yr_free((yyvsp[0].c_string));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
}
#line 2172 "grammar.c" /* yacc.c:1646 */
break;
case 46:
#line 653 "grammar.y" /* yacc.c:1646 */
{
YR_OBJECT* field = NULL;
if ((yyvsp[-2].expression).type == EXPRESSION_TYPE_OBJECT &&
(yyvsp[-2].expression).value.object->type == OBJECT_TYPE_STRUCTURE)
{
field = yr_object_lookup_field((yyvsp[-2].expression).value.object, (yyvsp[0].c_string));
if (field != NULL)
{
char* ident;
compiler->last_result = yr_arena_write_string(
compiler->sz_arena, (yyvsp[0].c_string), &ident);
if (compiler->last_result == ERROR_SUCCESS)
compiler->last_result = yr_parser_emit_with_arg_reloc(
yyscanner,
OP_OBJ_FIELD,
ident,
NULL,
NULL);
(yyval.expression).type = EXPRESSION_TYPE_OBJECT;
(yyval.expression).value.object = field;
(yyval.expression).identifier = field->identifier;
}
else
{
yr_compiler_set_error_extra_info(compiler, (yyvsp[0].c_string));
compiler->last_result = ERROR_INVALID_FIELD_NAME;
}
}
else
{
yr_compiler_set_error_extra_info(
compiler, (yyvsp[-2].expression).identifier);
compiler->last_result = ERROR_NOT_A_STRUCTURE;
}
yr_free((yyvsp[0].c_string));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
}
#line 2222 "grammar.c" /* yacc.c:1646 */
break;
case 47:
#line 699 "grammar.y" /* yacc.c:1646 */
{
YR_OBJECT_ARRAY* array;
YR_OBJECT_DICTIONARY* dict;
if ((yyvsp[-3].expression).type == EXPRESSION_TYPE_OBJECT &&
(yyvsp[-3].expression).value.object->type == OBJECT_TYPE_ARRAY)
{
if ((yyvsp[-1].expression).type != EXPRESSION_TYPE_INTEGER)
{
yr_compiler_set_error_extra_info(
compiler, "array indexes must be of integer type");
compiler->last_result = ERROR_WRONG_TYPE;
}
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
compiler->last_result = yr_parser_emit(
yyscanner, OP_INDEX_ARRAY, NULL);
array = (YR_OBJECT_ARRAY*) (yyvsp[-3].expression).value.object;
(yyval.expression).type = EXPRESSION_TYPE_OBJECT;
(yyval.expression).value.object = array->prototype_item;
(yyval.expression).identifier = array->identifier;
}
else if ((yyvsp[-3].expression).type == EXPRESSION_TYPE_OBJECT &&
(yyvsp[-3].expression).value.object->type == OBJECT_TYPE_DICTIONARY)
{
if ((yyvsp[-1].expression).type != EXPRESSION_TYPE_STRING)
{
yr_compiler_set_error_extra_info(
compiler, "dictionary keys must be of string type");
compiler->last_result = ERROR_WRONG_TYPE;
}
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
compiler->last_result = yr_parser_emit(
yyscanner, OP_LOOKUP_DICT, NULL);
dict = (YR_OBJECT_DICTIONARY*) (yyvsp[-3].expression).value.object;
(yyval.expression).type = EXPRESSION_TYPE_OBJECT;
(yyval.expression).value.object = dict->prototype_item;
(yyval.expression).identifier = dict->identifier;
}
else
{
yr_compiler_set_error_extra_info(
compiler, (yyvsp[-3].expression).identifier);
compiler->last_result = ERROR_NOT_INDEXABLE;
}
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
}
#line 2283 "grammar.c" /* yacc.c:1646 */
break;
case 48:
#line 757 "grammar.y" /* yacc.c:1646 */
{
YR_OBJECT_FUNCTION* function;
char* args_fmt;
if ((yyvsp[-3].expression).type == EXPRESSION_TYPE_OBJECT &&
(yyvsp[-3].expression).value.object->type == OBJECT_TYPE_FUNCTION)
{
compiler->last_result = yr_parser_check_types(
compiler, (YR_OBJECT_FUNCTION*) (yyvsp[-3].expression).value.object, (yyvsp[-1].c_string));
if (compiler->last_result == ERROR_SUCCESS)
compiler->last_result = yr_arena_write_string(
compiler->sz_arena, (yyvsp[-1].c_string), &args_fmt);
if (compiler->last_result == ERROR_SUCCESS)
compiler->last_result = yr_parser_emit_with_arg_reloc(
yyscanner,
OP_CALL,
args_fmt,
NULL,
NULL);
function = (YR_OBJECT_FUNCTION*) (yyvsp[-3].expression).value.object;
(yyval.expression).type = EXPRESSION_TYPE_OBJECT;
(yyval.expression).value.object = function->return_obj;
(yyval.expression).identifier = function->identifier;
}
else
{
yr_compiler_set_error_extra_info(
compiler, (yyvsp[-3].expression).identifier);
compiler->last_result = ERROR_NOT_A_FUNCTION;
}
yr_free((yyvsp[-1].c_string));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
}
#line 2328 "grammar.c" /* yacc.c:1646 */
break;
case 49:
#line 801 "grammar.y" /* yacc.c:1646 */
{ (yyval.c_string) = yr_strdup(""); }
#line 2334 "grammar.c" /* yacc.c:1646 */
break;
case 50:
#line 802 "grammar.y" /* yacc.c:1646 */
{ (yyval.c_string) = (yyvsp[0].c_string); }
#line 2340 "grammar.c" /* yacc.c:1646 */
break;
case 51:
#line 807 "grammar.y" /* yacc.c:1646 */
{
(yyval.c_string) = (char*) yr_malloc(MAX_FUNCTION_ARGS + 1);
switch((yyvsp[0].expression).type)
{
case EXPRESSION_TYPE_INTEGER:
strlcpy((yyval.c_string), "i", MAX_FUNCTION_ARGS);
break;
case EXPRESSION_TYPE_FLOAT:
strlcpy((yyval.c_string), "f", MAX_FUNCTION_ARGS);
break;
case EXPRESSION_TYPE_BOOLEAN:
strlcpy((yyval.c_string), "b", MAX_FUNCTION_ARGS);
break;
case EXPRESSION_TYPE_STRING:
strlcpy((yyval.c_string), "s", MAX_FUNCTION_ARGS);
break;
case EXPRESSION_TYPE_REGEXP:
strlcpy((yyval.c_string), "r", MAX_FUNCTION_ARGS);
break;
}
ERROR_IF((yyval.c_string) == NULL);
}
#line 2369 "grammar.c" /* yacc.c:1646 */
break;
case 52:
#line 832 "grammar.y" /* yacc.c:1646 */
{
if (strlen((yyvsp[-2].c_string)) == MAX_FUNCTION_ARGS)
{
compiler->last_result = ERROR_TOO_MANY_ARGUMENTS;
}
else
{
switch((yyvsp[0].expression).type)
{
case EXPRESSION_TYPE_INTEGER:
strlcat((yyvsp[-2].c_string), "i", MAX_FUNCTION_ARGS);
break;
case EXPRESSION_TYPE_FLOAT:
strlcat((yyvsp[-2].c_string), "f", MAX_FUNCTION_ARGS);
break;
case EXPRESSION_TYPE_BOOLEAN:
strlcat((yyvsp[-2].c_string), "b", MAX_FUNCTION_ARGS);
break;
case EXPRESSION_TYPE_STRING:
strlcat((yyvsp[-2].c_string), "s", MAX_FUNCTION_ARGS);
break;
case EXPRESSION_TYPE_REGEXP:
strlcat((yyvsp[-2].c_string), "r", MAX_FUNCTION_ARGS);
break;
}
}
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.c_string) = (yyvsp[-2].c_string);
}
#line 2405 "grammar.c" /* yacc.c:1646 */
break;
case 53:
#line 868 "grammar.y" /* yacc.c:1646 */
{
SIZED_STRING* sized_string = (yyvsp[0].sized_string);
RE* re;
RE_ERROR error;
int re_flags = 0;
if (sized_string->flags & SIZED_STRING_FLAGS_NO_CASE)
re_flags |= RE_FLAGS_NO_CASE;
if (sized_string->flags & SIZED_STRING_FLAGS_DOT_ALL)
re_flags |= RE_FLAGS_DOT_ALL;
compiler->last_result = yr_re_compile(
sized_string->c_string,
re_flags,
compiler->re_code_arena,
&re,
&error);
yr_free((yyvsp[0].sized_string));
if (compiler->last_result == ERROR_INVALID_REGULAR_EXPRESSION)
yr_compiler_set_error_extra_info(compiler, error.message);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
if (compiler->last_result == ERROR_SUCCESS)
compiler->last_result = yr_parser_emit_with_arg_reloc(
yyscanner,
OP_PUSH,
re->root_node->forward_code,
NULL,
NULL);
yr_re_destroy(re);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_REGEXP;
}
#line 2451 "grammar.c" /* yacc.c:1646 */
break;
case 54:
#line 914 "grammar.y" /* yacc.c:1646 */
{
if ((yyvsp[0].expression).type == EXPRESSION_TYPE_STRING)
{
if ((yyvsp[0].expression).value.sized_string != NULL)
{
yywarning(yyscanner,
"Using literal string \"%s\" in a boolean operation.",
(yyvsp[0].expression).value.sized_string->c_string);
}
compiler->last_result = yr_parser_emit(
yyscanner, OP_STR_TO_BOOL, NULL);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
}
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
}
#line 2474 "grammar.c" /* yacc.c:1646 */
break;
case 55:
#line 936 "grammar.y" /* yacc.c:1646 */
{
compiler->last_result = yr_parser_emit_with_arg(
yyscanner, OP_PUSH, 1, NULL, NULL);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
}
#line 2487 "grammar.c" /* yacc.c:1646 */
break;
case 56:
#line 945 "grammar.y" /* yacc.c:1646 */
{
compiler->last_result = yr_parser_emit_with_arg(
yyscanner, OP_PUSH, 0, NULL, NULL);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
}
#line 2500 "grammar.c" /* yacc.c:1646 */
break;
case 57:
#line 954 "grammar.y" /* yacc.c:1646 */
{
CHECK_TYPE((yyvsp[-2].expression), EXPRESSION_TYPE_STRING, "matches");
CHECK_TYPE((yyvsp[0].expression), EXPRESSION_TYPE_REGEXP, "matches");
if (compiler->last_result == ERROR_SUCCESS)
compiler->last_result = yr_parser_emit(
yyscanner,
OP_MATCHES,
NULL);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
}
#line 2519 "grammar.c" /* yacc.c:1646 */
break;
case 58:
#line 969 "grammar.y" /* yacc.c:1646 */
{
CHECK_TYPE((yyvsp[-2].expression), EXPRESSION_TYPE_STRING, "contains");
CHECK_TYPE((yyvsp[0].expression), EXPRESSION_TYPE_STRING, "contains");
compiler->last_result = yr_parser_emit(
yyscanner, OP_CONTAINS, NULL);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
}
#line 2535 "grammar.c" /* yacc.c:1646 */
break;
case 59:
#line 981 "grammar.y" /* yacc.c:1646 */
{
int result = yr_parser_reduce_string_identifier(
yyscanner,
(yyvsp[0].c_string),
OP_FOUND,
UNDEFINED);
yr_free((yyvsp[0].c_string));
ERROR_IF(result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
}
#line 2553 "grammar.c" /* yacc.c:1646 */
break;
case 60:
#line 995 "grammar.y" /* yacc.c:1646 */
{
CHECK_TYPE((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "at");
compiler->last_result = yr_parser_reduce_string_identifier(
yyscanner, (yyvsp[-2].c_string), OP_FOUND_AT, (yyvsp[0].expression).value.integer);
yr_free((yyvsp[-2].c_string));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
}
#line 2570 "grammar.c" /* yacc.c:1646 */
break;
case 61:
#line 1008 "grammar.y" /* yacc.c:1646 */
{
compiler->last_result = yr_parser_reduce_string_identifier(
yyscanner, (yyvsp[-2].c_string), OP_FOUND_IN, UNDEFINED);
yr_free((yyvsp[-2].c_string));
ERROR_IF(compiler->last_result!= ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
}
#line 2585 "grammar.c" /* yacc.c:1646 */
break;
case 62:
#line 1019 "grammar.y" /* yacc.c:1646 */
{
if (compiler->loop_depth > 0)
{
compiler->loop_depth--;
compiler->loop_identifier[compiler->loop_depth] = NULL;
}
}
#line 2597 "grammar.c" /* yacc.c:1646 */
break;
case 63:
#line 1027 "grammar.y" /* yacc.c:1646 */
{
int var_index;
if (compiler->loop_depth == MAX_LOOP_NESTING)
compiler->last_result = \
ERROR_LOOP_NESTING_LIMIT_EXCEEDED;
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
var_index = yr_parser_lookup_loop_variable(
yyscanner, (yyvsp[-1].c_string));
if (var_index >= 0)
{
yr_compiler_set_error_extra_info(
compiler, (yyvsp[-1].c_string));
compiler->last_result = \
ERROR_DUPLICATED_LOOP_IDENTIFIER;
}
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
// Push end-of-list marker
compiler->last_result = yr_parser_emit_with_arg(
yyscanner, OP_PUSH, UNDEFINED, NULL, NULL);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
}
#line 2631 "grammar.c" /* yacc.c:1646 */
break;
case 64:
#line 1057 "grammar.y" /* yacc.c:1646 */
{
int mem_offset = LOOP_LOCAL_VARS * compiler->loop_depth;
uint8_t* addr;
// Clear counter for number of expressions evaluating
// to TRUE.
yr_parser_emit_with_arg(
yyscanner, OP_CLEAR_M, mem_offset + 1, NULL, NULL);
// Clear iterations counter
yr_parser_emit_with_arg(
yyscanner, OP_CLEAR_M, mem_offset + 2, NULL, NULL);
if ((yyvsp[-1].integer) == INTEGER_SET_ENUMERATION)
{
// Pop the first integer
yr_parser_emit_with_arg(
yyscanner, OP_POP_M, mem_offset, &addr, NULL);
}
else // INTEGER_SET_RANGE
{
// Pop higher bound of set range
yr_parser_emit_with_arg(
yyscanner, OP_POP_M, mem_offset + 3, &addr, NULL);
// Pop lower bound of set range
yr_parser_emit_with_arg(
yyscanner, OP_POP_M, mem_offset, NULL, NULL);
}
compiler->loop_address[compiler->loop_depth] = addr;
compiler->loop_identifier[compiler->loop_depth] = (yyvsp[-4].c_string);
compiler->loop_depth++;
}
#line 2670 "grammar.c" /* yacc.c:1646 */
break;
case 65:
#line 1092 "grammar.y" /* yacc.c:1646 */
{
int mem_offset;
compiler->loop_depth--;
mem_offset = LOOP_LOCAL_VARS * compiler->loop_depth;
// The value at the top of the stack is the result of
// evaluating the boolean expression, so it could be
// 0, 1 or UNDEFINED. Add this value to a counter
// keeping the number of expressions evaluating to true.
// If the value is UNDEFINED instruction OP_ADD_M
// does nothing.
yr_parser_emit_with_arg(
yyscanner, OP_ADD_M, mem_offset + 1, NULL, NULL);
// Increment iterations counter
yr_parser_emit_with_arg(
yyscanner, OP_INCR_M, mem_offset + 2, NULL, NULL);
if ((yyvsp[-5].integer) == INTEGER_SET_ENUMERATION)
{
yr_parser_emit_with_arg_reloc(
yyscanner,
OP_JNUNDEF,
compiler->loop_address[compiler->loop_depth],
NULL,
NULL);
}
else // INTEGER_SET_RANGE
{
// Increment lower bound of integer set
yr_parser_emit_with_arg(
yyscanner, OP_INCR_M, mem_offset, NULL, NULL);
// Push lower bound of integer set
yr_parser_emit_with_arg(
yyscanner, OP_PUSH_M, mem_offset, NULL, NULL);
// Push higher bound of integer set
yr_parser_emit_with_arg(
yyscanner, OP_PUSH_M, mem_offset + 3, NULL, NULL);
// Compare higher bound with lower bound, do loop again
// if lower bound is still lower or equal than higher bound
yr_parser_emit_with_arg_reloc(
yyscanner,
OP_JLE,
compiler->loop_address[compiler->loop_depth],
NULL,
NULL);
yr_parser_emit(yyscanner, OP_POP, NULL);
yr_parser_emit(yyscanner, OP_POP, NULL);
}
// Pop end-of-list marker.
yr_parser_emit(yyscanner, OP_POP, NULL);
// At this point the loop quantifier (any, all, 1, 2,..)
// is at the top of the stack. Check if the quantifier
// is undefined (meaning "all") and replace it with the
// iterations counter in that case.
yr_parser_emit_with_arg(
yyscanner, OP_SWAPUNDEF, mem_offset + 2, NULL, NULL);
// Compare the loop quantifier with the number of
// expressions evaluating to TRUE.
yr_parser_emit_with_arg(
yyscanner, OP_PUSH_M, mem_offset + 1, NULL, NULL);
yr_parser_emit(yyscanner, OP_INT_LE, NULL);
compiler->loop_identifier[compiler->loop_depth] = NULL;
yr_free((yyvsp[-8].c_string));
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
}
#line 2753 "grammar.c" /* yacc.c:1646 */
break;
case 66:
#line 1171 "grammar.y" /* yacc.c:1646 */
{
int mem_offset = LOOP_LOCAL_VARS * compiler->loop_depth;
uint8_t* addr;
if (compiler->loop_depth == MAX_LOOP_NESTING)
compiler->last_result = \
ERROR_LOOP_NESTING_LIMIT_EXCEEDED;
if (compiler->loop_for_of_mem_offset != -1)
compiler->last_result = \
ERROR_NESTED_FOR_OF_LOOP;
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
yr_parser_emit_with_arg(
yyscanner, OP_CLEAR_M, mem_offset + 1, NULL, NULL);
yr_parser_emit_with_arg(
yyscanner, OP_CLEAR_M, mem_offset + 2, NULL, NULL);
// Pop the first string.
yr_parser_emit_with_arg(
yyscanner, OP_POP_M, mem_offset, &addr, NULL);
compiler->loop_for_of_mem_offset = mem_offset;
compiler->loop_address[compiler->loop_depth] = addr;
compiler->loop_identifier[compiler->loop_depth] = NULL;
compiler->loop_depth++;
}
#line 2787 "grammar.c" /* yacc.c:1646 */
break;
case 67:
#line 1201 "grammar.y" /* yacc.c:1646 */
{
int mem_offset;
compiler->loop_depth--;
compiler->loop_for_of_mem_offset = -1;
mem_offset = LOOP_LOCAL_VARS * compiler->loop_depth;
// Increment counter by the value returned by the
// boolean expression (0 or 1). If the boolean expression
// returned UNDEFINED the OP_ADD_M won't do anything.
yr_parser_emit_with_arg(
yyscanner, OP_ADD_M, mem_offset + 1, NULL, NULL);
// Increment iterations counter.
yr_parser_emit_with_arg(
yyscanner, OP_INCR_M, mem_offset + 2, NULL, NULL);
// If next string is not undefined, go back to the
// beginning of the loop.
yr_parser_emit_with_arg_reloc(
yyscanner,
OP_JNUNDEF,
compiler->loop_address[compiler->loop_depth],
NULL,
NULL);
// Pop end-of-list marker.
yr_parser_emit(yyscanner, OP_POP, NULL);
// At this point the loop quantifier (any, all, 1, 2,..)
// is at top of the stack. Check if the quantifier is
// undefined (meaning "all") and replace it with the
// iterations counter in that case.
yr_parser_emit_with_arg(
yyscanner, OP_SWAPUNDEF, mem_offset + 2, NULL, NULL);
// Compare the loop quantifier with the number of
// expressions evaluating to TRUE.
yr_parser_emit_with_arg(
yyscanner, OP_PUSH_M, mem_offset + 1, NULL, NULL);
yr_parser_emit(yyscanner, OP_INT_LE, NULL);
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
}
#line 2840 "grammar.c" /* yacc.c:1646 */
break;
case 68:
#line 1250 "grammar.y" /* yacc.c:1646 */
{
yr_parser_emit(yyscanner, OP_OF, NULL);
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
}
#line 2850 "grammar.c" /* yacc.c:1646 */
break;
case 69:
#line 1256 "grammar.y" /* yacc.c:1646 */
{
yr_parser_emit(yyscanner, OP_NOT, NULL);
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
}
#line 2860 "grammar.c" /* yacc.c:1646 */
break;
case 70:
#line 1262 "grammar.y" /* yacc.c:1646 */
{
YR_FIXUP* fixup;
void* jmp_destination_addr;
compiler->last_result = yr_parser_emit_with_arg_reloc(
yyscanner,
OP_JFALSE,
0, // still don't know the jump destination
NULL,
&jmp_destination_addr);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
// create a fixup entry for the jump and push it in the stack
fixup = (YR_FIXUP*) yr_malloc(sizeof(YR_FIXUP));
if (fixup == NULL)
compiler->last_error = ERROR_INSUFFICIENT_MEMORY;
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
fixup->address = jmp_destination_addr;
fixup->next = compiler->fixup_stack_head;
compiler->fixup_stack_head = fixup;
}
#line 2890 "grammar.c" /* yacc.c:1646 */
break;
case 71:
#line 1288 "grammar.y" /* yacc.c:1646 */
{
YR_FIXUP* fixup;
uint8_t* and_addr;
// Ensure that we have at least two consecutive bytes in the arena's
// current page, one for the AND opcode and one for opcode following the
// AND. This is necessary because we need to compute the address for the
// opcode following the AND, and we don't want the AND in one page and
// the following opcode in another page.
compiler->last_result = yr_arena_reserve_memory(
compiler->code_arena, 2);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
compiler->last_result = yr_parser_emit(yyscanner, OP_AND, &and_addr);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
// Now we know the jump destination, which is the address of the
// instruction following the AND. Let's fixup the jump address.
fixup = compiler->fixup_stack_head;
// We know that the AND opcode and the following one are within the same
// page, so we can compute the address for the opcode following the AND
// by simply adding one to its address.
*(void**)(fixup->address) = (void*)(and_addr + 1);
compiler->fixup_stack_head = fixup->next;
yr_free(fixup);
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
}
#line 2930 "grammar.c" /* yacc.c:1646 */
break;
case 72:
#line 1324 "grammar.y" /* yacc.c:1646 */
{
YR_FIXUP* fixup;
void* jmp_destination_addr;
compiler->last_result = yr_parser_emit_with_arg_reloc(
yyscanner,
OP_JTRUE,
0, // still don't know the jump destination
NULL,
&jmp_destination_addr);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
fixup = (YR_FIXUP*) yr_malloc(sizeof(YR_FIXUP));
if (fixup == NULL)
compiler->last_error = ERROR_INSUFFICIENT_MEMORY;
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
fixup->address = jmp_destination_addr;
fixup->next = compiler->fixup_stack_head;
compiler->fixup_stack_head = fixup;
}
#line 2959 "grammar.c" /* yacc.c:1646 */
break;
case 73:
#line 1349 "grammar.y" /* yacc.c:1646 */
{
YR_FIXUP* fixup;
uint8_t* or_addr;
// Ensure that we have at least two consecutive bytes in the arena's
// current page, one for the OR opcode and one for opcode following the
// OR. This is necessary because we need to compute the address for the
// opcode following the OR, and we don't want the OR in one page and
// the following opcode in another page.
compiler->last_result = yr_arena_reserve_memory(
compiler->code_arena, 2);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
compiler->last_result = yr_parser_emit(yyscanner, OP_OR, &or_addr);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
// Now we know the jump destination, which is the address of the
// instruction following the OP_OR. Let's fixup the jump address.
fixup = compiler->fixup_stack_head;
// We know that the OR opcode and the following one are within the same
// page, so we can compute the address for the opcode following the OR
// by simply adding one to its address.
*(void**)(fixup->address) = (void*)(or_addr + 1);
compiler->fixup_stack_head = fixup->next;
yr_free(fixup);
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
}
#line 2999 "grammar.c" /* yacc.c:1646 */
break;
case 74:
#line 1385 "grammar.y" /* yacc.c:1646 */
{
compiler->last_result = yr_parser_reduce_operation(
yyscanner, "<", (yyvsp[-2].expression), (yyvsp[0].expression));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
}
#line 3012 "grammar.c" /* yacc.c:1646 */
break;
case 75:
#line 1394 "grammar.y" /* yacc.c:1646 */
{
compiler->last_result = yr_parser_reduce_operation(
yyscanner, ">", (yyvsp[-2].expression), (yyvsp[0].expression));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
}
#line 3025 "grammar.c" /* yacc.c:1646 */
break;
case 76:
#line 1403 "grammar.y" /* yacc.c:1646 */
{
compiler->last_result = yr_parser_reduce_operation(
yyscanner, "<=", (yyvsp[-2].expression), (yyvsp[0].expression));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
}
#line 3038 "grammar.c" /* yacc.c:1646 */
break;
case 77:
#line 1412 "grammar.y" /* yacc.c:1646 */
{
compiler->last_result = yr_parser_reduce_operation(
yyscanner, ">=", (yyvsp[-2].expression), (yyvsp[0].expression));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
}
#line 3051 "grammar.c" /* yacc.c:1646 */
break;
case 78:
#line 1421 "grammar.y" /* yacc.c:1646 */
{
compiler->last_result = yr_parser_reduce_operation(
yyscanner, "==", (yyvsp[-2].expression), (yyvsp[0].expression));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
}
#line 3064 "grammar.c" /* yacc.c:1646 */
break;
case 79:
#line 1430 "grammar.y" /* yacc.c:1646 */
{
compiler->last_result = yr_parser_reduce_operation(
yyscanner, "!=", (yyvsp[-2].expression), (yyvsp[0].expression));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
}
#line 3077 "grammar.c" /* yacc.c:1646 */
break;
case 80:
#line 1439 "grammar.y" /* yacc.c:1646 */
{
(yyval.expression) = (yyvsp[0].expression);
}
#line 3085 "grammar.c" /* yacc.c:1646 */
break;
case 81:
#line 1443 "grammar.y" /* yacc.c:1646 */
{
(yyval.expression) = (yyvsp[-1].expression);
}
#line 3093 "grammar.c" /* yacc.c:1646 */
break;
case 82:
#line 1450 "grammar.y" /* yacc.c:1646 */
{ (yyval.integer) = INTEGER_SET_ENUMERATION; }
#line 3099 "grammar.c" /* yacc.c:1646 */
break;
case 83:
#line 1451 "grammar.y" /* yacc.c:1646 */
{ (yyval.integer) = INTEGER_SET_RANGE; }
#line 3105 "grammar.c" /* yacc.c:1646 */
break;
case 84:
#line 1457 "grammar.y" /* yacc.c:1646 */
{
if ((yyvsp[-3].expression).type != EXPRESSION_TYPE_INTEGER)
{
yr_compiler_set_error_extra_info(
compiler, "wrong type for range's lower bound");
compiler->last_result = ERROR_WRONG_TYPE;
}
if ((yyvsp[-1].expression).type != EXPRESSION_TYPE_INTEGER)
{
yr_compiler_set_error_extra_info(
compiler, "wrong type for range's upper bound");
compiler->last_result = ERROR_WRONG_TYPE;
}
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
}
#line 3127 "grammar.c" /* yacc.c:1646 */
break;
case 85:
#line 1479 "grammar.y" /* yacc.c:1646 */
{
if ((yyvsp[0].expression).type != EXPRESSION_TYPE_INTEGER)
{
yr_compiler_set_error_extra_info(
compiler, "wrong type for enumeration item");
compiler->last_result = ERROR_WRONG_TYPE;
}
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
}
#line 3143 "grammar.c" /* yacc.c:1646 */
break;
case 86:
#line 1491 "grammar.y" /* yacc.c:1646 */
{
if ((yyvsp[0].expression).type != EXPRESSION_TYPE_INTEGER)
{
yr_compiler_set_error_extra_info(
compiler, "wrong type for enumeration item");
compiler->last_result = ERROR_WRONG_TYPE;
}
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
}
#line 3158 "grammar.c" /* yacc.c:1646 */
break;
case 87:
#line 1506 "grammar.y" /* yacc.c:1646 */
{
// Push end-of-list marker
yr_parser_emit_with_arg(yyscanner, OP_PUSH, UNDEFINED, NULL, NULL);
}
#line 3167 "grammar.c" /* yacc.c:1646 */
break;
case 89:
#line 1512 "grammar.y" /* yacc.c:1646 */
{
yr_parser_emit_with_arg(yyscanner, OP_PUSH, UNDEFINED, NULL, NULL);
yr_parser_emit_pushes_for_strings(yyscanner, "$*");
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
}
#line 3178 "grammar.c" /* yacc.c:1646 */
break;
case 92:
#line 1529 "grammar.y" /* yacc.c:1646 */
{
yr_parser_emit_pushes_for_strings(yyscanner, (yyvsp[0].c_string));
yr_free((yyvsp[0].c_string));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
}
#line 3189 "grammar.c" /* yacc.c:1646 */
break;
case 93:
#line 1536 "grammar.y" /* yacc.c:1646 */
{
yr_parser_emit_pushes_for_strings(yyscanner, (yyvsp[0].c_string));
yr_free((yyvsp[0].c_string));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
}
#line 3200 "grammar.c" /* yacc.c:1646 */
break;
case 95:
#line 1548 "grammar.y" /* yacc.c:1646 */
{
yr_parser_emit_with_arg(yyscanner, OP_PUSH, UNDEFINED, NULL, NULL);
}
#line 3208 "grammar.c" /* yacc.c:1646 */
break;
case 96:
#line 1552 "grammar.y" /* yacc.c:1646 */
{
yr_parser_emit_with_arg(yyscanner, OP_PUSH, 1, NULL, NULL);
}
#line 3216 "grammar.c" /* yacc.c:1646 */
break;
case 97:
#line 1560 "grammar.y" /* yacc.c:1646 */
{
(yyval.expression) = (yyvsp[-1].expression);
}
#line 3224 "grammar.c" /* yacc.c:1646 */
break;
case 98:
#line 1564 "grammar.y" /* yacc.c:1646 */
{
compiler->last_result = yr_parser_emit(
yyscanner, OP_FILESIZE, NULL);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
(yyval.expression).value.integer = UNDEFINED;
}
#line 3238 "grammar.c" /* yacc.c:1646 */
break;
case 99:
#line 1574 "grammar.y" /* yacc.c:1646 */
{
yywarning(yyscanner,
"Using deprecated \"entrypoint\" keyword. Use the \"entry_point\" "
"function from PE module instead.");
compiler->last_result = yr_parser_emit(
yyscanner, OP_ENTRYPOINT, NULL);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
(yyval.expression).value.integer = UNDEFINED;
}
#line 3256 "grammar.c" /* yacc.c:1646 */
break;
case 100:
#line 1588 "grammar.y" /* yacc.c:1646 */
{
CHECK_TYPE((yyvsp[-1].expression), EXPRESSION_TYPE_INTEGER, "intXXXX or uintXXXX");
// _INTEGER_FUNCTION_ could be any of int8, int16, int32, uint8,
// uint32, etc. $1 contains an index that added to OP_READ_INT results
// in the proper OP_INTXX opcode.
compiler->last_result = yr_parser_emit(
yyscanner, (uint8_t) (OP_READ_INT + (yyvsp[-3].integer)), NULL);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
(yyval.expression).value.integer = UNDEFINED;
}
#line 3276 "grammar.c" /* yacc.c:1646 */
break;
case 101:
#line 1604 "grammar.y" /* yacc.c:1646 */
{
compiler->last_result = yr_parser_emit_with_arg(
yyscanner, OP_PUSH, (yyvsp[0].integer), NULL, NULL);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
(yyval.expression).value.integer = (yyvsp[0].integer);
}
#line 3290 "grammar.c" /* yacc.c:1646 */
break;
case 102:
#line 1614 "grammar.y" /* yacc.c:1646 */
{
compiler->last_result = yr_parser_emit_with_arg_double(
yyscanner, OP_PUSH, (yyvsp[0].double_), NULL, NULL);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_FLOAT;
}
#line 3303 "grammar.c" /* yacc.c:1646 */
break;
case 103:
#line 1623 "grammar.y" /* yacc.c:1646 */
{
SIZED_STRING* sized_string;
compiler->last_result = yr_arena_write_data(
compiler->sz_arena,
(yyvsp[0].sized_string),
(yyvsp[0].sized_string)->length + sizeof(SIZED_STRING),
(void**) &sized_string);
yr_free((yyvsp[0].sized_string));
if (compiler->last_result == ERROR_SUCCESS)
compiler->last_result = yr_parser_emit_with_arg_reloc(
yyscanner,
OP_PUSH,
sized_string,
NULL,
NULL);
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_STRING;
(yyval.expression).value.sized_string = sized_string;
}
#line 3332 "grammar.c" /* yacc.c:1646 */
break;
case 104:
#line 1648 "grammar.y" /* yacc.c:1646 */
{
compiler->last_result = yr_parser_reduce_string_identifier(
yyscanner, (yyvsp[0].c_string), OP_COUNT, UNDEFINED);
yr_free((yyvsp[0].c_string));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
(yyval.expression).value.integer = UNDEFINED;
}
#line 3348 "grammar.c" /* yacc.c:1646 */
break;
case 105:
#line 1660 "grammar.y" /* yacc.c:1646 */
{
compiler->last_result = yr_parser_reduce_string_identifier(
yyscanner, (yyvsp[-3].c_string), OP_OFFSET, UNDEFINED);
yr_free((yyvsp[-3].c_string));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
(yyval.expression).value.integer = UNDEFINED;
}
#line 3364 "grammar.c" /* yacc.c:1646 */
break;
case 106:
#line 1672 "grammar.y" /* yacc.c:1646 */
{
compiler->last_result = yr_parser_emit_with_arg(
yyscanner, OP_PUSH, 1, NULL, NULL);
if (compiler->last_result == ERROR_SUCCESS)
compiler->last_result = yr_parser_reduce_string_identifier(
yyscanner, (yyvsp[0].c_string), OP_OFFSET, UNDEFINED);
yr_free((yyvsp[0].c_string));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
(yyval.expression).value.integer = UNDEFINED;
}
#line 3384 "grammar.c" /* yacc.c:1646 */
break;
case 107:
#line 1688 "grammar.y" /* yacc.c:1646 */
{
compiler->last_result = yr_parser_reduce_string_identifier(
yyscanner, (yyvsp[-3].c_string), OP_LENGTH, UNDEFINED);
yr_free((yyvsp[-3].c_string));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
(yyval.expression).value.integer = UNDEFINED;
}
#line 3400 "grammar.c" /* yacc.c:1646 */
break;
case 108:
#line 1700 "grammar.y" /* yacc.c:1646 */
{
compiler->last_result = yr_parser_emit_with_arg(
yyscanner, OP_PUSH, 1, NULL, NULL);
if (compiler->last_result == ERROR_SUCCESS)
compiler->last_result = yr_parser_reduce_string_identifier(
yyscanner, (yyvsp[0].c_string), OP_LENGTH, UNDEFINED);
yr_free((yyvsp[0].c_string));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
(yyval.expression).value.integer = UNDEFINED;
}
#line 3420 "grammar.c" /* yacc.c:1646 */
break;
case 109:
#line 1716 "grammar.y" /* yacc.c:1646 */
{
if ((yyvsp[0].expression).type == EXPRESSION_TYPE_INTEGER) // loop identifier
{
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
(yyval.expression).value.integer = UNDEFINED;
}
else if ((yyvsp[0].expression).type == EXPRESSION_TYPE_BOOLEAN) // rule identifier
{
(yyval.expression).type = EXPRESSION_TYPE_BOOLEAN;
(yyval.expression).value.integer = UNDEFINED;
}
else if ((yyvsp[0].expression).type == EXPRESSION_TYPE_OBJECT)
{
compiler->last_result = yr_parser_emit(
yyscanner, OP_OBJ_VALUE, NULL);
switch((yyvsp[0].expression).value.object->type)
{
case OBJECT_TYPE_INTEGER:
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
(yyval.expression).value.integer = UNDEFINED;
break;
case OBJECT_TYPE_FLOAT:
(yyval.expression).type = EXPRESSION_TYPE_FLOAT;
break;
case OBJECT_TYPE_STRING:
(yyval.expression).type = EXPRESSION_TYPE_STRING;
(yyval.expression).value.sized_string = NULL;
break;
default:
yr_compiler_set_error_extra_info_fmt(
compiler,
"wrong usage of identifier \"%s\"",
(yyvsp[0].expression).identifier);
compiler->last_result = ERROR_WRONG_TYPE;
}
}
else
{
assert(FALSE);
}
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
}
#line 3469 "grammar.c" /* yacc.c:1646 */
break;
case 110:
#line 1761 "grammar.y" /* yacc.c:1646 */
{
CHECK_TYPE((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER | EXPRESSION_TYPE_FLOAT, "-");
if ((yyvsp[0].expression).type == EXPRESSION_TYPE_INTEGER)
{
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
(yyval.expression).value.integer = ((yyvsp[0].expression).value.integer == UNDEFINED) ?
UNDEFINED : -((yyvsp[0].expression).value.integer);
compiler->last_result = yr_parser_emit(yyscanner, OP_INT_MINUS, NULL);
}
else if ((yyvsp[0].expression).type == EXPRESSION_TYPE_FLOAT)
{
(yyval.expression).type = EXPRESSION_TYPE_FLOAT;
compiler->last_result = yr_parser_emit(yyscanner, OP_DBL_MINUS, NULL);
}
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
}
#line 3492 "grammar.c" /* yacc.c:1646 */
break;
case 111:
#line 1780 "grammar.y" /* yacc.c:1646 */
{
compiler->last_result = yr_parser_reduce_operation(
yyscanner, "+", (yyvsp[-2].expression), (yyvsp[0].expression));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
if ((yyvsp[-2].expression).type == EXPRESSION_TYPE_INTEGER &&
(yyvsp[0].expression).type == EXPRESSION_TYPE_INTEGER)
{
(yyval.expression).value.integer = OPERATION(+, (yyvsp[-2].expression).value.integer, (yyvsp[0].expression).value.integer);
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
}
else
{
(yyval.expression).type = EXPRESSION_TYPE_FLOAT;
}
}
#line 3514 "grammar.c" /* yacc.c:1646 */
break;
case 112:
#line 1798 "grammar.y" /* yacc.c:1646 */
{
compiler->last_result = yr_parser_reduce_operation(
yyscanner, "-", (yyvsp[-2].expression), (yyvsp[0].expression));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
if ((yyvsp[-2].expression).type == EXPRESSION_TYPE_INTEGER &&
(yyvsp[0].expression).type == EXPRESSION_TYPE_INTEGER)
{
(yyval.expression).value.integer = OPERATION(-, (yyvsp[-2].expression).value.integer, (yyvsp[0].expression).value.integer);
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
}
else
{
(yyval.expression).type = EXPRESSION_TYPE_FLOAT;
}
}
#line 3536 "grammar.c" /* yacc.c:1646 */
break;
case 113:
#line 1816 "grammar.y" /* yacc.c:1646 */
{
compiler->last_result = yr_parser_reduce_operation(
yyscanner, "*", (yyvsp[-2].expression), (yyvsp[0].expression));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
if ((yyvsp[-2].expression).type == EXPRESSION_TYPE_INTEGER &&
(yyvsp[0].expression).type == EXPRESSION_TYPE_INTEGER)
{
(yyval.expression).value.integer = OPERATION(*, (yyvsp[-2].expression).value.integer, (yyvsp[0].expression).value.integer);
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
}
else
{
(yyval.expression).type = EXPRESSION_TYPE_FLOAT;
}
}
#line 3558 "grammar.c" /* yacc.c:1646 */
break;
case 114:
#line 1834 "grammar.y" /* yacc.c:1646 */
{
compiler->last_result = yr_parser_reduce_operation(
yyscanner, "\\", (yyvsp[-2].expression), (yyvsp[0].expression));
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
if ((yyvsp[-2].expression).type == EXPRESSION_TYPE_INTEGER &&
(yyvsp[0].expression).type == EXPRESSION_TYPE_INTEGER)
{
if ((yyvsp[0].expression).value.integer != 0)
{
(yyval.expression).value.integer = OPERATION(/, (yyvsp[-2].expression).value.integer, (yyvsp[0].expression).value.integer);
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
}
else
{
compiler->last_result = ERROR_DIVISION_BY_ZERO;
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
}
}
else
{
(yyval.expression).type = EXPRESSION_TYPE_FLOAT;
}
}
#line 3588 "grammar.c" /* yacc.c:1646 */
break;
case 115:
#line 1860 "grammar.y" /* yacc.c:1646 */
{
CHECK_TYPE((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "%");
CHECK_TYPE((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "%");
yr_parser_emit(yyscanner, OP_MOD, NULL);
if ((yyvsp[0].expression).value.integer != 0)
{
(yyval.expression).value.integer = OPERATION(%, (yyvsp[-2].expression).value.integer, (yyvsp[0].expression).value.integer);
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
}
else
{
compiler->last_result = ERROR_DIVISION_BY_ZERO;
ERROR_IF(compiler->last_result != ERROR_SUCCESS);
}
}
#line 3610 "grammar.c" /* yacc.c:1646 */
break;
case 116:
#line 1878 "grammar.y" /* yacc.c:1646 */
{
CHECK_TYPE((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "^");
CHECK_TYPE((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "^");
yr_parser_emit(yyscanner, OP_BITWISE_XOR, NULL);
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
(yyval.expression).value.integer = OPERATION(^, (yyvsp[-2].expression).value.integer, (yyvsp[0].expression).value.integer);
}
#line 3624 "grammar.c" /* yacc.c:1646 */
break;
case 117:
#line 1888 "grammar.y" /* yacc.c:1646 */
{
CHECK_TYPE((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "^");
CHECK_TYPE((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "^");
yr_parser_emit(yyscanner, OP_BITWISE_AND, NULL);
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
(yyval.expression).value.integer = OPERATION(&, (yyvsp[-2].expression).value.integer, (yyvsp[0].expression).value.integer);
}
#line 3638 "grammar.c" /* yacc.c:1646 */
break;
case 118:
#line 1898 "grammar.y" /* yacc.c:1646 */
{
CHECK_TYPE((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "|");
CHECK_TYPE((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "|");
yr_parser_emit(yyscanner, OP_BITWISE_OR, NULL);
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
(yyval.expression).value.integer = OPERATION(|, (yyvsp[-2].expression).value.integer, (yyvsp[0].expression).value.integer);
}
#line 3652 "grammar.c" /* yacc.c:1646 */
break;
case 119:
#line 1908 "grammar.y" /* yacc.c:1646 */
{
CHECK_TYPE((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "~");
yr_parser_emit(yyscanner, OP_BITWISE_NOT, NULL);
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
(yyval.expression).value.integer = ((yyvsp[0].expression).value.integer == UNDEFINED) ?
UNDEFINED : ~((yyvsp[0].expression).value.integer);
}
#line 3666 "grammar.c" /* yacc.c:1646 */
break;
case 120:
#line 1918 "grammar.y" /* yacc.c:1646 */
{
CHECK_TYPE((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, "<<");
CHECK_TYPE((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, "<<");
yr_parser_emit(yyscanner, OP_SHL, NULL);
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
(yyval.expression).value.integer = OPERATION(<<, (yyvsp[-2].expression).value.integer, (yyvsp[0].expression).value.integer);
}
#line 3680 "grammar.c" /* yacc.c:1646 */
break;
case 121:
#line 1928 "grammar.y" /* yacc.c:1646 */
{
CHECK_TYPE((yyvsp[-2].expression), EXPRESSION_TYPE_INTEGER, ">>");
CHECK_TYPE((yyvsp[0].expression), EXPRESSION_TYPE_INTEGER, ">>");
yr_parser_emit(yyscanner, OP_SHR, NULL);
(yyval.expression).type = EXPRESSION_TYPE_INTEGER;
(yyval.expression).value.integer = OPERATION(>>, (yyvsp[-2].expression).value.integer, (yyvsp[0].expression).value.integer);
}
#line 3694 "grammar.c" /* yacc.c:1646 */
break;
case 122:
#line 1938 "grammar.y" /* yacc.c:1646 */
{
(yyval.expression) = (yyvsp[0].expression);
}
#line 3702 "grammar.c" /* yacc.c:1646 */
break;
#line 3706 "grammar.c" /* yacc.c:1646 */
default: break;
}
/* User semantic actions sometimes alter yychar, and that requires
that yytoken be updated with the new translation. We take the
approach of translating immediately before every use of yytoken.
One alternative is translating here after every semantic action,
but that translation would be missed if the semantic action invokes
YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
incorrect destructor might then be invoked immediately. In the
case of YYERROR or YYBACKUP, subsequent parser actions might lead
to an incorrect destructor call or verbose syntax error message
before the lookahead is translated. */
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
YYPOPSTACK (yylen);
yylen = 0;
YY_STACK_PRINT (yyss, yyssp);
*++yyvsp = yyval;
/* Now 'shift' the result of the reduction. Determine what state
that goes to, based on the state we popped back to and the rule
number reduced by. */
yyn = yyr1[yyn];
yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
yystate = yytable[yystate];
else
yystate = yydefgoto[yyn - YYNTOKENS];
goto yynewstate;
/*--------------------------------------.
| yyerrlab -- here on detecting error. |
`--------------------------------------*/
yyerrlab:
/* Make sure we have latest lookahead translation. See comments at
user semantic actions for why this is necessary. */
yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
/* If not already recovering from an error, report this error. */
if (!yyerrstatus)
{
++yynerrs;
#if ! YYERROR_VERBOSE
yyerror (yyscanner, compiler, YY_("syntax error"));
#else
# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
yyssp, yytoken)
{
char const *yymsgp = YY_("syntax error");
int yysyntax_error_status;
yysyntax_error_status = YYSYNTAX_ERROR;
if (yysyntax_error_status == 0)
yymsgp = yymsg;
else if (yysyntax_error_status == 1)
{
if (yymsg != yymsgbuf)
YYSTACK_FREE (yymsg);
yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
if (!yymsg)
{
yymsg = yymsgbuf;
yymsg_alloc = sizeof yymsgbuf;
yysyntax_error_status = 2;
}
else
{
yysyntax_error_status = YYSYNTAX_ERROR;
yymsgp = yymsg;
}
}
yyerror (yyscanner, compiler, yymsgp);
if (yysyntax_error_status == 2)
goto yyexhaustedlab;
}
# undef YYSYNTAX_ERROR
#endif
}
if (yyerrstatus == 3)
{
/* If just tried and failed to reuse lookahead token after an
error, discard it. */
if (yychar <= YYEOF)
{
/* Return failure if at end of input. */
if (yychar == YYEOF)
YYABORT;
}
else
{
yydestruct ("Error: discarding",
yytoken, &yylval, yyscanner, compiler);
yychar = YYEMPTY;
}
}
/* Else will try to reuse lookahead token after shifting the error
token. */
goto yyerrlab1;
/*---------------------------------------------------.
| yyerrorlab -- error raised explicitly by YYERROR. |
`---------------------------------------------------*/
yyerrorlab:
/* Pacify compilers like GCC when the user code never invokes
YYERROR and the label yyerrorlab therefore never appears in user
code. */
if (/*CONSTCOND*/ 0)
goto yyerrorlab;
/* Do not reclaim the symbols of the rule whose action triggered
this YYERROR. */
YYPOPSTACK (yylen);
yylen = 0;
YY_STACK_PRINT (yyss, yyssp);
yystate = *yyssp;
goto yyerrlab1;
/*-------------------------------------------------------------.
| yyerrlab1 -- common code for both syntax error and YYERROR. |
`-------------------------------------------------------------*/
yyerrlab1:
yyerrstatus = 3; /* Each real token shifted decrements this. */
for (;;)
{
yyn = yypact[yystate];
if (!yypact_value_is_default (yyn))
{
yyn += YYTERROR;
if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
{
yyn = yytable[yyn];
if (0 < yyn)
break;
}
}
/* Pop the current state because it cannot handle the error token. */
if (yyssp == yyss)
YYABORT;
yydestruct ("Error: popping",
yystos[yystate], yyvsp, yyscanner, compiler);
YYPOPSTACK (1);
yystate = *yyssp;
YY_STACK_PRINT (yyss, yyssp);
}
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
*++yyvsp = yylval;
YY_IGNORE_MAYBE_UNINITIALIZED_END
/* Shift the error token. */
YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
yystate = yyn;
goto yynewstate;
/*-------------------------------------.
| yyacceptlab -- YYACCEPT comes here. |
`-------------------------------------*/
yyacceptlab:
yyresult = 0;
goto yyreturn;
/*-----------------------------------.
| yyabortlab -- YYABORT comes here. |
`-----------------------------------*/
yyabortlab:
yyresult = 1;
goto yyreturn;
#if !defined yyoverflow || YYERROR_VERBOSE
/*-------------------------------------------------.
| yyexhaustedlab -- memory exhaustion comes here. |
`-------------------------------------------------*/
yyexhaustedlab:
yyerror (yyscanner, compiler, YY_("memory exhausted"));
yyresult = 2;
/* Fall through. */
#endif
yyreturn:
if (yychar != YYEMPTY)
{
/* Make sure we have latest lookahead translation. See comments at
user semantic actions for why this is necessary. */
yytoken = YYTRANSLATE (yychar);
yydestruct ("Cleanup: discarding lookahead",
yytoken, &yylval, yyscanner, compiler);
}
/* Do not reclaim the symbols of the rule whose action triggered
this YYABORT or YYACCEPT. */
YYPOPSTACK (yylen);
YY_STACK_PRINT (yyss, yyssp);
while (yyssp != yyss)
{
yydestruct ("Cleanup: popping",
yystos[*yyssp], yyvsp, yyscanner, compiler);
YYPOPSTACK (1);
}
#ifndef yyoverflow
if (yyss != yyssa)
YYSTACK_FREE (yyss);
#endif
#if YYERROR_VERBOSE
if (yymsg != yymsgbuf)
YYSTACK_FREE (yymsg);
#endif
return yyresult; | 9819 | True | 1 |
CVE-2017-8294 | 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.0/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/VirusTotal/yara/issues/646', 'name': 'https://github.com/VirusTotal/yara/issues/646', 'refsource': 'CONFIRM', 'tags': ['Issue Tracking', 'Patch']}, {'url': 'https://github.com/VirusTotal/yara/commit/83d799804648c2a0895d40a19835d9b757c6fa4e', 'name': 'https://github.com/VirusTotal/yara/commit/83d799804648c2a0895d40a19835d9b757c6fa4e', 'refsource': 'CONFIRM', 'tags': ['Patch']}, {'url': 'http://www.securityfocus.com/bid/98072', 'name': '98072', 'refsource': 'BID', 'tags': ['Third Party Advisory', 'VDB Entry']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:virustotal:yara:3.5.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'libyara/re.c in the regex component in YARA 3.5.0 allows remote attackers to cause a denial of service (out-of-bounds read and application crash) via a crafted rule that is mishandled in the yr_re_exec function.'}] | 2017-05-03T12:21Z | 2017-04-27T14:59Z | 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 | Victor M. Alvarez | 2017-04-27 11:39:04+02:00 | Fix issue #646 (#648)
* Fix issue #646 and some edge cases with wide regexps using \b and \B
* Rename function IS_WORD_CHAR to _yr_re_is_word_char | 83d799804648c2a0895d40a19835d9b757c6fa4e | False | VirusTotal/yara | The pattern matching swiss knife | 2012-12-06 15:33:08 | 2022-08-26 10:13:14 | https://virustotal.github.io/yara/ | VirusTotal | 5938.0 | 1229.0 | yr_re_exec | yr_re_exec( uint8_t * re_code , uint8_t * input_data , size_t input_size , int flags , RE_MATCH_CALLBACK_FUNC callback , void * callback_args) | ['re_code', 'input_data', 'input_size', 'flags', 'callback', 'callback_args'] | int yr_re_exec(
uint8_t* re_code,
uint8_t* input_data,
size_t input_size,
int flags,
RE_MATCH_CALLBACK_FUNC callback,
void* callback_args)
{
uint8_t* ip;
uint8_t* input;
uint8_t mask;
uint8_t value;
RE_FIBER_LIST fibers;
RE_THREAD_STORAGE* storage;
RE_FIBER* fiber;
RE_FIBER* next_fiber;
int error;
int bytes_matched;
int max_bytes_matched;
int match;
int character_size;
int input_incr;
int kill;
int action;
int result = -1;
#define ACTION_NONE 0
#define ACTION_CONTINUE 1
#define ACTION_KILL 2
#define ACTION_KILL_TAIL 3
#define prolog if (bytes_matched >= max_bytes_matched) \
{ \
action = ACTION_KILL; \
break; \
}
#define fail_if_error(e) switch (e) { \
case ERROR_INSUFFICIENT_MEMORY: \
return -2; \
case ERROR_TOO_MANY_RE_FIBERS: \
return -4; \
}
if (_yr_re_alloc_storage(&storage) != ERROR_SUCCESS)
return -2;
if (flags & RE_FLAGS_WIDE)
character_size = 2;
else
character_size = 1;
input = input_data;
input_incr = character_size;
if (flags & RE_FLAGS_BACKWARDS)
{
input -= character_size;
input_incr = -input_incr;
}
max_bytes_matched = (int) yr_min(input_size, RE_SCAN_LIMIT);
// Round down max_bytes_matched to a multiple of character_size, this way if
// character_size is 2 and input_size is odd we are ignoring the
// extra byte which can't match anyways.
max_bytes_matched = max_bytes_matched - max_bytes_matched % character_size;
bytes_matched = 0;
error = _yr_re_fiber_create(&storage->fiber_pool, &fiber);
fail_if_error(error);
fiber->ip = re_code;
fibers.head = fiber;
fibers.tail = fiber;
error = _yr_re_fiber_sync(&fibers, &storage->fiber_pool, fiber);
fail_if_error(error);
while (fibers.head != NULL)
{
fiber = fibers.head;
while(fiber != NULL)
{
ip = fiber->ip;
action = ACTION_NONE;
switch(*ip)
{
case RE_OPCODE_ANY:
prolog;
match = (flags & RE_FLAGS_DOT_ALL) || (*input != 0x0A);
action = match ? ACTION_NONE : ACTION_KILL;
fiber->ip += 1;
break;
case RE_OPCODE_REPEAT_ANY_GREEDY:
case RE_OPCODE_REPEAT_ANY_UNGREEDY:
prolog;
match = (flags & RE_FLAGS_DOT_ALL) || (*input != 0x0A);
action = match ? ACTION_NONE : ACTION_KILL;
// The instruction pointer is not incremented here. The current fiber
// spins in this instruction until reaching the required number of
// repetitions. The code controlling the number of repetitions is in
// _yr_re_fiber_sync.
break;
case RE_OPCODE_LITERAL:
prolog;
if (flags & RE_FLAGS_NO_CASE)
match = yr_lowercase[*input] == yr_lowercase[*(ip + 1)];
else
match = (*input == *(ip + 1));
action = match ? ACTION_NONE : ACTION_KILL;
fiber->ip += 2;
break;
case RE_OPCODE_MASKED_LITERAL:
prolog;
value = *(int16_t*)(ip + 1) & 0xFF;
mask = *(int16_t*)(ip + 1) >> 8;
// We don't need to take into account the case-insensitive
// case because this opcode is only used with hex strings,
// which can't be case-insensitive.
match = ((*input & mask) == value);
action = match ? ACTION_NONE : ACTION_KILL;
fiber->ip += 3;
break;
case RE_OPCODE_CLASS:
prolog;
match = CHAR_IN_CLASS(*input, ip + 1);
if (!match && (flags & RE_FLAGS_NO_CASE))
match = CHAR_IN_CLASS(yr_altercase[*input], ip + 1);
action = match ? ACTION_NONE : ACTION_KILL;
fiber->ip += 33;
break;
case RE_OPCODE_WORD_CHAR:
prolog;
match = IS_WORD_CHAR(*input);
action = match ? ACTION_NONE : ACTION_KILL;
fiber->ip += 1;
break;
case RE_OPCODE_NON_WORD_CHAR:
prolog;
match = !IS_WORD_CHAR(*input);
action = match ? ACTION_NONE : ACTION_KILL;
fiber->ip += 1;
break;
case RE_OPCODE_SPACE:
case RE_OPCODE_NON_SPACE:
prolog;
switch(*input)
{
case ' ':
case '\t':
case '\r':
case '\n':
case '\v':
case '\f':
match = TRUE;
break;
default:
match = FALSE;
}
if (*ip == RE_OPCODE_NON_SPACE)
match = !match;
action = match ? ACTION_NONE : ACTION_KILL;
fiber->ip += 1;
break;
case RE_OPCODE_DIGIT:
prolog;
match = isdigit(*input);
action = match ? ACTION_NONE : ACTION_KILL;
fiber->ip += 1;
break;
case RE_OPCODE_NON_DIGIT:
prolog;
match = !isdigit(*input);
action = match ? ACTION_NONE : ACTION_KILL;
fiber->ip += 1;
break;
case RE_OPCODE_WORD_BOUNDARY:
case RE_OPCODE_NON_WORD_BOUNDARY:
if (bytes_matched == 0 &&
!(flags & RE_FLAGS_NOT_AT_START) &&
!(flags & RE_FLAGS_BACKWARDS))
match = TRUE;
else if (bytes_matched >= max_bytes_matched)
match = TRUE;
else if (IS_WORD_CHAR(*(input - input_incr)) != IS_WORD_CHAR(*input))
match = TRUE;
else
match = FALSE;
if (*ip == RE_OPCODE_NON_WORD_BOUNDARY)
match = !match;
action = match ? ACTION_CONTINUE : ACTION_KILL;
fiber->ip += 1;
break;
case RE_OPCODE_MATCH_AT_START:
if (flags & RE_FLAGS_BACKWARDS)
kill = input_size > (size_t) bytes_matched;
else
kill = (flags & RE_FLAGS_NOT_AT_START) || (bytes_matched != 0);
action = kill ? ACTION_KILL : ACTION_CONTINUE;
fiber->ip += 1;
break;
case RE_OPCODE_MATCH_AT_END:
kill = flags & RE_FLAGS_BACKWARDS ||
input_size > (size_t) bytes_matched;
action = kill ? ACTION_KILL : ACTION_CONTINUE;
fiber->ip += 1;
break;
case RE_OPCODE_MATCH:
result = bytes_matched;
if (flags & RE_FLAGS_EXHAUSTIVE)
{
if (callback != NULL)
{
int cb_result;
if (flags & RE_FLAGS_BACKWARDS)
cb_result = callback(
input + character_size,
bytes_matched,
flags,
callback_args);
else
cb_result = callback(
input_data,
bytes_matched,
flags,
callback_args);
switch(cb_result)
{
case ERROR_INSUFFICIENT_MEMORY:
return -2;
case ERROR_TOO_MANY_MATCHES:
return -3;
default:
if (cb_result != ERROR_SUCCESS)
return -4;
}
}
action = ACTION_KILL;
}
else
{
action = ACTION_KILL_TAIL;
}
break;
default:
assert(FALSE);
}
switch(action)
{
case ACTION_KILL:
fiber = _yr_re_fiber_kill(&fibers, &storage->fiber_pool, fiber);
break;
case ACTION_KILL_TAIL:
_yr_re_fiber_kill_tail(&fibers, &storage->fiber_pool, fiber);
fiber = NULL;
break;
case ACTION_CONTINUE:
error = _yr_re_fiber_sync(&fibers, &storage->fiber_pool, fiber);
fail_if_error(error);
break;
default:
next_fiber = fiber->next;
error = _yr_re_fiber_sync(&fibers, &storage->fiber_pool, fiber);
fail_if_error(error);
fiber = next_fiber;
}
}
if (flags & RE_FLAGS_WIDE &&
bytes_matched < max_bytes_matched &&
*(input + 1) != 0)
{
_yr_re_fiber_kill_all(&fibers, &storage->fiber_pool);
}
input += input_incr;
bytes_matched += character_size;
if (flags & RE_FLAGS_SCAN && bytes_matched < max_bytes_matched)
{
error = _yr_re_fiber_create(&storage->fiber_pool, &fiber);
fail_if_error(error);
fiber->ip = re_code;
_yr_re_fiber_append(&fibers, fiber);
error = _yr_re_fiber_sync(&fibers, &storage->fiber_pool, fiber);
fail_if_error(error);
}
}
return result;
} | 1206 | True | 1 |
CVE-2017-8294 | 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.0/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/VirusTotal/yara/issues/646', 'name': 'https://github.com/VirusTotal/yara/issues/646', 'refsource': 'CONFIRM', 'tags': ['Issue Tracking', 'Patch']}, {'url': 'https://github.com/VirusTotal/yara/commit/83d799804648c2a0895d40a19835d9b757c6fa4e', 'name': 'https://github.com/VirusTotal/yara/commit/83d799804648c2a0895d40a19835d9b757c6fa4e', 'refsource': 'CONFIRM', 'tags': ['Patch']}, {'url': 'http://www.securityfocus.com/bid/98072', 'name': '98072', 'refsource': 'BID', 'tags': ['Third Party Advisory', 'VDB Entry']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:virustotal:yara:3.5.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'libyara/re.c in the regex component in YARA 3.5.0 allows remote attackers to cause a denial of service (out-of-bounds read and application crash) via a crafted rule that is mishandled in the yr_re_exec function.'}] | 2017-05-03T12:21Z | 2017-04-27T14:59Z | 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 | Victor M. Alvarez | 2017-04-27 11:39:04+02:00 | Fix issue #646 (#648)
* Fix issue #646 and some edge cases with wide regexps using \b and \B
* Rename function IS_WORD_CHAR to _yr_re_is_word_char | 83d799804648c2a0895d40a19835d9b757c6fa4e | False | VirusTotal/yara | The pattern matching swiss knife | 2012-12-06 15:33:08 | 2022-08-26 10:13:14 | https://virustotal.github.io/yara/ | VirusTotal | 5938.0 | 1229.0 | yr_re_fast_exec | yr_re_fast_exec( uint8_t * code , uint8_t * input_data , size_t input_size , int flags , RE_MATCH_CALLBACK_FUNC callback , void * callback_args) | ['code', 'input_data', 'input_size', 'flags', 'callback', 'callback_args'] | int yr_re_fast_exec(
uint8_t* code,
uint8_t* input_data,
size_t input_size,
int flags,
RE_MATCH_CALLBACK_FUNC callback,
void* callback_args)
{
RE_REPEAT_ANY_ARGS* repeat_any_args;
uint8_t* code_stack[MAX_FAST_RE_STACK];
uint8_t* input_stack[MAX_FAST_RE_STACK];
int matches_stack[MAX_FAST_RE_STACK];
uint8_t* ip = code;
uint8_t* input = input_data;
uint8_t* next_input;
uint8_t* next_opcode;
uint8_t mask;
uint8_t value;
int i;
int stop;
int input_incr;
int sp = 0;
int bytes_matched;
int max_bytes_matched = input_size;
input_incr = flags & RE_FLAGS_BACKWARDS ? -1 : 1;
if (flags & RE_FLAGS_BACKWARDS)
input--;
code_stack[sp] = code;
input_stack[sp] = input;
matches_stack[sp] = 0;
sp++;
while (sp > 0)
{
sp--;
ip = code_stack[sp];
input = input_stack[sp];
bytes_matched = matches_stack[sp];
stop = FALSE;
while(!stop)
{
if (*ip == RE_OPCODE_MATCH)
{
if (flags & RE_FLAGS_EXHAUSTIVE)
{
int cb_result = callback(
flags & RE_FLAGS_BACKWARDS ? input + 1 : input_data,
bytes_matched,
flags,
callback_args);
switch(cb_result)
{
case ERROR_INSUFFICIENT_MEMORY:
return -2;
case ERROR_TOO_MANY_MATCHES:
return -3;
default:
if (cb_result != ERROR_SUCCESS)
return -4;
}
break;
}
else
{
return bytes_matched;
}
}
if (bytes_matched >= max_bytes_matched)
break;
switch(*ip)
{
case RE_OPCODE_LITERAL:
if (*input == *(ip + 1))
{
bytes_matched++;
input += input_incr;
ip += 2;
}
else
{
stop = TRUE;
}
break;
case RE_OPCODE_MASKED_LITERAL:
value = *(int16_t*)(ip + 1) & 0xFF;
mask = *(int16_t*)(ip + 1) >> 8;
if ((*input & mask) == value)
{
bytes_matched++;
input += input_incr;
ip += 3;
}
else
{
stop = TRUE;
}
break;
case RE_OPCODE_ANY:
bytes_matched++;
input += input_incr;
ip += 1;
break;
case RE_OPCODE_REPEAT_ANY_UNGREEDY:
repeat_any_args = (RE_REPEAT_ANY_ARGS*)(ip + 1);
next_opcode = ip + 1 + sizeof(RE_REPEAT_ANY_ARGS);
for (i = repeat_any_args->min + 1; i <= repeat_any_args->max; i++)
{
next_input = input + i * input_incr;
if (bytes_matched + i >= max_bytes_matched)
break;
if ( *(next_opcode) != RE_OPCODE_LITERAL ||
(*(next_opcode) == RE_OPCODE_LITERAL &&
*(next_opcode + 1) == *next_input))
{
if (sp >= MAX_FAST_RE_STACK)
return -4;
code_stack[sp] = next_opcode;
input_stack[sp] = next_input;
matches_stack[sp] = bytes_matched + i;
sp++;
}
}
input += input_incr * repeat_any_args->min;
bytes_matched += repeat_any_args->min;
ip = next_opcode;
break;
default:
assert(FALSE);
}
}
}
return -1;
} | 560 | True | 1 |
CVE-2017-8294 | 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.0/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/VirusTotal/yara/issues/646', 'name': 'https://github.com/VirusTotal/yara/issues/646', 'refsource': 'CONFIRM', 'tags': ['Issue Tracking', 'Patch']}, {'url': 'https://github.com/VirusTotal/yara/commit/83d799804648c2a0895d40a19835d9b757c6fa4e', 'name': 'https://github.com/VirusTotal/yara/commit/83d799804648c2a0895d40a19835d9b757c6fa4e', 'refsource': 'CONFIRM', 'tags': ['Patch']}, {'url': 'http://www.securityfocus.com/bid/98072', 'name': '98072', 'refsource': 'BID', 'tags': ['Third Party Advisory', 'VDB Entry']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:virustotal:yara:3.5.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'libyara/re.c in the regex component in YARA 3.5.0 allows remote attackers to cause a denial of service (out-of-bounds read and application crash) via a crafted rule that is mishandled in the yr_re_exec function.'}] | 2017-05-03T12:21Z | 2017-04-27T14:59Z | 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 | Victor M. Alvarez | 2017-04-27 11:39:04+02:00 | Fix issue #646 (#648)
* Fix issue #646 and some edge cases with wide regexps using \b and \B
* Rename function IS_WORD_CHAR to _yr_re_is_word_char | 83d799804648c2a0895d40a19835d9b757c6fa4e | False | VirusTotal/yara | The pattern matching swiss knife | 2012-12-06 15:33:08 | 2022-08-26 10:13:14 | https://virustotal.github.io/yara/ | VirusTotal | 5938.0 | 1229.0 | _yr_scan_verify_re_match | _yr_scan_verify_re_match( YR_SCAN_CONTEXT * context , YR_AC_MATCH * ac_match , uint8_t * data , size_t data_size , size_t data_base , size_t offset) | ['context', 'ac_match', 'data', 'data_size', 'data_base', 'offset'] | int _yr_scan_verify_re_match(
YR_SCAN_CONTEXT* context,
YR_AC_MATCH* ac_match,
uint8_t* data,
size_t data_size,
size_t data_base,
size_t offset)
{
CALLBACK_ARGS callback_args;
RE_EXEC_FUNC exec;
int forward_matches = -1;
int backward_matches = -1;
int flags = 0;
if (STRING_IS_GREEDY_REGEXP(ac_match->string))
flags |= RE_FLAGS_GREEDY;
if (STRING_IS_NO_CASE(ac_match->string))
flags |= RE_FLAGS_NO_CASE;
if (STRING_IS_DOT_ALL(ac_match->string))
flags |= RE_FLAGS_DOT_ALL;
if (STRING_IS_FAST_REGEXP(ac_match->string))
exec = yr_re_fast_exec;
else
exec = yr_re_exec;
if (STRING_IS_ASCII(ac_match->string))
{
forward_matches = exec(
ac_match->forward_code,
data + offset,
data_size - offset,
offset > 0 ? flags | RE_FLAGS_NOT_AT_START : flags,
NULL,
NULL);
}
if (STRING_IS_WIDE(ac_match->string) && forward_matches == -1)
{
flags |= RE_FLAGS_WIDE;
forward_matches = exec(
ac_match->forward_code,
data + offset,
data_size - offset,
offset > 0 ? flags | RE_FLAGS_NOT_AT_START : flags,
NULL,
NULL);
}
switch(forward_matches)
{
case -1:
return ERROR_SUCCESS;
case -2:
return ERROR_INSUFFICIENT_MEMORY;
case -3:
return ERROR_TOO_MANY_MATCHES;
case -4:
return ERROR_TOO_MANY_RE_FIBERS;
case -5:
return ERROR_INTERNAL_FATAL_ERROR;
}
if (forward_matches == 0 && ac_match->backward_code == NULL)
return ERROR_SUCCESS;
callback_args.string = ac_match->string;
callback_args.context = context;
callback_args.data = data;
callback_args.data_size = data_size;
callback_args.data_base = data_base;
callback_args.forward_matches = forward_matches;
callback_args.full_word = STRING_IS_FULL_WORD(ac_match->string);
if (ac_match->backward_code != NULL)
{
backward_matches = exec(
ac_match->backward_code,
data + offset,
offset,
flags | RE_FLAGS_BACKWARDS | RE_FLAGS_EXHAUSTIVE,
_yr_scan_match_callback,
(void*) &callback_args);
switch(backward_matches)
{
case -2:
return ERROR_INSUFFICIENT_MEMORY;
case -3:
return ERROR_TOO_MANY_MATCHES;
case -4:
return ERROR_TOO_MANY_RE_FIBERS;
case -5:
return ERROR_INTERNAL_FATAL_ERROR;
}
}
else
{
FAIL_ON_ERROR(_yr_scan_match_callback(
data + offset, 0, flags, &callback_args));
}
return ERROR_SUCCESS;
} | 400 | True | 1 |
CVE-2017-8929 | 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.0/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/VirusTotal/yara/issues/658', 'name': 'https://github.com/VirusTotal/yara/issues/658', 'refsource': 'CONFIRM', 'tags': ['Issue Tracking', 'Patch']}, {'url': 'https://github.com/VirusTotal/yara/commit/053e67e3ec81cc9268ce30eaf0d6663d8639ed1e', 'name': 'https://github.com/VirusTotal/yara/commit/053e67e3ec81cc9268ce30eaf0d6663d8639ed1e', 'refsource': 'CONFIRM', 'tags': ['Patch']}] | [{'description': [{'lang': 'en', 'value': 'CWE-416'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:virustotal:yara:3.5.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'The sized_string_cmp function in libyara/sizedstr.c in YARA 3.5.0 allows remote attackers to cause a denial of service (use-after-free and application crash) via a crafted rule.'}] | 2017-05-23T18:22Z | 2017-05-14T22:29Z | 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 | Victor M. Alvarez | 2017-05-14 10:27:39+02:00 | Fix issue #658 | 053e67e3ec81cc9268ce30eaf0d6663d8639ed1e | False | VirusTotal/yara | The pattern matching swiss knife | 2012-12-06 15:33:08 | 2022-08-26 10:13:14 | https://virustotal.github.io/yara/ | VirusTotal | 5938.0 | 1229.0 | yr_execute_code | yr_execute_code( YR_RULES * rules , YR_SCAN_CONTEXT * context , int timeout , time_t start_time) | ['rules', 'context', 'timeout', 'start_time'] |
int yr_execute_code(
YR_RULES* rules,
YR_SCAN_CONTEXT* context,
int timeout,
time_t start_time)
{
int64_t mem[MEM_SIZE];
int32_t sp = 0;
uint8_t* ip = rules->code_start;
YR_VALUE args[MAX_FUNCTION_ARGS];
YR_VALUE *stack;
YR_VALUE r1;
YR_VALUE r2;
YR_VALUE r3;
#ifdef PROFILING_ENABLED
YR_RULE* current_rule = NULL;
#endif
YR_RULE* rule;
YR_MATCH* match;
YR_OBJECT_FUNCTION* function;
char* identifier;
char* args_fmt;
int i;
int found;
int count;
int result = ERROR_SUCCESS;
int stop = FALSE;
int cycle = 0;
int tidx = context->tidx;
int stack_size;
#ifdef PROFILING_ENABLED
clock_t start = clock();
#endif
yr_get_configuration(YR_CONFIG_STACK_SIZE, (void*) &stack_size);
stack = (YR_VALUE*) yr_malloc(stack_size * sizeof(YR_VALUE));
if (stack == NULL)
return ERROR_INSUFFICIENT_MEMORY;
while(!stop)
{
switch(*ip)
{
case OP_NOP:
break;
case OP_HALT:
assert(sp == 0); // When HALT is reached the stack should be empty.
stop = TRUE;
break;
case OP_PUSH:
r1.i = *(uint64_t*)(ip + 1);
ip += sizeof(uint64_t);
push(r1);
break;
case OP_POP:
pop(r1);
break;
case OP_CLEAR_M:
r1.i = *(uint64_t*)(ip + 1);
ip += sizeof(uint64_t);
mem[r1.i] = 0;
break;
case OP_ADD_M:
r1.i = *(uint64_t*)(ip + 1);
ip += sizeof(uint64_t);
pop(r2);
if (!is_undef(r2))
mem[r1.i] += r2.i;
break;
case OP_INCR_M:
r1.i = *(uint64_t*)(ip + 1);
ip += sizeof(uint64_t);
mem[r1.i]++;
break;
case OP_PUSH_M:
r1.i = *(uint64_t*)(ip + 1);
ip += sizeof(uint64_t);
r1.i = mem[r1.i];
push(r1);
break;
case OP_POP_M:
r1.i = *(uint64_t*)(ip + 1);
ip += sizeof(uint64_t);
pop(r2);
mem[r1.i] = r2.i;
break;
case OP_SWAPUNDEF:
r1.i = *(uint64_t*)(ip + 1);
ip += sizeof(uint64_t);
pop(r2);
if (is_undef(r2))
{
r1.i = mem[r1.i];
push(r1);
}
else
{
push(r2);
}
break;
case OP_JNUNDEF:
pop(r1);
push(r1);
ip = jmp_if(!is_undef(r1), ip);
break;
case OP_JLE:
pop(r2);
pop(r1);
push(r1);
push(r2);
ip = jmp_if(r1.i <= r2.i, ip);
break;
case OP_JTRUE:
pop(r1);
push(r1);
ip = jmp_if(!is_undef(r1) && r1.i, ip);
break;
case OP_JFALSE:
pop(r1);
push(r1);
ip = jmp_if(is_undef(r1) || !r1.i, ip);
break;
case OP_AND:
pop(r2);
pop(r1);
if (is_undef(r1) || is_undef(r2))
r1.i = 0;
else
r1.i = r1.i && r2.i;
push(r1);
break;
case OP_OR:
pop(r2);
pop(r1);
if (is_undef(r1))
{
push(r2);
}
else if (is_undef(r2))
{
push(r1);
}
else
{
r1.i = r1.i || r2.i;
push(r1);
}
break;
case OP_NOT:
pop(r1);
if (is_undef(r1))
r1.i = UNDEFINED;
else
r1.i= !r1.i;
push(r1);
break;
case OP_MOD:
pop(r2);
pop(r1);
ensure_defined(r2);
ensure_defined(r1);
if (r2.i != 0)
r1.i = r1.i % r2.i;
else
r1.i = UNDEFINED;
push(r1);
break;
case OP_SHR:
pop(r2);
pop(r1);
ensure_defined(r2);
ensure_defined(r1);
r1.i = r1.i >> r2.i;
push(r1);
break;
case OP_SHL:
pop(r2);
pop(r1);
ensure_defined(r2);
ensure_defined(r1);
r1.i = r1.i << r2.i;
push(r1);
break;
case OP_BITWISE_NOT:
pop(r1);
ensure_defined(r1);
r1.i = ~r1.i;
push(r1);
break;
case OP_BITWISE_AND:
pop(r2);
pop(r1);
ensure_defined(r2);
ensure_defined(r1);
r1.i = r1.i & r2.i;
push(r1);
break;
case OP_BITWISE_OR:
pop(r2);
pop(r1);
ensure_defined(r2);
ensure_defined(r1);
r1.i = r1.i | r2.i;
push(r1);
break;
case OP_BITWISE_XOR:
pop(r2);
pop(r1);
ensure_defined(r2);
ensure_defined(r1);
r1.i = r1.i ^ r2.i;
push(r1);
break;
case OP_PUSH_RULE:
rule = *(YR_RULE**)(ip + 1);
ip += sizeof(uint64_t);
r1.i = rule->t_flags[tidx] & RULE_TFLAGS_MATCH ? 1 : 0;
push(r1);
break;
case OP_INIT_RULE:
#ifdef PROFILING_ENABLED
current_rule = *(YR_RULE**)(ip + 1);
#endif
ip += sizeof(uint64_t);
break;
case OP_MATCH_RULE:
pop(r1);
rule = *(YR_RULE**)(ip + 1);
ip += sizeof(uint64_t);
if (!is_undef(r1) && r1.i)
rule->t_flags[tidx] |= RULE_TFLAGS_MATCH;
else if (RULE_IS_GLOBAL(rule))
rule->ns->t_flags[tidx] |= NAMESPACE_TFLAGS_UNSATISFIED_GLOBAL;
#ifdef PROFILING_ENABLED
rule->clock_ticks += clock() - start;
start = clock();
#endif
break;
case OP_OBJ_LOAD:
identifier = *(char**)(ip + 1);
ip += sizeof(uint64_t);
r1.o = (YR_OBJECT*) yr_hash_table_lookup(
context->objects_table,
identifier,
NULL);
assert(r1.o != NULL);
push(r1);
break;
case OP_OBJ_FIELD:
identifier = *(char**)(ip + 1);
ip += sizeof(uint64_t);
pop(r1);
ensure_defined(r1);
r1.o = yr_object_lookup_field(r1.o, identifier);
assert(r1.o != NULL);
push(r1);
break;
case OP_OBJ_VALUE:
pop(r1);
ensure_defined(r1);
switch(r1.o->type)
{
case OBJECT_TYPE_INTEGER:
r1.i = ((YR_OBJECT_INTEGER*) r1.o)->value;
break;
case OBJECT_TYPE_FLOAT:
if (isnan(((YR_OBJECT_DOUBLE*) r1.o)->value))
r1.i = UNDEFINED;
else
r1.d = ((YR_OBJECT_DOUBLE*) r1.o)->value;
break;
case OBJECT_TYPE_STRING:
if (((YR_OBJECT_STRING*) r1.o)->value == NULL)
r1.i = UNDEFINED;
else
r1.p = ((YR_OBJECT_STRING*) r1.o)->value;
break;
default:
assert(FALSE);
}
push(r1);
break;
case OP_INDEX_ARRAY:
pop(r1); // index
pop(r2); // array
ensure_defined(r1);
ensure_defined(r2);
assert(r2.o->type == OBJECT_TYPE_ARRAY);
r1.o = yr_object_array_get_item(r2.o, 0, (int) r1.i);
if (r1.o == NULL)
r1.i = UNDEFINED;
push(r1);
break;
case OP_LOOKUP_DICT:
pop(r1); // key
pop(r2); // dictionary
ensure_defined(r1);
ensure_defined(r2);
assert(r2.o->type == OBJECT_TYPE_DICTIONARY);
r1.o = yr_object_dict_get_item(
r2.o, 0, r1.ss->c_string);
if (r1.o == NULL)
r1.i = UNDEFINED;
push(r1);
break;
case OP_CALL:
args_fmt = *(char**)(ip + 1);
ip += sizeof(uint64_t);
i = (int) strlen(args_fmt);
count = 0;
// pop arguments from stack and copy them to args array
while (i > 0)
{
pop(r1);
if (is_undef(r1)) // count the number of undefined args
count++;
args[i - 1] = r1;
i--;
}
pop(r2);
ensure_defined(r2);
if (count > 0)
{
// if there are undefined args, result for function call
// is undefined as well.
r1.i = UNDEFINED;
push(r1);
break;
}
function = (YR_OBJECT_FUNCTION*) r2.o;
result = ERROR_INTERNAL_FATAL_ERROR;
for (i = 0; i < MAX_OVERLOADED_FUNCTIONS; i++)
{
if (function->prototypes[i].arguments_fmt == NULL)
break;
if (strcmp(function->prototypes[i].arguments_fmt, args_fmt) == 0)
{
result = function->prototypes[i].code(args, context, function);
break;
}
}
assert(i < MAX_OVERLOADED_FUNCTIONS);
if (result == ERROR_SUCCESS)
{
r1.o = function->return_obj;
push(r1);
}
else
{
stop = TRUE;
}
break;
case OP_FOUND:
pop(r1);
r1.i = r1.s->matches[tidx].tail != NULL ? 1 : 0;
push(r1);
break;
case OP_FOUND_AT:
pop(r2);
pop(r1);
if (is_undef(r1))
{
r1.i = 0;
push(r1);
break;
}
match = r2.s->matches[tidx].head;
r3.i = FALSE;
while (match != NULL)
{
if (r1.i == match->base + match->offset)
{
r3.i = TRUE;
break;
}
if (r1.i < match->base + match->offset)
break;
match = match->next;
}
push(r3);
break;
case OP_FOUND_IN:
pop(r3);
pop(r2);
pop(r1);
ensure_defined(r1);
ensure_defined(r2);
match = r3.s->matches[tidx].head;
r3.i = FALSE;
while (match != NULL && !r3.i)
{
if (match->base + match->offset >= r1.i &&
match->base + match->offset <= r2.i)
{
r3.i = TRUE;
}
if (match->base + match->offset > r2.i)
break;
match = match->next;
}
push(r3);
break;
case OP_COUNT:
pop(r1);
r1.i = r1.s->matches[tidx].count;
push(r1);
break;
case OP_OFFSET:
pop(r2);
pop(r1);
ensure_defined(r1);
match = r2.s->matches[tidx].head;
i = 1;
r3.i = UNDEFINED;
while (match != NULL && r3.i == UNDEFINED)
{
if (r1.i == i)
r3.i = match->base + match->offset;
i++;
match = match->next;
}
push(r3);
break;
case OP_LENGTH:
pop(r2);
pop(r1);
ensure_defined(r1);
match = r2.s->matches[tidx].head;
i = 1;
r3.i = UNDEFINED;
while (match != NULL && r3.i == UNDEFINED)
{
if (r1.i == i)
r3.i = match->match_length;
i++;
match = match->next;
}
push(r3);
break;
case OP_OF:
found = 0;
count = 0;
pop(r1);
while (!is_undef(r1))
{
if (r1.s->matches[tidx].tail != NULL)
found++;
count++;
pop(r1);
}
pop(r2);
if (is_undef(r2))
r1.i = found >= count ? 1 : 0;
else
r1.i = found >= r2.i ? 1 : 0;
push(r1);
break;
case OP_FILESIZE:
r1.i = context->file_size;
push(r1);
break;
case OP_ENTRYPOINT:
r1.i = context->entry_point;
push(r1);
break;
case OP_INT8:
pop(r1);
r1.i = read_int8_t_little_endian(context->iterator, (size_t) r1.i);
push(r1);
break;
case OP_INT16:
pop(r1);
r1.i = read_int16_t_little_endian(context->iterator, (size_t) r1.i);
push(r1);
break;
case OP_INT32:
pop(r1);
r1.i = read_int32_t_little_endian(context->iterator, (size_t) r1.i);
push(r1);
break;
case OP_UINT8:
pop(r1);
r1.i = read_uint8_t_little_endian(context->iterator, (size_t) r1.i);
push(r1);
break;
case OP_UINT16:
pop(r1);
r1.i = read_uint16_t_little_endian(context->iterator, (size_t) r1.i);
push(r1);
break;
case OP_UINT32:
pop(r1);
r1.i = read_uint32_t_little_endian(context->iterator, (size_t) r1.i);
push(r1);
break;
case OP_INT8BE:
pop(r1);
r1.i = read_int8_t_big_endian(context->iterator, (size_t) r1.i);
push(r1);
break;
case OP_INT16BE:
pop(r1);
r1.i = read_int16_t_big_endian(context->iterator, (size_t) r1.i);
push(r1);
break;
case OP_INT32BE:
pop(r1);
r1.i = read_int32_t_big_endian(context->iterator, (size_t) r1.i);
push(r1);
break;
case OP_UINT8BE:
pop(r1);
r1.i = read_uint8_t_big_endian(context->iterator, (size_t) r1.i);
push(r1);
break;
case OP_UINT16BE:
pop(r1);
r1.i = read_uint16_t_big_endian(context->iterator, (size_t) r1.i);
push(r1);
break;
case OP_UINT32BE:
pop(r1);
r1.i = read_uint32_t_big_endian(context->iterator, (size_t) r1.i);
push(r1);
break;
case OP_CONTAINS:
pop(r2);
pop(r1);
ensure_defined(r1);
ensure_defined(r2);
r1.i = memmem(r1.ss->c_string, r1.ss->length,
r2.ss->c_string, r2.ss->length) != NULL;
push(r1);
break;
case OP_IMPORT:
r1.i = *(uint64_t*)(ip + 1);
ip += sizeof(uint64_t);
result = yr_modules_load((char*) r1.p, context);
if (result != ERROR_SUCCESS)
stop = TRUE;
break;
case OP_MATCHES:
pop(r2);
pop(r1);
ensure_defined(r2);
ensure_defined(r1);
if (r1.ss->length == 0)
{
r1.i = FALSE;
push(r1);
break;
}
result = yr_re_exec(
(uint8_t*) r2.re->code,
(uint8_t*) r1.ss->c_string,
r1.ss->length,
0,
r2.re->flags | RE_FLAGS_SCAN,
NULL,
NULL,
&found);
if (result != ERROR_SUCCESS)
stop = TRUE;
r1.i = found >= 0;
push(r1);
break;
case OP_INT_TO_DBL:
r1.i = *(uint64_t*)(ip + 1);
ip += sizeof(uint64_t);
r2 = stack[sp - r1.i];
if (is_undef(r2))
stack[sp - r1.i].i = UNDEFINED;
else
stack[sp - r1.i].d = (double) r2.i;
break;
case OP_STR_TO_BOOL:
pop(r1);
ensure_defined(r1);
r1.i = r1.ss->length > 0;
push(r1);
break;
case OP_INT_EQ:
pop(r2);
pop(r1);
ensure_defined(r2);
ensure_defined(r1);
r1.i = r1.i == r2.i;
push(r1);
break;
case OP_INT_NEQ:
pop(r2);
pop(r1);
ensure_defined(r2);
ensure_defined(r1);
r1.i = r1.i != r2.i;
push(r1);
break;
case OP_INT_LT:
pop(r2);
pop(r1);
ensure_defined(r2);
ensure_defined(r1);
r1.i = r1.i < r2.i;
push(r1);
break;
case OP_INT_GT:
pop(r2);
pop(r1);
ensure_defined(r2);
ensure_defined(r1);
r1.i = r1.i > r2.i;
push(r1);
break;
case OP_INT_LE:
pop(r2);
pop(r1);
ensure_defined(r2);
ensure_defined(r1);
r1.i = r1.i <= r2.i;
push(r1);
break;
case OP_INT_GE:
pop(r2);
pop(r1);
ensure_defined(r2);
ensure_defined(r1);
r1.i = r1.i >= r2.i;
push(r1);
break;
case OP_INT_ADD:
pop(r2);
pop(r1);
ensure_defined(r2);
ensure_defined(r1);
r1.i = r1.i + r2.i;
push(r1);
break;
case OP_INT_SUB:
pop(r2);
pop(r1);
ensure_defined(r2);
ensure_defined(r1);
r1.i = r1.i - r2.i;
push(r1);
break;
case OP_INT_MUL:
pop(r2);
pop(r1);
ensure_defined(r2);
ensure_defined(r1);
r1.i = r1.i * r2.i;
push(r1);
break;
case OP_INT_DIV:
pop(r2);
pop(r1);
ensure_defined(r2);
ensure_defined(r1);
if (r2.i != 0)
r1.i = r1.i / r2.i;
else
r1.i = UNDEFINED;
push(r1);
break;
case OP_INT_MINUS:
pop(r1);
ensure_defined(r1);
r1.i = -r1.i;
push(r1);
break;
case OP_DBL_LT:
pop(r2);
pop(r1);
ensure_defined(r2);
ensure_defined(r1);
r1.i = r1.d < r2.d;
push(r1);
break;
case OP_DBL_GT:
pop(r2);
pop(r1);
ensure_defined(r2);
ensure_defined(r1);
r1.i = r1.d > r2.d;
push(r1);
break;
case OP_DBL_LE:
pop(r2);
pop(r1);
ensure_defined(r2);
ensure_defined(r1);
r1.i = r1.d <= r2.d;
push(r1);
break;
case OP_DBL_GE:
pop(r2);
pop(r1);
ensure_defined(r2);
ensure_defined(r1);
r1.i = r1.d >= r2.d;
push(r1);
break;
case OP_DBL_EQ:
pop(r2);
pop(r1);
ensure_defined(r2);
ensure_defined(r1);
r1.i = r1.d == r2.d;
push(r1);
break;
case OP_DBL_NEQ:
pop(r2);
pop(r1);
ensure_defined(r2);
ensure_defined(r1);
r1.i = r1.d != r2.d;
push(r1);
break;
case OP_DBL_ADD:
pop(r2);
pop(r1);
ensure_defined(r2);
ensure_defined(r1);
r1.d = r1.d + r2.d;
push(r1);
break;
case OP_DBL_SUB:
pop(r2);
pop(r1);
ensure_defined(r2);
ensure_defined(r1);
r1.d = r1.d - r2.d;
push(r1);
break;
case OP_DBL_MUL:
pop(r2);
pop(r1);
ensure_defined(r2);
ensure_defined(r1);
r1.d = r1.d * r2.d;
push(r1);
break;
case OP_DBL_DIV:
pop(r2);
pop(r1);
ensure_defined(r2);
ensure_defined(r1);
r1.d = r1.d / r2.d;
push(r1);
break;
case OP_DBL_MINUS:
pop(r1);
ensure_defined(r1);
r1.d = -r1.d;
push(r1);
break;
case OP_STR_EQ:
case OP_STR_NEQ:
case OP_STR_LT:
case OP_STR_LE:
case OP_STR_GT:
case OP_STR_GE:
pop(r2);
pop(r1);
ensure_defined(r1);
ensure_defined(r2);
switch(*ip)
{
case OP_STR_EQ:
r1.i = (sized_string_cmp(r1.ss, r2.ss) == 0);
break;
case OP_STR_NEQ:
r1.i = (sized_string_cmp(r1.ss, r2.ss) != 0);
break;
case OP_STR_LT:
r1.i = (sized_string_cmp(r1.ss, r2.ss) < 0);
break;
case OP_STR_LE:
r1.i = (sized_string_cmp(r1.ss, r2.ss) <= 0);
break;
case OP_STR_GT:
r1.i = (sized_string_cmp(r1.ss, r2.ss) > 0);
break;
case OP_STR_GE:
r1.i = (sized_string_cmp(r1.ss, r2.ss) >= 0);
break;
}
push(r1);
break;
default:
// Unknown instruction, this shouldn't happen.
assert(FALSE);
}
if (timeout > 0) // timeout == 0 means no timeout
{
// Check for timeout every 10 instruction cycles.
if (++cycle == 10)
{
if (difftime(time(NULL), start_time) > timeout)
{
#ifdef PROFILING_ENABLED
assert(current_rule != NULL);
current_rule->clock_ticks += clock() - start;
#endif
result = ERROR_SCAN_TIMEOUT;
stop = TRUE;
}
cycle = 0;
}
}
ip++;
}
yr_modules_unload_all(context);
yr_free(stack);
return result; | 4441 | True | 1 |
CVE-2017-8929 | 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.0/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/VirusTotal/yara/issues/658', 'name': 'https://github.com/VirusTotal/yara/issues/658', 'refsource': 'CONFIRM', 'tags': ['Issue Tracking', 'Patch']}, {'url': 'https://github.com/VirusTotal/yara/commit/053e67e3ec81cc9268ce30eaf0d6663d8639ed1e', 'name': 'https://github.com/VirusTotal/yara/commit/053e67e3ec81cc9268ce30eaf0d6663d8639ed1e', 'refsource': 'CONFIRM', 'tags': ['Patch']}] | [{'description': [{'lang': 'en', 'value': 'CWE-416'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:virustotal:yara:3.5.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'The sized_string_cmp function in libyara/sizedstr.c in YARA 3.5.0 allows remote attackers to cause a denial of service (use-after-free and application crash) via a crafted rule.'}] | 2017-05-23T18:22Z | 2017-05-14T22:29Z | 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 | Victor M. Alvarez | 2017-05-14 10:27:39+02:00 | Fix issue #658 | 053e67e3ec81cc9268ce30eaf0d6663d8639ed1e | False | VirusTotal/yara | The pattern matching swiss knife | 2012-12-06 15:33:08 | 2022-08-26 10:13:14 | https://virustotal.github.io/yara/ | VirusTotal | 5938.0 | 1229.0 | yr_object_copy | yr_object_copy( YR_OBJECT * object , YR_OBJECT ** object_copy) | ['object', 'object_copy'] | int yr_object_copy(
YR_OBJECT* object,
YR_OBJECT** object_copy)
{
YR_OBJECT* copy;
YR_OBJECT* o;
YR_STRUCTURE_MEMBER* structure_member;
YR_OBJECT_FUNCTION* func;
YR_OBJECT_FUNCTION* func_copy;
int i;
*object_copy = NULL;
FAIL_ON_ERROR(yr_object_create(
object->type,
object->identifier,
NULL,
©));
switch(object->type)
{
case OBJECT_TYPE_INTEGER:
((YR_OBJECT_INTEGER*) copy)->value = UNDEFINED;
break;
case OBJECT_TYPE_STRING:
((YR_OBJECT_STRING*) copy)->value = NULL;
break;
case OBJECT_TYPE_FUNCTION:
func = (YR_OBJECT_FUNCTION*) object;
func_copy = (YR_OBJECT_FUNCTION*) copy;
FAIL_ON_ERROR_WITH_CLEANUP(
yr_object_copy(func->return_obj, &func_copy->return_obj),
yr_object_destroy(copy));
for (i = 0; i < MAX_OVERLOADED_FUNCTIONS; i++)
func_copy->prototypes[i] = func->prototypes[i];
break;
case OBJECT_TYPE_STRUCTURE:
structure_member = ((YR_OBJECT_STRUCTURE*) object)->members;
while (structure_member != NULL)
{
FAIL_ON_ERROR_WITH_CLEANUP(
yr_object_copy(structure_member->object, &o),
yr_object_destroy(copy));
FAIL_ON_ERROR_WITH_CLEANUP(
yr_object_structure_set_member(copy, o),
yr_free(o);
yr_object_destroy(copy));
structure_member = structure_member->next;
}
break;
case OBJECT_TYPE_ARRAY:
yr_object_copy(
((YR_OBJECT_ARRAY *) object)->prototype_item,
&o);
((YR_OBJECT_ARRAY *)copy)->prototype_item = o;
break;
case OBJECT_TYPE_DICTIONARY:
yr_object_copy(
((YR_OBJECT_DICTIONARY *) object)->prototype_item,
&o);
((YR_OBJECT_DICTIONARY *)copy)->prototype_item = o;
break;
default:
assert(FALSE);
}
*object_copy = copy;
return ERROR_SUCCESS;
} | 319 | True | 1 |
CVE-2017-9438 | 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.0/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/VirusTotal/yara/issues/674', 'name': 'https://github.com/VirusTotal/yara/issues/674', 'refsource': 'CONFIRM', 'tags': ['Issue Tracking', 'Patch']}, {'url': 'https://github.com/VirusTotal/yara/commit/10e8bd3071677dd1fa76beeef4bc2fc427cea5e7', 'name': 'https://github.com/VirusTotal/yara/commit/10e8bd3071677dd1fa76beeef4bc2fc427cea5e7', 'refsource': 'CONFIRM', 'tags': ['Patch']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/XXM224OLGI6KAOROLDPPGGCZ2OQVQ6HH/', 'name': 'FEDORA-2021-f41d5fc954', 'refsource': 'FEDORA', 'tags': []}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/FKNXSH5ERG6NELTXCYVJLUPJJJ2TNEBD/', 'name': 'FEDORA-2021-dd62918333', 'refsource': 'FEDORA', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-674'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:virustotal:yara:3.5.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'libyara/re.c in the regexp module in YARA 3.5.0 allows remote attackers to cause a denial of service (stack consumption) via a crafted rule (involving hex strings) that is mishandled in the _yr_re_emit function, a different vulnerability than CVE-2017-9304.'}] | 2021-05-06T14:15Z | 2017-06-05T17:29Z | Uncontrolled Recursion | The product does not properly control the amount of recursion which takes place, consuming excessive resources, such as allocated memory or the program stack. | https://cwe.mitre.org/data/definitions/674.html | 0 | Victor Manuel Alvarez | 2017-06-01 16:10:05+02:00 | Fix issue #674 for hex strings. | 10e8bd3071677dd1fa76beeef4bc2fc427cea5e7 | False | VirusTotal/yara | The pattern matching swiss knife | 2012-12-06 15:33:08 | 2022-08-26 10:13:14 | https://virustotal.github.io/yara/ | VirusTotal | 5938.0 | 1229.0 | yydestruct | yydestruct( const char * yymsg , int yytype , YYSTYPE * yyvaluep , void * yyscanner , HEX_LEX_ENVIRONMENT * lex_env) | ['yymsg', 'yytype', 'yyvaluep', 'yyscanner', 'lex_env'] |
static void
yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, void *yyscanner, HEX_LEX_ENVIRONMENT *lex_env)
{
YYUSE (yyvaluep);
YYUSE (yyscanner);
YYUSE (lex_env);
if (!yymsg)
yymsg = "Deleting";
YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
switch (yytype)
{
case 16: /* tokens */
#line 94 "hex_grammar.y" /* yacc.c:1257 */
{ yr_re_node_destroy(((*yyvaluep).re_node)); }
#line 1023 "hex_grammar.c" /* yacc.c:1257 */
break;
case 17: /* token_sequence */
#line 95 "hex_grammar.y" /* yacc.c:1257 */
{ yr_re_node_destroy(((*yyvaluep).re_node)); }
#line 1029 "hex_grammar.c" /* yacc.c:1257 */
break;
case 18: /* token_or_range */
#line 96 "hex_grammar.y" /* yacc.c:1257 */
{ yr_re_node_destroy(((*yyvaluep).re_node)); }
#line 1035 "hex_grammar.c" /* yacc.c:1257 */
break;
case 19: /* token */
#line 97 "hex_grammar.y" /* yacc.c:1257 */
{ yr_re_node_destroy(((*yyvaluep).re_node)); }
#line 1041 "hex_grammar.c" /* yacc.c:1257 */
break;
case 21: /* range */
#line 100 "hex_grammar.y" /* yacc.c:1257 */
{ yr_re_node_destroy(((*yyvaluep).re_node)); }
#line 1047 "hex_grammar.c" /* yacc.c:1257 */
break;
case 22: /* alternatives */
#line 99 "hex_grammar.y" /* yacc.c:1257 */
{ yr_re_node_destroy(((*yyvaluep).re_node)); }
#line 1053 "hex_grammar.c" /* yacc.c:1257 */
break;
case 23: /* byte */
#line 98 "hex_grammar.y" /* yacc.c:1257 */
{ yr_re_node_destroy(((*yyvaluep).re_node)); }
#line 1059 "hex_grammar.c" /* yacc.c:1257 */
break;
default:
break;
} | 204 | True | 1 |
|
CVE-2017-9438 | 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.0/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/VirusTotal/yara/issues/674', 'name': 'https://github.com/VirusTotal/yara/issues/674', 'refsource': 'CONFIRM', 'tags': ['Issue Tracking', 'Patch']}, {'url': 'https://github.com/VirusTotal/yara/commit/10e8bd3071677dd1fa76beeef4bc2fc427cea5e7', 'name': 'https://github.com/VirusTotal/yara/commit/10e8bd3071677dd1fa76beeef4bc2fc427cea5e7', 'refsource': 'CONFIRM', 'tags': ['Patch']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/XXM224OLGI6KAOROLDPPGGCZ2OQVQ6HH/', 'name': 'FEDORA-2021-f41d5fc954', 'refsource': 'FEDORA', 'tags': []}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/FKNXSH5ERG6NELTXCYVJLUPJJJ2TNEBD/', 'name': 'FEDORA-2021-dd62918333', 'refsource': 'FEDORA', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-674'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:virustotal:yara:3.5.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'libyara/re.c in the regexp module in YARA 3.5.0 allows remote attackers to cause a denial of service (stack consumption) via a crafted rule (involving hex strings) that is mishandled in the _yr_re_emit function, a different vulnerability than CVE-2017-9304.'}] | 2021-05-06T14:15Z | 2017-06-05T17:29Z | Uncontrolled Recursion | The product does not properly control the amount of recursion which takes place, consuming excessive resources, such as allocated memory or the program stack. | https://cwe.mitre.org/data/definitions/674.html | 0 | Victor Manuel Alvarez | 2017-06-01 16:10:05+02:00 | Fix issue #674 for hex strings. | 10e8bd3071677dd1fa76beeef4bc2fc427cea5e7 | False | VirusTotal/yara | The pattern matching swiss knife | 2012-12-06 15:33:08 | 2022-08-26 10:13:14 | https://virustotal.github.io/yara/ | VirusTotal | 5938.0 | 1229.0 | yyparse | yyparse( void * yyscanner , HEX_LEX_ENVIRONMENT * lex_env) | ['yyscanner', 'lex_env'] |
int
yyparse (void *yyscanner, HEX_LEX_ENVIRONMENT *lex_env)
{
/* The lookahead symbol. */
int yychar;
/* The semantic value of the lookahead symbol. */
/* Default value used for initialization, for pacifying older GCCs
or non-GCC compilers. */
YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
/* Number of syntax errors so far. */
int yynerrs;
int yystate;
/* Number of tokens to shift before error messages enabled. */
int yyerrstatus;
/* The stacks and their tools:
'yyss': related to states.
'yyvs': related to semantic values.
Refer to the stacks through separate pointers, to allow yyoverflow
to reallocate them elsewhere. */
/* The state stack. */
yytype_int16 yyssa[YYINITDEPTH];
yytype_int16 *yyss;
yytype_int16 *yyssp;
/* The semantic value stack. */
YYSTYPE yyvsa[YYINITDEPTH];
YYSTYPE *yyvs;
YYSTYPE *yyvsp;
YYSIZE_T yystacksize;
int yyn;
int yyresult;
/* Lookahead token as an internal (translated) token number. */
int yytoken = 0;
/* The variables used to return semantic value and location from the
action routines. */
YYSTYPE yyval;
#if YYERROR_VERBOSE
/* Buffer for error messages, and its allocated size. */
char yymsgbuf[128];
char *yymsg = yymsgbuf;
YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
#endif
#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
/* The number of symbols on the RHS of the reduced rule.
Keep to zero when no symbol should be popped. */
int yylen = 0;
yyssp = yyss = yyssa;
yyvsp = yyvs = yyvsa;
yystacksize = YYINITDEPTH;
YYDPRINTF ((stderr, "Starting parse\n"));
yystate = 0;
yyerrstatus = 0;
yynerrs = 0;
yychar = YYEMPTY; /* Cause a token to be read. */
goto yysetstate;
/*------------------------------------------------------------.
| yynewstate -- Push a new state, which is found in yystate. |
`------------------------------------------------------------*/
yynewstate:
/* In all cases, when you get here, the value and location stacks
have just been pushed. So pushing a state here evens the stacks. */
yyssp++;
yysetstate:
*yyssp = yystate;
if (yyss + yystacksize - 1 <= yyssp)
{
/* Get the current used size of the three stacks, in elements. */
YYSIZE_T yysize = yyssp - yyss + 1;
#ifdef yyoverflow
{
/* Give user a chance to reallocate the stack. Use copies of
these so that the &'s don't force the real ones into
memory. */
YYSTYPE *yyvs1 = yyvs;
yytype_int16 *yyss1 = yyss;
/* Each stack pointer address is followed by the size of the
data in use in that stack, in bytes. This used to be a
conditional around just the two extra args, but that might
be undefined if yyoverflow is a macro. */
yyoverflow (YY_("memory exhausted"),
&yyss1, yysize * sizeof (*yyssp),
&yyvs1, yysize * sizeof (*yyvsp),
&yystacksize);
yyss = yyss1;
yyvs = yyvs1;
}
#else /* no yyoverflow */
# ifndef YYSTACK_RELOCATE
goto yyexhaustedlab;
# else
/* Extend the stack our own way. */
if (YYMAXDEPTH <= yystacksize)
goto yyexhaustedlab;
yystacksize *= 2;
if (YYMAXDEPTH < yystacksize)
yystacksize = YYMAXDEPTH;
{
yytype_int16 *yyss1 = yyss;
union yyalloc *yyptr =
(union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
if (! yyptr)
goto yyexhaustedlab;
YYSTACK_RELOCATE (yyss_alloc, yyss);
YYSTACK_RELOCATE (yyvs_alloc, yyvs);
# undef YYSTACK_RELOCATE
if (yyss1 != yyssa)
YYSTACK_FREE (yyss1);
}
# endif
#endif /* no yyoverflow */
yyssp = yyss + yysize - 1;
yyvsp = yyvs + yysize - 1;
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
(unsigned long int) yystacksize));
if (yyss + yystacksize - 1 <= yyssp)
YYABORT;
}
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
if (yystate == YYFINAL)
YYACCEPT;
goto yybackup;
/*-----------.
| yybackup. |
`-----------*/
yybackup:
/* Do appropriate processing given the current state. Read a
lookahead token if we need one and don't already have one. */
/* First try to decide what to do without reference to lookahead token. */
yyn = yypact[yystate];
if (yypact_value_is_default (yyn))
goto yydefault;
/* Not known => get a lookahead token if don't already have one. */
/* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
if (yychar == YYEMPTY)
{
YYDPRINTF ((stderr, "Reading a token: "));
yychar = yylex (&yylval, yyscanner, lex_env);
}
if (yychar <= YYEOF)
{
yychar = yytoken = YYEOF;
YYDPRINTF ((stderr, "Now at end of input.\n"));
}
else
{
yytoken = YYTRANSLATE (yychar);
YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
}
/* If the proper action on seeing token YYTOKEN is to reduce or to
detect an error, take that action. */
yyn += yytoken;
if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
goto yydefault;
yyn = yytable[yyn];
if (yyn <= 0)
{
if (yytable_value_is_error (yyn))
goto yyerrlab;
yyn = -yyn;
goto yyreduce;
}
/* Count tokens shifted since error; after three, turn off error
status. */
if (yyerrstatus)
yyerrstatus--;
/* Shift the lookahead token. */
YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
/* Discard the shifted token. */
yychar = YYEMPTY;
yystate = yyn;
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
*++yyvsp = yylval;
YY_IGNORE_MAYBE_UNINITIALIZED_END
goto yynewstate;
/*-----------------------------------------------------------.
| yydefault -- do the default action for the current state. |
`-----------------------------------------------------------*/
yydefault:
yyn = yydefact[yystate];
if (yyn == 0)
goto yyerrlab;
goto yyreduce;
/*-----------------------------.
| yyreduce -- Do a reduction. |
`-----------------------------*/
yyreduce:
/* yyn is the number of a rule to reduce with. */
yylen = yyr2[yyn];
/* If YYLEN is nonzero, implement the default value of the action:
'$$ = $1'.
Otherwise, the following line sets YYVAL to garbage.
This behavior is undocumented and Bison
users should not rely upon it. Assigning to YYVAL
unconditionally makes the parser a bit smaller, and it avoids a
GCC warning that YYVAL may be used uninitialized. */
yyval = yyvsp[1-yylen];
YY_REDUCE_PRINT (yyn);
switch (yyn)
{
case 2:
#line 106 "hex_grammar.y" /* yacc.c:1646 */
{
RE_AST* re_ast = yyget_extra(yyscanner);
re_ast->root_node = (yyvsp[-1].re_node);
}
#line 1330 "hex_grammar.c" /* yacc.c:1646 */
break;
case 3:
#line 115 "hex_grammar.y" /* yacc.c:1646 */
{
(yyval.re_node) = (yyvsp[0].re_node);
}
#line 1338 "hex_grammar.c" /* yacc.c:1646 */
break;
case 4:
#line 119 "hex_grammar.y" /* yacc.c:1646 */
{
(yyval.re_node) = yr_re_node_create(RE_NODE_CONCAT, (yyvsp[-1].re_node), (yyvsp[0].re_node));
DESTROY_NODE_IF((yyval.re_node) == NULL, (yyvsp[-1].re_node));
DESTROY_NODE_IF((yyval.re_node) == NULL, (yyvsp[0].re_node));
ERROR_IF((yyval.re_node) == NULL, ERROR_INSUFFICIENT_MEMORY);
}
#line 1351 "hex_grammar.c" /* yacc.c:1646 */
break;
case 5:
#line 128 "hex_grammar.y" /* yacc.c:1646 */
{
RE_NODE* new_concat;
RE_NODE* leftmost_concat = NULL;
RE_NODE* leftmost_node = (yyvsp[-1].re_node);
(yyval.re_node) = NULL;
/*
Some portions of the code (i.e: yr_re_split_at_chaining_point)
expect a left-unbalanced tree where the right child of a concat node
can't be another concat node. A concat node must be always the left
child of its parent if the parent is also a concat. For this reason
the can't simply create two new concat nodes arranged like this:
concat
/ \
/ \
token's \
subtree concat
/ \
/ \
/ \
token_sequence's token's
subtree subtree
Instead we must insert the subtree for the first token as the
leftmost node of the token_sequence subtree.
*/
while (leftmost_node->type == RE_NODE_CONCAT)
{
leftmost_concat = leftmost_node;
leftmost_node = leftmost_node->left;
}
new_concat = yr_re_node_create(
RE_NODE_CONCAT, (yyvsp[-2].re_node), leftmost_node);
if (new_concat != NULL)
{
if (leftmost_concat != NULL)
{
leftmost_concat->left = new_concat;
(yyval.re_node) = yr_re_node_create(RE_NODE_CONCAT, (yyvsp[-1].re_node), (yyvsp[0].re_node));
}
else
{
(yyval.re_node) = yr_re_node_create(RE_NODE_CONCAT, new_concat, (yyvsp[0].re_node));
}
}
DESTROY_NODE_IF((yyval.re_node) == NULL, (yyvsp[-2].re_node));
DESTROY_NODE_IF((yyval.re_node) == NULL, (yyvsp[-1].re_node));
DESTROY_NODE_IF((yyval.re_node) == NULL, (yyvsp[0].re_node));
ERROR_IF((yyval.re_node) == NULL, ERROR_INSUFFICIENT_MEMORY);
}
#line 1413 "hex_grammar.c" /* yacc.c:1646 */
break;
case 6:
#line 190 "hex_grammar.y" /* yacc.c:1646 */
{
(yyval.re_node) = (yyvsp[0].re_node);
}
#line 1421 "hex_grammar.c" /* yacc.c:1646 */
break;
case 7:
#line 194 "hex_grammar.y" /* yacc.c:1646 */
{
(yyval.re_node) = yr_re_node_create(RE_NODE_CONCAT, (yyvsp[-1].re_node), (yyvsp[0].re_node));
DESTROY_NODE_IF((yyval.re_node) == NULL, (yyvsp[-1].re_node));
DESTROY_NODE_IF((yyval.re_node) == NULL, (yyvsp[0].re_node));
ERROR_IF((yyval.re_node) == NULL, ERROR_INSUFFICIENT_MEMORY);
}
#line 1434 "hex_grammar.c" /* yacc.c:1646 */
break;
case 8:
#line 207 "hex_grammar.y" /* yacc.c:1646 */
{
(yyval.re_node) = (yyvsp[0].re_node);
}
#line 1442 "hex_grammar.c" /* yacc.c:1646 */
break;
case 9:
#line 211 "hex_grammar.y" /* yacc.c:1646 */
{
(yyval.re_node) = (yyvsp[0].re_node);
(yyval.re_node)->greedy = FALSE;
}
#line 1451 "hex_grammar.c" /* yacc.c:1646 */
break;
case 10:
#line 220 "hex_grammar.y" /* yacc.c:1646 */
{
lex_env->token_count++;
if (lex_env->token_count > MAX_HEX_STRING_TOKENS)
{
yr_re_node_destroy((yyvsp[0].re_node));
yyerror(yyscanner, lex_env, "string too long");
YYABORT;
}
(yyval.re_node) = (yyvsp[0].re_node);
}
#line 1468 "hex_grammar.c" /* yacc.c:1646 */
break;
case 11:
#line 233 "hex_grammar.y" /* yacc.c:1646 */
{
lex_env->inside_or++;
}
#line 1476 "hex_grammar.c" /* yacc.c:1646 */
break;
case 12:
#line 237 "hex_grammar.y" /* yacc.c:1646 */
{
(yyval.re_node) = (yyvsp[-1].re_node);
lex_env->inside_or--;
}
#line 1485 "hex_grammar.c" /* yacc.c:1646 */
break;
case 13:
#line 246 "hex_grammar.y" /* yacc.c:1646 */
{
if ((yyvsp[-1].integer) <= 0)
{
yyerror(yyscanner, lex_env, "invalid jump length");
YYABORT;
}
if (lex_env->inside_or && (yyvsp[-1].integer) > STRING_CHAINING_THRESHOLD)
{
yyerror(yyscanner, lex_env, "jumps over "
STR(STRING_CHAINING_THRESHOLD)
" now allowed inside alternation (|)");
YYABORT;
}
(yyval.re_node) = yr_re_node_create(RE_NODE_RANGE_ANY, NULL, NULL);
ERROR_IF((yyval.re_node) == NULL, ERROR_INSUFFICIENT_MEMORY);
(yyval.re_node)->start = (int) (yyvsp[-1].integer);
(yyval.re_node)->end = (int) (yyvsp[-1].integer);
}
#line 1512 "hex_grammar.c" /* yacc.c:1646 */
break;
case 14:
#line 269 "hex_grammar.y" /* yacc.c:1646 */
{
if (lex_env->inside_or &&
((yyvsp[-3].integer) > STRING_CHAINING_THRESHOLD ||
(yyvsp[-1].integer) > STRING_CHAINING_THRESHOLD) )
{
yyerror(yyscanner, lex_env, "jumps over "
STR(STRING_CHAINING_THRESHOLD)
" now allowed inside alternation (|)");
YYABORT;
}
if ((yyvsp[-3].integer) < 0 || (yyvsp[-1].integer) < 0)
{
yyerror(yyscanner, lex_env, "invalid negative jump length");
YYABORT;
}
if ((yyvsp[-3].integer) > (yyvsp[-1].integer))
{
yyerror(yyscanner, lex_env, "invalid jump range");
YYABORT;
}
(yyval.re_node) = yr_re_node_create(RE_NODE_RANGE_ANY, NULL, NULL);
ERROR_IF((yyval.re_node) == NULL, ERROR_INSUFFICIENT_MEMORY);
(yyval.re_node)->start = (int) (yyvsp[-3].integer);
(yyval.re_node)->end = (int) (yyvsp[-1].integer);
}
#line 1548 "hex_grammar.c" /* yacc.c:1646 */
break;
case 15:
#line 301 "hex_grammar.y" /* yacc.c:1646 */
{
if (lex_env->inside_or)
{
yyerror(yyscanner, lex_env,
"unbounded jumps not allowed inside alternation (|)");
YYABORT;
}
if ((yyvsp[-2].integer) < 0)
{
yyerror(yyscanner, lex_env, "invalid negative jump length");
YYABORT;
}
(yyval.re_node) = yr_re_node_create(RE_NODE_RANGE_ANY, NULL, NULL);
ERROR_IF((yyval.re_node) == NULL, ERROR_INSUFFICIENT_MEMORY);
(yyval.re_node)->start = (int) (yyvsp[-2].integer);
(yyval.re_node)->end = INT_MAX;
}
#line 1574 "hex_grammar.c" /* yacc.c:1646 */
break;
case 16:
#line 323 "hex_grammar.y" /* yacc.c:1646 */
{
if (lex_env->inside_or)
{
yyerror(yyscanner, lex_env,
"unbounded jumps not allowed inside alternation (|)");
YYABORT;
}
(yyval.re_node) = yr_re_node_create(RE_NODE_RANGE_ANY, NULL, NULL);
ERROR_IF((yyval.re_node) == NULL, ERROR_INSUFFICIENT_MEMORY);
(yyval.re_node)->start = 0;
(yyval.re_node)->end = INT_MAX;
}
#line 1594 "hex_grammar.c" /* yacc.c:1646 */
break;
case 17:
#line 343 "hex_grammar.y" /* yacc.c:1646 */
{
(yyval.re_node) = (yyvsp[0].re_node);
}
#line 1602 "hex_grammar.c" /* yacc.c:1646 */
break;
case 18:
#line 347 "hex_grammar.y" /* yacc.c:1646 */
{
mark_as_not_fast_regexp();
(yyval.re_node) = yr_re_node_create(RE_NODE_ALT, (yyvsp[-2].re_node), (yyvsp[0].re_node));
DESTROY_NODE_IF((yyval.re_node) == NULL, (yyvsp[-2].re_node));
DESTROY_NODE_IF((yyval.re_node) == NULL, (yyvsp[0].re_node));
ERROR_IF((yyval.re_node) == NULL, ERROR_INSUFFICIENT_MEMORY);
}
#line 1617 "hex_grammar.c" /* yacc.c:1646 */
break;
case 19:
#line 361 "hex_grammar.y" /* yacc.c:1646 */
{
(yyval.re_node) = yr_re_node_create(RE_NODE_LITERAL, NULL, NULL);
ERROR_IF((yyval.re_node) == NULL, ERROR_INSUFFICIENT_MEMORY);
(yyval.re_node)->value = (int) (yyvsp[0].integer);
}
#line 1629 "hex_grammar.c" /* yacc.c:1646 */
break;
case 20:
#line 369 "hex_grammar.y" /* yacc.c:1646 */
{
uint8_t mask = (uint8_t) ((yyvsp[0].integer) >> 8);
if (mask == 0x00)
{
(yyval.re_node) = yr_re_node_create(RE_NODE_ANY, NULL, NULL);
ERROR_IF((yyval.re_node) == NULL, ERROR_INSUFFICIENT_MEMORY);
}
else
{
(yyval.re_node) = yr_re_node_create(RE_NODE_MASKED_LITERAL, NULL, NULL);
ERROR_IF((yyval.re_node) == NULL, ERROR_INSUFFICIENT_MEMORY);
(yyval.re_node)->value = (yyvsp[0].integer) & 0xFF;
(yyval.re_node)->mask = mask;
}
}
#line 1653 "hex_grammar.c" /* yacc.c:1646 */
break;
#line 1657 "hex_grammar.c" /* yacc.c:1646 */
default: break;
}
/* User semantic actions sometimes alter yychar, and that requires
that yytoken be updated with the new translation. We take the
approach of translating immediately before every use of yytoken.
One alternative is translating here after every semantic action,
but that translation would be missed if the semantic action invokes
YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
incorrect destructor might then be invoked immediately. In the
case of YYERROR or YYBACKUP, subsequent parser actions might lead
to an incorrect destructor call or verbose syntax error message
before the lookahead is translated. */
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
YYPOPSTACK (yylen);
yylen = 0;
YY_STACK_PRINT (yyss, yyssp);
*++yyvsp = yyval;
/* Now 'shift' the result of the reduction. Determine what state
that goes to, based on the state we popped back to and the rule
number reduced by. */
yyn = yyr1[yyn];
yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
yystate = yytable[yystate];
else
yystate = yydefgoto[yyn - YYNTOKENS];
goto yynewstate;
/*--------------------------------------.
| yyerrlab -- here on detecting error. |
`--------------------------------------*/
yyerrlab:
/* Make sure we have latest lookahead translation. See comments at
user semantic actions for why this is necessary. */
yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
/* If not already recovering from an error, report this error. */
if (!yyerrstatus)
{
++yynerrs;
#if ! YYERROR_VERBOSE
yyerror (yyscanner, lex_env, YY_("syntax error"));
#else
# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
yyssp, yytoken)
{
char const *yymsgp = YY_("syntax error");
int yysyntax_error_status;
yysyntax_error_status = YYSYNTAX_ERROR;
if (yysyntax_error_status == 0)
yymsgp = yymsg;
else if (yysyntax_error_status == 1)
{
if (yymsg != yymsgbuf)
YYSTACK_FREE (yymsg);
yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
if (!yymsg)
{
yymsg = yymsgbuf;
yymsg_alloc = sizeof yymsgbuf;
yysyntax_error_status = 2;
}
else
{
yysyntax_error_status = YYSYNTAX_ERROR;
yymsgp = yymsg;
}
}
yyerror (yyscanner, lex_env, yymsgp);
if (yysyntax_error_status == 2)
goto yyexhaustedlab;
}
# undef YYSYNTAX_ERROR
#endif
}
if (yyerrstatus == 3)
{
/* If just tried and failed to reuse lookahead token after an
error, discard it. */
if (yychar <= YYEOF)
{
/* Return failure if at end of input. */
if (yychar == YYEOF)
YYABORT;
}
else
{
yydestruct ("Error: discarding",
yytoken, &yylval, yyscanner, lex_env);
yychar = YYEMPTY;
}
}
/* Else will try to reuse lookahead token after shifting the error
token. */
goto yyerrlab1;
/*---------------------------------------------------.
| yyerrorlab -- error raised explicitly by YYERROR. |
`---------------------------------------------------*/
yyerrorlab:
/* Pacify compilers like GCC when the user code never invokes
YYERROR and the label yyerrorlab therefore never appears in user
code. */
if (/*CONSTCOND*/ 0)
goto yyerrorlab;
/* Do not reclaim the symbols of the rule whose action triggered
this YYERROR. */
YYPOPSTACK (yylen);
yylen = 0;
YY_STACK_PRINT (yyss, yyssp);
yystate = *yyssp;
goto yyerrlab1;
/*-------------------------------------------------------------.
| yyerrlab1 -- common code for both syntax error and YYERROR. |
`-------------------------------------------------------------*/
yyerrlab1:
yyerrstatus = 3; /* Each real token shifted decrements this. */
for (;;)
{
yyn = yypact[yystate];
if (!yypact_value_is_default (yyn))
{
yyn += YYTERROR;
if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
{
yyn = yytable[yyn];
if (0 < yyn)
break;
}
}
/* Pop the current state because it cannot handle the error token. */
if (yyssp == yyss)
YYABORT;
yydestruct ("Error: popping",
yystos[yystate], yyvsp, yyscanner, lex_env);
YYPOPSTACK (1);
yystate = *yyssp;
YY_STACK_PRINT (yyss, yyssp);
}
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
*++yyvsp = yylval;
YY_IGNORE_MAYBE_UNINITIALIZED_END
/* Shift the error token. */
YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
yystate = yyn;
goto yynewstate;
/*-------------------------------------.
| yyacceptlab -- YYACCEPT comes here. |
`-------------------------------------*/
yyacceptlab:
yyresult = 0;
goto yyreturn;
/*-----------------------------------.
| yyabortlab -- YYABORT comes here. |
`-----------------------------------*/
yyabortlab:
yyresult = 1;
goto yyreturn;
#if !defined yyoverflow || YYERROR_VERBOSE
/*-------------------------------------------------.
| yyexhaustedlab -- memory exhaustion comes here. |
`-------------------------------------------------*/
yyexhaustedlab:
yyerror (yyscanner, lex_env, YY_("memory exhausted"));
yyresult = 2;
/* Fall through. */
#endif
yyreturn:
if (yychar != YYEMPTY)
{
/* Make sure we have latest lookahead translation. See comments at
user semantic actions for why this is necessary. */
yytoken = YYTRANSLATE (yychar);
yydestruct ("Cleanup: discarding lookahead",
yytoken, &yylval, yyscanner, lex_env);
}
/* Do not reclaim the symbols of the rule whose action triggered
this YYABORT or YYACCEPT. */
YYPOPSTACK (yylen);
YY_STACK_PRINT (yyss, yyssp);
while (yyssp != yyss)
{
yydestruct ("Cleanup: popping",
yystos[*yyssp], yyvsp, yyscanner, lex_env);
YYPOPSTACK (1);
}
#ifndef yyoverflow
if (yyss != yyssa)
YYSTACK_FREE (yyss);
#endif
#if YYERROR_VERBOSE
if (yymsg != yymsgbuf)
YYSTACK_FREE (yymsg);
#endif | 2691 | True | 1 |
|
CVE-2017-9465 | False | False | False | True | AV:N/AC:M/Au:N/C:P/I:N/A:P | NETWORK | MEDIUM | NONE | PARTIAL | NONE | PARTIAL | 5.8 | CVSS:3.0/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:H | LOCAL | LOW | NONE | REQUIRED | UNCHANGED | HIGH | NONE | HIGH | 7.1 | HIGH | 1.8 | 5.2 | nan | [{'url': 'https://github.com/VirusTotal/yara/issues/678', 'name': 'https://github.com/VirusTotal/yara/issues/678', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/VirusTotal/yara/commit/992480c30f75943e9cd6245bb2015c7737f9b661', 'name': 'https://github.com/VirusTotal/yara/commit/992480c30f75943e9cd6245bb2015c7737f9b661', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:virustotal:yara:3.6.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'The yr_arena_write_data function in YARA 3.6.1 allows remote attackers to cause a denial of service (buffer over-read and application crash) or obtain sensitive information from process memory via a crafted file that is mishandled in the yr_re_fast_exec function in libyara/re.c and the _yr_scan_match_callback function in libyara/scan.c.'}] | 2019-10-03T00:03Z | 2017-06-06T21:29Z | 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 | Victor M. Alvarez | 2017-06-06 19:07:27+02:00 | Fix buffer overrun (issue #678). Add assert for detecting this kind of issues earlier. | 992480c30f75943e9cd6245bb2015c7737f9b661 | False | VirusTotal/yara | The pattern matching swiss knife | 2012-12-06 15:33:08 | 2022-08-26 10:13:14 | https://virustotal.github.io/yara/ | VirusTotal | 5938.0 | 1229.0 | yr_re_fast_exec | yr_re_fast_exec( uint8_t * code , uint8_t * input_data , size_t input_forwards_size , size_t input_backwards_size , int flags , RE_MATCH_CALLBACK_FUNC callback , void * callback_args , int * matches) | ['code', 'input_data', 'input_forwards_size', 'input_backwards_size', 'flags', 'callback', 'callback_args', 'matches'] | int yr_re_fast_exec(
uint8_t* code,
uint8_t* input_data,
size_t input_forwards_size,
size_t input_backwards_size,
int flags,
RE_MATCH_CALLBACK_FUNC callback,
void* callback_args,
int* matches)
{
RE_REPEAT_ANY_ARGS* repeat_any_args;
uint8_t* code_stack[MAX_FAST_RE_STACK];
uint8_t* input_stack[MAX_FAST_RE_STACK];
int matches_stack[MAX_FAST_RE_STACK];
uint8_t* ip = code;
uint8_t* input = input_data;
uint8_t* next_input;
uint8_t* next_opcode;
uint8_t mask;
uint8_t value;
int i;
int stop;
int input_incr;
int sp = 0;
int bytes_matched;
int max_bytes_matched;
max_bytes_matched = flags & RE_FLAGS_BACKWARDS ?
(int) input_backwards_size :
(int) input_forwards_size;
input_incr = flags & RE_FLAGS_BACKWARDS ? -1 : 1;
if (flags & RE_FLAGS_BACKWARDS)
input--;
code_stack[sp] = code;
input_stack[sp] = input;
matches_stack[sp] = 0;
sp++;
while (sp > 0)
{
sp--;
ip = code_stack[sp];
input = input_stack[sp];
bytes_matched = matches_stack[sp];
stop = FALSE;
while(!stop)
{
if (*ip == RE_OPCODE_MATCH)
{
if (flags & RE_FLAGS_EXHAUSTIVE)
{
FAIL_ON_ERROR(callback(
flags & RE_FLAGS_BACKWARDS ? input + 1 : input_data,
bytes_matched,
flags,
callback_args));
break;
}
else
{
if (matches != NULL)
*matches = bytes_matched;
return ERROR_SUCCESS;
}
}
if (bytes_matched >= max_bytes_matched)
break;
switch(*ip)
{
case RE_OPCODE_LITERAL:
if (*input == *(ip + 1))
{
bytes_matched++;
input += input_incr;
ip += 2;
}
else
{
stop = TRUE;
}
break;
case RE_OPCODE_MASKED_LITERAL:
value = *(int16_t*)(ip + 1) & 0xFF;
mask = *(int16_t*)(ip + 1) >> 8;
if ((*input & mask) == value)
{
bytes_matched++;
input += input_incr;
ip += 3;
}
else
{
stop = TRUE;
}
break;
case RE_OPCODE_ANY:
bytes_matched++;
input += input_incr;
ip += 1;
break;
case RE_OPCODE_REPEAT_ANY_UNGREEDY:
repeat_any_args = (RE_REPEAT_ANY_ARGS*)(ip + 1);
next_opcode = ip + 1 + sizeof(RE_REPEAT_ANY_ARGS);
for (i = repeat_any_args->min + 1; i <= repeat_any_args->max; i++)
{
next_input = input + i * input_incr;
if (bytes_matched + i >= max_bytes_matched)
break;
if ( *(next_opcode) != RE_OPCODE_LITERAL ||
(*(next_opcode) == RE_OPCODE_LITERAL &&
*(next_opcode + 1) == *next_input))
{
if (sp >= MAX_FAST_RE_STACK)
return -4;
code_stack[sp] = next_opcode;
input_stack[sp] = next_input;
matches_stack[sp] = bytes_matched + i;
sp++;
}
}
input += input_incr * repeat_any_args->min;
bytes_matched += repeat_any_args->min;
ip = next_opcode;
break;
default:
assert(FALSE);
}
}
}
if (matches != NULL)
*matches = -1;
return ERROR_SUCCESS;
} | 571 | True | 1 |
CVE-2017-11328 | 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.0/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 | nan | [{'url': 'https://github.com/VirusTotal/yara/commit/4a342f01e5439b9bb901aff1c6c23c536baeeb3f', 'name': 'https://github.com/VirusTotal/yara/commit/4a342f01e5439b9bb901aff1c6c23c536baeeb3f', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-119'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:virustotal:yara:3.4.0:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:virustotal:yara:3.6.2:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:virustotal:yara:3.3.0:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:virustotal:yara:3.6.3:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:virustotal:yara:3.5.0:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:virustotal:yara:3.6.0:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:virustotal:yara:3.6.1:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:virustotal:yara:3.1.0:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:virustotal:yara:3.2.0:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:virustotal:yara:3.0.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Heap buffer overflow in the yr_object_array_set_item() function in object.c in YARA 3.x allows a denial-of-service attack by scanning a crafted .NET file.'}] | 2017-08-04T14:30Z | 2017-07-17T13:18Z | 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 | Victor Manuel Alvarez | 2017-07-05 10:01:03+02:00 | Fix heap overflow (reported by Jurriaan Bremer)
When setting a new array item with yr_object_array_set_item() the array size is doubled if the index for the new item is larger than the already allocated ones. No further checks were made to ensure that the index fits into the array after doubling its capacity. If the array capacity was for example 64, and a new object is assigned to an index larger than 128 the overflow occurs. As yr_object_array_set_item() is usually invoked with indexes that increase monotonically by one, this bug never triggered before. But the new "dotnet" module has the potential to allow the exploitation of this bug by scanning a specially crafted .NET binary. | 4a342f01e5439b9bb901aff1c6c23c536baeeb3f | False | VirusTotal/yara | The pattern matching swiss knife | 2012-12-06 15:33:08 | 2022-08-26 10:13:14 | https://virustotal.github.io/yara/ | VirusTotal | 5938.0 | 1229.0 | yr_object_array_set_item | yr_object_array_set_item( YR_OBJECT * object , YR_OBJECT * item , int index) | ['object', 'item', 'index'] | int yr_object_array_set_item(
YR_OBJECT* object,
YR_OBJECT* item,
int index)
{
YR_OBJECT_ARRAY* array;
int i;
int count;
assert(index >= 0);
assert(object->type == OBJECT_TYPE_ARRAY);
array = object_as_array(object);
if (array->items == NULL)
{
count = yr_max(64, (index + 1) * 2);
array->items = (YR_ARRAY_ITEMS*) yr_malloc(
sizeof(YR_ARRAY_ITEMS) + count * sizeof(YR_OBJECT*));
if (array->items == NULL)
return ERROR_INSUFFICIENT_MEMORY;
memset(array->items->objects, 0, count * sizeof(YR_OBJECT*));
array->items->count = count;
}
else if (index >= array->items->count)
{
count = array->items->count * 2;
array->items = (YR_ARRAY_ITEMS*) yr_realloc(
array->items,
sizeof(YR_ARRAY_ITEMS) + count * sizeof(YR_OBJECT*));
if (array->items == NULL)
return ERROR_INSUFFICIENT_MEMORY;
for (i = array->items->count; i < count; i++)
array->items->objects[i] = NULL;
array->items->count = count;
}
item->parent = object;
array->items->objects[index] = item;
return ERROR_SUCCESS;
} | 253 | True | 1 |
CVE-2017-7870 | 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.0/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 | True | [{'url': 'https://github.com/LibreOffice/core/commit/62a97e6a561ce65e88d4c537a1b82c336f012722', 'name': 'https://github.com/LibreOffice/core/commit/62a97e6a561ce65e88d4c537a1b82c336f012722', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=372', 'name': 'https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=372', 'refsource': 'MISC', 'tags': ['Third Party Advisory', 'VDB Entry']}, {'url': 'http://www.securityfocus.com/bid/97671', 'name': '97671', 'refsource': 'BID', 'tags': ['Third Party Advisory', 'VDB Entry']}, {'url': 'https://security.gentoo.org/glsa/201706-28', 'name': 'GLSA-201706-28', 'refsource': 'GENTOO', 'tags': []}, {'url': 'http://www.securitytracker.com/id/1039029', 'name': '1039029', 'refsource': 'SECTRACK', 'tags': []}, {'url': 'http://www.debian.org/security/2017/dsa-3837', 'name': 'DSA-3837', 'refsource': 'DEBIAN', 'tags': []}, {'url': 'http://www.libreoffice.org/about-us/security/advisories/cve-2017-7870/', 'name': 'http://www.libreoffice.org/about-us/security/advisories/cve-2017-7870/', 'refsource': 'CONFIRM', 'tags': []}, {'url': 'https://access.redhat.com/errata/RHSA-2017:1975', 'name': 'RHSA-2017:1975', 'refsource': 'REDHAT', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-787'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:libreoffice:libreoffice:*:beta2:*:*:*:*:*:*', 'versionEndIncluding': '5.3.0.0', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'LibreOffice before 2017-01-02 has an out-of-bounds write caused by a heap-based buffer overflow related to the tools::Polygon::Insert function in tools/source/generic/poly.cxx.'}] | 2018-01-05T02:31Z | 2017-04-14T04:59Z | 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 | Caolán McNamara | 2017-01-02 11:53:31+00:00 | ofz#372 check if ImplSplit succeeded
Change-Id: I1e34295fe3ee5f77e787f583616d52fa92a0eca4 | 62a97e6a561ce65e88d4c537a1b82c336f012722 | False | LibreOffice/core | Read-only LibreOffice core repo - no pull request (use gerrit instead https://gerrit.libreoffice.org/) - don't download zip, use https://dev-www.libreoffice.org/bundles/ instead | 2013-10-31 15:46:52 | 2022-08-26 07:36:21 | https://www.libreoffice.org/ | LibreOffice | 1673.0 | 496.0 | ImplPolygon::ImplSplit | ImplPolygon::ImplSplit( sal_uInt16 nPos , sal_uInt16 nSpace , ImplPolygon const * pInitPoly) | ['nPos', 'nSpace', 'pInitPoly'] | void ImplPolygon::ImplSplit( sal_uInt16 nPos, sal_uInt16 nSpace, ImplPolygon const * pInitPoly )
{
//Can't fit this in :-(, throw ?
if (mnPoints + nSpace > USHRT_MAX)
return;
const sal_uInt16 nNewSize = mnPoints + nSpace;
const std::size_t nSpaceSize = static_cast<std::size_t>(nSpace) * sizeof(Point);
if( nPos >= mnPoints )
{
// Append at the back
nPos = mnPoints;
ImplSetSize( nNewSize );
if( pInitPoly )
{
memcpy( mpPointAry + nPos, pInitPoly->mpPointAry, nSpaceSize );
if( pInitPoly->mpFlagAry )
memcpy( mpFlagAry + nPos, pInitPoly->mpFlagAry, nSpace );
}
}
else
{
const sal_uInt16 nSecPos = nPos + nSpace;
const sal_uInt16 nRest = mnPoints - nPos;
Point* pNewAry = reinterpret_cast<Point*>(new char[ static_cast<std::size_t>(nNewSize) * sizeof(Point) ]);
memcpy( pNewAry, mpPointAry, nPos * sizeof( Point ) );
if( pInitPoly )
memcpy( pNewAry + nPos, pInitPoly->mpPointAry, nSpaceSize );
else
memset( pNewAry + nPos, 0, nSpaceSize );
memcpy( pNewAry + nSecPos, mpPointAry + nPos, nRest * sizeof( Point ) );
delete[] reinterpret_cast<char*>(mpPointAry);
// consider FlagArray
if( mpFlagAry )
{
PolyFlags* pNewFlagAry = new PolyFlags[ nNewSize ];
memcpy( pNewFlagAry, mpFlagAry, nPos );
if( pInitPoly && pInitPoly->mpFlagAry )
memcpy( pNewFlagAry + nPos, pInitPoly->mpFlagAry, nSpace );
else
memset( pNewFlagAry + nPos, 0, nSpace );
memcpy( pNewFlagAry + nSecPos, mpFlagAry + nPos, nRest );
delete[] mpFlagAry;
mpFlagAry = pNewFlagAry;
}
mpPointAry = pNewAry;
mnPoints = nNewSize;
}
} | 321 | True | 1 |
CVE-2017-7870 | 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.0/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 | True | [{'url': 'https://github.com/LibreOffice/core/commit/62a97e6a561ce65e88d4c537a1b82c336f012722', 'name': 'https://github.com/LibreOffice/core/commit/62a97e6a561ce65e88d4c537a1b82c336f012722', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=372', 'name': 'https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=372', 'refsource': 'MISC', 'tags': ['Third Party Advisory', 'VDB Entry']}, {'url': 'http://www.securityfocus.com/bid/97671', 'name': '97671', 'refsource': 'BID', 'tags': ['Third Party Advisory', 'VDB Entry']}, {'url': 'https://security.gentoo.org/glsa/201706-28', 'name': 'GLSA-201706-28', 'refsource': 'GENTOO', 'tags': []}, {'url': 'http://www.securitytracker.com/id/1039029', 'name': '1039029', 'refsource': 'SECTRACK', 'tags': []}, {'url': 'http://www.debian.org/security/2017/dsa-3837', 'name': 'DSA-3837', 'refsource': 'DEBIAN', 'tags': []}, {'url': 'http://www.libreoffice.org/about-us/security/advisories/cve-2017-7870/', 'name': 'http://www.libreoffice.org/about-us/security/advisories/cve-2017-7870/', 'refsource': 'CONFIRM', 'tags': []}, {'url': 'https://access.redhat.com/errata/RHSA-2017:1975', 'name': 'RHSA-2017:1975', 'refsource': 'REDHAT', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-787'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:libreoffice:libreoffice:*:beta2:*:*:*:*:*:*', 'versionEndIncluding': '5.3.0.0', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'LibreOffice before 2017-01-02 has an out-of-bounds write caused by a heap-based buffer overflow related to the tools::Polygon::Insert function in tools/source/generic/poly.cxx.'}] | 2018-01-05T02:31Z | 2017-04-14T04:59Z | 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 | Caolán McNamara | 2017-01-02 11:53:31+00:00 | ofz#372 check if ImplSplit succeeded
Change-Id: I1e34295fe3ee5f77e787f583616d52fa92a0eca4 | 62a97e6a561ce65e88d4c537a1b82c336f012722 | False | LibreOffice/core | Read-only LibreOffice core repo - no pull request (use gerrit instead https://gerrit.libreoffice.org/) - don't download zip, use https://dev-www.libreoffice.org/bundles/ instead | 2013-10-31 15:46:52 | 2022-08-26 07:36:21 | https://www.libreoffice.org/ | LibreOffice | 1673.0 | 496.0 | tools::Polygon::Insert | tools::Polygon::Insert( sal_uInt16 nPos , const Point & rPt) | ['nPos', 'rPt'] | void Polygon::Insert( sal_uInt16 nPos, const Point& rPt )
{
ImplMakeUnique();
if( nPos >= mpImplPolygon->mnPoints )
nPos = mpImplPolygon->mnPoints;
mpImplPolygon->ImplSplit( nPos, 1 );
mpImplPolygon->mpPointAry[ nPos ] = rPt;
} | 50 | True | 1 |
CVE-2017-7856 | 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.0/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 | True | [{'url': 'https://github.com/LibreOffice/core/commit/28e61b634353110445e334ccaa415d7fb6629d62', 'name': 'https://github.com/LibreOffice/core/commit/28e61b634353110445e334ccaa415d7fb6629d62', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=817', 'name': 'https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=817', 'refsource': 'MISC', 'tags': ['Third Party Advisory', 'VDB Entry']}, {'url': 'http://www.securityfocus.com/bid/97667', 'name': '97667', 'refsource': 'BID', 'tags': ['Third Party Advisory', 'VDB Entry']}, {'url': 'http://www.libreoffice.org/about-us/security/advisories/cve-2017-7856/', 'name': 'http://www.libreoffice.org/about-us/security/advisories/cve-2017-7856/', 'refsource': 'CONFIRM', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-787'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:libreoffice:libreoffice:*:*:*:*:*:*:*:*', 'versionEndIncluding': '5.2.6.1', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'LibreOffice before 2017-03-11 has an out-of-bounds write caused by a heap-based buffer overflow in the SVMConverter::ImplConvertFromSVM1 function in vcl/source/gdi/svmconverter.cxx.'}] | 2017-11-15T02:29Z | 2017-04-14T04:59Z | 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 | Caolán McNamara | 2017-03-11 17:29:05+00:00 | ofz#817 nStrLen-1 changed to nStrLen-3
regression from...
commit ff8f6629287d0d1bdbcf4f8ed16cb8d077d08c7a
Author: Caolán McNamara <[email protected]>
Date: Thu Jan 19 16:56:34 2017 +0000
Resolves: ofz#424 guard against broken dxary length
but this weird typo doesn't appears in the 5-2 and 5-3 backports,
odd how I managed that
Change-Id: I5fb1db2284d48ee78e717d41274a3d37ab0255cf | 28e61b634353110445e334ccaa415d7fb6629d62 | False | LibreOffice/core | Read-only LibreOffice core repo - no pull request (use gerrit instead https://gerrit.libreoffice.org/) - don't download zip, use https://dev-www.libreoffice.org/bundles/ instead | 2013-10-31 15:46:52 | 2022-08-26 07:36:21 | https://www.libreoffice.org/ | LibreOffice | 1673.0 | 496.0 | SVMConverter::ImplConvertFromSVM1 | SVMConverter::ImplConvertFromSVM1( SvStream & rIStm , GDIMetaFile & rMtf) | ['rIStm', 'rMtf'] | void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf )
{
const sal_uLong nPos = rIStm.Tell();
const SvStreamEndian nOldFormat = rIStm.GetEndian();
rIStm.SetEndian( SvStreamEndian::LITTLE );
char aCode[ 5 ];
Size aPrefSz;
// read header
rIStm.ReadBytes(aCode, sizeof(aCode)); // Identifier
sal_Int16 nSize(0);
rIStm.ReadInt16( nSize ); // Size
sal_Int16 nVersion(0);
rIStm.ReadInt16( nVersion ); // Version
sal_Int32 nTmp32(0);
rIStm.ReadInt32( nTmp32 );
aPrefSz.Width() = nTmp32; // PrefSize.Width()
rIStm.ReadInt32( nTmp32 );
aPrefSz.Height() = nTmp32; // PrefSize.Height()
// check header-magic and version
if( rIStm.GetError()
|| ( memcmp( aCode, "SVGDI", sizeof( aCode ) ) != 0 )
|| ( nVersion != 200 ) )
{
rIStm.SetError( SVSTREAM_FILEFORMAT_ERROR );
rIStm.SetEndian( nOldFormat );
rIStm.Seek( nPos );
return;
}
LineInfo aLineInfo( LineStyle::NONE, 0 );
std::stack<std::unique_ptr<LineInfo>> aLIStack;
ScopedVclPtrInstance< VirtualDevice > aFontVDev;
rtl_TextEncoding eActualCharSet = osl_getThreadTextEncoding();
bool bFatLine = false;
tools::Polygon aActionPoly;
Rectangle aRect;
Point aPt, aPt1;
Size aSz;
Color aActionColor;
sal_uInt32 nUnicodeCommentStreamPos = 0;
sal_Int32 nUnicodeCommentActionNumber = 0;
rMtf.SetPrefSize(aPrefSz);
MapMode aMapMode;
if (ImplReadMapMode(rIStm, aMapMode)) // MapMode
rMtf.SetPrefMapMode(aMapMode);
sal_Int32 nActions(0);
rIStm.ReadInt32(nActions); // Action count
if (nActions < 0)
{
SAL_WARN("vcl.gdi", "svm claims negative action count (" << nActions << ")");
nActions = 0;
}
const size_t nMinActionSize = sizeof(sal_uInt16) + sizeof(sal_Int32);
const size_t nMaxPossibleActions = rIStm.remainingSize() / nMinActionSize;
if (static_cast<sal_uInt32>(nActions) > nMaxPossibleActions)
{
SAL_WARN("vcl.gdi", "svm claims more actions (" << nActions << ") than stream could provide, truncating");
nActions = nMaxPossibleActions;
}
size_t nLastPolygonAction(0);
for (sal_Int32 i = 0; i < nActions && rIStm.good(); ++i)
{
sal_Int16 nType(0);
rIStm.ReadInt16(nType);
sal_Int32 nActBegin = rIStm.Tell();
sal_Int32 nActionSize(0);
rIStm.ReadInt32(nActionSize);
SAL_WARN_IF( ( nType > 33 ) && ( nType < 1024 ), "vcl.gdi", "Unknown GDIMetaAction while converting!" );
switch( nType )
{
case GDI_PIXEL_ACTION:
{
ReadPair( rIStm, aPt );
ImplReadColor( rIStm, aActionColor );
rMtf.AddAction( new MetaPixelAction( aPt, aActionColor ) );
}
break;
case GDI_POINT_ACTION:
{
ReadPair( rIStm, aPt );
rMtf.AddAction( new MetaPointAction( aPt ) );
}
break;
case GDI_LINE_ACTION:
{
ReadPair( rIStm, aPt );
ReadPair( rIStm, aPt1 );
rMtf.AddAction( new MetaLineAction( aPt, aPt1, aLineInfo ) );
}
break;
case GDI_LINEJOIN_ACTION :
{
sal_Int16 nLineJoin(0);
rIStm.ReadInt16( nLineJoin );
aLineInfo.SetLineJoin((basegfx::B2DLineJoin)nLineJoin);
}
break;
case GDI_LINECAP_ACTION :
{
sal_Int16 nLineCap(0);
rIStm.ReadInt16( nLineCap );
aLineInfo.SetLineCap((css::drawing::LineCap)nLineCap);
}
break;
case GDI_LINEDASHDOT_ACTION :
{
sal_Int16 a(0);
sal_Int32 b(0);
rIStm.ReadInt16( a ); aLineInfo.SetDashCount(a);
rIStm.ReadInt32( b ); aLineInfo.SetDashLen(b);
rIStm.ReadInt16( a ); aLineInfo.SetDotCount(a);
rIStm.ReadInt32( b ); aLineInfo.SetDotLen(b);
rIStm.ReadInt32( b ); aLineInfo.SetDistance(b);
if(((aLineInfo.GetDashCount() && aLineInfo.GetDashLen())
|| (aLineInfo.GetDotCount() && aLineInfo.GetDotLen()))
&& aLineInfo.GetDistance())
{
aLineInfo.SetStyle(LineStyle::Dash);
}
}
break;
case GDI_EXTENDEDPOLYGON_ACTION :
{
// read the tools::PolyPolygon in every case
tools::PolyPolygon aInputPolyPolygon;
ImplReadExtendedPolyPolygonAction(rIStm, aInputPolyPolygon);
// now check if it can be set somewhere
if(nLastPolygonAction < rMtf.GetActionSize())
{
MetaPolyLineAction* pPolyLineAction = dynamic_cast< MetaPolyLineAction* >(rMtf.GetAction(nLastPolygonAction));
if(pPolyLineAction)
{
// replace MetaPolyLineAction when we have a single polygon. Do not rely on the
// same point count; the originally written GDI_POLYLINE_ACTION may have been
// Subdivided for better quality for older usages
if(1 == aInputPolyPolygon.Count())
{
MetaAction* pAction = rMtf.ReplaceAction(
new MetaPolyLineAction(
aInputPolyPolygon.GetObject(0),
pPolyLineAction->GetLineInfo()),
nLastPolygonAction);
if(pAction)
pAction->Delete();
}
}
else
{
MetaPolyPolygonAction* pPolyPolygonAction = dynamic_cast< MetaPolyPolygonAction* >(rMtf.GetAction(nLastPolygonAction));
if(pPolyPolygonAction)
{
// replace MetaPolyPolygonAction when we have a curved polygon. Do rely on the
// same sub-polygon count
if(pPolyPolygonAction->GetPolyPolygon().Count() == aInputPolyPolygon.Count())
{
MetaAction* pAction = rMtf.ReplaceAction(
new MetaPolyPolygonAction(
aInputPolyPolygon),
nLastPolygonAction);
if(pAction)
pAction->Delete();
}
}
else
{
MetaPolygonAction* pPolygonAction = dynamic_cast< MetaPolygonAction* >(rMtf.GetAction(nLastPolygonAction));
if(pPolygonAction)
{
// replace MetaPolygonAction
if(1 == aInputPolyPolygon.Count())
{
MetaAction* pAction = rMtf.ReplaceAction(
new MetaPolygonAction(
aInputPolyPolygon.GetObject(0)),
nLastPolygonAction);
if(pAction)
pAction->Delete();
}
}
}
}
}
}
break;
case GDI_RECT_ACTION:
{
ImplReadRect( rIStm, aRect );
sal_Int32 nTmp(0), nTmp1(0);
rIStm.ReadInt32( nTmp ).ReadInt32( nTmp1 );
if( nTmp || nTmp1 )
rMtf.AddAction( new MetaRoundRectAction( aRect, nTmp, nTmp1 ) );
else
{
rMtf.AddAction( new MetaRectAction( aRect ) );
if( bFatLine )
rMtf.AddAction( new MetaPolyLineAction( aRect, aLineInfo ) );
}
}
break;
case GDI_ELLIPSE_ACTION:
{
ImplReadRect( rIStm, aRect );
if( bFatLine )
{
const tools::Polygon aPoly( aRect.Center(), aRect.GetWidth() >> 1, aRect.GetHeight() >> 1 );
rMtf.AddAction( new MetaPushAction( PushFlags::LINECOLOR ) );
rMtf.AddAction( new MetaLineColorAction( COL_TRANSPARENT, false ) );
rMtf.AddAction( new MetaPolygonAction( aPoly ) );
rMtf.AddAction( new MetaPopAction() );
rMtf.AddAction( new MetaPolyLineAction( aPoly, aLineInfo ) );
}
else
rMtf.AddAction( new MetaEllipseAction( aRect ) );
}
break;
case GDI_ARC_ACTION:
{
ImplReadRect( rIStm, aRect );
ReadPair( rIStm, aPt );
ReadPair( rIStm, aPt1 );
if( bFatLine )
{
const tools::Polygon aPoly( aRect, aPt, aPt1, PolyStyle::Arc );
rMtf.AddAction( new MetaPushAction( PushFlags::LINECOLOR ) );
rMtf.AddAction( new MetaLineColorAction( COL_TRANSPARENT, false ) );
rMtf.AddAction( new MetaPolygonAction( aPoly ) );
rMtf.AddAction( new MetaPopAction() );
rMtf.AddAction( new MetaPolyLineAction( aPoly, aLineInfo ) );
}
else
rMtf.AddAction( new MetaArcAction( aRect, aPt, aPt1 ) );
}
break;
case GDI_PIE_ACTION:
{
ImplReadRect( rIStm, aRect );
ReadPair( rIStm, aPt );
ReadPair( rIStm, aPt1 );
if( bFatLine )
{
const tools::Polygon aPoly( aRect, aPt, aPt1, PolyStyle::Pie );
rMtf.AddAction( new MetaPushAction( PushFlags::LINECOLOR ) );
rMtf.AddAction( new MetaLineColorAction( COL_TRANSPARENT, false ) );
rMtf.AddAction( new MetaPolygonAction( aPoly ) );
rMtf.AddAction( new MetaPopAction() );
rMtf.AddAction( new MetaPolyLineAction( aPoly, aLineInfo ) );
}
else
rMtf.AddAction( new MetaPieAction( aRect, aPt, aPt1 ) );
}
break;
case GDI_INVERTRECT_ACTION:
case GDI_HIGHLIGHTRECT_ACTION:
{
ImplReadRect( rIStm, aRect );
rMtf.AddAction( new MetaPushAction( PushFlags::RASTEROP ) );
rMtf.AddAction( new MetaRasterOpAction( RasterOp::Invert ) );
rMtf.AddAction( new MetaRectAction( aRect ) );
rMtf.AddAction( new MetaPopAction() );
}
break;
case GDI_POLYLINE_ACTION:
{
if (ImplReadPoly(rIStm, aActionPoly))
{
nLastPolygonAction = rMtf.GetActionSize();
if( bFatLine )
rMtf.AddAction( new MetaPolyLineAction( aActionPoly, aLineInfo ) );
else
rMtf.AddAction( new MetaPolyLineAction( aActionPoly ) );
}
}
break;
case GDI_POLYGON_ACTION:
{
if (ImplReadPoly(rIStm, aActionPoly))
{
if( bFatLine )
{
rMtf.AddAction( new MetaPushAction( PushFlags::LINECOLOR ) );
rMtf.AddAction( new MetaLineColorAction( COL_TRANSPARENT, false ) );
rMtf.AddAction( new MetaPolygonAction( aActionPoly ) );
rMtf.AddAction( new MetaPopAction() );
rMtf.AddAction( new MetaPolyLineAction( aActionPoly, aLineInfo ) );
}
else
{
nLastPolygonAction = rMtf.GetActionSize();
rMtf.AddAction( new MetaPolygonAction( aActionPoly ) );
}
}
}
break;
case GDI_POLYPOLYGON_ACTION:
{
tools::PolyPolygon aPolyPoly;
if (ImplReadPolyPoly(rIStm, aPolyPoly))
{
if( bFatLine )
{
rMtf.AddAction( new MetaPushAction( PushFlags::LINECOLOR ) );
rMtf.AddAction( new MetaLineColorAction( COL_TRANSPARENT, false ) );
rMtf.AddAction( new MetaPolyPolygonAction( aPolyPoly ) );
rMtf.AddAction( new MetaPopAction() );
for( sal_uInt16 nPoly = 0, nCount = aPolyPoly.Count(); nPoly < nCount; nPoly++ )
rMtf.AddAction( new MetaPolyLineAction( aPolyPoly[ nPoly ], aLineInfo ) );
}
else
{
nLastPolygonAction = rMtf.GetActionSize();
rMtf.AddAction( new MetaPolyPolygonAction( aPolyPoly ) );
}
}
}
break;
case GDI_FONT_ACTION:
{
vcl::Font aFont;
char aName[LF_FACESIZE+1];
ImplReadColor( rIStm, aActionColor ); aFont.SetColor( aActionColor );
ImplReadColor( rIStm, aActionColor ); aFont.SetFillColor( aActionColor );
size_t nRet = rIStm.ReadBytes(aName, LF_FACESIZE);
aName[nRet] = 0;
aFont.SetFamilyName( OUString( aName, strlen(aName), rIStm.GetStreamCharSet() ) );
sal_Int32 nWidth(0), nHeight(0);
rIStm.ReadInt32(nWidth).ReadInt32(nHeight);
sal_Int16 nCharOrient(0), nLineOrient(0);
rIStm.ReadInt16(nCharOrient).ReadInt16(nLineOrient);
sal_Int16 nCharSet(0), nFamily(0), nPitch(0), nAlign(0), nWeight(0), nUnderline(0), nStrikeout(0);
rIStm.ReadInt16(nCharSet).ReadInt16(nFamily).ReadInt16(nPitch).ReadInt16(nAlign).ReadInt16(nWeight).ReadInt16(nUnderline).ReadInt16(nStrikeout);
bool bItalic(false), bOutline(false), bShadow(false), bTransparent(false);
rIStm.ReadCharAsBool(bItalic).ReadCharAsBool(bOutline).ReadCharAsBool(bShadow).ReadCharAsBool(bTransparent);
aFont.SetFontSize( Size( nWidth, nHeight ) );
aFont.SetCharSet( (rtl_TextEncoding) nCharSet );
aFont.SetFamily( (FontFamily) nFamily );
aFont.SetPitch( (FontPitch) nPitch );
aFont.SetAlignment( (FontAlign) nAlign );
aFont.SetWeight( ( nWeight == 1 ) ? WEIGHT_LIGHT : ( nWeight == 2 ) ? WEIGHT_NORMAL :
( nWeight == 3 ) ? WEIGHT_BOLD : WEIGHT_DONTKNOW );
aFont.SetUnderline( (FontLineStyle) nUnderline );
aFont.SetStrikeout( (FontStrikeout) nStrikeout );
aFont.SetItalic( bItalic ? ITALIC_NORMAL : ITALIC_NONE );
aFont.SetOutline( bOutline );
aFont.SetShadow( bShadow );
aFont.SetOrientation( nLineOrient );
aFont.SetTransparent( bTransparent );
eActualCharSet = aFont.GetCharSet();
if ( eActualCharSet == RTL_TEXTENCODING_DONTKNOW )
eActualCharSet = osl_getThreadTextEncoding();
rMtf.AddAction( new MetaFontAction( aFont ) );
rMtf.AddAction( new MetaTextAlignAction( aFont.GetAlignment() ) );
rMtf.AddAction( new MetaTextColorAction( aFont.GetColor() ) );
rMtf.AddAction( new MetaTextFillColorAction( aFont.GetFillColor(), !aFont.IsTransparent() ) );
// #106172# Track font relevant data in shadow VDev
aFontVDev->SetFont( aFont );
}
break;
case GDI_TEXT_ACTION:
{
sal_Int32 nIndex(0), nLen(0), nTmp(0);
ReadPair( rIStm, aPt ).ReadInt32( nIndex ).ReadInt32( nLen ).ReadInt32( nTmp );
if (nTmp > 0)
{
OString aByteStr = read_uInt8s_ToOString(rIStm, nTmp);
sal_uInt8 nTerminator = 0;
rIStm.ReadUChar( nTerminator );
SAL_WARN_IF( nTerminator != 0, "vcl.gdi", "expected string to be NULL terminated" );
OUString aStr(OStringToOUString(aByteStr, eActualCharSet));
if ( nUnicodeCommentActionNumber == i )
ImplReadUnicodeComment( nUnicodeCommentStreamPos, rIStm, aStr );
rMtf.AddAction( new MetaTextAction( aPt, aStr, nIndex, nLen ) );
}
rIStm.Seek( nActBegin + nActionSize );
}
break;
case GDI_TEXTARRAY_ACTION:
{
sal_Int32 nIndex(0), nLen(0), nAryLen(0), nTmp(0);
ReadPair( rIStm, aPt ).ReadInt32( nIndex ).ReadInt32( nLen ).ReadInt32( nTmp ).ReadInt32( nAryLen );
if (nTmp > 0)
{
OString aByteStr = read_uInt8s_ToOString(rIStm, nTmp);
sal_uInt8 nTerminator = 0;
rIStm.ReadUChar( nTerminator );
SAL_WARN_IF( nTerminator != 0, "vcl.gdi", "expected string to be NULL terminated" );
OUString aStr(OStringToOUString(aByteStr, eActualCharSet));
std::unique_ptr<long[]> pDXAry;
sal_Int32 nDXAryLen = 0;
if (nAryLen > 0)
{
const size_t nMinRecordSize = sizeof(sal_Int32);
const size_t nMaxRecords = rIStm.remainingSize() / nMinRecordSize;
if (static_cast<sal_uInt32>(nAryLen) > nMaxRecords)
{
SAL_WARN("vcl.gdi", "Parsing error: " << nMaxRecords <<
" max possible entries, but " << nAryLen << " claimed, truncating");
nAryLen = nMaxRecords;
}
sal_Int32 nStrLen( aStr.getLength() );
nDXAryLen = std::max(nAryLen, nStrLen);
if (nDXAryLen < nLen)
{
//MetaTextArrayAction ctor expects pDXAry to be >= nLen if set, so if this can't
//be achieved, don't read it, it's utterly broken.
SAL_WARN("vcl.gdi", "dxary too short, discarding completely");
rIStm.SeekRel(sizeof(sal_Int32) * nDXAryLen);
nLen = 0;
nIndex = 0;
}
else
{
pDXAry.reset(new long[nDXAryLen]);
for (sal_Int32 j = 0; j < nAryLen; ++j)
rIStm.ReadInt32( nTmp ), pDXAry[ j ] = nTmp;
// #106172# Add last DX array elem, if missing
if( nAryLen != nStrLen )
{
if (nAryLen+1 == nStrLen && nIndex >= 0)
{
std::unique_ptr<long[]> pTmpAry(new long[nStrLen]);
aFontVDev->GetTextArray( aStr, pTmpAry.get(), nIndex, nLen );
// now, the difference between the
// last and the second last DX array
// is the advancement for the last
// glyph. Thus, to complete our meta
// action's DX array, just add that
// difference to last elem and store
// in very last.
if( nStrLen > 1 )
pDXAry[ nStrLen-3 ] = pDXAry[ nStrLen-2 ] + pTmpAry[ nStrLen-1 ] - pTmpAry[ nStrLen-2 ];
else
pDXAry[ nStrLen-1 ] = pTmpAry[ nStrLen-1 ]; // len=1: 0th position taken to be 0
}
#ifdef DBG_UTIL
else
OSL_FAIL("More than one DX array element missing on SVM import");
#endif
}
}
}
if ( nUnicodeCommentActionNumber == i )
ImplReadUnicodeComment( nUnicodeCommentStreamPos, rIStm, aStr );
rMtf.AddAction( new MetaTextArrayAction( aPt, aStr, pDXAry.get(), nIndex, nLen ) );
}
rIStm.Seek( nActBegin + nActionSize );
}
break;
case GDI_STRETCHTEXT_ACTION:
{
sal_Int32 nIndex(0), nLen(0), nWidth(0), nTmp(0);
ReadPair( rIStm, aPt ).ReadInt32( nIndex ).ReadInt32( nLen ).ReadInt32( nTmp ).ReadInt32( nWidth );
if (nTmp > 0)
{
OString aByteStr = read_uInt8s_ToOString(rIStm, nTmp);
sal_uInt8 nTerminator = 0;
rIStm.ReadUChar( nTerminator );
SAL_WARN_IF( nTerminator != 0, "vcl.gdi", "expected string to be NULL terminated" );
OUString aStr(OStringToOUString(aByteStr, eActualCharSet));
if ( nUnicodeCommentActionNumber == i )
ImplReadUnicodeComment( nUnicodeCommentStreamPos, rIStm, aStr );
rMtf.AddAction( new MetaStretchTextAction( aPt, nWidth, aStr, nIndex, nLen ) );
}
rIStm.Seek( nActBegin + nActionSize );
}
break;
case GDI_BITMAP_ACTION:
{
Bitmap aBmp;
ReadPair( rIStm, aPt );
ReadDIB(aBmp, rIStm, true);
rMtf.AddAction( new MetaBmpAction( aPt, aBmp ) );
}
break;
case GDI_BITMAPSCALE_ACTION:
{
Bitmap aBmp;
ReadPair( rIStm, aPt );
ReadPair( rIStm, aSz );
ReadDIB(aBmp, rIStm, true);
rMtf.AddAction( new MetaBmpScaleAction( aPt, aSz, aBmp ) );
}
break;
case GDI_BITMAPSCALEPART_ACTION:
{
Bitmap aBmp;
Size aSz2;
ReadPair( rIStm, aPt );
ReadPair( rIStm, aSz );
ReadPair( rIStm, aPt1 );
ReadPair( rIStm, aSz2 );
ReadDIB(aBmp, rIStm, true);
rMtf.AddAction( new MetaBmpScalePartAction( aPt, aSz, aPt1, aSz2, aBmp ) );
}
break;
case GDI_PEN_ACTION:
{
sal_Int32 nPenWidth;
sal_Int16 nPenStyle;
ImplReadColor( rIStm, aActionColor );
rIStm.ReadInt32( nPenWidth ).ReadInt16( nPenStyle );
aLineInfo.SetStyle( nPenStyle ? LineStyle::Solid : LineStyle::NONE );
aLineInfo.SetWidth( nPenWidth );
bFatLine = nPenStyle && !aLineInfo.IsDefault();
rMtf.AddAction( new MetaLineColorAction( aActionColor, nPenStyle != 0 ) );
}
break;
case GDI_FILLBRUSH_ACTION:
{
sal_Int16 nBrushStyle;
ImplReadColor( rIStm, aActionColor );
rIStm.SeekRel( 6 );
rIStm.ReadInt16( nBrushStyle );
rMtf.AddAction( new MetaFillColorAction( aActionColor, nBrushStyle != 0 ) );
rIStm.SeekRel( 2 );
}
break;
case GDI_MAPMODE_ACTION:
{
if (ImplReadMapMode(rIStm, aMapMode))
{
rMtf.AddAction(new MetaMapModeAction(aMapMode));
// #106172# Track font relevant data in shadow VDev
aFontVDev->SetMapMode(aMapMode);
};
}
break;
case GDI_CLIPREGION_ACTION:
{
vcl::Region aRegion;
sal_Int16 nRegType;
sal_Int16 bIntersect;
bool bClip = false;
rIStm.ReadInt16( nRegType ).ReadInt16( bIntersect );
ImplReadRect( rIStm, aRect );
switch( nRegType )
{
case 0:
break;
case 1:
{
Rectangle aRegRect;
ImplReadRect( rIStm, aRegRect );
aRegion = vcl::Region( aRegRect );
bClip = true;
}
break;
case 2:
{
if (ImplReadPoly(rIStm, aActionPoly))
{
aRegion = vcl::Region( aActionPoly );
bClip = true;
}
}
break;
case 3:
{
bool bSuccess = true;
tools::PolyPolygon aPolyPoly;
sal_Int32 nPolyCount32(0);
rIStm.ReadInt32(nPolyCount32);
sal_uInt16 nPolyCount(nPolyCount32);
for (sal_uInt16 j = 0; j < nPolyCount && rIStm.good(); ++j)
{
if (!ImplReadPoly(rIStm, aActionPoly))
{
bSuccess = false;
break;
}
aPolyPoly.Insert(aActionPoly);
}
if (bSuccess)
{
aRegion = vcl::Region( aPolyPoly );
bClip = true;
}
}
break;
}
if( bIntersect )
aRegion.Intersect( aRect );
rMtf.AddAction( new MetaClipRegionAction( aRegion, bClip ) );
}
break;
case GDI_MOVECLIPREGION_ACTION:
{
sal_Int32 nTmp(0), nTmp1(0);
rIStm.ReadInt32( nTmp ).ReadInt32( nTmp1 );
rMtf.AddAction( new MetaMoveClipRegionAction( nTmp, nTmp1 ) );
}
break;
case GDI_ISECTCLIPREGION_ACTION:
{
ImplReadRect( rIStm, aRect );
rMtf.AddAction( new MetaISectRectClipRegionAction( aRect ) );
}
break;
case GDI_RASTEROP_ACTION:
{
RasterOp eRasterOp;
sal_Int16 nRasterOp;
rIStm.ReadInt16( nRasterOp );
switch( nRasterOp )
{
case 1:
eRasterOp = RasterOp::Invert;
break;
case 4:
case 5:
eRasterOp = RasterOp::Xor;
break;
default:
eRasterOp = RasterOp::OverPaint;
break;
}
rMtf.AddAction( new MetaRasterOpAction( eRasterOp ) );
}
break;
case GDI_PUSH_ACTION:
{
aLIStack.push(o3tl::make_unique<LineInfo>(aLineInfo));
rMtf.AddAction( new MetaPushAction( PushFlags::ALL ) );
// #106172# Track font relevant data in shadow VDev
aFontVDev->Push();
}
break;
case GDI_POP_ACTION:
{
std::unique_ptr<LineInfo> xLineInfo;
if (!aLIStack.empty())
{
xLineInfo = std::move(aLIStack.top());
aLIStack.pop();
}
// restore line info
if (xLineInfo)
{
aLineInfo = *xLineInfo;
xLineInfo.reset();
bFatLine = ( LineStyle::NONE != aLineInfo.GetStyle() ) && !aLineInfo.IsDefault();
}
rMtf.AddAction( new MetaPopAction() );
// #106172# Track font relevant data in shadow VDev
aFontVDev->Pop();
}
break;
case GDI_GRADIENT_ACTION:
{
Color aStartCol;
Color aEndCol;
sal_Int16 nStyle;
sal_Int16 nAngle;
sal_Int16 nBorder;
sal_Int16 nOfsX;
sal_Int16 nOfsY;
sal_Int16 nIntensityStart;
sal_Int16 nIntensityEnd;
ImplReadRect( rIStm, aRect );
rIStm.ReadInt16( nStyle );
ImplReadColor( rIStm, aStartCol );
ImplReadColor( rIStm, aEndCol );
rIStm.ReadInt16( nAngle ).ReadInt16( nBorder ).ReadInt16( nOfsX ).ReadInt16( nOfsY ).ReadInt16( nIntensityStart ).ReadInt16( nIntensityEnd );
Gradient aGrad( (GradientStyle) nStyle, aStartCol, aEndCol );
aGrad.SetAngle( nAngle );
aGrad.SetBorder( nBorder );
aGrad.SetOfsX( nOfsX );
aGrad.SetOfsY( nOfsY );
aGrad.SetStartIntensity( nIntensityStart );
aGrad.SetEndIntensity( nIntensityEnd );
rMtf.AddAction( new MetaGradientAction( aRect, aGrad ) );
}
break;
case GDI_TRANSPARENT_COMMENT:
{
tools::PolyPolygon aPolyPoly;
sal_Int32 nFollowingActionCount;
sal_Int16 nTrans;
ReadPolyPolygon( rIStm, aPolyPoly );
rIStm.ReadInt16( nTrans ).ReadInt32( nFollowingActionCount );
ImplSkipActions( rIStm, nFollowingActionCount );
rMtf.AddAction( new MetaTransparentAction( aPolyPoly, nTrans ) );
i += nFollowingActionCount;
}
break;
case GDI_FLOATTRANSPARENT_COMMENT:
{
GDIMetaFile aMtf;
Point aPos;
Size aSize;
Gradient aGradient;
sal_Int32 nFollowingActionCount;
ReadGDIMetaFile( rIStm, aMtf );
ReadPair( rIStm, aPos );
ReadPair( rIStm, aSize );
ReadGradient( rIStm, aGradient );
rIStm.ReadInt32( nFollowingActionCount );
ImplSkipActions( rIStm, nFollowingActionCount );
rMtf.AddAction( new MetaFloatTransparentAction( aMtf, aPos, aSize, aGradient ) );
i += nFollowingActionCount;
}
break;
case GDI_HATCH_COMMENT:
{
tools::PolyPolygon aPolyPoly;
Hatch aHatch;
sal_Int32 nFollowingActionCount;
ReadPolyPolygon( rIStm, aPolyPoly );
ReadHatch( rIStm, aHatch );
rIStm.ReadInt32( nFollowingActionCount );
ImplSkipActions( rIStm, nFollowingActionCount );
rMtf.AddAction( new MetaHatchAction( aPolyPoly, aHatch ) );
i += nFollowingActionCount;
}
break;
case GDI_REFPOINT_COMMENT:
{
Point aRefPoint;
bool bSet;
sal_Int32 nFollowingActionCount;
ReadPair( rIStm, aRefPoint );
rIStm.ReadCharAsBool( bSet ).ReadInt32( nFollowingActionCount );
ImplSkipActions( rIStm, nFollowingActionCount );
rMtf.AddAction( new MetaRefPointAction( aRefPoint, bSet ) );
i += nFollowingActionCount;
// #106172# Track font relevant data in shadow VDev
if( bSet )
aFontVDev->SetRefPoint( aRefPoint );
else
aFontVDev->SetRefPoint();
}
break;
case GDI_TEXTLINECOLOR_COMMENT:
{
Color aColor;
bool bSet;
sal_Int32 nFollowingActionCount;
ReadColor( rIStm, aColor );
rIStm.ReadCharAsBool( bSet ).ReadInt32( nFollowingActionCount );
ImplSkipActions( rIStm, nFollowingActionCount );
rMtf.AddAction( new MetaTextLineColorAction( aColor, bSet ) );
i += nFollowingActionCount;
}
break;
case GDI_TEXTLINE_COMMENT:
{
Point aStartPt;
sal_Int32 nWidth(0);
sal_uInt32 nStrikeout(0);
sal_uInt32 nUnderline(0);
sal_Int32 nFollowingActionCount(0);
ReadPair( rIStm, aStartPt );
rIStm.ReadInt32(nWidth ).ReadUInt32(nStrikeout).ReadUInt32(nUnderline).ReadInt32(nFollowingActionCount);
ImplSkipActions(rIStm, nFollowingActionCount);
rMtf.AddAction( new MetaTextLineAction( aStartPt, nWidth,
(FontStrikeout) nStrikeout,
(FontLineStyle) nUnderline,
LINESTYLE_NONE ) );
i += nFollowingActionCount;
}
break;
case GDI_GRADIENTEX_COMMENT:
{
tools::PolyPolygon aPolyPoly;
Gradient aGradient;
sal_Int32 nFollowingActionCount;
ReadPolyPolygon( rIStm, aPolyPoly );
ReadGradient( rIStm, aGradient );
rIStm.ReadInt32( nFollowingActionCount );
ImplSkipActions( rIStm, nFollowingActionCount );
rMtf.AddAction( new MetaGradientExAction( aPolyPoly, aGradient ) );
i += nFollowingActionCount;
}
break;
case GDI_COMMENT_COMMENT:
{
sal_Int32 nValue;
sal_uInt32 nDataSize;
std::vector<sal_uInt8> aData;
sal_Int32 nFollowingActionCount;
OString aComment = read_uInt16_lenPrefixed_uInt8s_ToOString(rIStm);
rIStm.ReadInt32( nValue ).ReadUInt32( nDataSize );
if (nDataSize)
{
aData.resize(nDataSize);
nDataSize = rIStm.ReadBytes(aData.data(), nDataSize);
}
rIStm.ReadInt32( nFollowingActionCount );
ImplSkipActions( rIStm, nFollowingActionCount );
rMtf.AddAction(new MetaCommentAction(aComment, nValue, aData.data(), nDataSize));
i += nFollowingActionCount;
}
break;
case GDI_UNICODE_COMMENT:
{
nUnicodeCommentActionNumber = i + 1;
nUnicodeCommentStreamPos = rIStm.Tell() - 6;
if (nActionSize < 4)
rIStm.SetError(SVSTREAM_FILEFORMAT_ERROR);
else
rIStm.SeekRel(nActionSize - 4);
}
break;
default:
if (nActionSize < 4)
rIStm.SetError(SVSTREAM_FILEFORMAT_ERROR);
else
rIStm.SeekRel(nActionSize - 4);
break;
}
}
rIStm.SetEndian( nOldFormat );
} | 4756 | True | 1 |
CVE-2017-8358 | 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.0/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 | nan | [{'url': 'https://github.com/LibreOffice/core/commit/6e6e54f944a5ebb49e9110bdeff844d00a96c56c', 'name': 'https://github.com/LibreOffice/core/commit/6e6e54f944a5ebb49e9110bdeff844d00a96c56c', 'refsource': 'MISC', 'tags': ['Issue Tracking', 'Patch', 'Third Party Advisory']}, {'url': 'https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=889', 'name': 'https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=889', 'refsource': 'MISC', 'tags': ['Issue Tracking', 'Third Party Advisory']}, {'url': 'http://www.securityfocus.com/bid/98395', 'name': '98395', 'refsource': 'BID', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-119'}, {'lang': 'en', 'value': 'CWE-787'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:libreoffice:libreoffice:*:*:*:*:*:*:*:*', 'versionEndIncluding': '5.2.6', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'LibreOffice before 2017-03-17 has an out-of-bounds write caused by a heap-based buffer overflow related to the ReadJPEG function in vcl/source/filter/jpeg/jpegc.cxx.'}] | 2017-05-20T01:29Z | 2017-04-30T17:59Z | 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 | Caolán McNamara | 2017-03-17 10:57:03+00:00 | ofz#889 readjust jpeg import
Change-Id: I4e25db429b8dee9265ab2ad468c21cc34a50df6c
Reviewed-on: https://gerrit.libreoffice.org/35325
Tested-by: Jenkins <[email protected]>
Reviewed-by: Caolán McNamara <[email protected]>
Tested-by: Caolán McNamara <[email protected]> | 6e6e54f944a5ebb49e9110bdeff844d00a96c56c | False | LibreOffice/core | Read-only LibreOffice core repo - no pull request (use gerrit instead https://gerrit.libreoffice.org/) - don't download zip, use https://dev-www.libreoffice.org/bundles/ instead | 2013-10-31 15:46:52 | 2022-08-26 07:36:21 | https://www.libreoffice.org/ | LibreOffice | 1673.0 | 496.0 | ReadJPEG | ReadJPEG( JPEGReader * pJPEGReader , void * pInputStream , long * pLines , Size const & previewSize) | ['pJPEGReader', 'pInputStream', 'pLines', 'previewSize'] | void ReadJPEG( JPEGReader* pJPEGReader, void* pInputStream, long* pLines,
Size const & previewSize )
{
jpeg_decompress_struct cinfo;
ErrorManagerStruct jerr;
if ( setjmp( jerr.setjmp_buffer ) )
{
jpeg_destroy_decompress( &cinfo );
return;
}
cinfo.err = jpeg_std_error( &jerr.pub );
jerr.pub.error_exit = errorExit;
jerr.pub.output_message = outputMessage;
jpeg_create_decompress( &cinfo );
jpeg_svstream_src( &cinfo, pInputStream );
SourceManagerStruct *source = reinterpret_cast<SourceManagerStruct*>(cinfo.src);
jpeg_read_header( &cinfo, TRUE );
cinfo.scale_num = 1;
cinfo.scale_denom = 1;
cinfo.output_gamma = 1.0;
cinfo.raw_data_out = FALSE;
cinfo.quantize_colors = FALSE;
/* change scale for preview import */
long nPreviewWidth = previewSize.Width();
long nPreviewHeight = previewSize.Height();
if( nPreviewWidth || nPreviewHeight )
{
if( nPreviewWidth == 0 )
{
nPreviewWidth = ( cinfo.image_width * nPreviewHeight ) / cinfo.image_height;
if( nPreviewWidth <= 0 )
{
nPreviewWidth = 1;
}
}
else if( nPreviewHeight == 0 )
{
nPreviewHeight = ( cinfo.image_height * nPreviewWidth ) / cinfo.image_width;
if( nPreviewHeight <= 0 )
{
nPreviewHeight = 1;
}
}
for( cinfo.scale_denom = 1; cinfo.scale_denom < 8; cinfo.scale_denom *= 2 )
{
if( cinfo.image_width < nPreviewWidth * cinfo.scale_denom )
break;
if( cinfo.image_height < nPreviewHeight * cinfo.scale_denom )
break;
}
if( cinfo.scale_denom > 1 )
{
cinfo.dct_method = JDCT_FASTEST;
cinfo.do_fancy_upsampling = FALSE;
cinfo.do_block_smoothing = FALSE;
}
}
jpeg_start_decompress( &cinfo );
long nWidth = cinfo.output_width;
long nHeight = cinfo.output_height;
bool bGray = (cinfo.output_components == 1);
JPEGCreateBitmapParam aCreateBitmapParam;
aCreateBitmapParam.nWidth = nWidth;
aCreateBitmapParam.nHeight = nHeight;
aCreateBitmapParam.density_unit = cinfo.density_unit;
aCreateBitmapParam.X_density = cinfo.X_density;
aCreateBitmapParam.Y_density = cinfo.Y_density;
aCreateBitmapParam.bGray = bGray;
bool bBitmapCreated = pJPEGReader->CreateBitmap(aCreateBitmapParam);
if (bBitmapCreated)
{
Bitmap::ScopedWriteAccess pAccess(pJPEGReader->GetBitmap());
if (pAccess)
{
int nPixelSize = 3;
J_COLOR_SPACE best_out_color_space = JCS_RGB;
ScanlineFormat eScanlineFormat = ScanlineFormat::N24BitTcRgb;
ScanlineFormat eFinalFormat = pAccess->GetScanlineFormat();
if (eFinalFormat == ScanlineFormat::N32BitTcBgra)
{
best_out_color_space = JCS_EXT_BGRA;
eScanlineFormat = eFinalFormat;
nPixelSize = 4;
}
else if (eFinalFormat == ScanlineFormat::N32BitTcRgba)
{
best_out_color_space = JCS_EXT_RGBA;
eScanlineFormat = eFinalFormat;
nPixelSize = 4;
}
else if (eFinalFormat == ScanlineFormat::N32BitTcArgb)
{
best_out_color_space = JCS_EXT_ARGB;
eScanlineFormat = eFinalFormat;
nPixelSize = 4;
}
if ( cinfo.jpeg_color_space == JCS_YCbCr )
cinfo.out_color_space = best_out_color_space;
else if ( cinfo.jpeg_color_space == JCS_YCCK )
cinfo.out_color_space = JCS_CMYK;
if (cinfo.out_color_space != JCS_CMYK &&
cinfo.out_color_space != JCS_GRAYSCALE &&
cinfo.out_color_space != best_out_color_space)
{
SAL_WARN("vcl.filter", "jpg with unknown out color space, forcing to :" << best_out_color_space);
cinfo.out_color_space = best_out_color_space;
}
JSAMPLE* aRangeLimit = cinfo.sample_range_limit;
std::vector<sal_uInt8> pScanLineBuffer(nWidth * (bGray ? 1 : nPixelSize));
std::vector<sal_uInt8> pCYMKBuffer;
if (cinfo.out_color_space == JCS_CMYK)
{
pCYMKBuffer.resize(nWidth * 4);
}
std::unique_ptr<BitmapColor[]> pCols;
if (bGray)
{
pCols.reset(new BitmapColor[256]);
for (sal_uInt16 n = 0; n < 256; n++)
{
const sal_uInt8 cGray = n;
pCols[n] = pAccess->GetBestMatchingColor(BitmapColor(cGray, cGray, cGray));
}
}
for (*pLines = 0; *pLines < nHeight && !source->no_data_available; (*pLines)++)
{
size_t yIndex = *pLines;
sal_uInt8* p = (cinfo.out_color_space == JCS_CMYK) ? pCYMKBuffer.data() : pScanLineBuffer.data();
jpeg_read_scanlines(&cinfo, reinterpret_cast<JSAMPARRAY>(&p), 1);
if (bGray)
{
for (long x = 0; x < nWidth; ++x)
{
sal_uInt8 nColorGray = pScanLineBuffer[x];
pAccess->SetPixel(yIndex, x, pCols[nColorGray]);
}
}
else if (cinfo.out_color_space == JCS_CMYK)
{
// convert CMYK to RGB
for (long cmyk = 0, x = 0; cmyk < nWidth * 4; cmyk += 4, ++x)
{
int color_C = 255 - pCYMKBuffer[cmyk + 0];
int color_M = 255 - pCYMKBuffer[cmyk + 1];
int color_Y = 255 - pCYMKBuffer[cmyk + 2];
int color_K = 255 - pCYMKBuffer[cmyk + 3];
sal_uInt8 cRed = aRangeLimit[255L - (color_C + color_K)];
sal_uInt8 cGreen = aRangeLimit[255L - (color_M + color_K)];
sal_uInt8 cBlue = aRangeLimit[255L - (color_Y + color_K)];
pAccess->SetPixel(yIndex, x, BitmapColor(cRed, cGreen, cBlue));
}
}
else
{
pAccess->CopyScanline(yIndex, pScanLineBuffer.data(), eScanlineFormat, pScanLineBuffer.size());
}
/* PENDING ??? */
if (cinfo.err->msg_code == 113)
break;
}
}
}
if (bBitmapCreated)
{
jpeg_finish_decompress( &cinfo );
}
else
{
jpeg_abort_decompress( &cinfo );
}
jpeg_destroy_decompress( &cinfo );
} | 1034 | True | 1 |
CVE-2017-8358 | 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.0/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 | nan | [{'url': 'https://github.com/LibreOffice/core/commit/6e6e54f944a5ebb49e9110bdeff844d00a96c56c', 'name': 'https://github.com/LibreOffice/core/commit/6e6e54f944a5ebb49e9110bdeff844d00a96c56c', 'refsource': 'MISC', 'tags': ['Issue Tracking', 'Patch', 'Third Party Advisory']}, {'url': 'https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=889', 'name': 'https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=889', 'refsource': 'MISC', 'tags': ['Issue Tracking', 'Third Party Advisory']}, {'url': 'http://www.securityfocus.com/bid/98395', 'name': '98395', 'refsource': 'BID', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-119'}, {'lang': 'en', 'value': 'CWE-787'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:libreoffice:libreoffice:*:*:*:*:*:*:*:*', 'versionEndIncluding': '5.2.6', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'LibreOffice before 2017-03-17 has an out-of-bounds write caused by a heap-based buffer overflow related to the ReadJPEG function in vcl/source/filter/jpeg/jpegc.cxx.'}] | 2017-05-20T01:29Z | 2017-04-30T17:59Z | 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 | Caolán McNamara | 2017-03-17 10:57:03+00:00 | ofz#889 readjust jpeg import
Change-Id: I4e25db429b8dee9265ab2ad468c21cc34a50df6c
Reviewed-on: https://gerrit.libreoffice.org/35325
Tested-by: Jenkins <[email protected]>
Reviewed-by: Caolán McNamara <[email protected]>
Tested-by: Caolán McNamara <[email protected]> | 6e6e54f944a5ebb49e9110bdeff844d00a96c56c | False | LibreOffice/core | Read-only LibreOffice core repo - no pull request (use gerrit instead https://gerrit.libreoffice.org/) - don't download zip, use https://dev-www.libreoffice.org/bundles/ instead | 2013-10-31 15:46:52 | 2022-08-26 07:36:21 | https://www.libreoffice.org/ | LibreOffice | 1673.0 | 496.0 | ReadJPEG | ReadJPEG( JPEGReader * pJPEGReader , void * pInputStream , long * pLines , Size const & previewSize) | ['pJPEGReader', 'pInputStream', 'pLines', 'previewSize'] | void ReadJPEG( JPEGReader* pJPEGReader, void* pInputStream, long* pLines,
Size const & previewSize )
{
jpeg_decompress_struct cinfo;
ErrorManagerStruct jerr;
if ( setjmp( jerr.setjmp_buffer ) )
{
jpeg_destroy_decompress( &cinfo );
return;
}
cinfo.err = jpeg_std_error( &jerr.pub );
jerr.pub.error_exit = errorExit;
jerr.pub.output_message = outputMessage;
jpeg_create_decompress( &cinfo );
jpeg_svstream_src( &cinfo, pInputStream );
SourceManagerStruct *source = reinterpret_cast<SourceManagerStruct*>(cinfo.src);
jpeg_read_header( &cinfo, TRUE );
cinfo.scale_num = 1;
cinfo.scale_denom = 1;
cinfo.output_gamma = 1.0;
cinfo.raw_data_out = FALSE;
cinfo.quantize_colors = FALSE;
/* change scale for preview import */
long nPreviewWidth = previewSize.Width();
long nPreviewHeight = previewSize.Height();
if( nPreviewWidth || nPreviewHeight )
{
if( nPreviewWidth == 0 )
{
nPreviewWidth = ( cinfo.image_width * nPreviewHeight ) / cinfo.image_height;
if( nPreviewWidth <= 0 )
{
nPreviewWidth = 1;
}
}
else if( nPreviewHeight == 0 )
{
nPreviewHeight = ( cinfo.image_height * nPreviewWidth ) / cinfo.image_width;
if( nPreviewHeight <= 0 )
{
nPreviewHeight = 1;
}
}
for( cinfo.scale_denom = 1; cinfo.scale_denom < 8; cinfo.scale_denom *= 2 )
{
if( cinfo.image_width < nPreviewWidth * cinfo.scale_denom )
break;
if( cinfo.image_height < nPreviewHeight * cinfo.scale_denom )
break;
}
if( cinfo.scale_denom > 1 )
{
cinfo.dct_method = JDCT_FASTEST;
cinfo.do_fancy_upsampling = FALSE;
cinfo.do_block_smoothing = FALSE;
}
}
jpeg_start_decompress( &cinfo );
long nWidth = cinfo.output_width;
long nHeight = cinfo.output_height;
bool bGray = (cinfo.output_components == 1);
JPEGCreateBitmapParam aCreateBitmapParam;
aCreateBitmapParam.nWidth = nWidth;
aCreateBitmapParam.nHeight = nHeight;
aCreateBitmapParam.density_unit = cinfo.density_unit;
aCreateBitmapParam.X_density = cinfo.X_density;
aCreateBitmapParam.Y_density = cinfo.Y_density;
aCreateBitmapParam.bGray = bGray;
bool bBitmapCreated = pJPEGReader->CreateBitmap(aCreateBitmapParam);
if (bBitmapCreated)
{
Bitmap::ScopedWriteAccess pAccess(pJPEGReader->GetBitmap());
if (pAccess)
{
int nPixelSize = 3;
J_COLOR_SPACE best_out_color_space = JCS_RGB;
ScanlineFormat eScanlineFormat = ScanlineFormat::N24BitTcRgb;
ScanlineFormat eFinalFormat = pAccess->GetScanlineFormat();
if (eFinalFormat == ScanlineFormat::N32BitTcBgra)
{
best_out_color_space = JCS_EXT_BGRA;
eScanlineFormat = eFinalFormat;
nPixelSize = 4;
}
else if (eFinalFormat == ScanlineFormat::N32BitTcRgba)
{
best_out_color_space = JCS_EXT_RGBA;
eScanlineFormat = eFinalFormat;
nPixelSize = 4;
}
else if (eFinalFormat == ScanlineFormat::N32BitTcArgb)
{
best_out_color_space = JCS_EXT_ARGB;
eScanlineFormat = eFinalFormat;
nPixelSize = 4;
}
if ( cinfo.jpeg_color_space == JCS_YCbCr )
cinfo.out_color_space = best_out_color_space;
else if ( cinfo.jpeg_color_space == JCS_YCCK )
cinfo.out_color_space = JCS_CMYK;
if (cinfo.out_color_space != JCS_CMYK &&
cinfo.out_color_space != JCS_GRAYSCALE &&
cinfo.out_color_space != best_out_color_space)
{
SAL_WARN("vcl.filter", "jpg with unknown out color space, forcing to :" << best_out_color_space);
cinfo.out_color_space = best_out_color_space;
}
JSAMPLE* aRangeLimit = cinfo.sample_range_limit;
std::vector<sal_uInt8> pScanLineBuffer(nWidth * (bGray ? 1 : nPixelSize));
std::vector<sal_uInt8> pCYMKBuffer;
if (cinfo.out_color_space == JCS_CMYK)
{
pCYMKBuffer.resize(nWidth * 4);
}
std::unique_ptr<BitmapColor[]> pCols;
if (bGray)
{
pCols.reset(new BitmapColor[256]);
for (sal_uInt16 n = 0; n < 256; n++)
{
const sal_uInt8 cGray = n;
pCols[n] = pAccess->GetBestMatchingColor(BitmapColor(cGray, cGray, cGray));
}
}
for (*pLines = 0; *pLines < nHeight && !source->no_data_available; (*pLines)++)
{
size_t yIndex = *pLines;
sal_uInt8* p = (cinfo.out_color_space == JCS_CMYK) ? pCYMKBuffer.data() : pScanLineBuffer.data();
jpeg_read_scanlines(&cinfo, reinterpret_cast<JSAMPARRAY>(&p), 1);
if (bGray)
{
for (long x = 0; x < nWidth; ++x)
{
sal_uInt8 nColorGray = pScanLineBuffer[x];
pAccess->SetPixel(yIndex, x, pCols[nColorGray]);
}
}
else if (cinfo.out_color_space == JCS_CMYK)
{
// convert CMYK to RGB
for (long cmyk = 0, x = 0; cmyk < nWidth * 4; cmyk += 4, ++x)
{
int color_C = 255 - pCYMKBuffer[cmyk + 0];
int color_M = 255 - pCYMKBuffer[cmyk + 1];
int color_Y = 255 - pCYMKBuffer[cmyk + 2];
int color_K = 255 - pCYMKBuffer[cmyk + 3];
sal_uInt8 cRed = aRangeLimit[255L - (color_C + color_K)];
sal_uInt8 cGreen = aRangeLimit[255L - (color_M + color_K)];
sal_uInt8 cBlue = aRangeLimit[255L - (color_Y + color_K)];
pAccess->SetPixel(yIndex, x, BitmapColor(cRed, cGreen, cBlue));
}
}
else
{
pAccess->CopyScanline(yIndex, pScanLineBuffer.data(), eScanlineFormat, pScanLineBuffer.size());
}
/* PENDING ??? */
if (cinfo.err->msg_code == 113)
break;
}
}
}
if (bBitmapCreated)
{
jpeg_finish_decompress( &cinfo );
}
else
{
jpeg_abort_decompress( &cinfo );
}
jpeg_destroy_decompress( &cinfo );
} | 1034 | True | 1 |
CVE-2016-10375 | 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.0/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 | True | [{'url': 'https://github.com/fbb-git/yodl/issues/1', 'name': 'https://github.com/fbb-git/yodl/issues/1', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/fbb-git/yodl/commit/fd85f8c94182558ff1480d06a236d6fb927979a3', 'name': 'https://github.com/fbb-git/yodl/commit/fd85f8c94182558ff1480d06a236d6fb927979a3', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2020/04/msg00026.html', 'name': '[debian-lts-announce] 20200430 [SECURITY] [DLA 2194-1] yodl security update', 'refsource': 'MLIST', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-119'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:yodl_project:yodl:*:*:*:*:*:*:*:*', 'versionEndIncluding': '3.06.00', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Yodl before 3.07.01 has a Buffer Over-read in the queue_push function in queue/queuepush.c.'}] | 2020-04-30T18:15Z | 2017-05-26T17:29Z | 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 | Frank B. Brokken | 2016-02-04 22:37:17+01:00 | fixed invalid memory reads detected by the address sanitizer | fd85f8c94182558ff1480d06a236d6fb927979a3 | False | fbb-git/yodl | Yodl implements a document language. Yodl documents can easily be converted to, e.g., html, LaTeX, txt, man | 2015-08-25 07:38:53 | 2018-08-31 14:07:46 | null | fbb-git | 19.0 | 0.0 | queue_push | queue_push( register Queue * qp , size_t extra_length , char const * info) | ['qp', 'extra_length', 'info'] | void queue_push(register Queue *qp, size_t extra_length, char const *info)
{
register char *cp;
size_t memory_length;
size_t available_length;
size_t begin_length;
size_t n_begin;
size_t q_length;
if (!extra_length)
return;
memory_length = qp->d_memory_end - qp->d_memory;
q_length =
qp->d_read <= qp->d_write ?
(size_t)(qp->d_write - qp->d_read)
:
memory_length - (qp->d_read - qp->d_write);
available_length = memory_length - q_length - 1;
/* -1, as the Q cannot completely fill up all */
/* available memory in the buffer */
if (message_show(MSG_INFO))
message("push_front %u bytes in `%s'", (unsigned)extra_length, info);
if (extra_length > available_length)
{
/* enlarge the buffer: */
memory_length += extra_length - available_length + BLOCK_QUEUE;
cp = new_memory(memory_length, sizeof(char));
if (message_show(MSG_INFO))
message("Reallocating queue at %p to %p", qp->d_memory, cp);
if (qp->d_read > qp->d_write) /* q wraps around end */
{
size_t tail_len = qp->d_memory_end - qp->d_read;
memcpy(cp, qp->d_read, tail_len); /* first part -> begin */
/* 2nd part beyond */
memcpy(cp + tail_len, qp->d_memory,
(size_t)(qp->d_write - qp->d_memory));
qp->d_write = cp + q_length;
qp->d_read = cp;
}
else /* q as one block */
{
memcpy(cp, qp->d_memory, memory_length);/* cp existing buffer */
qp->d_read = cp + (qp->d_read - qp->d_memory);
qp->d_write = cp + (qp->d_write - qp->d_memory);
}
free(qp->d_memory); /* free old memory */
qp->d_memory_end = cp + memory_length; /* update d_memory_end */
qp->d_memory = cp; /* update d_memory */
}
/*
Write as much as possible at the begin of the buffer, then write
the remaining chars at the end.
q_length is increased by the length of the info string
The first chars to write are at the end of info, and the 2nd part to
write are the initial chars of info, since the initial part of info
is then read first.
*/
/* # chars available at the */
begin_length = qp->d_read - qp->d_memory; /* begin of the buffer */
n_begin = extra_length <= begin_length ? /* determine # to write at */
extra_length /* the begin of the buffer */
:
begin_length;
memcpy /* write trailing part of */
( /* info first */
qp->d_read -= n_begin,
info + extra_length - n_begin,
n_begin
);
if (extra_length > begin_length) /* not yet all chars written*/
{
/* continue with the remaining number of characters. Insert these at*/
/* the end of the buffer */
extra_length -= begin_length; /* reduce # to write */
memcpy /* d_read wraps to the end */
( /* write info's rest */
qp->d_read = qp->d_memory_end - extra_length,
info,
extra_length
);
}
} | 367 | True | 1 |
CVE-2016-10544 | 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.0/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H | NETWORK | HIGH | NONE | NONE | UNCHANGED | NONE | NONE | HIGH | 5.9 | MEDIUM | 2.2 | 3.6 | nan | [{'url': 'https://nodesecurity.io/advisories/149', 'name': 'https://nodesecurity.io/advisories/149', 'refsource': 'MISC', 'tags': ['Third Party Advisory']}, {'url': 'https://github.com/uWebSockets/uWebSockets/commit/37deefd01f0875e133ea967122e3a5e421b8fcd9', 'name': 'https://github.com/uWebSockets/uWebSockets/commit/37deefd01f0875e133ea967122e3a5e421b8fcd9', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-20'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:uws_project:uws:*:*:*:*:*:node.js:*:*', 'versionStartIncluding': '0.10.0', 'versionEndIncluding': '0.10.8', 'cpe_name': []}]}] | [{'lang': 'en', 'value': "uws is a WebSocket server library. By sending a 256mb websocket message to a uws server instance with permessage-deflate enabled, there is a possibility used compression will shrink said 256mb down to less than 16mb of websocket payload which passes the length check of 16mb payload. This data will then inflate up to 256mb and crash the node process by exceeding V8's maximum string size. This affects uws >=0.10.0 <=0.10.8."}] | 2019-10-09T23:16Z | 2018-05-31T20:29Z | Improper Input Validation | The product receives input or data, but it does
not validate or incorrectly validates that the input has the
properties that are required to process the data safely and
correctly. |
Input validation is a frequently-used technique
for checking potentially dangerous inputs in order to
ensure that the inputs are safe for processing within the
code, or when communicating with other components. When
software does not validate input properly, an attacker is
able to craft the input in a form that is not expected by
the rest of the application. This will lead to parts of the
system receiving unintended input, which may result in
altered control flow, arbitrary control of a resource, or
arbitrary code execution.
Input validation is not the only technique for
processing input, however. Other techniques attempt to
transform potentially-dangerous input into something safe, such
as filtering (CWE-790) - which attempts to remove dangerous
inputs - or encoding/escaping (CWE-116), which attempts to
ensure that the input is not misinterpreted when it is included
in output to another component. Other techniques exist as well
(see CWE-138 for more examples.)
Input validation can be applied to:
raw data - strings, numbers, parameters, file contents, etc.
metadata - information about the raw data, such as headers or size
Data can be simple or structured. Structured data
can be composed of many nested layers, composed of
combinations of metadata and raw data, with other simple or
structured data.
Many properties of raw data or metadata may need
to be validated upon entry into the code, such
as:
specified quantities such as size, length, frequency, price, rate, number of operations, time, etc.
implied or derived quantities, such as the actual size of a file instead of a specified size
indexes, offsets, or positions into more complex data structures
symbolic keys or other elements into hash tables, associative arrays, etc.
well-formedness, i.e. syntactic correctness - compliance with expected syntax
lexical token correctness - compliance with rules for what is treated as a token
specified or derived type - the actual type of the input (or what the input appears to be)
consistency - between individual data elements, between raw data and metadata, between references, etc.
conformance to domain-specific rules, e.g. business logic
equivalence - ensuring that equivalent inputs are treated the same
authenticity, ownership, or other attestations about the input, e.g. a cryptographic signature to prove the source of the data
Implied or derived properties of data must often
be calculated or inferred by the code itself. Errors in
deriving properties may be considered a contributing factor
to improper input validation.
Note that "input validation" has very different
meanings to different people, or within different
classification schemes. Caution must be used when
referencing this CWE entry or mapping to it. For example,
some weaknesses might involve inadvertently giving control
to an attacker over an input when they should not be able
to provide an input at all, but sometimes this is referred
to as input validation.
Finally, it is important to emphasize that the
distinctions between input validation and output escaping
are often blurred, and developers must be careful to
understand the difference, including how input validation
is not always sufficient to prevent vulnerabilities,
especially when less stringent data types must be
supported, such as free-form text. Consider a SQL injection
scenario in which a person's last name is inserted into a
query. The name "O'Reilly" would likely pass the validation
step since it is a common last name in the English
language. However, this valid name cannot be directly
inserted into the database because it contains the "'"
apostrophe character, which would need to be escaped or
otherwise transformed. In this case, removing the
apostrophe might reduce the risk of SQL injection, but it
would produce incorrect behavior because the wrong name
would be recorded.
| https://cwe.mitre.org/data/definitions/20.html | 0 | Alex Hultman | 2016-10-13 23:19:43+02:00 | Don't inflate more than ~16mb, drop connection on inflate error | 37deefd01f0875e133ea967122e3a5e421b8fcd9 | False | visit repo url | visit repo url | visit repo url | visit repo url | visit repo url | uWebSockets | visit repo url | visit repo url | uWS::Hub::inflate | uWS::Hub::inflate( char * data , size_t & length) | ['data', 'length'] | char *Hub::inflate(char *data, size_t &length) {
dynamicInflationBuffer.clear();
inflationStream.next_in = (Bytef *) data;
inflationStream.avail_in = length;
int err;
do {
inflationStream.next_out = (Bytef *) inflationBuffer;
inflationStream.avail_out = LARGE_BUFFER_SIZE;
err = ::inflate(&inflationStream, Z_FINISH);
if (!inflationStream.avail_in) {
break;
}
dynamicInflationBuffer.append(inflationBuffer, LARGE_BUFFER_SIZE - inflationStream.avail_out);
} while (err == Z_BUF_ERROR);
inflateReset(&inflationStream);
if (err != Z_BUF_ERROR && err != Z_OK) {
length = 0;
return nullptr;
}
if (dynamicInflationBuffer.length()) {
dynamicInflationBuffer.append(inflationBuffer, LARGE_BUFFER_SIZE - inflationStream.avail_out);
length = dynamicInflationBuffer.length();
return (char *) dynamicInflationBuffer.data();
}
length = LARGE_BUFFER_SIZE - inflationStream.avail_out;
return inflationBuffer;
} | 178 | True | 1 |
CVE-2016-10749 | 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.openwall.com/lists/oss-security/2016/11/07/2', 'name': 'https://www.openwall.com/lists/oss-security/2016/11/07/2', 'refsource': 'MISC', 'tags': ['Exploit', 'Mailing List', 'Patch', 'Third Party Advisory']}, {'url': 'https://github.com/DaveGamble/cJSON/issues/30', 'name': 'https://github.com/DaveGamble/cJSON/issues/30', 'refsource': 'MISC', 'tags': ['Exploit', 'Patch', 'Third Party Advisory']}, {'url': 'https://github.com/DaveGamble/cJSON/commit/94df772485c92866ca417d92137747b2e3b0a917', 'name': 'https://github.com/DaveGamble/cJSON/commit/94df772485c92866ca417d92137747b2e3b0a917', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:cjson_project:cjson:*:*:*:*:*:*:*:*', 'versionEndExcluding': '0.0.0', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'parse_string in cJSON.c in cJSON before 2016-10-02 has a buffer over-read, as demonstrated by a string that begins with a " character and ends with a \\ character.'}] | 2019-12-27T15:45Z | 2019-04-29T14:29Z | 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 | Max Bruckner | 2016-10-02 18:56:53+07:00 | fix buffer overflow (#30) | 94df772485c92866ca417d92137747b2e3b0a917 | False | DaveGamble/cJSON | Ultralightweight JSON parser in ANSI C | 2016-03-19 18:22:54 | 2022-08-01 21:48:19 | DaveGamble | 7826.0 | 2695.0 | parse_string | parse_string( cJSON * item , const char * str , const char ** ep) | ['item', 'str', 'ep'] | static const char *parse_string(cJSON *item,const char *str,const char **ep)
{
const char *ptr=str+1,*end_ptr=str+1;char *ptr2;char *out;int len=0;unsigned uc,uc2;
if (*str!='\"') {*ep=str;return 0;} /* not a string! */
while (*end_ptr!='\"' && *end_ptr && ++len) if (*end_ptr++ == '\\') end_ptr++; /* Skip escaped quotes. */
out=(char*)cJSON_malloc(len+1); /* This is how long we need for the string, roughly. */
if (!out) return 0;
item->valuestring=out; /* assign here so out will be deleted during cJSON_Delete() later */
item->type=cJSON_String;
ptr=str+1;ptr2=out;
while (ptr < end_ptr)
{
if (*ptr!='\\') *ptr2++=*ptr++;
else
{
ptr++;
switch (*ptr)
{
case 'b': *ptr2++='\b'; break;
case 'f': *ptr2++='\f'; break;
case 'n': *ptr2++='\n'; break;
case 'r': *ptr2++='\r'; break;
case 't': *ptr2++='\t'; break;
case 'u': /* transcode utf16 to utf8. */
uc=parse_hex4(ptr+1);ptr+=4; /* get the unicode char. */
if (ptr >= end_ptr) {*ep=str;return 0;} /* invalid */
if ((uc>=0xDC00 && uc<=0xDFFF) || uc==0) {*ep=str;return 0;} /* check for invalid. */
if (uc>=0xD800 && uc<=0xDBFF) /* UTF16 surrogate pairs. */
{
if (ptr+6 > end_ptr) {*ep=str;return 0;} /* invalid */
if (ptr[1]!='\\' || ptr[2]!='u') {*ep=str;return 0;} /* missing second-half of surrogate. */
uc2=parse_hex4(ptr+3);ptr+=6;
if (uc2<0xDC00 || uc2>0xDFFF) {*ep=str;return 0;} /* invalid second-half of surrogate. */
uc=0x10000 + (((uc&0x3FF)<<10) | (uc2&0x3FF));
}
len=4;if (uc<0x80) len=1;else if (uc<0x800) len=2;else if (uc<0x10000) len=3; ptr2+=len;
switch (len) {
case 4: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6;
case 3: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6;
case 2: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6;
case 1: *--ptr2 =(uc | firstByteMark[len]);
}
ptr2+=len;
break;
default: *ptr2++=*ptr; break;
}
ptr++;
}
}
*ptr2=0;
if (*ptr=='\"') ptr++;
return ptr;
} | 560 | True | 1 |
|
CVE-2019-1010239 | 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/DaveGamble/cJSON/issues/315', 'name': 'https://github.com/DaveGamble/cJSON/issues/315', 'refsource': 'MISC', 'tags': ['Exploit', 'Issue Tracking', 'Third Party Advisory']}, {'url': 'https://github.com/DaveGamble/cJSON/commit/be749d7efa7c9021da746e685bd6dec79f9dd99b', 'name': 'https://github.com/DaveGamble/cJSON/commit/be749d7efa7c9021da746e685bd6dec79f9dd99b', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://www.oracle.com/security-alerts/cpuoct2020.html', 'name': 'https://www.oracle.com/security-alerts/cpuoct2020.html', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-754'}, {'lang': 'en', 'value': 'CWE-476'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:cjson_project:cjson:1.7.8:*:*:*:*:*:*:*', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:oracle:timesten_in-memory_database:*:*:*:*:*:*:*:*', 'versionEndExcluding': '18.1.3.1.0', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'DaveGamble/cJSON cJSON 1.7.8 is affected by: Improper Check for Unusual or Exceptional Conditions. The impact is: Null dereference, so attack can cause denial of service. The component is: cJSON_GetObjectItemCaseSensitive() function. The attack vector is: crafted json file. The fixed version is: 1.7.9 and later.'}] | 2022-05-03T14:28Z | 2019-07-19T17: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 | Max Bruckner | 2018-12-16 11:06:40+01:00 | Fix crash of cJSON_GetObjectItemCaseSensitive when calling it on arrays | be749d7efa7c9021da746e685bd6dec79f9dd99b | False | DaveGamble/cJSON | Ultralightweight JSON parser in ANSI C | 2016-03-19 18:22:54 | 2022-08-01 21:48:19 | DaveGamble | 7826.0 | 2695.0 | get_object_item | get_object_item( const cJSON * const object , const char * const name , const cJSON_bool case_sensitive) | ['object', 'name', 'case_sensitive'] | static cJSON *get_object_item(const cJSON * const object, const char * const name, const cJSON_bool case_sensitive)
{
cJSON *current_element = NULL;
if ((object == NULL) || (name == NULL))
{
return NULL;
}
current_element = object->child;
if (case_sensitive)
{
while ((current_element != NULL) && (strcmp(name, current_element->string) != 0))
{
current_element = current_element->next;
}
}
else
{
while ((current_element != NULL) && (case_insensitive_strcmp((const unsigned char*)name, (const unsigned char*)(current_element->string)) != 0))
{
current_element = current_element->next;
}
}
return current_element;
} | 135 | True | 1 |
|
CVE-2019-1010239 | 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/DaveGamble/cJSON/issues/315', 'name': 'https://github.com/DaveGamble/cJSON/issues/315', 'refsource': 'MISC', 'tags': ['Exploit', 'Issue Tracking', 'Third Party Advisory']}, {'url': 'https://github.com/DaveGamble/cJSON/commit/be749d7efa7c9021da746e685bd6dec79f9dd99b', 'name': 'https://github.com/DaveGamble/cJSON/commit/be749d7efa7c9021da746e685bd6dec79f9dd99b', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://www.oracle.com/security-alerts/cpuoct2020.html', 'name': 'https://www.oracle.com/security-alerts/cpuoct2020.html', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-754'}, {'lang': 'en', 'value': 'CWE-476'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:cjson_project:cjson:1.7.8:*:*:*:*:*:*:*', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:oracle:timesten_in-memory_database:*:*:*:*:*:*:*:*', 'versionEndExcluding': '18.1.3.1.0', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'DaveGamble/cJSON cJSON 1.7.8 is affected by: Improper Check for Unusual or Exceptional Conditions. The impact is: Null dereference, so attack can cause denial of service. The component is: cJSON_GetObjectItemCaseSensitive() function. The attack vector is: crafted json file. The fixed version is: 1.7.9 and later.'}] | 2022-05-03T14:28Z | 2019-07-19T17:15Z | Improper Check for Unusual or Exceptional Conditions | The software does not check or incorrectly checks for unusual or exceptional conditions that are not expected to occur frequently during day to day operation of the software. |
The programmer may assume that certain events or conditions will never occur or do not need to be worried about, such as low memory conditions, lack of access to resources due to restrictive permissions, or misbehaving clients or components. However, attackers may intentionally trigger these unusual conditions, thus violating the programmer's assumptions, possibly introducing instability, incorrect behavior, or a vulnerability.
Note that this entry is not exclusively about the use of exceptions and exception handling, which are mechanisms for both checking and handling unusual or unexpected conditions.
| https://cwe.mitre.org/data/definitions/754.html | 0 | Max Bruckner | 2018-12-16 11:06:40+01:00 | Fix crash of cJSON_GetObjectItemCaseSensitive when calling it on arrays | be749d7efa7c9021da746e685bd6dec79f9dd99b | False | DaveGamble/cJSON | Ultralightweight JSON parser in ANSI C | 2016-03-19 18:22:54 | 2022-08-01 21:48:19 | DaveGamble | 7826.0 | 2695.0 | get_object_item | get_object_item( const cJSON * const object , const char * const name , const cJSON_bool case_sensitive) | ['object', 'name', 'case_sensitive'] | static cJSON *get_object_item(const cJSON * const object, const char * const name, const cJSON_bool case_sensitive)
{
cJSON *current_element = NULL;
if ((object == NULL) || (name == NULL))
{
return NULL;
}
current_element = object->child;
if (case_sensitive)
{
while ((current_element != NULL) && (strcmp(name, current_element->string) != 0))
{
current_element = current_element->next;
}
}
else
{
while ((current_element != NULL) && (case_insensitive_strcmp((const unsigned char*)name, (const unsigned char*)(current_element->string)) != 0))
{
current_element = current_element->next;
}
}
return current_element;
} | 135 | True | 1 |
|
CVE-2020-26272 | 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:U/C:L/I:L/A:N | NETWORK | LOW | NONE | NONE | UNCHANGED | LOW | LOW | NONE | 6.5 | MEDIUM | 3.9 | 2.5 | False | [{'url': 'https://github.com/electron/electron/releases/tag/v9.4.0', 'name': 'https://github.com/electron/electron/releases/tag/v9.4.0', 'refsource': 'MISC', 'tags': ['Release Notes', 'Third Party Advisory']}, {'url': 'https://github.com/electron/electron/pull/26875', 'name': 'https://github.com/electron/electron/pull/26875', 'refsource': 'MISC', 'tags': ['Third Party Advisory']}, {'url': 'https://github.com/electron/electron/commit/07a1c2a3e5845901f7e2eda9506695be58edc73c', 'name': 'https://github.com/electron/electron/commit/07a1c2a3e5845901f7e2eda9506695be58edc73c', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/electron/electron/security/advisories/GHSA-hvf8-h2qh-37m9', 'name': 'https://github.com/electron/electron/security/advisories/GHSA-hvf8-h2qh-37m9', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'https://www.electronjs.org/releases/stable?version=9#9.4.0', 'name': 'https://www.electronjs.org/releases/stable?version=9#9.4.0', 'refsource': 'MISC', 'tags': ['Release Notes', 'Vendor Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-668'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta11:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta12:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta13:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta14:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta15:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta16:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta17:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta18:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta19:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta1:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta10:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta2:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta20:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta3:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta4:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta5:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta6:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta7:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta8:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta9:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta1:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta10:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta11:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta21:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta23:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta24:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta25:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta12:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta13:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta14:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta15:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta17:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta19:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta2:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta20:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta3:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta4:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta5:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta6:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta7:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta8:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta9:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta1:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta10:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta11:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta12:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta13:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta14:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta3:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta4:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta5:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta6:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta7:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta8:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta9:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:12.0.0:beta1:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:12.0.0:beta3:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:12.0.0:beta4:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:12.0.0:beta5:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:12.0.0:beta6:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:12.0.0:beta7:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:12.0.0:beta8:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:12.0.0:beta9:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:*:*:*:*:*:*:*:*', 'versionStartIncluding': '9.0.0', 'versionEndExcluding': '9.4.0', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta21:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta22:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta23:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta24:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:*:*:*:*:*:*:*:*', 'versionStartIncluding': '10.0.0', 'versionEndExcluding': '10.2.0', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:*:*:*:*:*:*:*:*', 'versionStartIncluding': '11.0.0', 'versionEndExcluding': '11.1.0', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta15:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta16:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta17:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta18:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta19:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta20:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta21:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta22:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta23:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'The Electron framework lets you write cross-platform desktop applications using JavaScript, HTML and CSS. In affected versions of Electron IPC messages sent from the main process to a subframe in the renderer process, through webContents.sendToFrame, event.reply or when using the remote module, can in some cases be delivered to the wrong frame. If your app uses remote, calls webContents.sendToFrame, or calls event.reply in an IPC message handler then it is impacted by this issue. This has been fixed in versions 9.4.0, 10.2.0, 11.1.0, and 12.0.0-beta.9. There are no workarounds for this issue.'}] | 2021-02-04T19:03Z | 2021-01-28T19:15Z | Exposure of Resource to Wrong Sphere | The product exposes a resource to the wrong control sphere, providing unintended actors with inappropriate access to the resource. |
Resources such as files and directories may be inadvertently exposed through mechanisms such as insecure permissions, or when a program accidentally operates on the wrong object. For example, a program may intend that private files can only be provided to a specific user. This effectively defines a control sphere that is intended to prevent attackers from accessing these private files. If the file permissions are insecure, then parties other than the user will be able to access those files.
A separate control sphere might effectively require that the user can only access the private files, but not any other files on the system. If the program does not ensure that the user is only requesting private files, then the user might be able to access other files on the system.
In either case, the end result is that a resource has been exposed to the wrong party.
| https://cwe.mitre.org/data/definitions/668.html | 0 | Jeremy Rose | 2020-12-09 12:48:16-08:00 | fix: restrict sendToFrame to same-process frames by default (#26875) | 07a1c2a3e5845901f7e2eda9506695be58edc73c | False | electron/electron | :electron: Build cross-platform desktop apps with JavaScript, HTML, and CSS | 2013-04-12 01:47:36 | 2022-08-27 16:11:33 | https://electronjs.org | electron | 103374.0 | 13806.0 | electron::api::WebContents::SendIPCMessageToFrame | electron::api::WebContents::SendIPCMessageToFrame( bool internal , int32_t frame_id , const std :: string & channel , v8 :: Local<v8::Value> args) | ['internal', 'frame_id', 'channel', 'args'] | bool WebContents::SendIPCMessageToFrame(bool internal,
int32_t frame_id,
const std::string& channel,
v8::Local<v8::Value> args) {
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
blink::CloneableMessage message;
if (!gin::ConvertFromV8(isolate, args, &message)) {
isolate->ThrowException(v8::Exception::Error(
gin::StringToV8(isolate, "Failed to serialize arguments")));
return false;
}
auto frames = web_contents()->GetAllFrames();
auto iter = std::find_if(frames.begin(), frames.end(), [frame_id](auto* f) {
return f->GetRoutingID() == frame_id;
});
if (iter == frames.end())
return false;
if (!(*iter)->IsRenderFrameLive())
return false;
mojo::AssociatedRemote<mojom::ElectronRenderer> electron_renderer;
(*iter)->GetRemoteAssociatedInterfaces()->GetInterface(&electron_renderer);
electron_renderer->Message(internal, channel, std::move(message),
0 /* sender_id */);
return true;
} | 212 | True | 1 |
CVE-2020-26272 | 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:U/C:L/I:L/A:N | NETWORK | LOW | NONE | NONE | UNCHANGED | LOW | LOW | NONE | 6.5 | MEDIUM | 3.9 | 2.5 | False | [{'url': 'https://github.com/electron/electron/releases/tag/v9.4.0', 'name': 'https://github.com/electron/electron/releases/tag/v9.4.0', 'refsource': 'MISC', 'tags': ['Release Notes', 'Third Party Advisory']}, {'url': 'https://github.com/electron/electron/pull/26875', 'name': 'https://github.com/electron/electron/pull/26875', 'refsource': 'MISC', 'tags': ['Third Party Advisory']}, {'url': 'https://github.com/electron/electron/commit/07a1c2a3e5845901f7e2eda9506695be58edc73c', 'name': 'https://github.com/electron/electron/commit/07a1c2a3e5845901f7e2eda9506695be58edc73c', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/electron/electron/security/advisories/GHSA-hvf8-h2qh-37m9', 'name': 'https://github.com/electron/electron/security/advisories/GHSA-hvf8-h2qh-37m9', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'https://www.electronjs.org/releases/stable?version=9#9.4.0', 'name': 'https://www.electronjs.org/releases/stable?version=9#9.4.0', 'refsource': 'MISC', 'tags': ['Release Notes', 'Vendor Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-668'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta11:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta12:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta13:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta14:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta15:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta16:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta17:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta18:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta19:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta1:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta10:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta2:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta20:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta3:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta4:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta5:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta6:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta7:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta8:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta9:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta1:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta10:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta11:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta21:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta23:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta24:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta25:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta12:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta13:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta14:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta15:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta17:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta19:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta2:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta20:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta3:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta4:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta5:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta6:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta7:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta8:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:10.0.0:beta9:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta1:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta10:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta11:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta12:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta13:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta14:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta3:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta4:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta5:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta6:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta7:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta8:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta9:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:12.0.0:beta1:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:12.0.0:beta3:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:12.0.0:beta4:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:12.0.0:beta5:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:12.0.0:beta6:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:12.0.0:beta7:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:12.0.0:beta8:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:12.0.0:beta9:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:*:*:*:*:*:*:*:*', 'versionStartIncluding': '9.0.0', 'versionEndExcluding': '9.4.0', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta21:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta22:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta23:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:9.0.0:beta24:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:*:*:*:*:*:*:*:*', 'versionStartIncluding': '10.0.0', 'versionEndExcluding': '10.2.0', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:*:*:*:*:*:*:*:*', 'versionStartIncluding': '11.0.0', 'versionEndExcluding': '11.1.0', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta15:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta16:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta17:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta18:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta19:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta20:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta21:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta22:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:electronjs:electron:11.0.0:beta23:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'The Electron framework lets you write cross-platform desktop applications using JavaScript, HTML and CSS. In affected versions of Electron IPC messages sent from the main process to a subframe in the renderer process, through webContents.sendToFrame, event.reply or when using the remote module, can in some cases be delivered to the wrong frame. If your app uses remote, calls webContents.sendToFrame, or calls event.reply in an IPC message handler then it is impacted by this issue. This has been fixed in versions 9.4.0, 10.2.0, 11.1.0, and 12.0.0-beta.9. There are no workarounds for this issue.'}] | 2021-02-04T19:03Z | 2021-01-28T19:15Z | Exposure of Resource to Wrong Sphere | The product exposes a resource to the wrong control sphere, providing unintended actors with inappropriate access to the resource. |
Resources such as files and directories may be inadvertently exposed through mechanisms such as insecure permissions, or when a program accidentally operates on the wrong object. For example, a program may intend that private files can only be provided to a specific user. This effectively defines a control sphere that is intended to prevent attackers from accessing these private files. If the file permissions are insecure, then parties other than the user will be able to access those files.
A separate control sphere might effectively require that the user can only access the private files, but not any other files on the system. If the program does not ensure that the user is only requesting private files, then the user might be able to access other files on the system.
In either case, the end result is that a resource has been exposed to the wrong party.
| https://cwe.mitre.org/data/definitions/668.html | 0 | Jeremy Rose | 2020-12-09 12:48:16-08:00 | fix: restrict sendToFrame to same-process frames by default (#26875) | 07a1c2a3e5845901f7e2eda9506695be58edc73c | False | electron/electron | :electron: Build cross-platform desktop apps with JavaScript, HTML, and CSS | 2013-04-12 01:47:36 | 2022-08-27 16:11:33 | https://electronjs.org | electron | 103374.0 | 13806.0 | gin_helper::internal::CreateNativeEvent | gin_helper::internal::CreateNativeEvent( v8 :: Isolate * isolate , v8 :: Local<v8::Object> sender , content :: RenderFrameHost * frame , electron :: mojom :: ElectronBrowser :: MessageSyncCallback callback) | ['isolate', 'sender', 'frame', 'callback'] | v8::Local<v8::Object> CreateNativeEvent(
v8::Isolate* isolate,
v8::Local<v8::Object> sender,
content::RenderFrameHost* frame,
electron::mojom::ElectronBrowser::MessageSyncCallback callback) {
v8::Local<v8::Object> event;
if (frame && callback) {
gin::Handle<Event> native_event = Event::Create(isolate);
native_event->SetCallback(std::move(callback));
event = v8::Local<v8::Object>::Cast(native_event.ToV8());
} else {
// No need to create native event if we do not need to send reply.
event = CreateEvent(isolate);
}
Dictionary dict(isolate, event);
dict.Set("sender", sender);
// Should always set frameId even when callback is null.
if (frame)
dict.Set("frameId", frame->GetRoutingID());
return event;
} | 147 | True | 1 |
CVE-2016-1245 | 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.0/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 | nan | [{'url': 'https://www.debian.org/security/2016/dsa-3695', 'name': 'DSA-3695', 'refsource': 'DEBIAN', 'tags': ['Third Party Advisory']}, {'url': 'https://github.com/Quagga/quagga/commit/cfb1fae25f8c092e0d17073eaf7bd428ce1cd546', 'name': 'https://github.com/Quagga/quagga/commit/cfb1fae25f8c092e0d17073eaf7bd428ce1cd546', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://bugzilla.redhat.com/show_bug.cgi?id=1386109', 'name': 'https://bugzilla.redhat.com/show_bug.cgi?id=1386109', 'refsource': 'CONFIRM', 'tags': ['Issue Tracking', 'Third Party Advisory']}, {'url': 'http://www.gossamer-threads.com/lists/quagga/users/31952', 'name': 'http://www.gossamer-threads.com/lists/quagga/users/31952', 'refsource': 'CONFIRM', 'tags': ['Mailing List', 'Mitigation', 'Third Party Advisory']}, {'url': 'http://www.securityfocus.com/bid/93775', 'name': '93775', 'refsource': 'BID', 'tags': ['Third Party Advisory', 'VDB Entry']}, {'url': 'https://security.gentoo.org/glsa/201701-48', 'name': 'GLSA-201701-48', 'refsource': 'GENTOO', 'tags': []}, {'url': 'http://rhn.redhat.com/errata/RHSA-2017-0794.html', 'name': 'RHSA-2017:0794', 'refsource': 'REDHAT', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-119'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:quagga:quagga:*:*:*:*:*:*:*:*', 'versionEndIncluding': '1.0.20160315', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:debian:debian_linux:8.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'It was discovered that the zebra daemon in Quagga before 1.0.20161017 suffered from a stack-based buffer overflow when processing IPv6 Neighbor Discovery messages. The root cause was relying on BUFSIZ to be compatible with a message size; however, BUFSIZ is system-dependent.'}] | 2018-01-05T02:30Z | 2017-02-22T23:59Z | 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 | David Lamparter | 2016-08-31 13:31:16+02:00 | zebra: stack overrun in IPv6 RA receive code (CVE-2016-1245)
The IPv6 RA code also receives ICMPv6 RS and RA messages.
Unfortunately, by bad coding practice, the buffer size specified on
receiving such messages mixed up 2 constants that in fact have
different values.
The code itself has:
#define RTADV_MSG_SIZE 4096
While BUFSIZ is system-dependent, in my case (x86_64 glibc):
/usr/include/_G_config.h:#define _G_BUFSIZ 8192
/usr/include/libio.h:#define _IO_BUFSIZ _G_BUFSIZ
/usr/include/stdio.h:# define BUFSIZ _IO_BUFSIZ
FreeBSD, OpenBSD, NetBSD and Illumos are not affected, since all of them
have BUFSIZ == 1024.
As the latter is passed to the kernel on recvmsg(), it's possible to
overwrite 4kB of stack -- with ICMPv6 packets that can be globally sent
to any of the system's addresses (using fragmentation to get to 8k).
(The socket has filters installed limiting this to RS and RA packets,
but does not have a filter for source address or TTL.)
Issue discovered by trying to test other stuff, which randomly caused
the stack to be smaller than 8kB in that code location, which then
causes the kernel to report EFAULT (Bad address).
Signed-off-by: David Lamparter <[email protected]>
Reviewed-by: Donald Sharp <[email protected]> | cfb1fae25f8c092e0d17073eaf7bd428ce1cd546 | False | Quagga/quagga | Quagga Tracking repository - Master is at http://git.savannah.gnu.org/cgit/quagga.git | 2012-02-17 13:22:22 | 2022-01-18 04:46:06 | http://www.nongnu.org/quagga/ | Quagga | 226.0 | 125.0 | rtadv_read | rtadv_read( struct thread * thread) | ['thread'] | rtadv_read (struct thread *thread)
{
int sock;
int len;
u_char buf[RTADV_MSG_SIZE];
struct sockaddr_in6 from;
ifindex_t ifindex = 0;
int hoplimit = -1;
struct zebra_vrf *zvrf = THREAD_ARG (thread);
sock = THREAD_FD (thread);
zvrf->rtadv.ra_read = NULL;
/* Register myself. */
rtadv_event (zvrf, RTADV_READ, sock);
len = rtadv_recv_packet (sock, buf, BUFSIZ, &from, &ifindex, &hoplimit);
if (len < 0)
{
zlog_warn ("router solicitation recv failed: %s.", safe_strerror (errno));
return len;
}
rtadv_process_packet (buf, (unsigned)len, ifindex, hoplimit, zvrf->vrf_id);
return 0;
} | 132 | True | 1 |
CVE-2021-3770 | 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/vim/vim/commit/b7081e135a16091c93f6f5f7525a5c58fb7ca9f9', 'name': 'https://github.com/vim/vim/commit/b7081e135a16091c93f6f5f7525a5c58fb7ca9f9', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://huntr.dev/bounties/016ad2f2-07c1-4d14-a8ce-6eed10729365', 'name': 'https://huntr.dev/bounties/016ad2f2-07c1-4d14-a8ce-6eed10729365', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Issue Tracking', 'Patch', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/J2CJLY3CF55I2ULG2X4ENXLSXAXYW5J4/', 'name': 'FEDORA-2021-5fa81a2b04', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/X4FFQARG3LGREPDZRI4C7ERQL3RJKEWQ/', 'name': 'FEDORA-2021-4a43cbe0b4', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/ZFNTMVZCN4TRTTCAXRLVQ7H2P7FYAIZQ/', 'name': 'FEDORA-2021-e982f972f2', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2021/10/01/1', 'name': "[oss-security] 20210930 3 new CVE's in vim", 'refsource': 'MLIST', 'tags': ['Mailing List', 'Patch', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-122'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.3408', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:fedoraproject:fedora:33:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:fedoraproject:fedora:34:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:fedoraproject:fedora:35:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'vim is vulnerable to Heap-based Buffer Overflow'}] | 2022-08-21T08:15Z | 2021-09-06T12:15Z | Heap-based Buffer Overflow | A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc(). | https://cwe.mitre.org/data/definitions/122.html | 0 | Bram Moolenaar | 2021-09-04 18:47:28+02:00 | patch 8.2.3402: invalid memory access when using :retab with large value
Problem: Invalid memory access when using :retab with large value.
Solution: Check the number is positive. | b7081e135a16091c93f6f5f7525a5c58fb7ca9f9 | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | ex_retab | ex_retab( exarg_T * eap) | ['eap'] | ex_retab(exarg_T *eap)
{
linenr_T lnum;
int got_tab = FALSE;
long num_spaces = 0;
long num_tabs;
long len;
long col;
long vcol;
long start_col = 0; // For start of white-space string
long start_vcol = 0; // For start of white-space string
long old_len;
char_u *ptr;
char_u *new_line = (char_u *)1; // init to non-NULL
int did_undo; // called u_save for current line
#ifdef FEAT_VARTABS
int *new_vts_array = NULL;
char_u *new_ts_str; // string value of tab argument
#else
int temp;
int new_ts;
#endif
int save_list;
linenr_T first_line = 0; // first changed line
linenr_T last_line = 0; // last changed line
save_list = curwin->w_p_list;
curwin->w_p_list = 0; // don't want list mode here
#ifdef FEAT_VARTABS
new_ts_str = eap->arg;
if (!tabstop_set(eap->arg, &new_vts_array))
return;
while (vim_isdigit(*(eap->arg)) || *(eap->arg) == ',')
++(eap->arg);
// This ensures that either new_vts_array and new_ts_str are freshly
// allocated, or new_vts_array points to an existing array and new_ts_str
// is null.
if (new_vts_array == NULL)
{
new_vts_array = curbuf->b_p_vts_array;
new_ts_str = NULL;
}
else
new_ts_str = vim_strnsave(new_ts_str, eap->arg - new_ts_str);
#else
new_ts = getdigits(&(eap->arg));
if (new_ts < 0)
{
emsg(_(e_positive));
return;
}
if (new_ts == 0)
new_ts = curbuf->b_p_ts;
#endif
for (lnum = eap->line1; !got_int && lnum <= eap->line2; ++lnum)
{
ptr = ml_get(lnum);
col = 0;
vcol = 0;
did_undo = FALSE;
for (;;)
{
if (VIM_ISWHITE(ptr[col]))
{
if (!got_tab && num_spaces == 0)
{
// First consecutive white-space
start_vcol = vcol;
start_col = col;
}
if (ptr[col] == ' ')
num_spaces++;
else
got_tab = TRUE;
}
else
{
if (got_tab || (eap->forceit && num_spaces > 1))
{
// Retabulate this string of white-space
// len is virtual length of white string
len = num_spaces = vcol - start_vcol;
num_tabs = 0;
if (!curbuf->b_p_et)
{
#ifdef FEAT_VARTABS
int t, s;
tabstop_fromto(start_vcol, vcol,
curbuf->b_p_ts, new_vts_array, &t, &s);
num_tabs = t;
num_spaces = s;
#else
temp = new_ts - (start_vcol % new_ts);
if (num_spaces >= temp)
{
num_spaces -= temp;
num_tabs++;
}
num_tabs += num_spaces / new_ts;
num_spaces -= (num_spaces / new_ts) * new_ts;
#endif
}
if (curbuf->b_p_et || got_tab ||
(num_spaces + num_tabs < len))
{
if (did_undo == FALSE)
{
did_undo = TRUE;
if (u_save((linenr_T)(lnum - 1),
(linenr_T)(lnum + 1)) == FAIL)
{
new_line = NULL; // flag out-of-memory
break;
}
}
// len is actual number of white characters used
len = num_spaces + num_tabs;
old_len = (long)STRLEN(ptr);
new_line = alloc(old_len - col + start_col + len + 1);
if (new_line == NULL)
break;
if (start_col > 0)
mch_memmove(new_line, ptr, (size_t)start_col);
mch_memmove(new_line + start_col + len,
ptr + col, (size_t)(old_len - col + 1));
ptr = new_line + start_col;
for (col = 0; col < len; col++)
ptr[col] = (col < num_tabs) ? '\t' : ' ';
if (ml_replace(lnum, new_line, FALSE) == OK)
// "new_line" may have been copied
new_line = curbuf->b_ml.ml_line_ptr;
if (first_line == 0)
first_line = lnum;
last_line = lnum;
ptr = new_line;
col = start_col + len;
}
}
got_tab = FALSE;
num_spaces = 0;
}
if (ptr[col] == NUL)
break;
vcol += chartabsize(ptr + col, (colnr_T)vcol);
if (has_mbyte)
col += (*mb_ptr2len)(ptr + col);
else
++col;
}
if (new_line == NULL) // out of memory
break;
line_breakcheck();
}
if (got_int)
emsg(_(e_interr));
#ifdef FEAT_VARTABS
// If a single value was given then it can be considered equal to
// either the value of 'tabstop' or the value of 'vartabstop'.
if (tabstop_count(curbuf->b_p_vts_array) == 0
&& tabstop_count(new_vts_array) == 1
&& curbuf->b_p_ts == tabstop_first(new_vts_array))
; // not changed
else if (tabstop_count(curbuf->b_p_vts_array) > 0
&& tabstop_eq(curbuf->b_p_vts_array, new_vts_array))
; // not changed
else
redraw_curbuf_later(NOT_VALID);
#else
if (curbuf->b_p_ts != new_ts)
redraw_curbuf_later(NOT_VALID);
#endif
if (first_line != 0)
changed_lines(first_line, 0, last_line + 1, 0L);
curwin->w_p_list = save_list; // restore 'list'
#ifdef FEAT_VARTABS
if (new_ts_str != NULL) // set the new tabstop
{
// If 'vartabstop' is in use or if the value given to retab has more
// than one tabstop then update 'vartabstop'.
int *old_vts_ary = curbuf->b_p_vts_array;
if (tabstop_count(old_vts_ary) > 0 || tabstop_count(new_vts_array) > 1)
{
set_string_option_direct((char_u *)"vts", -1, new_ts_str,
OPT_FREE|OPT_LOCAL, 0);
curbuf->b_p_vts_array = new_vts_array;
vim_free(old_vts_ary);
}
else
{
// 'vartabstop' wasn't in use and a single value was given to
// retab then update 'tabstop'.
curbuf->b_p_ts = tabstop_first(new_vts_array);
vim_free(new_vts_array);
}
vim_free(new_ts_str);
}
#else
curbuf->b_p_ts = new_ts;
#endif
coladvance(curwin->w_curswant);
u_clearline();
} | 934 | True | 1 |
|
CVE-2021-3770 | 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/vim/vim/commit/b7081e135a16091c93f6f5f7525a5c58fb7ca9f9', 'name': 'https://github.com/vim/vim/commit/b7081e135a16091c93f6f5f7525a5c58fb7ca9f9', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://huntr.dev/bounties/016ad2f2-07c1-4d14-a8ce-6eed10729365', 'name': 'https://huntr.dev/bounties/016ad2f2-07c1-4d14-a8ce-6eed10729365', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Issue Tracking', 'Patch', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/J2CJLY3CF55I2ULG2X4ENXLSXAXYW5J4/', 'name': 'FEDORA-2021-5fa81a2b04', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/X4FFQARG3LGREPDZRI4C7ERQL3RJKEWQ/', 'name': 'FEDORA-2021-4a43cbe0b4', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/ZFNTMVZCN4TRTTCAXRLVQ7H2P7FYAIZQ/', 'name': 'FEDORA-2021-e982f972f2', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2021/10/01/1', 'name': "[oss-security] 20210930 3 new CVE's in vim", 'refsource': 'MLIST', 'tags': ['Mailing List', 'Patch', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-122'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.3408', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:fedoraproject:fedora:33:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:fedoraproject:fedora:34:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:fedoraproject:fedora:35:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'vim is vulnerable to Heap-based Buffer Overflow'}] | 2022-08-21T08:15Z | 2021-09-06T12:15Z | Heap-based Buffer Overflow | A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc(). | https://cwe.mitre.org/data/definitions/122.html | 0 | Bram Moolenaar | 2021-09-04 18:47:28+02:00 | patch 8.2.3402: invalid memory access when using :retab with large value
Problem: Invalid memory access when using :retab with large value.
Solution: Check the number is positive. | b7081e135a16091c93f6f5f7525a5c58fb7ca9f9 | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | tabstop_set | tabstop_set( char_u * var , int ** array) | ['var', 'array'] | tabstop_set(char_u *var, int **array)
{
int valcount = 1;
int t;
char_u *cp;
if (var[0] == NUL || (var[0] == '0' && var[1] == NUL))
{
*array = NULL;
return TRUE;
}
for (cp = var; *cp != NUL; ++cp)
{
if (cp == var || cp[-1] == ',')
{
char_u *end;
if (strtol((char *)cp, (char **)&end, 10) <= 0)
{
if (cp != end)
emsg(_(e_positive));
else
emsg(_(e_invarg));
return FALSE;
}
}
if (VIM_ISDIGIT(*cp))
continue;
if (cp[0] == ',' && cp > var && cp[-1] != ',' && cp[1] != NUL)
{
++valcount;
continue;
}
emsg(_(e_invarg));
return FALSE;
}
*array = ALLOC_MULT(int, valcount + 1);
if (*array == NULL)
return FALSE;
(*array)[0] = valcount;
t = 1;
for (cp = var; *cp != NUL;)
{
(*array)[t++] = atoi((char *)cp);
while (*cp != NUL && *cp != ',')
++cp;
if (*cp != NUL)
++cp;
}
return TRUE;
} | 297 | True | 1 |
|
CVE-2021-3770 | 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/vim/vim/commit/b7081e135a16091c93f6f5f7525a5c58fb7ca9f9', 'name': 'https://github.com/vim/vim/commit/b7081e135a16091c93f6f5f7525a5c58fb7ca9f9', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://huntr.dev/bounties/016ad2f2-07c1-4d14-a8ce-6eed10729365', 'name': 'https://huntr.dev/bounties/016ad2f2-07c1-4d14-a8ce-6eed10729365', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Issue Tracking', 'Patch', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/J2CJLY3CF55I2ULG2X4ENXLSXAXYW5J4/', 'name': 'FEDORA-2021-5fa81a2b04', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/X4FFQARG3LGREPDZRI4C7ERQL3RJKEWQ/', 'name': 'FEDORA-2021-4a43cbe0b4', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/ZFNTMVZCN4TRTTCAXRLVQ7H2P7FYAIZQ/', 'name': 'FEDORA-2021-e982f972f2', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2021/10/01/1', 'name': "[oss-security] 20210930 3 new CVE's in vim", 'refsource': 'MLIST', 'tags': ['Mailing List', 'Patch', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-122'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.3408', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:fedoraproject:fedora:33:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:fedoraproject:fedora:34:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:fedoraproject:fedora:35:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'vim is vulnerable to Heap-based Buffer Overflow'}] | 2022-08-21T08:15Z | 2021-09-06T12:15Z | Heap-based Buffer Overflow | A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc(). | https://cwe.mitre.org/data/definitions/122.html | 0 | Bram Moolenaar | 2021-09-04 18:47:28+02:00 | patch 8.2.3402: invalid memory access when using :retab with large value
Problem: Invalid memory access when using :retab with large value.
Solution: Check the number is positive. | b7081e135a16091c93f6f5f7525a5c58fb7ca9f9 | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | buf_copy_options | buf_copy_options( buf_T * buf , int flags) | ['buf', 'flags'] | buf_copy_options(buf_T *buf, int flags)
{
int should_copy = TRUE;
char_u *save_p_isk = NULL; // init for GCC
int dont_do_help;
int did_isk = FALSE;
/*
* Skip this when the option defaults have not been set yet. Happens when
* main() allocates the first buffer.
*/
if (p_cpo != NULL)
{
/*
* Always copy when entering and 'cpo' contains 'S'.
* Don't copy when already initialized.
* Don't copy when 'cpo' contains 's' and not entering.
* 'S' BCO_ENTER initialized 's' should_copy
* yes yes X X TRUE
* yes no yes X FALSE
* no X yes X FALSE
* X no no yes FALSE
* X no no no TRUE
* no yes no X TRUE
*/
if ((vim_strchr(p_cpo, CPO_BUFOPTGLOB) == NULL || !(flags & BCO_ENTER))
&& (buf->b_p_initialized
|| (!(flags & BCO_ENTER)
&& vim_strchr(p_cpo, CPO_BUFOPT) != NULL)))
should_copy = FALSE;
if (should_copy || (flags & BCO_ALWAYS))
{
#ifdef FEAT_EVAL
CLEAR_FIELD(buf->b_p_script_ctx);
init_buf_opt_idx();
#endif
// Don't copy the options specific to a help buffer when
// BCO_NOHELP is given or the options were initialized already
// (jumping back to a help file with CTRL-T or CTRL-O)
dont_do_help = ((flags & BCO_NOHELP) && buf->b_help)
|| buf->b_p_initialized;
if (dont_do_help) // don't free b_p_isk
{
save_p_isk = buf->b_p_isk;
buf->b_p_isk = NULL;
}
/*
* Always free the allocated strings. If not already initialized,
* reset 'readonly' and copy 'fileformat'.
*/
if (!buf->b_p_initialized)
{
free_buf_options(buf, TRUE);
buf->b_p_ro = FALSE; // don't copy readonly
buf->b_p_tx = p_tx;
buf->b_p_fenc = vim_strsave(p_fenc);
switch (*p_ffs)
{
case 'm':
buf->b_p_ff = vim_strsave((char_u *)FF_MAC); break;
case 'd':
buf->b_p_ff = vim_strsave((char_u *)FF_DOS); break;
case 'u':
buf->b_p_ff = vim_strsave((char_u *)FF_UNIX); break;
default:
buf->b_p_ff = vim_strsave(p_ff);
}
if (buf->b_p_ff != NULL)
buf->b_start_ffc = *buf->b_p_ff;
buf->b_p_bh = empty_option;
buf->b_p_bt = empty_option;
}
else
free_buf_options(buf, FALSE);
buf->b_p_ai = p_ai;
COPY_OPT_SCTX(buf, BV_AI);
buf->b_p_ai_nopaste = p_ai_nopaste;
buf->b_p_sw = p_sw;
COPY_OPT_SCTX(buf, BV_SW);
buf->b_p_tw = p_tw;
COPY_OPT_SCTX(buf, BV_TW);
buf->b_p_tw_nopaste = p_tw_nopaste;
buf->b_p_tw_nobin = p_tw_nobin;
buf->b_p_wm = p_wm;
COPY_OPT_SCTX(buf, BV_WM);
buf->b_p_wm_nopaste = p_wm_nopaste;
buf->b_p_wm_nobin = p_wm_nobin;
buf->b_p_bin = p_bin;
COPY_OPT_SCTX(buf, BV_BIN);
buf->b_p_bomb = p_bomb;
COPY_OPT_SCTX(buf, BV_BOMB);
buf->b_p_fixeol = p_fixeol;
COPY_OPT_SCTX(buf, BV_FIXEOL);
buf->b_p_et = p_et;
COPY_OPT_SCTX(buf, BV_ET);
buf->b_p_et_nobin = p_et_nobin;
buf->b_p_et_nopaste = p_et_nopaste;
buf->b_p_ml = p_ml;
COPY_OPT_SCTX(buf, BV_ML);
buf->b_p_ml_nobin = p_ml_nobin;
buf->b_p_inf = p_inf;
COPY_OPT_SCTX(buf, BV_INF);
if (cmdmod.cmod_flags & CMOD_NOSWAPFILE)
buf->b_p_swf = FALSE;
else
{
buf->b_p_swf = p_swf;
COPY_OPT_SCTX(buf, BV_INF);
}
buf->b_p_cpt = vim_strsave(p_cpt);
COPY_OPT_SCTX(buf, BV_CPT);
#ifdef BACKSLASH_IN_FILENAME
buf->b_p_csl = vim_strsave(p_csl);
COPY_OPT_SCTX(buf, BV_CSL);
#endif
#ifdef FEAT_COMPL_FUNC
buf->b_p_cfu = vim_strsave(p_cfu);
COPY_OPT_SCTX(buf, BV_CFU);
buf->b_p_ofu = vim_strsave(p_ofu);
COPY_OPT_SCTX(buf, BV_OFU);
#endif
#ifdef FEAT_EVAL
buf->b_p_tfu = vim_strsave(p_tfu);
COPY_OPT_SCTX(buf, BV_TFU);
#endif
buf->b_p_sts = p_sts;
COPY_OPT_SCTX(buf, BV_STS);
buf->b_p_sts_nopaste = p_sts_nopaste;
#ifdef FEAT_VARTABS
buf->b_p_vsts = vim_strsave(p_vsts);
COPY_OPT_SCTX(buf, BV_VSTS);
if (p_vsts && p_vsts != empty_option)
tabstop_set(p_vsts, &buf->b_p_vsts_array);
else
buf->b_p_vsts_array = 0;
buf->b_p_vsts_nopaste = p_vsts_nopaste
? vim_strsave(p_vsts_nopaste) : NULL;
#endif
buf->b_p_sn = p_sn;
COPY_OPT_SCTX(buf, BV_SN);
buf->b_p_com = vim_strsave(p_com);
COPY_OPT_SCTX(buf, BV_COM);
#ifdef FEAT_FOLDING
buf->b_p_cms = vim_strsave(p_cms);
COPY_OPT_SCTX(buf, BV_CMS);
#endif
buf->b_p_fo = vim_strsave(p_fo);
COPY_OPT_SCTX(buf, BV_FO);
buf->b_p_flp = vim_strsave(p_flp);
COPY_OPT_SCTX(buf, BV_FLP);
// NOTE: Valgrind may report a bogus memory leak for 'nrformats'
// when it is set to 8 bytes in defaults.vim.
buf->b_p_nf = vim_strsave(p_nf);
COPY_OPT_SCTX(buf, BV_NF);
buf->b_p_mps = vim_strsave(p_mps);
COPY_OPT_SCTX(buf, BV_MPS);
#ifdef FEAT_SMARTINDENT
buf->b_p_si = p_si;
COPY_OPT_SCTX(buf, BV_SI);
#endif
buf->b_p_ci = p_ci;
COPY_OPT_SCTX(buf, BV_CI);
#ifdef FEAT_CINDENT
buf->b_p_cin = p_cin;
COPY_OPT_SCTX(buf, BV_CIN);
buf->b_p_cink = vim_strsave(p_cink);
COPY_OPT_SCTX(buf, BV_CINK);
buf->b_p_cino = vim_strsave(p_cino);
COPY_OPT_SCTX(buf, BV_CINO);
#endif
// Don't copy 'filetype', it must be detected
buf->b_p_ft = empty_option;
buf->b_p_pi = p_pi;
COPY_OPT_SCTX(buf, BV_PI);
#if defined(FEAT_SMARTINDENT) || defined(FEAT_CINDENT)
buf->b_p_cinw = vim_strsave(p_cinw);
COPY_OPT_SCTX(buf, BV_CINW);
#endif
#ifdef FEAT_LISP
buf->b_p_lisp = p_lisp;
COPY_OPT_SCTX(buf, BV_LISP);
#endif
#ifdef FEAT_SYN_HL
// Don't copy 'syntax', it must be set
buf->b_p_syn = empty_option;
buf->b_p_smc = p_smc;
COPY_OPT_SCTX(buf, BV_SMC);
buf->b_s.b_syn_isk = empty_option;
#endif
#ifdef FEAT_SPELL
buf->b_s.b_p_spc = vim_strsave(p_spc);
COPY_OPT_SCTX(buf, BV_SPC);
(void)compile_cap_prog(&buf->b_s);
buf->b_s.b_p_spf = vim_strsave(p_spf);
COPY_OPT_SCTX(buf, BV_SPF);
buf->b_s.b_p_spl = vim_strsave(p_spl);
COPY_OPT_SCTX(buf, BV_SPL);
buf->b_s.b_p_spo = vim_strsave(p_spo);
COPY_OPT_SCTX(buf, BV_SPO);
#endif
#if defined(FEAT_CINDENT) && defined(FEAT_EVAL)
buf->b_p_inde = vim_strsave(p_inde);
COPY_OPT_SCTX(buf, BV_INDE);
buf->b_p_indk = vim_strsave(p_indk);
COPY_OPT_SCTX(buf, BV_INDK);
#endif
buf->b_p_fp = empty_option;
#if defined(FEAT_EVAL)
buf->b_p_fex = vim_strsave(p_fex);
COPY_OPT_SCTX(buf, BV_FEX);
#endif
#ifdef FEAT_CRYPT
buf->b_p_key = vim_strsave(p_key);
COPY_OPT_SCTX(buf, BV_KEY);
#endif
#ifdef FEAT_SEARCHPATH
buf->b_p_sua = vim_strsave(p_sua);
COPY_OPT_SCTX(buf, BV_SUA);
#endif
#ifdef FEAT_KEYMAP
buf->b_p_keymap = vim_strsave(p_keymap);
COPY_OPT_SCTX(buf, BV_KMAP);
buf->b_kmap_state |= KEYMAP_INIT;
#endif
#ifdef FEAT_TERMINAL
buf->b_p_twsl = p_twsl;
COPY_OPT_SCTX(buf, BV_TWSL);
#endif
// This isn't really an option, but copying the langmap and IME
// state from the current buffer is better than resetting it.
buf->b_p_iminsert = p_iminsert;
COPY_OPT_SCTX(buf, BV_IMI);
buf->b_p_imsearch = p_imsearch;
COPY_OPT_SCTX(buf, BV_IMS);
// options that are normally global but also have a local value
// are not copied, start using the global value
buf->b_p_ar = -1;
buf->b_p_ul = NO_LOCAL_UNDOLEVEL;
buf->b_p_bkc = empty_option;
buf->b_bkc_flags = 0;
#ifdef FEAT_QUICKFIX
buf->b_p_gp = empty_option;
buf->b_p_mp = empty_option;
buf->b_p_efm = empty_option;
#endif
buf->b_p_ep = empty_option;
buf->b_p_kp = empty_option;
buf->b_p_path = empty_option;
buf->b_p_tags = empty_option;
buf->b_p_tc = empty_option;
buf->b_tc_flags = 0;
#ifdef FEAT_FIND_ID
buf->b_p_def = empty_option;
buf->b_p_inc = empty_option;
# ifdef FEAT_EVAL
buf->b_p_inex = vim_strsave(p_inex);
COPY_OPT_SCTX(buf, BV_INEX);
# endif
#endif
buf->b_p_dict = empty_option;
buf->b_p_tsr = empty_option;
#ifdef FEAT_TEXTOBJ
buf->b_p_qe = vim_strsave(p_qe);
COPY_OPT_SCTX(buf, BV_QE);
#endif
#if defined(FEAT_BEVAL) && defined(FEAT_EVAL)
buf->b_p_bexpr = empty_option;
#endif
#if defined(FEAT_CRYPT)
buf->b_p_cm = empty_option;
#endif
#ifdef FEAT_PERSISTENT_UNDO
buf->b_p_udf = p_udf;
COPY_OPT_SCTX(buf, BV_UDF);
#endif
#ifdef FEAT_LISP
buf->b_p_lw = empty_option;
#endif
buf->b_p_menc = empty_option;
/*
* Don't copy the options set by ex_help(), use the saved values,
* when going from a help buffer to a non-help buffer.
* Don't touch these at all when BCO_NOHELP is used and going from
* or to a help buffer.
*/
if (dont_do_help)
{
buf->b_p_isk = save_p_isk;
#ifdef FEAT_VARTABS
if (p_vts && p_vts != empty_option && !buf->b_p_vts_array)
tabstop_set(p_vts, &buf->b_p_vts_array);
else
buf->b_p_vts_array = NULL;
#endif
}
else
{
buf->b_p_isk = vim_strsave(p_isk);
COPY_OPT_SCTX(buf, BV_ISK);
did_isk = TRUE;
buf->b_p_ts = p_ts;
#ifdef FEAT_VARTABS
buf->b_p_vts = vim_strsave(p_vts);
COPY_OPT_SCTX(buf, BV_VTS);
if (p_vts && p_vts != empty_option && !buf->b_p_vts_array)
tabstop_set(p_vts, &buf->b_p_vts_array);
else
buf->b_p_vts_array = NULL;
#endif
buf->b_help = FALSE;
if (buf->b_p_bt[0] == 'h')
clear_string_option(&buf->b_p_bt);
buf->b_p_ma = p_ma;
COPY_OPT_SCTX(buf, BV_MA);
}
}
/*
* When the options should be copied (ignoring BCO_ALWAYS), set the
* flag that indicates that the options have been initialized.
*/
if (should_copy)
buf->b_p_initialized = TRUE;
}
check_buf_options(buf); // make sure we don't have NULLs
if (did_isk)
(void)buf_init_chartab(buf, FALSE);
} | 1493 | True | 1 |
|
CVE-2021-3770 | 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/vim/vim/commit/b7081e135a16091c93f6f5f7525a5c58fb7ca9f9', 'name': 'https://github.com/vim/vim/commit/b7081e135a16091c93f6f5f7525a5c58fb7ca9f9', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://huntr.dev/bounties/016ad2f2-07c1-4d14-a8ce-6eed10729365', 'name': 'https://huntr.dev/bounties/016ad2f2-07c1-4d14-a8ce-6eed10729365', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Issue Tracking', 'Patch', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/J2CJLY3CF55I2ULG2X4ENXLSXAXYW5J4/', 'name': 'FEDORA-2021-5fa81a2b04', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/X4FFQARG3LGREPDZRI4C7ERQL3RJKEWQ/', 'name': 'FEDORA-2021-4a43cbe0b4', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/ZFNTMVZCN4TRTTCAXRLVQ7H2P7FYAIZQ/', 'name': 'FEDORA-2021-e982f972f2', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2021/10/01/1', 'name': "[oss-security] 20210930 3 new CVE's in vim", 'refsource': 'MLIST', 'tags': ['Mailing List', 'Patch', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-122'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.3408', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:fedoraproject:fedora:33:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:fedoraproject:fedora:34:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:fedoraproject:fedora:35:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'vim is vulnerable to Heap-based Buffer Overflow'}] | 2022-08-21T08:15Z | 2021-09-06T12:15Z | Heap-based Buffer Overflow | A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc(). | https://cwe.mitre.org/data/definitions/122.html | 0 | Bram Moolenaar | 2021-09-04 18:47:28+02:00 | patch 8.2.3402: invalid memory access when using :retab with large value
Problem: Invalid memory access when using :retab with large value.
Solution: Check the number is positive. | b7081e135a16091c93f6f5f7525a5c58fb7ca9f9 | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | didset_options2 | didset_options2( void) | ['void'] | didset_options2(void)
{
// Initialize the highlight_attr[] table.
(void)highlight_changed();
// Parse default for 'wildmode'
check_opt_wim();
// Parse default for 'listchars'.
(void)set_chars_option(curwin, &curwin->w_p_lcs);
// Parse default for 'fillchars'.
(void)set_chars_option(curwin, &p_fcs);
#ifdef FEAT_CLIPBOARD
// Parse default for 'clipboard'
(void)check_clipboard_option();
#endif
#ifdef FEAT_VARTABS
vim_free(curbuf->b_p_vsts_array);
tabstop_set(curbuf->b_p_vsts, &curbuf->b_p_vsts_array);
vim_free(curbuf->b_p_vts_array);
tabstop_set(curbuf->b_p_vts, &curbuf->b_p_vts_array);
#endif
} | 86 | True | 1 |
|
CVE-2021-3770 | 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/vim/vim/commit/b7081e135a16091c93f6f5f7525a5c58fb7ca9f9', 'name': 'https://github.com/vim/vim/commit/b7081e135a16091c93f6f5f7525a5c58fb7ca9f9', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://huntr.dev/bounties/016ad2f2-07c1-4d14-a8ce-6eed10729365', 'name': 'https://huntr.dev/bounties/016ad2f2-07c1-4d14-a8ce-6eed10729365', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Issue Tracking', 'Patch', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/J2CJLY3CF55I2ULG2X4ENXLSXAXYW5J4/', 'name': 'FEDORA-2021-5fa81a2b04', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/X4FFQARG3LGREPDZRI4C7ERQL3RJKEWQ/', 'name': 'FEDORA-2021-4a43cbe0b4', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/ZFNTMVZCN4TRTTCAXRLVQ7H2P7FYAIZQ/', 'name': 'FEDORA-2021-e982f972f2', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2021/10/01/1', 'name': "[oss-security] 20210930 3 new CVE's in vim", 'refsource': 'MLIST', 'tags': ['Mailing List', 'Patch', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-122'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.3408', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:fedoraproject:fedora:33:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:fedoraproject:fedora:34:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:fedoraproject:fedora:35:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'vim is vulnerable to Heap-based Buffer Overflow'}] | 2022-08-21T08:15Z | 2021-09-06T12:15Z | Heap-based Buffer Overflow | A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc(). | https://cwe.mitre.org/data/definitions/122.html | 0 | Bram Moolenaar | 2021-09-04 18:47:28+02:00 | patch 8.2.3402: invalid memory access when using :retab with large value
Problem: Invalid memory access when using :retab with large value.
Solution: Check the number is positive. | b7081e135a16091c93f6f5f7525a5c58fb7ca9f9 | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | paste_option_changed | paste_option_changed( void) | ['void'] | paste_option_changed(void)
{
static int old_p_paste = FALSE;
static int save_sm = 0;
static int save_sta = 0;
#ifdef FEAT_CMDL_INFO
static int save_ru = 0;
#endif
#ifdef FEAT_RIGHTLEFT
static int save_ri = 0;
static int save_hkmap = 0;
#endif
buf_T *buf;
if (p_paste)
{
/*
* Paste switched from off to on.
* Save the current values, so they can be restored later.
*/
if (!old_p_paste)
{
// save options for each buffer
FOR_ALL_BUFFERS(buf)
{
buf->b_p_tw_nopaste = buf->b_p_tw;
buf->b_p_wm_nopaste = buf->b_p_wm;
buf->b_p_sts_nopaste = buf->b_p_sts;
buf->b_p_ai_nopaste = buf->b_p_ai;
buf->b_p_et_nopaste = buf->b_p_et;
#ifdef FEAT_VARTABS
if (buf->b_p_vsts_nopaste)
vim_free(buf->b_p_vsts_nopaste);
buf->b_p_vsts_nopaste = buf->b_p_vsts && buf->b_p_vsts != empty_option
? vim_strsave(buf->b_p_vsts) : NULL;
#endif
}
// save global options
save_sm = p_sm;
save_sta = p_sta;
#ifdef FEAT_CMDL_INFO
save_ru = p_ru;
#endif
#ifdef FEAT_RIGHTLEFT
save_ri = p_ri;
save_hkmap = p_hkmap;
#endif
// save global values for local buffer options
p_ai_nopaste = p_ai;
p_et_nopaste = p_et;
p_sts_nopaste = p_sts;
p_tw_nopaste = p_tw;
p_wm_nopaste = p_wm;
#ifdef FEAT_VARTABS
if (p_vsts_nopaste)
vim_free(p_vsts_nopaste);
p_vsts_nopaste = p_vsts && p_vsts != empty_option ? vim_strsave(p_vsts) : NULL;
#endif
}
/*
* Always set the option values, also when 'paste' is set when it is
* already on.
*/
// set options for each buffer
FOR_ALL_BUFFERS(buf)
{
buf->b_p_tw = 0; // textwidth is 0
buf->b_p_wm = 0; // wrapmargin is 0
buf->b_p_sts = 0; // softtabstop is 0
buf->b_p_ai = 0; // no auto-indent
buf->b_p_et = 0; // no expandtab
#ifdef FEAT_VARTABS
if (buf->b_p_vsts)
free_string_option(buf->b_p_vsts);
buf->b_p_vsts = empty_option;
if (buf->b_p_vsts_array)
vim_free(buf->b_p_vsts_array);
buf->b_p_vsts_array = 0;
#endif
}
// set global options
p_sm = 0; // no showmatch
p_sta = 0; // no smarttab
#ifdef FEAT_CMDL_INFO
if (p_ru)
status_redraw_all(); // redraw to remove the ruler
p_ru = 0; // no ruler
#endif
#ifdef FEAT_RIGHTLEFT
p_ri = 0; // no reverse insert
p_hkmap = 0; // no Hebrew keyboard
#endif
// set global values for local buffer options
p_tw = 0;
p_wm = 0;
p_sts = 0;
p_ai = 0;
#ifdef FEAT_VARTABS
if (p_vsts)
free_string_option(p_vsts);
p_vsts = empty_option;
#endif
}
/*
* Paste switched from on to off: Restore saved values.
*/
else if (old_p_paste)
{
// restore options for each buffer
FOR_ALL_BUFFERS(buf)
{
buf->b_p_tw = buf->b_p_tw_nopaste;
buf->b_p_wm = buf->b_p_wm_nopaste;
buf->b_p_sts = buf->b_p_sts_nopaste;
buf->b_p_ai = buf->b_p_ai_nopaste;
buf->b_p_et = buf->b_p_et_nopaste;
#ifdef FEAT_VARTABS
if (buf->b_p_vsts)
free_string_option(buf->b_p_vsts);
buf->b_p_vsts = buf->b_p_vsts_nopaste
? vim_strsave(buf->b_p_vsts_nopaste) : empty_option;
if (buf->b_p_vsts_array)
vim_free(buf->b_p_vsts_array);
if (buf->b_p_vsts && buf->b_p_vsts != empty_option)
tabstop_set(buf->b_p_vsts, &buf->b_p_vsts_array);
else
buf->b_p_vsts_array = 0;
#endif
}
// restore global options
p_sm = save_sm;
p_sta = save_sta;
#ifdef FEAT_CMDL_INFO
if (p_ru != save_ru)
status_redraw_all(); // redraw to draw the ruler
p_ru = save_ru;
#endif
#ifdef FEAT_RIGHTLEFT
p_ri = save_ri;
p_hkmap = save_hkmap;
#endif
// set global values for local buffer options
p_ai = p_ai_nopaste;
p_et = p_et_nopaste;
p_sts = p_sts_nopaste;
p_tw = p_tw_nopaste;
p_wm = p_wm_nopaste;
#ifdef FEAT_VARTABS
if (p_vsts)
free_string_option(p_vsts);
p_vsts = p_vsts_nopaste ? vim_strsave(p_vsts_nopaste) : empty_option;
#endif
}
old_p_paste = p_paste;
} | 537 | True | 1 |
|
CVE-2021-3770 | 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/vim/vim/commit/b7081e135a16091c93f6f5f7525a5c58fb7ca9f9', 'name': 'https://github.com/vim/vim/commit/b7081e135a16091c93f6f5f7525a5c58fb7ca9f9', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://huntr.dev/bounties/016ad2f2-07c1-4d14-a8ce-6eed10729365', 'name': 'https://huntr.dev/bounties/016ad2f2-07c1-4d14-a8ce-6eed10729365', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Issue Tracking', 'Patch', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/J2CJLY3CF55I2ULG2X4ENXLSXAXYW5J4/', 'name': 'FEDORA-2021-5fa81a2b04', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/X4FFQARG3LGREPDZRI4C7ERQL3RJKEWQ/', 'name': 'FEDORA-2021-4a43cbe0b4', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/ZFNTMVZCN4TRTTCAXRLVQ7H2P7FYAIZQ/', 'name': 'FEDORA-2021-e982f972f2', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2021/10/01/1', 'name': "[oss-security] 20210930 3 new CVE's in vim", 'refsource': 'MLIST', 'tags': ['Mailing List', 'Patch', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-122'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.3408', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:fedoraproject:fedora:33:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:fedoraproject:fedora:34:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:fedoraproject:fedora:35:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'vim is vulnerable to Heap-based Buffer Overflow'}] | 2022-08-21T08:15Z | 2021-09-06T12:15Z | Heap-based Buffer Overflow | A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc(). | https://cwe.mitre.org/data/definitions/122.html | 0 | Bram Moolenaar | 2021-09-04 18:47:28+02:00 | patch 8.2.3402: invalid memory access when using :retab with large value
Problem: Invalid memory access when using :retab with large value.
Solution: Check the number is positive. | b7081e135a16091c93f6f5f7525a5c58fb7ca9f9 | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | did_set_string_option | did_set_string_option( int opt_idx , char_u ** varp , int new_value_alloced , char_u * oldval , char * errbuf , int opt_flags , int * value_checked) | ['opt_idx', 'varp', 'new_value_alloced', 'oldval', 'errbuf', 'opt_flags', 'value_checked'] | did_set_string_option(
int opt_idx, // index in options[] table
char_u **varp, // pointer to the option variable
int new_value_alloced, // new value was allocated
char_u *oldval, // previous value of the option
char *errbuf, // buffer for errors, or NULL
int opt_flags, // OPT_LOCAL and/or OPT_GLOBAL
int *value_checked) // value was checked to be save, no
// need to set P_INSECURE
{
char *errmsg = NULL;
char_u *s, *p;
int did_chartab = FALSE;
char_u **gvarp;
long_u free_oldval = (get_option_flags(opt_idx) & P_ALLOCED);
#ifdef FEAT_GUI
// set when changing an option that only requires a redraw in the GUI
int redraw_gui_only = FALSE;
#endif
int value_changed = FALSE;
#if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS)
int did_swaptcap = FALSE;
#endif
// Get the global option to compare with, otherwise we would have to check
// two values for all local options.
gvarp = (char_u **)get_option_varp_scope(opt_idx, OPT_GLOBAL);
// Disallow changing some options from secure mode
if ((secure
#ifdef HAVE_SANDBOX
|| sandbox != 0
#endif
) && (get_option_flags(opt_idx) & P_SECURE))
errmsg = e_secure;
// Check for a "normal" directory or file name in some options. Disallow a
// path separator (slash and/or backslash), wildcards and characters that
// are often illegal in a file name. Be more permissive if "secure" is off.
else if (((get_option_flags(opt_idx) & P_NFNAME)
&& vim_strpbrk(*varp, (char_u *)(secure
? "/\\*?[|;&<>\r\n" : "/\\*?[<>\r\n")) != NULL)
|| ((get_option_flags(opt_idx) & P_NDNAME)
&& vim_strpbrk(*varp, (char_u *)"*?[|;&<>\r\n") != NULL))
errmsg = e_invarg;
// 'term'
else if (varp == &T_NAME)
{
if (T_NAME[0] == NUL)
errmsg = N_("E529: Cannot set 'term' to empty string");
#ifdef FEAT_GUI
else if (gui.in_use)
errmsg = N_("E530: Cannot change term in GUI");
else if (term_is_gui(T_NAME))
errmsg = N_("E531: Use \":gui\" to start the GUI");
#endif
else if (set_termname(T_NAME) == FAIL)
errmsg = N_("E522: Not found in termcap");
else
{
// Screen colors may have changed.
redraw_later_clear();
// Both 'term' and 'ttytype' point to T_NAME, only set the
// P_ALLOCED flag on 'term'.
opt_idx = findoption((char_u *)"term");
free_oldval = (get_option_flags(opt_idx) & P_ALLOCED);
}
}
// 'backupcopy'
else if (gvarp == &p_bkc)
{
char_u *bkc = p_bkc;
unsigned int *flags = &bkc_flags;
if (opt_flags & OPT_LOCAL)
{
bkc = curbuf->b_p_bkc;
flags = &curbuf->b_bkc_flags;
}
if ((opt_flags & OPT_LOCAL) && *bkc == NUL)
// make the local value empty: use the global value
*flags = 0;
else
{
if (opt_strings_flags(bkc, p_bkc_values, flags, TRUE) != OK)
errmsg = e_invarg;
if ((((int)*flags & BKC_AUTO) != 0)
+ (((int)*flags & BKC_YES) != 0)
+ (((int)*flags & BKC_NO) != 0) != 1)
{
// Must have exactly one of "auto", "yes" and "no".
(void)opt_strings_flags(oldval, p_bkc_values, flags, TRUE);
errmsg = e_invarg;
}
}
}
// 'backupext' and 'patchmode'
else if (varp == &p_bex || varp == &p_pm)
{
if (STRCMP(*p_bex == '.' ? p_bex + 1 : p_bex,
*p_pm == '.' ? p_pm + 1 : p_pm) == 0)
errmsg = N_("E589: 'backupext' and 'patchmode' are equal");
}
#ifdef FEAT_LINEBREAK
// 'breakindentopt'
else if (varp == &curwin->w_p_briopt)
{
if (briopt_check(curwin) == FAIL)
errmsg = e_invarg;
}
#endif
// 'isident', 'iskeyword', 'isprint or 'isfname' option: refill g_chartab[]
// If the new option is invalid, use old value. 'lisp' option: refill
// g_chartab[] for '-' char
else if ( varp == &p_isi
|| varp == &(curbuf->b_p_isk)
|| varp == &p_isp
|| varp == &p_isf)
{
if (init_chartab() == FAIL)
{
did_chartab = TRUE; // need to restore it below
errmsg = e_invarg; // error in value
}
}
// 'helpfile'
else if (varp == &p_hf)
{
// May compute new values for $VIM and $VIMRUNTIME
if (didset_vim)
{
vim_setenv((char_u *)"VIM", (char_u *)"");
didset_vim = FALSE;
}
if (didset_vimruntime)
{
vim_setenv((char_u *)"VIMRUNTIME", (char_u *)"");
didset_vimruntime = FALSE;
}
}
#ifdef FEAT_SYN_HL
// 'cursorlineopt'
else if (varp == &curwin->w_p_culopt
|| gvarp == &curwin->w_allbuf_opt.wo_culopt)
{
if (**varp == NUL || fill_culopt_flags(*varp, curwin) != OK)
errmsg = e_invarg;
}
// 'colorcolumn'
else if (varp == &curwin->w_p_cc)
errmsg = check_colorcolumn(curwin);
#endif
#ifdef FEAT_MULTI_LANG
// 'helplang'
else if (varp == &p_hlg)
{
// Check for "", "ab", "ab,cd", etc.
for (s = p_hlg; *s != NUL; s += 3)
{
if (s[1] == NUL || ((s[2] != ',' || s[3] == NUL) && s[2] != NUL))
{
errmsg = e_invarg;
break;
}
if (s[2] == NUL)
break;
}
}
#endif
// 'highlight'
else if (varp == &p_hl)
{
if (highlight_changed() == FAIL)
errmsg = e_invarg; // invalid flags
}
// 'nrformats'
else if (gvarp == &p_nf)
{
if (check_opt_strings(*varp, p_nf_values, TRUE) != OK)
errmsg = e_invarg;
}
#ifdef FEAT_SESSION
// 'sessionoptions'
else if (varp == &p_ssop)
{
if (opt_strings_flags(p_ssop, p_ssop_values, &ssop_flags, TRUE) != OK)
errmsg = e_invarg;
if ((ssop_flags & SSOP_CURDIR) && (ssop_flags & SSOP_SESDIR))
{
// Don't allow both "sesdir" and "curdir".
(void)opt_strings_flags(oldval, p_ssop_values, &ssop_flags, TRUE);
errmsg = e_invarg;
}
}
// 'viewoptions'
else if (varp == &p_vop)
{
if (opt_strings_flags(p_vop, p_ssop_values, &vop_flags, TRUE) != OK)
errmsg = e_invarg;
}
#endif
// 'scrollopt'
else if (varp == &p_sbo)
{
if (check_opt_strings(p_sbo, p_scbopt_values, TRUE) != OK)
errmsg = e_invarg;
}
// 'ambiwidth'
else if (varp == &p_ambw || varp == &p_emoji)
{
if (check_opt_strings(p_ambw, p_ambw_values, FALSE) != OK)
errmsg = e_invarg;
else if (set_chars_option(curwin, &p_fcs) != NULL)
errmsg = _("E835: Conflicts with value of 'fillchars'");
else
{
tabpage_T *tp;
win_T *wp;
FOR_ALL_TAB_WINDOWS(tp, wp)
{
if (set_chars_option(wp, &wp->w_p_lcs) != NULL)
{
errmsg = _("E834: Conflicts with value of 'listchars'");
goto ambw_end;
}
}
}
ambw_end:
{}
}
// 'background'
else if (varp == &p_bg)
{
if (check_opt_strings(p_bg, p_bg_values, FALSE) == OK)
{
#ifdef FEAT_EVAL
int dark = (*p_bg == 'd');
#endif
init_highlight(FALSE, FALSE);
#ifdef FEAT_EVAL
if (dark != (*p_bg == 'd')
&& get_var_value((char_u *)"g:colors_name") != NULL)
{
// The color scheme must have set 'background' back to another
// value, that's not what we want here. Disable the color
// scheme and set the colors again.
do_unlet((char_u *)"g:colors_name", TRUE);
free_string_option(p_bg);
p_bg = vim_strsave((char_u *)(dark ? "dark" : "light"));
check_string_option(&p_bg);
init_highlight(FALSE, FALSE);
}
#endif
#ifdef FEAT_TERMINAL
term_update_colors_all();
#endif
}
else
errmsg = e_invarg;
}
// 'wildmode'
else if (varp == &p_wim)
{
if (check_opt_wim() == FAIL)
errmsg = e_invarg;
}
// 'wildoptions'
else if (varp == &p_wop)
{
if (check_opt_strings(p_wop, p_wop_values, TRUE) != OK)
errmsg = e_invarg;
}
#ifdef FEAT_WAK
// 'winaltkeys'
else if (varp == &p_wak)
{
if (*p_wak == NUL
|| check_opt_strings(p_wak, p_wak_values, FALSE) != OK)
errmsg = e_invarg;
# ifdef FEAT_MENU
# ifdef FEAT_GUI_MOTIF
else if (gui.in_use)
gui_motif_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
# else
# ifdef FEAT_GUI_GTK
else if (gui.in_use)
gui_gtk_set_mnemonics(p_wak[0] == 'y' || p_wak[0] == 'm');
# endif
# endif
# endif
}
#endif
// 'eventignore'
else if (varp == &p_ei)
{
if (check_ei() == FAIL)
errmsg = e_invarg;
}
// 'encoding', 'fileencoding', 'termencoding' and 'makeencoding'
else if (varp == &p_enc || gvarp == &p_fenc || varp == &p_tenc
|| gvarp == &p_menc)
{
if (gvarp == &p_fenc)
{
if (!curbuf->b_p_ma && opt_flags != OPT_GLOBAL)
errmsg = e_cannot_make_changes_modifiable_is_off;
else if (vim_strchr(*varp, ',') != NULL)
// No comma allowed in 'fileencoding'; catches confusing it
// with 'fileencodings'.
errmsg = e_invarg;
else
{
#ifdef FEAT_TITLE
// May show a "+" in the title now.
redraw_titles();
#endif
// Add 'fileencoding' to the swap file.
ml_setflags(curbuf);
}
}
if (errmsg == NULL)
{
// canonize the value, so that STRCMP() can be used on it
p = enc_canonize(*varp);
if (p != NULL)
{
vim_free(*varp);
*varp = p;
}
if (varp == &p_enc)
{
errmsg = mb_init();
#ifdef FEAT_TITLE
redraw_titles();
#endif
}
}
#if defined(FEAT_GUI_GTK)
if (errmsg == NULL && varp == &p_tenc && gui.in_use)
{
// GTK+ 2 uses only a single encoding, and that is UTF-8.
if (STRCMP(p_tenc, "utf-8") != 0)
errmsg = N_("E617: Cannot be changed in the GTK+ 2 GUI");
}
#endif
if (errmsg == NULL)
{
#ifdef FEAT_KEYMAP
// When 'keymap' is used and 'encoding' changes, reload the keymap
// (with another encoding).
if (varp == &p_enc && *curbuf->b_p_keymap != NUL)
(void)keymap_init();
#endif
// When 'termencoding' is not empty and 'encoding' changes or when
// 'termencoding' changes, need to setup for keyboard input and
// display output conversion.
if (((varp == &p_enc && *p_tenc != NUL) || varp == &p_tenc))
{
if (convert_setup(&input_conv, p_tenc, p_enc) == FAIL
|| convert_setup(&output_conv, p_enc, p_tenc) == FAIL)
{
semsg(_("E950: Cannot convert between %s and %s"),
p_tenc, p_enc);
errmsg = e_invarg;
}
}
#if defined(MSWIN)
// $HOME may have characters in active code page.
if (varp == &p_enc)
init_homedir();
#endif
}
}
#if defined(FEAT_POSTSCRIPT)
else if (varp == &p_penc)
{
// Canonize printencoding if VIM standard one
p = enc_canonize(p_penc);
if (p != NULL)
{
vim_free(p_penc);
p_penc = p;
}
else
{
// Ensure lower case and '-' for '_'
for (s = p_penc; *s != NUL; s++)
{
if (*s == '_')
*s = '-';
else
*s = TOLOWER_ASC(*s);
}
}
}
#endif
#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
else if (varp == &p_imak)
{
if (!im_xim_isvalid_imactivate())
errmsg = e_invarg;
}
#endif
#ifdef FEAT_KEYMAP
else if (varp == &curbuf->b_p_keymap)
{
if (!valid_filetype(*varp))
errmsg = e_invarg;
else
{
int secure_save = secure;
// Reset the secure flag, since the value of 'keymap' has
// been checked to be safe.
secure = 0;
// load or unload key mapping tables
errmsg = keymap_init();
secure = secure_save;
// Since we check the value, there is no need to set P_INSECURE,
// even when the value comes from a modeline.
*value_checked = TRUE;
}
if (errmsg == NULL)
{
if (*curbuf->b_p_keymap != NUL)
{
// Installed a new keymap, switch on using it.
curbuf->b_p_iminsert = B_IMODE_LMAP;
if (curbuf->b_p_imsearch != B_IMODE_USE_INSERT)
curbuf->b_p_imsearch = B_IMODE_LMAP;
}
else
{
// Cleared the keymap, may reset 'iminsert' and 'imsearch'.
if (curbuf->b_p_iminsert == B_IMODE_LMAP)
curbuf->b_p_iminsert = B_IMODE_NONE;
if (curbuf->b_p_imsearch == B_IMODE_LMAP)
curbuf->b_p_imsearch = B_IMODE_USE_INSERT;
}
if ((opt_flags & OPT_LOCAL) == 0)
{
set_iminsert_global();
set_imsearch_global();
}
status_redraw_curbuf();
}
}
#endif
// 'fileformat'
else if (gvarp == &p_ff)
{
if (!curbuf->b_p_ma && !(opt_flags & OPT_GLOBAL))
errmsg = e_cannot_make_changes_modifiable_is_off;
else if (check_opt_strings(*varp, p_ff_values, FALSE) != OK)
errmsg = e_invarg;
else
{
// may also change 'textmode'
if (get_fileformat(curbuf) == EOL_DOS)
curbuf->b_p_tx = TRUE;
else
curbuf->b_p_tx = FALSE;
#ifdef FEAT_TITLE
redraw_titles();
#endif
// update flag in swap file
ml_setflags(curbuf);
// Redraw needed when switching to/from "mac": a CR in the text
// will be displayed differently.
if (get_fileformat(curbuf) == EOL_MAC || *oldval == 'm')
redraw_curbuf_later(NOT_VALID);
}
}
// 'fileformats'
else if (varp == &p_ffs)
{
if (check_opt_strings(p_ffs, p_ff_values, TRUE) != OK)
errmsg = e_invarg;
else
{
// also change 'textauto'
if (*p_ffs == NUL)
p_ta = FALSE;
else
p_ta = TRUE;
}
}
#if defined(FEAT_CRYPT)
// 'cryptkey'
else if (gvarp == &p_key)
{
// Make sure the ":set" command doesn't show the new value in the
// history.
remove_key_from_history();
if (STRCMP(curbuf->b_p_key, oldval) != 0)
// Need to update the swapfile.
{
ml_set_crypt_key(curbuf, oldval,
*curbuf->b_p_cm == NUL ? p_cm : curbuf->b_p_cm);
changed_internal();
}
}
else if (gvarp == &p_cm)
{
if (opt_flags & OPT_LOCAL)
p = curbuf->b_p_cm;
else
p = p_cm;
if (check_opt_strings(p, p_cm_values, TRUE) != OK)
errmsg = e_invarg;
else if (crypt_self_test() == FAIL)
errmsg = e_invarg;
else
{
// When setting the global value to empty, make it "zip".
if (*p_cm == NUL)
{
if (new_value_alloced)
free_string_option(p_cm);
p_cm = vim_strsave((char_u *)"zip");
new_value_alloced = TRUE;
}
// When using ":set cm=name" the local value is going to be empty.
// Do that here, otherwise the crypt functions will still use the
// local value.
if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
{
free_string_option(curbuf->b_p_cm);
curbuf->b_p_cm = empty_option;
}
// Need to update the swapfile when the effective method changed.
// Set "s" to the effective old value, "p" to the effective new
// method and compare.
if ((opt_flags & OPT_LOCAL) && *oldval == NUL)
s = p_cm; // was previously using the global value
else
s = oldval;
if (*curbuf->b_p_cm == NUL)
p = p_cm; // is now using the global value
else
p = curbuf->b_p_cm;
if (STRCMP(s, p) != 0)
ml_set_crypt_key(curbuf, curbuf->b_p_key, s);
// If the global value changes need to update the swapfile for all
// buffers using that value.
if ((opt_flags & OPT_GLOBAL) && STRCMP(p_cm, oldval) != 0)
{
buf_T *buf;
FOR_ALL_BUFFERS(buf)
if (buf != curbuf && *buf->b_p_cm == NUL)
ml_set_crypt_key(buf, buf->b_p_key, oldval);
}
}
}
#endif
// 'matchpairs'
else if (gvarp == &p_mps)
{
if (has_mbyte)
{
for (p = *varp; *p != NUL; ++p)
{
int x2 = -1;
int x3 = -1;
if (*p != NUL)
p += mb_ptr2len(p);
if (*p != NUL)
x2 = *p++;
if (*p != NUL)
{
x3 = mb_ptr2char(p);
p += mb_ptr2len(p);
}
if (x2 != ':' || x3 == -1 || (*p != NUL && *p != ','))
{
errmsg = e_invarg;
break;
}
if (*p == NUL)
break;
}
}
else
{
// Check for "x:y,x:y"
for (p = *varp; *p != NUL; p += 4)
{
if (p[1] != ':' || p[2] == NUL || (p[3] != NUL && p[3] != ','))
{
errmsg = e_invarg;
break;
}
if (p[3] == NUL)
break;
}
}
}
// 'comments'
else if (gvarp == &p_com)
{
for (s = *varp; *s; )
{
while (*s && *s != ':')
{
if (vim_strchr((char_u *)COM_ALL, *s) == NULL
&& !VIM_ISDIGIT(*s) && *s != '-')
{
errmsg = illegal_char(errbuf, *s);
break;
}
++s;
}
if (*s++ == NUL)
errmsg = N_("E524: Missing colon");
else if (*s == ',' || *s == NUL)
errmsg = N_("E525: Zero length string");
if (errmsg != NULL)
break;
while (*s && *s != ',')
{
if (*s == '\\' && s[1] != NUL)
++s;
++s;
}
s = skip_to_option_part(s);
}
}
// global 'listchars'
else if (varp == &p_lcs)
{
errmsg = set_chars_option(curwin, varp);
if (errmsg == NULL)
{
tabpage_T *tp;
win_T *wp;
// The current window is set to use the global 'listchars' value.
// So clear the window-local value.
if (!(opt_flags & OPT_GLOBAL))
clear_string_option(&curwin->w_p_lcs);
FOR_ALL_TAB_WINDOWS(tp, wp)
{
errmsg = set_chars_option(wp, &wp->w_p_lcs);
if (errmsg)
break;
}
redraw_all_later(NOT_VALID);
}
}
// local 'listchars'
else if (varp == &curwin->w_p_lcs)
errmsg = set_chars_option(curwin, varp);
// 'fillchars'
else if (varp == &p_fcs)
{
errmsg = set_chars_option(curwin, varp);
}
#ifdef FEAT_CMDWIN
// 'cedit'
else if (varp == &p_cedit)
{
errmsg = check_cedit();
}
#endif
// 'verbosefile'
else if (varp == &p_vfile)
{
verbose_stop();
if (*p_vfile != NUL && verbose_open() == FAIL)
errmsg = e_invarg;
}
#ifdef FEAT_VIMINFO
// 'viminfo'
else if (varp == &p_viminfo)
{
for (s = p_viminfo; *s;)
{
// Check it's a valid character
if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL)
{
errmsg = illegal_char(errbuf, *s);
break;
}
if (*s == 'n') // name is always last one
break;
else if (*s == 'r') // skip until next ','
{
while (*++s && *s != ',')
;
}
else if (*s == '%')
{
// optional number
while (vim_isdigit(*++s))
;
}
else if (*s == '!' || *s == 'h' || *s == 'c')
++s; // no extra chars
else // must have a number
{
while (vim_isdigit(*++s))
;
if (!VIM_ISDIGIT(*(s - 1)))
{
if (errbuf != NULL)
{
sprintf(errbuf, _("E526: Missing number after <%s>"),
transchar_byte(*(s - 1)));
errmsg = errbuf;
}
else
errmsg = "";
break;
}
}
if (*s == ',')
++s;
else if (*s)
{
if (errbuf != NULL)
errmsg = N_("E527: Missing comma");
else
errmsg = "";
break;
}
}
if (*p_viminfo && errmsg == NULL && get_viminfo_parameter('\'') < 0)
errmsg = N_("E528: Must specify a ' value");
}
#endif // FEAT_VIMINFO
// terminal options
else if (istermoption_idx(opt_idx) && full_screen)
{
// ":set t_Co=0" and ":set t_Co=1" do ":set t_Co="
if (varp == &T_CCO)
{
int colors = atoi((char *)T_CCO);
// Only reinitialize colors if t_Co value has really changed to
// avoid expensive reload of colorscheme if t_Co is set to the
// same value multiple times.
if (colors != t_colors)
{
t_colors = colors;
if (t_colors <= 1)
{
if (new_value_alloced)
vim_free(T_CCO);
T_CCO = empty_option;
}
#if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS)
if (is_term_win32())
{
swap_tcap();
did_swaptcap = TRUE;
}
#endif
// We now have a different color setup, initialize it again.
init_highlight(TRUE, FALSE);
}
}
ttest(FALSE);
if (varp == &T_ME)
{
out_str(T_ME);
redraw_later(CLEAR);
#if defined(MSWIN) && (!defined(FEAT_GUI_MSWIN) || defined(VIMDLL))
// Since t_me has been set, this probably means that the user
// wants to use this as default colors. Need to reset default
// background/foreground colors.
# ifdef VIMDLL
if (!gui.in_use && !gui.starting)
# endif
mch_set_normal_colors();
#endif
}
if (varp == &T_BE && termcap_active)
{
#ifdef FEAT_JOB_CHANNEL
ch_log_output = TRUE;
#endif
if (*T_BE == NUL)
// When clearing t_BE we assume the user no longer wants
// bracketed paste, thus disable it by writing t_BD.
out_str(T_BD);
else
out_str(T_BE);
}
}
#ifdef FEAT_LINEBREAK
// 'showbreak'
else if (gvarp == &p_sbr)
{
for (s = *varp; *s; )
{
if (ptr2cells(s) != 1)
errmsg = N_("E595: 'showbreak' contains unprintable or wide character");
MB_PTR_ADV(s);
}
}
#endif
#ifdef FEAT_GUI
// 'guifont'
else if (varp == &p_guifont)
{
if (gui.in_use)
{
p = p_guifont;
# if defined(FEAT_GUI_GTK)
// Put up a font dialog and let the user select a new value.
// If this is cancelled go back to the old value but don't
// give an error message.
if (STRCMP(p, "*") == 0)
{
p = gui_mch_font_dialog(oldval);
if (new_value_alloced)
free_string_option(p_guifont);
p_guifont = (p != NULL) ? p : vim_strsave(oldval);
new_value_alloced = TRUE;
}
# endif
if (p != NULL && gui_init_font(p_guifont, FALSE) != OK)
{
# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_PHOTON)
if (STRCMP(p_guifont, "*") == 0)
{
// Dialog was cancelled: Keep the old value without giving
// an error message.
if (new_value_alloced)
free_string_option(p_guifont);
p_guifont = vim_strsave(oldval);
new_value_alloced = TRUE;
}
else
# endif
errmsg = N_("E596: Invalid font(s)");
}
}
redraw_gui_only = TRUE;
}
# ifdef FEAT_XFONTSET
else if (varp == &p_guifontset)
{
if (STRCMP(p_guifontset, "*") == 0)
errmsg = N_("E597: can't select fontset");
else if (gui.in_use && gui_init_font(p_guifontset, TRUE) != OK)
errmsg = N_("E598: Invalid fontset");
redraw_gui_only = TRUE;
}
# endif
else if (varp == &p_guifontwide)
{
if (STRCMP(p_guifontwide, "*") == 0)
errmsg = N_("E533: can't select wide font");
else if (gui_get_wide_font() == FAIL)
errmsg = N_("E534: Invalid wide font");
redraw_gui_only = TRUE;
}
#endif
#ifdef CURSOR_SHAPE
// 'guicursor'
else if (varp == &p_guicursor)
errmsg = parse_shape_opt(SHAPE_CURSOR);
#endif
#ifdef FEAT_MOUSESHAPE
// 'mouseshape'
else if (varp == &p_mouseshape)
{
errmsg = parse_shape_opt(SHAPE_MOUSE);
update_mouseshape(-1);
}
#endif
#ifdef FEAT_PRINTER
else if (varp == &p_popt)
errmsg = parse_printoptions();
# if defined(FEAT_POSTSCRIPT)
else if (varp == &p_pmfn)
errmsg = parse_printmbfont();
# endif
#endif
#ifdef FEAT_LANGMAP
// 'langmap'
else if (varp == &p_langmap)
langmap_set();
#endif
#ifdef FEAT_LINEBREAK
// 'breakat'
else if (varp == &p_breakat)
fill_breakat_flags();
#endif
#ifdef FEAT_TITLE
// 'titlestring' and 'iconstring'
else if (varp == &p_titlestring || varp == &p_iconstring)
{
# ifdef FEAT_STL_OPT
int flagval = (varp == &p_titlestring) ? STL_IN_TITLE : STL_IN_ICON;
// NULL => statusline syntax
if (vim_strchr(*varp, '%') && check_stl_option(*varp) == NULL)
stl_syntax |= flagval;
else
stl_syntax &= ~flagval;
# endif
did_set_title();
}
#endif
#ifdef FEAT_GUI
// 'guioptions'
else if (varp == &p_go)
{
gui_init_which_components(oldval);
redraw_gui_only = TRUE;
}
#endif
#if defined(FEAT_GUI_TABLINE)
// 'guitablabel'
else if (varp == &p_gtl)
{
redraw_tabline = TRUE;
redraw_gui_only = TRUE;
}
// 'guitabtooltip'
else if (varp == &p_gtt)
{
redraw_gui_only = TRUE;
}
#endif
#if defined(UNIX) || defined(VMS)
// 'ttymouse'
else if (varp == &p_ttym)
{
// Switch the mouse off before changing the escape sequences used for
// that.
mch_setmouse(FALSE);
if (opt_strings_flags(p_ttym, p_ttym_values, &ttym_flags, FALSE) != OK)
errmsg = e_invarg;
else
check_mouse_termcode();
if (termcap_active)
setmouse(); // may switch it on again
}
#endif
// 'selection'
else if (varp == &p_sel)
{
if (*p_sel == NUL
|| check_opt_strings(p_sel, p_sel_values, FALSE) != OK)
errmsg = e_invarg;
}
// 'selectmode'
else if (varp == &p_slm)
{
if (check_opt_strings(p_slm, p_slm_values, TRUE) != OK)
errmsg = e_invarg;
}
#ifdef FEAT_BROWSE
// 'browsedir'
else if (varp == &p_bsdir)
{
if (check_opt_strings(p_bsdir, p_bsdir_values, FALSE) != OK
&& !mch_isdir(p_bsdir))
errmsg = e_invarg;
}
#endif
// 'keymodel'
else if (varp == &p_km)
{
if (check_opt_strings(p_km, p_km_values, TRUE) != OK)
errmsg = e_invarg;
else
{
km_stopsel = (vim_strchr(p_km, 'o') != NULL);
km_startsel = (vim_strchr(p_km, 'a') != NULL);
}
}
// 'mousemodel'
else if (varp == &p_mousem)
{
if (check_opt_strings(p_mousem, p_mousem_values, FALSE) != OK)
errmsg = e_invarg;
#if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU) && (XmVersion <= 1002)
else if (*p_mousem != *oldval)
// Changed from "extend" to "popup" or "popup_setpos" or vv: need
// to create or delete the popup menus.
gui_motif_update_mousemodel(root_menu);
#endif
}
// 'switchbuf'
else if (varp == &p_swb)
{
if (opt_strings_flags(p_swb, p_swb_values, &swb_flags, TRUE) != OK)
errmsg = e_invarg;
}
// 'debug'
else if (varp == &p_debug)
{
if (check_opt_strings(p_debug, p_debug_values, TRUE) != OK)
errmsg = e_invarg;
}
// 'display'
else if (varp == &p_dy)
{
if (opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE) != OK)
errmsg = e_invarg;
else
(void)init_chartab();
}
// 'eadirection'
else if (varp == &p_ead)
{
if (check_opt_strings(p_ead, p_ead_values, FALSE) != OK)
errmsg = e_invarg;
}
#ifdef FEAT_CLIPBOARD
// 'clipboard'
else if (varp == &p_cb)
errmsg = check_clipboard_option();
#endif
#ifdef FEAT_SPELL
// When 'spelllang' or 'spellfile' is set and there is a window for this
// buffer in which 'spell' is set load the wordlists.
else if (varp == &(curwin->w_s->b_p_spl)
|| varp == &(curwin->w_s->b_p_spf))
{
int is_spellfile = varp == &(curwin->w_s->b_p_spf);
if ((is_spellfile && !valid_spellfile(*varp))
|| (!is_spellfile && !valid_spelllang(*varp)))
errmsg = e_invarg;
else
errmsg = did_set_spell_option(is_spellfile);
}
// When 'spellcapcheck' is set compile the regexp program.
else if (varp == &(curwin->w_s->b_p_spc))
{
errmsg = compile_cap_prog(curwin->w_s);
}
// 'spelloptions'
else if (varp == &(curwin->w_s->b_p_spo))
{
if (**varp != NUL && STRCMP("camel", *varp) != 0)
errmsg = e_invarg;
}
// 'spellsuggest'
else if (varp == &p_sps)
{
if (spell_check_sps() != OK)
errmsg = e_invarg;
}
// 'mkspellmem'
else if (varp == &p_msm)
{
if (spell_check_msm() != OK)
errmsg = e_invarg;
}
#endif
// When 'bufhidden' is set, check for valid value.
else if (gvarp == &p_bh)
{
if (check_opt_strings(curbuf->b_p_bh, p_bufhidden_values, FALSE) != OK)
errmsg = e_invarg;
}
// When 'buftype' is set, check for valid value.
else if (gvarp == &p_bt)
{
if (check_opt_strings(curbuf->b_p_bt, p_buftype_values, FALSE) != OK)
errmsg = e_invarg;
else
{
if (curwin->w_status_height)
{
curwin->w_redr_status = TRUE;
redraw_later(VALID);
}
curbuf->b_help = (curbuf->b_p_bt[0] == 'h');
#ifdef FEAT_TITLE
redraw_titles();
#endif
}
}
#ifdef FEAT_STL_OPT
// 'statusline' or 'rulerformat'
else if (gvarp == &p_stl || varp == &p_ruf)
{
int wid;
if (varp == &p_ruf) // reset ru_wid first
ru_wid = 0;
s = *varp;
if (varp == &p_ruf && *s == '%')
{
// set ru_wid if 'ruf' starts with "%99("
if (*++s == '-') // ignore a '-'
s++;
wid = getdigits(&s);
if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL)
ru_wid = wid;
else
errmsg = check_stl_option(p_ruf);
}
// check 'statusline' only if it doesn't start with "%!"
else if (varp == &p_ruf || s[0] != '%' || s[1] != '!')
errmsg = check_stl_option(s);
if (varp == &p_ruf && errmsg == NULL)
comp_col();
}
#endif
// check if it is a valid value for 'complete' -- Acevedo
else if (gvarp == &p_cpt)
{
for (s = *varp; *s;)
{
while (*s == ',' || *s == ' ')
s++;
if (!*s)
break;
if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL)
{
errmsg = illegal_char(errbuf, *s);
break;
}
if (*++s != NUL && *s != ',' && *s != ' ')
{
if (s[-1] == 'k' || s[-1] == 's')
{
// skip optional filename after 'k' and 's'
while (*s && *s != ',' && *s != ' ')
{
if (*s == '\\' && s[1] != NUL)
++s;
++s;
}
}
else
{
if (errbuf != NULL)
{
sprintf((char *)errbuf,
_("E535: Illegal character after <%c>"),
*--s);
errmsg = errbuf;
}
else
errmsg = "";
break;
}
}
}
}
// 'completeopt'
else if (varp == &p_cot)
{
if (check_opt_strings(p_cot, p_cot_values, TRUE) != OK)
errmsg = e_invarg;
else
completeopt_was_set();
}
#ifdef BACKSLASH_IN_FILENAME
// 'completeslash'
else if (gvarp == &p_csl)
{
if (check_opt_strings(p_csl, p_csl_values, FALSE) != OK
|| check_opt_strings(curbuf->b_p_csl, p_csl_values, FALSE) != OK)
errmsg = e_invarg;
}
#endif
#ifdef FEAT_SIGNS
// 'signcolumn'
else if (varp == &curwin->w_p_scl)
{
if (check_opt_strings(*varp, p_scl_values, FALSE) != OK)
errmsg = e_invarg;
// When changing the 'signcolumn' to or from 'number', recompute the
// width of the number column if 'number' or 'relativenumber' is set.
if (((*oldval == 'n' && *(oldval + 1) == 'u')
|| (*curwin->w_p_scl == 'n' && *(curwin->w_p_scl + 1) =='u'))
&& (curwin->w_p_nu || curwin->w_p_rnu))
curwin->w_nrwidth_line_count = 0;
}
#endif
#if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_MSWIN)
// 'toolbar'
else if (varp == &p_toolbar)
{
if (opt_strings_flags(p_toolbar, p_toolbar_values,
&toolbar_flags, TRUE) != OK)
errmsg = e_invarg;
else
{
out_flush();
gui_mch_show_toolbar((toolbar_flags &
(TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
}
}
#endif
#if defined(FEAT_TOOLBAR) && defined(FEAT_GUI_GTK)
// 'toolbariconsize': GTK+ 2 only
else if (varp == &p_tbis)
{
if (opt_strings_flags(p_tbis, p_tbis_values, &tbis_flags, FALSE) != OK)
errmsg = e_invarg;
else
{
out_flush();
gui_mch_show_toolbar((toolbar_flags &
(TOOLBAR_TEXT | TOOLBAR_ICONS)) != 0);
}
}
#endif
// 'pastetoggle': translate key codes like in a mapping
else if (varp == &p_pt)
{
if (*p_pt)
{
(void)replace_termcodes(p_pt, &p,
REPTERM_FROM_PART | REPTERM_DO_LT, NULL);
if (p != NULL)
{
if (new_value_alloced)
free_string_option(p_pt);
p_pt = p;
new_value_alloced = TRUE;
}
}
}
// 'backspace'
else if (varp == &p_bs)
{
if (VIM_ISDIGIT(*p_bs))
{
if (*p_bs > '3' || p_bs[1] != NUL)
errmsg = e_invarg;
}
else if (check_opt_strings(p_bs, p_bs_values, TRUE) != OK)
errmsg = e_invarg;
}
else if (varp == &p_bo)
{
if (opt_strings_flags(p_bo, p_bo_values, &bo_flags, TRUE) != OK)
errmsg = e_invarg;
}
// 'tagcase'
else if (gvarp == &p_tc)
{
unsigned int *flags;
if (opt_flags & OPT_LOCAL)
{
p = curbuf->b_p_tc;
flags = &curbuf->b_tc_flags;
}
else
{
p = p_tc;
flags = &tc_flags;
}
if ((opt_flags & OPT_LOCAL) && *p == NUL)
// make the local value empty: use the global value
*flags = 0;
else if (*p == NUL
|| opt_strings_flags(p, p_tc_values, flags, FALSE) != OK)
errmsg = e_invarg;
}
// 'casemap'
else if (varp == &p_cmp)
{
if (opt_strings_flags(p_cmp, p_cmp_values, &cmp_flags, TRUE) != OK)
errmsg = e_invarg;
}
#ifdef FEAT_DIFF
// 'diffopt'
else if (varp == &p_dip)
{
if (diffopt_changed() == FAIL)
errmsg = e_invarg;
}
#endif
#ifdef FEAT_FOLDING
// 'foldmethod'
else if (gvarp == &curwin->w_allbuf_opt.wo_fdm)
{
if (check_opt_strings(*varp, p_fdm_values, FALSE) != OK
|| *curwin->w_p_fdm == NUL)
errmsg = e_invarg;
else
{
foldUpdateAll(curwin);
if (foldmethodIsDiff(curwin))
newFoldLevel();
}
}
# ifdef FEAT_EVAL
// 'foldexpr'
else if (varp == &curwin->w_p_fde)
{
if (foldmethodIsExpr(curwin))
foldUpdateAll(curwin);
}
# endif
// 'foldmarker'
else if (gvarp == &curwin->w_allbuf_opt.wo_fmr)
{
p = vim_strchr(*varp, ',');
if (p == NULL)
errmsg = N_("E536: comma required");
else if (p == *varp || p[1] == NUL)
errmsg = e_invarg;
else if (foldmethodIsMarker(curwin))
foldUpdateAll(curwin);
}
// 'commentstring'
else if (gvarp == &p_cms)
{
if (**varp != NUL && strstr((char *)*varp, "%s") == NULL)
errmsg = N_("E537: 'commentstring' must be empty or contain %s");
}
// 'foldopen'
else if (varp == &p_fdo)
{
if (opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE) != OK)
errmsg = e_invarg;
}
// 'foldclose'
else if (varp == &p_fcl)
{
if (check_opt_strings(p_fcl, p_fcl_values, TRUE) != OK)
errmsg = e_invarg;
}
// 'foldignore'
else if (gvarp == &curwin->w_allbuf_opt.wo_fdi)
{
if (foldmethodIsIndent(curwin))
foldUpdateAll(curwin);
}
#endif
// 'virtualedit'
else if (gvarp == &p_ve)
{
char_u *ve = p_ve;
unsigned int *flags = &ve_flags;
if (opt_flags & OPT_LOCAL)
{
ve = curwin->w_p_ve;
flags = &curwin->w_ve_flags;
}
if ((opt_flags & OPT_LOCAL) && *ve == NUL)
// make the local value empty: use the global value
*flags = 0;
else
{
if (opt_strings_flags(ve, p_ve_values, flags, TRUE) != OK)
errmsg = e_invarg;
else if (STRCMP(p_ve, oldval) != 0)
{
// Recompute cursor position in case the new 've' setting
// changes something.
validate_virtcol();
coladvance(curwin->w_virtcol);
}
}
}
#if defined(FEAT_CSCOPE) && defined(FEAT_QUICKFIX)
else if (varp == &p_csqf)
{
if (p_csqf != NULL)
{
p = p_csqf;
while (*p != NUL)
{
if (vim_strchr((char_u *)CSQF_CMDS, *p) == NULL
|| p[1] == NUL
|| vim_strchr((char_u *)CSQF_FLAGS, p[1]) == NULL
|| (p[2] != NUL && p[2] != ','))
{
errmsg = e_invarg;
break;
}
else if (p[2] == NUL)
break;
else
p += 3;
}
}
}
#endif
#ifdef FEAT_CINDENT
// 'cinoptions'
else if (gvarp == &p_cino)
{
// TODO: recognize errors
parse_cino(curbuf);
}
#endif
#if defined(FEAT_RENDER_OPTIONS)
// 'renderoptions'
else if (varp == &p_rop)
{
if (!gui_mch_set_rendering_options(p_rop))
errmsg = e_invarg;
}
#endif
else if (gvarp == &p_ft)
{
if (!valid_filetype(*varp))
errmsg = e_invarg;
else
{
value_changed = STRCMP(oldval, *varp) != 0;
// Since we check the value, there is no need to set P_INSECURE,
// even when the value comes from a modeline.
*value_checked = TRUE;
}
}
#ifdef FEAT_SYN_HL
else if (gvarp == &p_syn)
{
if (!valid_filetype(*varp))
errmsg = e_invarg;
else
{
value_changed = STRCMP(oldval, *varp) != 0;
// Since we check the value, there is no need to set P_INSECURE,
// even when the value comes from a modeline.
*value_checked = TRUE;
}
}
#endif
#ifdef FEAT_TERMINAL
// 'termwinkey'
else if (varp == &curwin->w_p_twk)
{
if (*curwin->w_p_twk != NUL
&& string_to_key(curwin->w_p_twk, TRUE) == 0)
errmsg = e_invarg;
}
// 'termwinsize'
else if (varp == &curwin->w_p_tws)
{
if (*curwin->w_p_tws != NUL)
{
p = skipdigits(curwin->w_p_tws);
if (p == curwin->w_p_tws
|| (*p != 'x' && *p != '*')
|| *skipdigits(p + 1) != NUL)
errmsg = e_invarg;
}
}
// 'wincolor'
else if (varp == &curwin->w_p_wcr)
{
if (curwin->w_buffer->b_term != NULL)
term_update_colors(curwin->w_buffer->b_term);
}
# if defined(MSWIN)
// 'termwintype'
else if (varp == &p_twt)
{
if (check_opt_strings(*varp, p_twt_values, FALSE) != OK)
errmsg = e_invarg;
}
# endif
#endif
#ifdef FEAT_VARTABS
// 'varsofttabstop'
else if (varp == &(curbuf->b_p_vsts))
{
char_u *cp;
if (!(*varp)[0] || ((*varp)[0] == '0' && !(*varp)[1]))
{
if (curbuf->b_p_vsts_array)
{
vim_free(curbuf->b_p_vsts_array);
curbuf->b_p_vsts_array = 0;
}
}
else
{
for (cp = *varp; *cp; ++cp)
{
if (vim_isdigit(*cp))
continue;
if (*cp == ',' && cp > *varp && *(cp-1) != ',')
continue;
errmsg = e_invarg;
break;
}
if (errmsg == NULL)
{
int *oldarray = curbuf->b_p_vsts_array;
if (tabstop_set(*varp, &(curbuf->b_p_vsts_array)))
{
if (oldarray)
vim_free(oldarray);
}
else
errmsg = e_invarg;
}
}
}
// 'vartabstop'
else if (varp == &(curbuf->b_p_vts))
{
char_u *cp;
if (!(*varp)[0] || ((*varp)[0] == '0' && !(*varp)[1]))
{
if (curbuf->b_p_vts_array)
{
vim_free(curbuf->b_p_vts_array);
curbuf->b_p_vts_array = NULL;
}
}
else
{
for (cp = *varp; *cp; ++cp)
{
if (vim_isdigit(*cp))
continue;
if (*cp == ',' && cp > *varp && *(cp-1) != ',')
continue;
errmsg = e_invarg;
break;
}
if (errmsg == NULL)
{
int *oldarray = curbuf->b_p_vts_array;
if (tabstop_set(*varp, &(curbuf->b_p_vts_array)))
{
vim_free(oldarray);
#ifdef FEAT_FOLDING
if (foldmethodIsIndent(curwin))
foldUpdateAll(curwin);
#endif
}
else
errmsg = e_invarg;
}
}
}
#endif
#ifdef FEAT_PROP_POPUP
// 'previewpopup'
else if (varp == &p_pvp)
{
if (parse_previewpopup(NULL) == FAIL)
errmsg = e_invarg;
}
# ifdef FEAT_QUICKFIX
// 'completepopup'
else if (varp == &p_cpp)
{
if (parse_completepopup(NULL) == FAIL)
errmsg = e_invarg;
else
popup_close_info();
}
# endif
#endif
#ifdef FEAT_QUICKFIX
else if (varp == &p_qftf)
{
if (qf_process_qftf_option() == FALSE)
errmsg = e_invarg;
}
#endif
// Options that are a list of flags.
else
{
p = NULL;
if (varp == &p_ww) // 'whichwrap'
p = (char_u *)WW_ALL;
if (varp == &p_shm) // 'shortmess'
p = (char_u *)SHM_ALL;
else if (varp == &(p_cpo)) // 'cpoptions'
p = (char_u *)CPO_ALL;
else if (varp == &(curbuf->b_p_fo)) // 'formatoptions'
p = (char_u *)FO_ALL;
#ifdef FEAT_CONCEAL
else if (varp == &curwin->w_p_cocu) // 'concealcursor'
p = (char_u *)COCU_ALL;
#endif
else if (varp == &p_mouse) // 'mouse'
{
p = (char_u *)MOUSE_ALL;
}
#if defined(FEAT_GUI)
else if (varp == &p_go) // 'guioptions'
p = (char_u *)GO_ALL;
#endif
if (p != NULL)
{
for (s = *varp; *s; ++s)
if (vim_strchr(p, *s) == NULL)
{
errmsg = illegal_char(errbuf, *s);
break;
}
}
}
// If error detected, restore the previous value.
if (errmsg != NULL)
{
if (new_value_alloced)
free_string_option(*varp);
*varp = oldval;
// When resetting some values, need to act on it.
if (did_chartab)
(void)init_chartab();
if (varp == &p_hl)
(void)highlight_changed();
}
else
{
#ifdef FEAT_EVAL
// Remember where the option was set.
set_option_sctx_idx(opt_idx, opt_flags, current_sctx);
#endif
// Free string options that are in allocated memory.
// Use "free_oldval", because recursiveness may change the flags under
// our fingers (esp. init_highlight()).
if (free_oldval)
free_string_option(oldval);
if (new_value_alloced)
set_option_flag(opt_idx, P_ALLOCED);
else
clear_option_flag(opt_idx, P_ALLOCED);
if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0
&& is_global_local_option(opt_idx))
{
// global option with local value set to use global value; free
// the local value and make it empty
p = get_option_varp_scope(opt_idx, OPT_LOCAL);
free_string_option(*(char_u **)p);
*(char_u **)p = empty_option;
}
// May set global value for local option.
else if (!(opt_flags & OPT_LOCAL) && opt_flags != OPT_GLOBAL)
set_string_option_global(opt_idx, varp);
// Trigger the autocommand only after setting the flags.
#ifdef FEAT_SYN_HL
// When 'syntax' is set, load the syntax of that name
if (varp == &(curbuf->b_p_syn))
{
static int syn_recursive = 0;
++syn_recursive;
// Only pass TRUE for "force" when the value changed or not used
// recursively, to avoid endless recurrence.
apply_autocmds(EVENT_SYNTAX, curbuf->b_p_syn, curbuf->b_fname,
value_changed || syn_recursive == 1, curbuf);
curbuf->b_flags |= BF_SYN_SET;
--syn_recursive;
}
#endif
else if (varp == &(curbuf->b_p_ft))
{
// 'filetype' is set, trigger the FileType autocommand.
// Skip this when called from a modeline and the filetype was
// already set to this value.
if (!(opt_flags & OPT_MODELINE) || value_changed)
{
static int ft_recursive = 0;
int secure_save = secure;
// Reset the secure flag, since the value of 'filetype' has
// been checked to be safe.
secure = 0;
++ft_recursive;
did_filetype = TRUE;
// Only pass TRUE for "force" when the value changed or not
// used recursively, to avoid endless recurrence.
apply_autocmds(EVENT_FILETYPE, curbuf->b_p_ft, curbuf->b_fname,
value_changed || ft_recursive == 1, curbuf);
--ft_recursive;
// Just in case the old "curbuf" is now invalid.
if (varp != &(curbuf->b_p_ft))
varp = NULL;
secure = secure_save;
}
}
#ifdef FEAT_SPELL
if (varp == &(curwin->w_s->b_p_spl))
{
char_u fname[200];
char_u *q = curwin->w_s->b_p_spl;
// Skip the first name if it is "cjk".
if (STRNCMP(q, "cjk,", 4) == 0)
q += 4;
// Source the spell/LANG.vim in 'runtimepath'.
// They could set 'spellcapcheck' depending on the language.
// Use the first name in 'spelllang' up to '_region' or
// '.encoding'.
for (p = q; *p != NUL; ++p)
if (!ASCII_ISALNUM(*p) && *p != '-')
break;
if (p > q)
{
vim_snprintf((char *)fname, 200, "spell/%.*s.vim",
(int)(p - q), q);
source_runtime(fname, DIP_ALL);
}
}
#endif
}
if (varp == &p_mouse)
{
if (*p_mouse == NUL)
mch_setmouse(FALSE); // switch mouse off
else
setmouse(); // in case 'mouse' changed
}
#if defined(FEAT_LUA) || defined(PROTO)
if (varp == &p_rtp)
update_package_paths_in_lua();
#endif
if (curwin->w_curswant != MAXCOL
&& (get_option_flags(opt_idx) & (P_CURSWANT | P_RALL)) != 0)
curwin->w_set_curswant = TRUE;
if ((opt_flags & OPT_NO_REDRAW) == 0)
{
#ifdef FEAT_GUI
// check redraw when it's not a GUI option or the GUI is active.
if (!redraw_gui_only || gui.in_use)
#endif
check_redraw(get_option_flags(opt_idx));
}
#if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS)
if (did_swaptcap)
{
set_termname((char_u *)"win32");
init_highlight(TRUE, FALSE);
}
#endif
return errmsg;
} | 7146 | True | 1 |
|
CVE-2021-3778 | 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/vim/vim/commit/65b605665997fad54ef39a93199e305af2fe4d7f', 'name': 'https://github.com/vim/vim/commit/65b605665997fad54ef39a93199e305af2fe4d7f', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://huntr.dev/bounties/d9c17308-2c99-4f9f-a706-f7f72c24c273', 'name': 'https://huntr.dev/bounties/d9c17308-2c99-4f9f-a706-f7f72c24c273', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Issue Tracking', 'Patch', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2021/10/01/1', 'name': "[oss-security] 20210930 3 new CVE's in vim", 'refsource': 'MLIST', 'tags': ['Mailing List']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/TE62UMYBZE4AE53K6OBBWK32XQ7544QM/', 'name': 'FEDORA-2021-968f57ec98', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/S42L4Z4DTW4LHLQ4FJ33VEOXRCBE7WN4/', 'name': 'FEDORA-2021-84f4cf3244', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/7K4JJBIH3OQSZRVTWKCJCDLGMFGQ5DOH/', 'name': 'FEDORA-2021-6988830606', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2022/01/msg00003.html', 'name': '[debian-lts-announce] 20220110 [SECURITY] [DLA 2876-1] vim security update', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-122'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.3409', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:fedoraproject:fedora:33:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:fedoraproject:fedora:34:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:fedoraproject:fedora:35:*:*:*:*:*:*:*', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:debian:debian_linux:9.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'vim is vulnerable to Heap-based Buffer Overflow'}] | 2022-08-21T06:15Z | 2021-09-15T08:15Z | Heap-based Buffer Overflow | A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc(). | https://cwe.mitre.org/data/definitions/122.html | 0 | Bram Moolenaar | 2021-09-07 19:26:53+02:00 | patch 8.2.3409: reading beyond end of line with invalid utf-8 character
Problem: Reading beyond end of line with invalid utf-8 character.
Solution: Check for NUL when advancing. | 65b605665997fad54ef39a93199e305af2fe4d7f | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | find_match_text | find_match_text( colnr_T startcol , int regstart , char_u * match_text) | ['startcol', 'regstart', 'match_text'] | find_match_text(colnr_T startcol, int regstart, char_u *match_text)
{
colnr_T col = startcol;
int c1, c2;
int len1, len2;
int match;
for (;;)
{
match = TRUE;
len2 = MB_CHAR2LEN(regstart); // skip regstart
for (len1 = 0; match_text[len1] != NUL; len1 += MB_CHAR2LEN(c1))
{
c1 = PTR2CHAR(match_text + len1);
c2 = PTR2CHAR(rex.line + col + len2);
if (c1 != c2 && (!rex.reg_ic || MB_CASEFOLD(c1) != MB_CASEFOLD(c2)))
{
match = FALSE;
break;
}
len2 += MB_CHAR2LEN(c2);
}
if (match
// check that no composing char follows
&& !(enc_utf8
&& utf_iscomposing(PTR2CHAR(rex.line + col + len2))))
{
cleanup_subexpr();
if (REG_MULTI)
{
rex.reg_startpos[0].lnum = rex.lnum;
rex.reg_startpos[0].col = col;
rex.reg_endpos[0].lnum = rex.lnum;
rex.reg_endpos[0].col = col + len2;
}
else
{
rex.reg_startp[0] = rex.line + col;
rex.reg_endp[0] = rex.line + col + len2;
}
return 1L;
}
// Try finding regstart after the current match.
col += MB_CHAR2LEN(regstart); // skip regstart
if (skip_to_start(regstart, &col) == FAIL)
break;
}
return 0L;
} | 275 | True | 1 |
|
CVE-2021-3796 | 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:L/A:H | LOCAL | LOW | NONE | REQUIRED | UNCHANGED | HIGH | LOW | HIGH | 7.3 | HIGH | 1.8 | 5.5 | False | [{'url': 'https://github.com/vim/vim/commit/35a9a00afcb20897d462a766793ff45534810dc3', 'name': 'https://github.com/vim/vim/commit/35a9a00afcb20897d462a766793ff45534810dc3', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://huntr.dev/bounties/ab60b7f3-6fb1-4ac2-a4fa-4d592e08008d', 'name': 'https://huntr.dev/bounties/ab60b7f3-6fb1-4ac2-a4fa-4d592e08008d', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Issue Tracking', 'Patch', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2021/10/01/1', 'name': "[oss-security] 20210930 3 new CVE's in vim", 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/TE62UMYBZE4AE53K6OBBWK32XQ7544QM/', 'name': 'FEDORA-2021-968f57ec98', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/S42L4Z4DTW4LHLQ4FJ33VEOXRCBE7WN4/', 'name': 'FEDORA-2021-84f4cf3244', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/7K4JJBIH3OQSZRVTWKCJCDLGMFGQ5DOH/', 'name': 'FEDORA-2021-6988830606', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2022/01/msg00003.html', 'name': '[debian-lts-announce] 20220110 [SECURITY] [DLA 2876-1] vim security update', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-416'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.3428', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:fedoraproject:fedora:33:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:fedoraproject:fedora:34:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:fedoraproject:fedora:35:*:*:*:*:*:*:*', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:debian:debian_linux:9.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'vim is vulnerable to Use After Free'}] | 2022-08-21T07:15Z | 2021-09-15T13: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 | Bram Moolenaar | 2021-09-11 21:14:20+02:00 | patch 8.2.3428: using freed memory when replacing
Problem: Using freed memory when replacing. (Dhiraj Mishra)
Solution: Get the line pointer after calling ins_copychar(). | 35a9a00afcb20897d462a766793ff45534810dc3 | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | nv_replace | nv_replace( cmdarg_T * cap) | ['cap'] | nv_replace(cmdarg_T *cap)
{
char_u *ptr;
int had_ctrl_v;
long n;
if (checkclearop(cap->oap))
return;
#ifdef FEAT_JOB_CHANNEL
if (bt_prompt(curbuf) && !prompt_curpos_editable())
{
clearopbeep(cap->oap);
return;
}
#endif
// get another character
if (cap->nchar == Ctrl_V)
{
had_ctrl_v = Ctrl_V;
cap->nchar = get_literal(FALSE);
// Don't redo a multibyte character with CTRL-V.
if (cap->nchar > DEL)
had_ctrl_v = NUL;
}
else
had_ctrl_v = NUL;
// Abort if the character is a special key.
if (IS_SPECIAL(cap->nchar))
{
clearopbeep(cap->oap);
return;
}
// Visual mode "r"
if (VIsual_active)
{
if (got_int)
reset_VIsual();
if (had_ctrl_v)
{
// Use a special (negative) number to make a difference between a
// literal CR or NL and a line break.
if (cap->nchar == CAR)
cap->nchar = REPLACE_CR_NCHAR;
else if (cap->nchar == NL)
cap->nchar = REPLACE_NL_NCHAR;
}
nv_operator(cap);
return;
}
// Break tabs, etc.
if (virtual_active())
{
if (u_save_cursor() == FAIL)
return;
if (gchar_cursor() == NUL)
{
// Add extra space and put the cursor on the first one.
coladvance_force((colnr_T)(getviscol() + cap->count1));
curwin->w_cursor.col -= cap->count1;
}
else if (gchar_cursor() == TAB)
coladvance_force(getviscol());
}
// Abort if not enough characters to replace.
ptr = ml_get_cursor();
if (STRLEN(ptr) < (unsigned)cap->count1
|| (has_mbyte && mb_charlen(ptr) < cap->count1))
{
clearopbeep(cap->oap);
return;
}
/*
* Replacing with a TAB is done by edit() when it is complicated because
* 'expandtab' or 'smarttab' is set. CTRL-V TAB inserts a literal TAB.
* Other characters are done below to avoid problems with things like
* CTRL-V 048 (for edit() this would be R CTRL-V 0 ESC).
*/
if (had_ctrl_v != Ctrl_V && cap->nchar == '\t' && (curbuf->b_p_et || p_sta))
{
stuffnumReadbuff(cap->count1);
stuffcharReadbuff('R');
stuffcharReadbuff('\t');
stuffcharReadbuff(ESC);
return;
}
// save line for undo
if (u_save_cursor() == FAIL)
return;
if (had_ctrl_v != Ctrl_V && (cap->nchar == '\r' || cap->nchar == '\n'))
{
/*
* Replace character(s) by a single newline.
* Strange vi behaviour: Only one newline is inserted.
* Delete the characters here.
* Insert the newline with an insert command, takes care of
* autoindent. The insert command depends on being on the last
* character of a line or not.
*/
(void)del_chars(cap->count1, FALSE); // delete the characters
stuffcharReadbuff('\r');
stuffcharReadbuff(ESC);
// Give 'r' to edit(), to get the redo command right.
invoke_edit(cap, TRUE, 'r', FALSE);
}
else
{
prep_redo(cap->oap->regname, cap->count1,
NUL, 'r', NUL, had_ctrl_v, cap->nchar);
curbuf->b_op_start = curwin->w_cursor;
if (has_mbyte)
{
int old_State = State;
if (cap->ncharC1 != 0)
AppendCharToRedobuff(cap->ncharC1);
if (cap->ncharC2 != 0)
AppendCharToRedobuff(cap->ncharC2);
// This is slow, but it handles replacing a single-byte with a
// multi-byte and the other way around. Also handles adding
// composing characters for utf-8.
for (n = cap->count1; n > 0; --n)
{
State = REPLACE;
if (cap->nchar == Ctrl_E || cap->nchar == Ctrl_Y)
{
int c = ins_copychar(curwin->w_cursor.lnum
+ (cap->nchar == Ctrl_Y ? -1 : 1));
if (c != NUL)
ins_char(c);
else
// will be decremented further down
++curwin->w_cursor.col;
}
else
ins_char(cap->nchar);
State = old_State;
if (cap->ncharC1 != 0)
ins_char(cap->ncharC1);
if (cap->ncharC2 != 0)
ins_char(cap->ncharC2);
}
}
else
{
/*
* Replace the characters within one line.
*/
for (n = cap->count1; n > 0; --n)
{
/*
* Get ptr again, because u_save and/or showmatch() will have
* released the line. At the same time we let know that the
* line will be changed.
*/
ptr = ml_get_buf(curbuf, curwin->w_cursor.lnum, TRUE);
if (cap->nchar == Ctrl_E || cap->nchar == Ctrl_Y)
{
int c = ins_copychar(curwin->w_cursor.lnum
+ (cap->nchar == Ctrl_Y ? -1 : 1));
if (c != NUL)
ptr[curwin->w_cursor.col] = c;
}
else
ptr[curwin->w_cursor.col] = cap->nchar;
if (p_sm && msg_silent == 0)
showmatch(cap->nchar);
++curwin->w_cursor.col;
}
#ifdef FEAT_NETBEANS_INTG
if (netbeans_active())
{
colnr_T start = (colnr_T)(curwin->w_cursor.col - cap->count1);
netbeans_removed(curbuf, curwin->w_cursor.lnum, start,
(long)cap->count1);
netbeans_inserted(curbuf, curwin->w_cursor.lnum, start,
&ptr[start], (int)cap->count1);
}
#endif
// mark the buffer as changed and prepare for displaying
changed_bytes(curwin->w_cursor.lnum,
(colnr_T)(curwin->w_cursor.col - cap->count1));
}
--curwin->w_cursor.col; // cursor on the last replaced char
// if the character on the left of the current cursor is a multi-byte
// character, move two characters left
if (has_mbyte)
mb_adjust_cursor();
curbuf->b_op_end = curwin->w_cursor;
curwin->w_set_curswant = TRUE;
set_last_insert(cap->nchar);
}
} | 854 | True | 1 |
CVE-2021-3872 | 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/vim/vim/commit/826bfe4bbd7594188e3d74d2539d9707b1c6a14b', 'name': 'https://github.com/vim/vim/commit/826bfe4bbd7594188e3d74d2539d9707b1c6a14b', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://huntr.dev/bounties/c958013b-1c09-4939-92ca-92f50aa169e8', 'name': 'https://huntr.dev/bounties/c958013b-1c09-4939-92ca-92f50aa169e8', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Patch', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/S42L4Z4DTW4LHLQ4FJ33VEOXRCBE7WN4/', 'name': 'FEDORA-2021-84f4cf3244', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/7K4JJBIH3OQSZRVTWKCJCDLGMFGQ5DOH/', 'name': 'FEDORA-2021-6988830606', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2022/03/msg00018.html', 'name': '[debian-lts-announce] 20220311 [SECURITY] [DLA 2947-1] vim security update', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-122'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.3487', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:fedoraproject:fedora:33:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:fedoraproject:fedora:35:*:*:*:*:*:*:*', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:debian:debian_linux:9.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'vim is vulnerable to Heap-based Buffer Overflow'}] | 2022-08-21T08:15Z | 2021-10-19T13:15Z | Heap-based Buffer Overflow | A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc(). | https://cwe.mitre.org/data/definitions/122.html | 0 | Bram Moolenaar | 2021-10-08 18:39:28+01:00 | patch 8.2.3487: illegal memory access if buffer name is very long
Problem: Illegal memory access if buffer name is very long.
Solution: Make sure not to go over the end of the buffer. | 826bfe4bbd7594188e3d74d2539d9707b1c6a14b | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | win_redr_status | win_redr_status( win_T * wp , int ignore_pum UNUSED) | ['wp', 'UNUSED'] | win_redr_status(win_T *wp, int ignore_pum UNUSED)
{
int row;
char_u *p;
int len;
int fillchar;
int attr;
int this_ru_col;
static int busy = FALSE;
// It's possible to get here recursively when 'statusline' (indirectly)
// invokes ":redrawstatus". Simply ignore the call then.
if (busy)
return;
busy = TRUE;
row = statusline_row(wp);
wp->w_redr_status = FALSE;
if (wp->w_status_height == 0)
{
// no status line, can only be last window
redraw_cmdline = TRUE;
}
else if (!redrawing()
// don't update status line when popup menu is visible and may be
// drawn over it, unless it will be redrawn later
|| (!ignore_pum && pum_visible()))
{
// Don't redraw right now, do it later.
wp->w_redr_status = TRUE;
}
#ifdef FEAT_STL_OPT
else if (*p_stl != NUL || *wp->w_p_stl != NUL)
{
// redraw custom status line
redraw_custom_statusline(wp);
}
#endif
else
{
fillchar = fillchar_status(&attr, wp);
get_trans_bufname(wp->w_buffer);
p = NameBuff;
len = (int)STRLEN(p);
if (bt_help(wp->w_buffer)
#ifdef FEAT_QUICKFIX
|| wp->w_p_pvw
#endif
|| bufIsChanged(wp->w_buffer)
|| wp->w_buffer->b_p_ro)
*(p + len++) = ' ';
if (bt_help(wp->w_buffer))
{
STRCPY(p + len, _("[Help]"));
len += (int)STRLEN(p + len);
}
#ifdef FEAT_QUICKFIX
if (wp->w_p_pvw)
{
STRCPY(p + len, _("[Preview]"));
len += (int)STRLEN(p + len);
}
#endif
if (bufIsChanged(wp->w_buffer)
#ifdef FEAT_TERMINAL
&& !bt_terminal(wp->w_buffer)
#endif
)
{
STRCPY(p + len, "[+]");
len += 3;
}
if (wp->w_buffer->b_p_ro)
{
STRCPY(p + len, _("[RO]"));
len += (int)STRLEN(p + len);
}
this_ru_col = ru_col - (Columns - wp->w_width);
if (this_ru_col < (wp->w_width + 1) / 2)
this_ru_col = (wp->w_width + 1) / 2;
if (this_ru_col <= 1)
{
p = (char_u *)"<"; // No room for file name!
len = 1;
}
else if (has_mbyte)
{
int clen = 0, i;
// Count total number of display cells.
clen = mb_string2cells(p, -1);
// Find first character that will fit.
// Going from start to end is much faster for DBCS.
for (i = 0; p[i] != NUL && clen >= this_ru_col - 1;
i += (*mb_ptr2len)(p + i))
clen -= (*mb_ptr2cells)(p + i);
len = clen;
if (i > 0)
{
p = p + i - 1;
*p = '<';
++len;
}
}
else if (len > this_ru_col - 1)
{
p += len - (this_ru_col - 1);
*p = '<';
len = this_ru_col - 1;
}
screen_puts(p, row, wp->w_wincol, attr);
screen_fill(row, row + 1, len + wp->w_wincol,
this_ru_col + wp->w_wincol, fillchar, fillchar, attr);
if (get_keymap_str(wp, (char_u *)"<%s>", NameBuff, MAXPATHL)
&& (int)(this_ru_col - len) > (int)(STRLEN(NameBuff) + 1))
screen_puts(NameBuff, row, (int)(this_ru_col - STRLEN(NameBuff)
- 1 + wp->w_wincol), attr);
#ifdef FEAT_CMDL_INFO
win_redr_ruler(wp, TRUE, ignore_pum);
#endif
}
/*
* May need to draw the character below the vertical separator.
*/
if (wp->w_vsep_width != 0 && wp->w_status_height != 0 && redrawing())
{
if (stl_connected(wp))
fillchar = fillchar_status(&attr, wp);
else
fillchar = fillchar_vsep(&attr);
screen_putchar(fillchar, row, W_ENDCOL(wp), attr);
}
busy = FALSE;
} | 687 | True | 1 |
|
CVE-2021-3903 | 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/vim/vim/commit/777e7c21b7627be80961848ac560cb0a9978ff43', 'name': 'https://github.com/vim/vim/commit/777e7c21b7627be80961848ac560cb0a9978ff43', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://huntr.dev/bounties/35738a4f-55ce-446c-b836-2fb0b39625f8', 'name': 'https://huntr.dev/bounties/35738a4f-55ce-446c-b836-2fb0b39625f8', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Issue Tracking', 'Patch', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/BN4EX7BPQU7RP6PXCNCSDORUZBXQ4JUH/', 'name': 'FEDORA-2021-a5e55a9e02', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/DU26T75PYA3OF7XJGNKMT2ZCQEU4UKP5/', 'name': 'FEDORA-2021-af135cabe2', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/FNXY7T5OORA7UJIMGSJBGHFMU6UZWS6P/', 'name': 'FEDORA-2021-b0ac29efb1', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2022/01/15/1', 'name': "[oss-security] 20220114 Re: 3 new CVE's in vim", 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2022/06/msg00014.html', 'name': '[debian-lts-announce] 20220620 [SECURITY] [DLA 3053-1] vim security update', 'refsource': 'MLIST', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-122'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.3564', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:fedoraproject:fedora:33:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:fedoraproject:fedora:34:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:fedoraproject:fedora:35:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'vim is vulnerable to Heap-based Buffer Overflow'}] | 2022-06-20T15:15Z | 2021-10-27T21:15Z | Heap-based Buffer Overflow | A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc(). | https://cwe.mitre.org/data/definitions/122.html | 0 | Bram Moolenaar | 2021-10-25 17:07:04+01:00 | patch 8.2.3564: invalid memory access when scrolling without valid screen
Problem: Invalid memory access when scrolling without a valid screen.
Solution: Do not set VALID_BOTLINE in w_valid. | 777e7c21b7627be80961848ac560cb0a9978ff43 | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | update_topline | update_topline( void) | ['void'] | update_topline(void)
{
long line_count;
int halfheight;
int n;
linenr_T old_topline;
#ifdef FEAT_DIFF
int old_topfill;
#endif
#ifdef FEAT_FOLDING
linenr_T lnum;
#endif
int check_topline = FALSE;
int check_botline = FALSE;
long *so_ptr = curwin->w_p_so >= 0 ? &curwin->w_p_so : &p_so;
int save_so = *so_ptr;
// If there is no valid screen and when the window height is zero just use
// the cursor line.
if (!screen_valid(TRUE) || curwin->w_height == 0)
{
check_cursor_lnum();
curwin->w_topline = curwin->w_cursor.lnum;
curwin->w_botline = curwin->w_topline;
curwin->w_valid |= VALID_BOTLINE|VALID_BOTLINE_AP;
curwin->w_scbind_pos = 1;
return;
}
check_cursor_moved(curwin);
if (curwin->w_valid & VALID_TOPLINE)
return;
// When dragging with the mouse, don't scroll that quickly
if (mouse_dragging > 0)
*so_ptr = mouse_dragging - 1;
old_topline = curwin->w_topline;
#ifdef FEAT_DIFF
old_topfill = curwin->w_topfill;
#endif
/*
* If the buffer is empty, always set topline to 1.
*/
if (BUFEMPTY()) // special case - file is empty
{
if (curwin->w_topline != 1)
redraw_later(NOT_VALID);
curwin->w_topline = 1;
curwin->w_botline = 2;
curwin->w_valid |= VALID_BOTLINE|VALID_BOTLINE_AP;
curwin->w_scbind_pos = 1;
}
/*
* If the cursor is above or near the top of the window, scroll the window
* to show the line the cursor is in, with 'scrolloff' context.
*/
else
{
if (curwin->w_topline > 1)
{
// If the cursor is above topline, scrolling is always needed.
// If the cursor is far below topline and there is no folding,
// scrolling down is never needed.
if (curwin->w_cursor.lnum < curwin->w_topline)
check_topline = TRUE;
else if (check_top_offset())
check_topline = TRUE;
}
#ifdef FEAT_DIFF
// Check if there are more filler lines than allowed.
if (!check_topline && curwin->w_topfill > diff_check_fill(curwin,
curwin->w_topline))
check_topline = TRUE;
#endif
if (check_topline)
{
halfheight = curwin->w_height / 2 - 1;
if (halfheight < 2)
halfheight = 2;
#ifdef FEAT_FOLDING
if (hasAnyFolding(curwin))
{
// Count the number of logical lines between the cursor and
// topline + scrolloff (approximation of how much will be
// scrolled).
n = 0;
for (lnum = curwin->w_cursor.lnum;
lnum < curwin->w_topline + *so_ptr; ++lnum)
{
++n;
// stop at end of file or when we know we are far off
if (lnum >= curbuf->b_ml.ml_line_count || n >= halfheight)
break;
(void)hasFolding(lnum, NULL, &lnum);
}
}
else
#endif
n = curwin->w_topline + *so_ptr - curwin->w_cursor.lnum;
// If we weren't very close to begin with, we scroll to put the
// cursor in the middle of the window. Otherwise put the cursor
// near the top of the window.
if (n >= halfheight)
scroll_cursor_halfway(FALSE);
else
{
scroll_cursor_top(scrolljump_value(), FALSE);
check_botline = TRUE;
}
}
else
{
#ifdef FEAT_FOLDING
// Make sure topline is the first line of a fold.
(void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL);
#endif
check_botline = TRUE;
}
}
/*
* If the cursor is below the bottom of the window, scroll the window
* to put the cursor on the window.
* When w_botline is invalid, recompute it first, to avoid a redraw later.
* If w_botline was approximated, we might need a redraw later in a few
* cases, but we don't want to spend (a lot of) time recomputing w_botline
* for every small change.
*/
if (check_botline)
{
if (!(curwin->w_valid & VALID_BOTLINE_AP))
validate_botline();
if (curwin->w_botline <= curbuf->b_ml.ml_line_count)
{
if (curwin->w_cursor.lnum < curwin->w_botline)
{
if (((long)curwin->w_cursor.lnum
>= (long)curwin->w_botline - *so_ptr
#ifdef FEAT_FOLDING
|| hasAnyFolding(curwin)
#endif
))
{
lineoff_T loff;
// Cursor is (a few lines) above botline, check if there are
// 'scrolloff' window lines below the cursor. If not, need to
// scroll.
n = curwin->w_empty_rows;
loff.lnum = curwin->w_cursor.lnum;
#ifdef FEAT_FOLDING
// In a fold go to its last line.
(void)hasFolding(loff.lnum, NULL, &loff.lnum);
#endif
#ifdef FEAT_DIFF
loff.fill = 0;
n += curwin->w_filler_rows;
#endif
loff.height = 0;
while (loff.lnum < curwin->w_botline
#ifdef FEAT_DIFF
&& (loff.lnum + 1 < curwin->w_botline || loff.fill == 0)
#endif
)
{
n += loff.height;
if (n >= *so_ptr)
break;
botline_forw(&loff);
}
if (n >= *so_ptr)
// sufficient context, no need to scroll
check_botline = FALSE;
}
else
// sufficient context, no need to scroll
check_botline = FALSE;
}
if (check_botline)
{
#ifdef FEAT_FOLDING
if (hasAnyFolding(curwin))
{
// Count the number of logical lines between the cursor and
// botline - scrolloff (approximation of how much will be
// scrolled).
line_count = 0;
for (lnum = curwin->w_cursor.lnum;
lnum >= curwin->w_botline - *so_ptr; --lnum)
{
++line_count;
// stop at end of file or when we know we are far off
if (lnum <= 0 || line_count > curwin->w_height + 1)
break;
(void)hasFolding(lnum, &lnum, NULL);
}
}
else
#endif
line_count = curwin->w_cursor.lnum - curwin->w_botline
+ 1 + *so_ptr;
if (line_count <= curwin->w_height + 1)
scroll_cursor_bot(scrolljump_value(), FALSE);
else
scroll_cursor_halfway(FALSE);
}
}
}
curwin->w_valid |= VALID_TOPLINE;
/*
* Need to redraw when topline changed.
*/
if (curwin->w_topline != old_topline
#ifdef FEAT_DIFF
|| curwin->w_topfill != old_topfill
#endif
)
{
dollar_vcol = -1;
if (curwin->w_skipcol != 0)
{
curwin->w_skipcol = 0;
redraw_later(NOT_VALID);
}
else
redraw_later(VALID);
// May need to set w_skipcol when cursor in w_topline.
if (curwin->w_cursor.lnum == curwin->w_topline)
validate_cursor();
}
*so_ptr = save_so;
} | 816 | True | 1 |
|
CVE-2021-3928 | 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://huntr.dev/bounties/29c3ebd2-d601-481c-bf96-76975369d0cd', 'name': 'https://huntr.dev/bounties/29c3ebd2-d601-481c-bf96-76975369d0cd', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Patch', 'Third Party Advisory']}, {'url': 'https://github.com/vim/vim/commit/15d9890eee53afc61eb0a03b878a19cb5672f732', 'name': 'https://github.com/vim/vim/commit/15d9890eee53afc61eb0a03b878a19cb5672f732', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/PGW56Z6IN4UVM3E5RXXF4G7LGGTRBI5C/', 'name': 'FEDORA-2021-58ab85548d', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/BCQWPEY2AEYBELCMJYHYWYCD3PZVD2H7/', 'name': 'FEDORA-2021-cfadac570a', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/FNXY7T5OORA7UJIMGSJBGHFMU6UZWS6P/', 'name': 'FEDORA-2021-b0ac29efb1', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2022/01/15/1', 'name': "[oss-security] 20220114 Re: 3 new CVE's in vim", 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2022/03/msg00018.html', 'name': '[debian-lts-announce] 20220311 [SECURITY] [DLA 2947-1] vim security update', 'refsource': 'MLIST', 'tags': ['Mitigation', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-457'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.3582', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:fedoraproject:fedora:33:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:fedoraproject:fedora:34:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:fedoraproject:fedora:35:*:*:*:*:*:*:*', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:debian:debian_linux:9.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'vim is vulnerable to Use of Uninitialized Variable'}] | 2022-08-26T20:19Z | 2021-11-05T15:15Z | Use of Uninitialized Variable | The code uses a variable that has not been initialized, leading to unpredictable or unintended results. | In some languages such as C and C++, stack variables are not initialized by default. They generally contain junk data with the contents of stack memory before the function was invoked. An attacker can sometimes control or read these contents. In other languages or conditions, a variable that is not explicitly initialized can be given a default value that has security implications, depending on the logic of the program. The presence of an uninitialized variable can sometimes indicate a typographic error in the code.
| https://cwe.mitre.org/data/definitions/457.html | 0 | Bram Moolenaar | 2021-11-04 15:46:05+00:00 | patch 8.2.3582: reading uninitialized memory when giving spell suggestions
Problem: Reading uninitialized memory when giving spell suggestions.
Solution: Check that preword is not empty. | 15d9890eee53afc61eb0a03b878a19cb5672f732 | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | suggest_trie_walk | suggest_trie_walk( suginfo_T * su , langp_T * lp , char_u * fword , int soundfold) | ['su', 'lp', 'fword', 'soundfold'] | suggest_trie_walk(
suginfo_T *su,
langp_T *lp,
char_u *fword,
int soundfold)
{
char_u tword[MAXWLEN]; // good word collected so far
trystate_T stack[MAXWLEN];
char_u preword[MAXWLEN * 3]; // word found with proper case;
// concatenation of prefix compound
// words and split word. NUL terminated
// when going deeper but not when coming
// back.
char_u compflags[MAXWLEN]; // compound flags, one for each word
trystate_T *sp;
int newscore;
int score;
char_u *byts, *fbyts, *pbyts;
idx_T *idxs, *fidxs, *pidxs;
int depth;
int c, c2, c3;
int n = 0;
int flags;
garray_T *gap;
idx_T arridx;
int len;
char_u *p;
fromto_T *ftp;
int fl = 0, tl;
int repextra = 0; // extra bytes in fword[] from REP item
slang_T *slang = lp->lp_slang;
int fword_ends;
int goodword_ends;
#ifdef DEBUG_TRIEWALK
// Stores the name of the change made at each level.
char_u changename[MAXWLEN][80];
#endif
int breakcheckcount = 1000;
int compound_ok;
// Go through the whole case-fold tree, try changes at each node.
// "tword[]" contains the word collected from nodes in the tree.
// "fword[]" the word we are trying to match with (initially the bad
// word).
depth = 0;
sp = &stack[0];
CLEAR_POINTER(sp);
sp->ts_curi = 1;
if (soundfold)
{
// Going through the soundfold tree.
byts = fbyts = slang->sl_sbyts;
idxs = fidxs = slang->sl_sidxs;
pbyts = NULL;
pidxs = NULL;
sp->ts_prefixdepth = PFD_NOPREFIX;
sp->ts_state = STATE_START;
}
else
{
// When there are postponed prefixes we need to use these first. At
// the end of the prefix we continue in the case-fold tree.
fbyts = slang->sl_fbyts;
fidxs = slang->sl_fidxs;
pbyts = slang->sl_pbyts;
pidxs = slang->sl_pidxs;
if (pbyts != NULL)
{
byts = pbyts;
idxs = pidxs;
sp->ts_prefixdepth = PFD_PREFIXTREE;
sp->ts_state = STATE_NOPREFIX; // try without prefix first
}
else
{
byts = fbyts;
idxs = fidxs;
sp->ts_prefixdepth = PFD_NOPREFIX;
sp->ts_state = STATE_START;
}
}
// Loop to find all suggestions. At each round we either:
// - For the current state try one operation, advance "ts_curi",
// increase "depth".
// - When a state is done go to the next, set "ts_state".
// - When all states are tried decrease "depth".
while (depth >= 0 && !got_int)
{
sp = &stack[depth];
switch (sp->ts_state)
{
case STATE_START:
case STATE_NOPREFIX:
// Start of node: Deal with NUL bytes, which means
// tword[] may end here.
arridx = sp->ts_arridx; // current node in the tree
len = byts[arridx]; // bytes in this node
arridx += sp->ts_curi; // index of current byte
if (sp->ts_prefixdepth == PFD_PREFIXTREE)
{
// Skip over the NUL bytes, we use them later.
for (n = 0; n < len && byts[arridx + n] == 0; ++n)
;
sp->ts_curi += n;
// Always past NUL bytes now.
n = (int)sp->ts_state;
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_ENDNUL;
sp->ts_save_badflags = su->su_badflags;
// At end of a prefix or at start of prefixtree: check for
// following word.
if (byts[arridx] == 0 || n == (int)STATE_NOPREFIX)
{
// Set su->su_badflags to the caps type at this position.
// Use the caps type until here for the prefix itself.
if (has_mbyte)
n = nofold_len(fword, sp->ts_fidx, su->su_badptr);
else
n = sp->ts_fidx;
flags = badword_captype(su->su_badptr, su->su_badptr + n);
su->su_badflags = badword_captype(su->su_badptr + n,
su->su_badptr + su->su_badlen);
#ifdef DEBUG_TRIEWALK
sprintf(changename[depth], "prefix");
#endif
go_deeper(stack, depth, 0);
++depth;
sp = &stack[depth];
sp->ts_prefixdepth = depth - 1;
byts = fbyts;
idxs = fidxs;
sp->ts_arridx = 0;
// Move the prefix to preword[] with the right case
// and make find_keepcap_word() works.
tword[sp->ts_twordlen] = NUL;
make_case_word(tword + sp->ts_splitoff,
preword + sp->ts_prewordlen, flags);
sp->ts_prewordlen = (char_u)STRLEN(preword);
sp->ts_splitoff = sp->ts_twordlen;
}
break;
}
if (sp->ts_curi > len || byts[arridx] != 0)
{
// Past bytes in node and/or past NUL bytes.
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_ENDNUL;
sp->ts_save_badflags = su->su_badflags;
break;
}
// End of word in tree.
++sp->ts_curi; // eat one NUL byte
flags = (int)idxs[arridx];
// Skip words with the NOSUGGEST flag.
if (flags & WF_NOSUGGEST)
break;
fword_ends = (fword[sp->ts_fidx] == NUL
|| (soundfold
? VIM_ISWHITE(fword[sp->ts_fidx])
: !spell_iswordp(fword + sp->ts_fidx, curwin)));
tword[sp->ts_twordlen] = NUL;
if (sp->ts_prefixdepth <= PFD_NOTSPECIAL
&& (sp->ts_flags & TSF_PREFIXOK) == 0
&& pbyts != NULL)
{
// There was a prefix before the word. Check that the prefix
// can be used with this word.
// Count the length of the NULs in the prefix. If there are
// none this must be the first try without a prefix.
n = stack[sp->ts_prefixdepth].ts_arridx;
len = pbyts[n++];
for (c = 0; c < len && pbyts[n + c] == 0; ++c)
;
if (c > 0)
{
c = valid_word_prefix(c, n, flags,
tword + sp->ts_splitoff, slang, FALSE);
if (c == 0)
break;
// Use the WF_RARE flag for a rare prefix.
if (c & WF_RAREPFX)
flags |= WF_RARE;
// Tricky: when checking for both prefix and compounding
// we run into the prefix flag first.
// Remember that it's OK, so that we accept the prefix
// when arriving at a compound flag.
sp->ts_flags |= TSF_PREFIXOK;
}
}
// Check NEEDCOMPOUND: can't use word without compounding. Do try
// appending another compound word below.
if (sp->ts_complen == sp->ts_compsplit && fword_ends
&& (flags & WF_NEEDCOMP))
goodword_ends = FALSE;
else
goodword_ends = TRUE;
p = NULL;
compound_ok = TRUE;
if (sp->ts_complen > sp->ts_compsplit)
{
if (slang->sl_nobreak)
{
// There was a word before this word. When there was no
// change in this word (it was correct) add the first word
// as a suggestion. If this word was corrected too, we
// need to check if a correct word follows.
if (sp->ts_fidx - sp->ts_splitfidx
== sp->ts_twordlen - sp->ts_splitoff
&& STRNCMP(fword + sp->ts_splitfidx,
tword + sp->ts_splitoff,
sp->ts_fidx - sp->ts_splitfidx) == 0)
{
preword[sp->ts_prewordlen] = NUL;
newscore = score_wordcount_adj(slang, sp->ts_score,
preword + sp->ts_prewordlen,
sp->ts_prewordlen > 0);
// Add the suggestion if the score isn't too bad.
if (newscore <= su->su_maxscore)
add_suggestion(su, &su->su_ga, preword,
sp->ts_splitfidx - repextra,
newscore, 0, FALSE,
lp->lp_sallang, FALSE);
break;
}
}
else
{
// There was a compound word before this word. If this
// word does not support compounding then give up
// (splitting is tried for the word without compound
// flag).
if (((unsigned)flags >> 24) == 0
|| sp->ts_twordlen - sp->ts_splitoff
< slang->sl_compminlen)
break;
// For multi-byte chars check character length against
// COMPOUNDMIN.
if (has_mbyte
&& slang->sl_compminlen > 0
&& mb_charlen(tword + sp->ts_splitoff)
< slang->sl_compminlen)
break;
compflags[sp->ts_complen] = ((unsigned)flags >> 24);
compflags[sp->ts_complen + 1] = NUL;
vim_strncpy(preword + sp->ts_prewordlen,
tword + sp->ts_splitoff,
sp->ts_twordlen - sp->ts_splitoff);
// Verify CHECKCOMPOUNDPATTERN rules.
if (match_checkcompoundpattern(preword, sp->ts_prewordlen,
&slang->sl_comppat))
compound_ok = FALSE;
if (compound_ok)
{
p = preword;
while (*skiptowhite(p) != NUL)
p = skipwhite(skiptowhite(p));
if (fword_ends && !can_compound(slang, p,
compflags + sp->ts_compsplit))
// Compound is not allowed. But it may still be
// possible if we add another (short) word.
compound_ok = FALSE;
}
// Get pointer to last char of previous word.
p = preword + sp->ts_prewordlen;
MB_PTR_BACK(preword, p);
}
}
// Form the word with proper case in preword.
// If there is a word from a previous split, append.
// For the soundfold tree don't change the case, simply append.
if (soundfold)
STRCPY(preword + sp->ts_prewordlen, tword + sp->ts_splitoff);
else if (flags & WF_KEEPCAP)
// Must find the word in the keep-case tree.
find_keepcap_word(slang, tword + sp->ts_splitoff,
preword + sp->ts_prewordlen);
else
{
// Include badflags: If the badword is onecap or allcap
// use that for the goodword too. But if the badword is
// allcap and it's only one char long use onecap.
c = su->su_badflags;
if ((c & WF_ALLCAP)
&& su->su_badlen == (*mb_ptr2len)(su->su_badptr))
c = WF_ONECAP;
c |= flags;
// When appending a compound word after a word character don't
// use Onecap.
if (p != NULL && spell_iswordp_nmw(p, curwin))
c &= ~WF_ONECAP;
make_case_word(tword + sp->ts_splitoff,
preword + sp->ts_prewordlen, c);
}
if (!soundfold)
{
// Don't use a banned word. It may appear again as a good
// word, thus remember it.
if (flags & WF_BANNED)
{
add_banned(su, preword + sp->ts_prewordlen);
break;
}
if ((sp->ts_complen == sp->ts_compsplit
&& WAS_BANNED(su, preword + sp->ts_prewordlen))
|| WAS_BANNED(su, preword))
{
if (slang->sl_compprog == NULL)
break;
// the word so far was banned but we may try compounding
goodword_ends = FALSE;
}
}
newscore = 0;
if (!soundfold) // soundfold words don't have flags
{
if ((flags & WF_REGION)
&& (((unsigned)flags >> 16) & lp->lp_region) == 0)
newscore += SCORE_REGION;
if (flags & WF_RARE)
newscore += SCORE_RARE;
if (!spell_valid_case(su->su_badflags,
captype(preword + sp->ts_prewordlen, NULL)))
newscore += SCORE_ICASE;
}
// TODO: how about splitting in the soundfold tree?
if (fword_ends
&& goodword_ends
&& sp->ts_fidx >= sp->ts_fidxtry
&& compound_ok)
{
// The badword also ends: add suggestions.
#ifdef DEBUG_TRIEWALK
if (soundfold && STRCMP(preword, "smwrd") == 0)
{
int j;
// print the stack of changes that brought us here
smsg("------ %s -------", fword);
for (j = 0; j < depth; ++j)
smsg("%s", changename[j]);
}
#endif
if (soundfold)
{
// For soundfolded words we need to find the original
// words, the edit distance and then add them.
add_sound_suggest(su, preword, sp->ts_score, lp);
}
else if (sp->ts_fidx > 0)
{
// Give a penalty when changing non-word char to word
// char, e.g., "thes," -> "these".
p = fword + sp->ts_fidx;
MB_PTR_BACK(fword, p);
if (!spell_iswordp(p, curwin))
{
p = preword + STRLEN(preword);
MB_PTR_BACK(preword, p);
if (spell_iswordp(p, curwin))
newscore += SCORE_NONWORD;
}
// Give a bonus to words seen before.
score = score_wordcount_adj(slang,
sp->ts_score + newscore,
preword + sp->ts_prewordlen,
sp->ts_prewordlen > 0);
// Add the suggestion if the score isn't too bad.
if (score <= su->su_maxscore)
{
add_suggestion(su, &su->su_ga, preword,
sp->ts_fidx - repextra,
score, 0, FALSE, lp->lp_sallang, FALSE);
if (su->su_badflags & WF_MIXCAP)
{
// We really don't know if the word should be
// upper or lower case, add both.
c = captype(preword, NULL);
if (c == 0 || c == WF_ALLCAP)
{
make_case_word(tword + sp->ts_splitoff,
preword + sp->ts_prewordlen,
c == 0 ? WF_ALLCAP : 0);
add_suggestion(su, &su->su_ga, preword,
sp->ts_fidx - repextra,
score + SCORE_ICASE, 0, FALSE,
lp->lp_sallang, FALSE);
}
}
}
}
}
// Try word split and/or compounding.
if ((sp->ts_fidx >= sp->ts_fidxtry || fword_ends)
// Don't split halfway a character.
&& (!has_mbyte || sp->ts_tcharlen == 0))
{
int try_compound;
int try_split;
// If past the end of the bad word don't try a split.
// Otherwise try changing the next word. E.g., find
// suggestions for "the the" where the second "the" is
// different. It's done like a split.
// TODO: word split for soundfold words
try_split = (sp->ts_fidx - repextra < su->su_badlen)
&& !soundfold;
// Get here in several situations:
// 1. The word in the tree ends:
// If the word allows compounding try that. Otherwise try
// a split by inserting a space. For both check that a
// valid words starts at fword[sp->ts_fidx].
// For NOBREAK do like compounding to be able to check if
// the next word is valid.
// 2. The badword does end, but it was due to a change (e.g.,
// a swap). No need to split, but do check that the
// following word is valid.
// 3. The badword and the word in the tree end. It may still
// be possible to compound another (short) word.
try_compound = FALSE;
if (!soundfold
&& !slang->sl_nocompoundsugs
&& slang->sl_compprog != NULL
&& ((unsigned)flags >> 24) != 0
&& sp->ts_twordlen - sp->ts_splitoff
>= slang->sl_compminlen
&& (!has_mbyte
|| slang->sl_compminlen == 0
|| mb_charlen(tword + sp->ts_splitoff)
>= slang->sl_compminlen)
&& (slang->sl_compsylmax < MAXWLEN
|| sp->ts_complen + 1 - sp->ts_compsplit
< slang->sl_compmax)
&& (can_be_compound(sp, slang,
compflags, ((unsigned)flags >> 24))))
{
try_compound = TRUE;
compflags[sp->ts_complen] = ((unsigned)flags >> 24);
compflags[sp->ts_complen + 1] = NUL;
}
// For NOBREAK we never try splitting, it won't make any word
// valid.
if (slang->sl_nobreak && !slang->sl_nocompoundsugs)
try_compound = TRUE;
// If we could add a compound word, and it's also possible to
// split at this point, do the split first and set
// TSF_DIDSPLIT to avoid doing it again.
else if (!fword_ends
&& try_compound
&& (sp->ts_flags & TSF_DIDSPLIT) == 0)
{
try_compound = FALSE;
sp->ts_flags |= TSF_DIDSPLIT;
--sp->ts_curi; // do the same NUL again
compflags[sp->ts_complen] = NUL;
}
else
sp->ts_flags &= ~TSF_DIDSPLIT;
if (try_split || try_compound)
{
if (!try_compound && (!fword_ends || !goodword_ends))
{
// If we're going to split need to check that the
// words so far are valid for compounding. If there
// is only one word it must not have the NEEDCOMPOUND
// flag.
if (sp->ts_complen == sp->ts_compsplit
&& (flags & WF_NEEDCOMP))
break;
p = preword;
while (*skiptowhite(p) != NUL)
p = skipwhite(skiptowhite(p));
if (sp->ts_complen > sp->ts_compsplit
&& !can_compound(slang, p,
compflags + sp->ts_compsplit))
break;
if (slang->sl_nosplitsugs)
newscore += SCORE_SPLIT_NO;
else
newscore += SCORE_SPLIT;
// Give a bonus to words seen before.
newscore = score_wordcount_adj(slang, newscore,
preword + sp->ts_prewordlen, TRUE);
}
if (TRY_DEEPER(su, stack, depth, newscore))
{
go_deeper(stack, depth, newscore);
#ifdef DEBUG_TRIEWALK
if (!try_compound && !fword_ends)
sprintf(changename[depth], "%.*s-%s: split",
sp->ts_twordlen, tword, fword + sp->ts_fidx);
else
sprintf(changename[depth], "%.*s-%s: compound",
sp->ts_twordlen, tword, fword + sp->ts_fidx);
#endif
// Save things to be restored at STATE_SPLITUNDO.
sp->ts_save_badflags = su->su_badflags;
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_SPLITUNDO;
++depth;
sp = &stack[depth];
// Append a space to preword when splitting.
if (!try_compound && !fword_ends)
STRCAT(preword, " ");
sp->ts_prewordlen = (char_u)STRLEN(preword);
sp->ts_splitoff = sp->ts_twordlen;
sp->ts_splitfidx = sp->ts_fidx;
// If the badword has a non-word character at this
// position skip it. That means replacing the
// non-word character with a space. Always skip a
// character when the word ends. But only when the
// good word can end.
if (((!try_compound && !spell_iswordp_nmw(fword
+ sp->ts_fidx,
curwin))
|| fword_ends)
&& fword[sp->ts_fidx] != NUL
&& goodword_ends)
{
int l;
l = mb_ptr2len(fword + sp->ts_fidx);
if (fword_ends)
{
// Copy the skipped character to preword.
mch_memmove(preword + sp->ts_prewordlen,
fword + sp->ts_fidx, l);
sp->ts_prewordlen += l;
preword[sp->ts_prewordlen] = NUL;
}
else
sp->ts_score -= SCORE_SPLIT - SCORE_SUBST;
sp->ts_fidx += l;
}
// When compounding include compound flag in
// compflags[] (already set above). When splitting we
// may start compounding over again.
if (try_compound)
++sp->ts_complen;
else
sp->ts_compsplit = sp->ts_complen;
sp->ts_prefixdepth = PFD_NOPREFIX;
// set su->su_badflags to the caps type at this
// position
if (has_mbyte)
n = nofold_len(fword, sp->ts_fidx, su->su_badptr);
else
n = sp->ts_fidx;
su->su_badflags = badword_captype(su->su_badptr + n,
su->su_badptr + su->su_badlen);
// Restart at top of the tree.
sp->ts_arridx = 0;
// If there are postponed prefixes, try these too.
if (pbyts != NULL)
{
byts = pbyts;
idxs = pidxs;
sp->ts_prefixdepth = PFD_PREFIXTREE;
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_NOPREFIX;
}
}
}
}
break;
case STATE_SPLITUNDO:
// Undo the changes done for word split or compound word.
su->su_badflags = sp->ts_save_badflags;
// Continue looking for NUL bytes.
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_START;
// In case we went into the prefix tree.
byts = fbyts;
idxs = fidxs;
break;
case STATE_ENDNUL:
// Past the NUL bytes in the node.
su->su_badflags = sp->ts_save_badflags;
if (fword[sp->ts_fidx] == NUL && sp->ts_tcharlen == 0)
{
// The badword ends, can't use STATE_PLAIN.
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_DEL;
break;
}
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_PLAIN;
// FALLTHROUGH
case STATE_PLAIN:
// Go over all possible bytes at this node, add each to tword[]
// and use child node. "ts_curi" is the index.
arridx = sp->ts_arridx;
if (sp->ts_curi > byts[arridx])
{
// Done all bytes at this node, do next state. When still at
// already changed bytes skip the other tricks.
PROF_STORE(sp->ts_state)
if (sp->ts_fidx >= sp->ts_fidxtry)
sp->ts_state = STATE_DEL;
else
sp->ts_state = STATE_FINAL;
}
else
{
arridx += sp->ts_curi++;
c = byts[arridx];
// Normal byte, go one level deeper. If it's not equal to the
// byte in the bad word adjust the score. But don't even try
// when the byte was already changed. And don't try when we
// just deleted this byte, accepting it is always cheaper than
// delete + substitute.
if (c == fword[sp->ts_fidx]
|| (sp->ts_tcharlen > 0 && sp->ts_isdiff != DIFF_NONE))
newscore = 0;
else
newscore = SCORE_SUBST;
if ((newscore == 0
|| (sp->ts_fidx >= sp->ts_fidxtry
&& ((sp->ts_flags & TSF_DIDDEL) == 0
|| c != fword[sp->ts_delidx])))
&& TRY_DEEPER(su, stack, depth, newscore))
{
go_deeper(stack, depth, newscore);
#ifdef DEBUG_TRIEWALK
if (newscore > 0)
sprintf(changename[depth], "%.*s-%s: subst %c to %c",
sp->ts_twordlen, tword, fword + sp->ts_fidx,
fword[sp->ts_fidx], c);
else
sprintf(changename[depth], "%.*s-%s: accept %c",
sp->ts_twordlen, tword, fword + sp->ts_fidx,
fword[sp->ts_fidx]);
#endif
++depth;
sp = &stack[depth];
++sp->ts_fidx;
tword[sp->ts_twordlen++] = c;
sp->ts_arridx = idxs[arridx];
if (newscore == SCORE_SUBST)
sp->ts_isdiff = DIFF_YES;
if (has_mbyte)
{
// Multi-byte characters are a bit complicated to
// handle: They differ when any of the bytes differ
// and then their length may also differ.
if (sp->ts_tcharlen == 0)
{
// First byte.
sp->ts_tcharidx = 0;
sp->ts_tcharlen = MB_BYTE2LEN(c);
sp->ts_fcharstart = sp->ts_fidx - 1;
sp->ts_isdiff = (newscore != 0)
? DIFF_YES : DIFF_NONE;
}
else if (sp->ts_isdiff == DIFF_INSERT)
// When inserting trail bytes don't advance in the
// bad word.
--sp->ts_fidx;
if (++sp->ts_tcharidx == sp->ts_tcharlen)
{
// Last byte of character.
if (sp->ts_isdiff == DIFF_YES)
{
// Correct ts_fidx for the byte length of the
// character (we didn't check that before).
sp->ts_fidx = sp->ts_fcharstart
+ mb_ptr2len(
fword + sp->ts_fcharstart);
// For changing a composing character adjust
// the score from SCORE_SUBST to
// SCORE_SUBCOMP.
if (enc_utf8
&& utf_iscomposing(
utf_ptr2char(tword
+ sp->ts_twordlen
- sp->ts_tcharlen))
&& utf_iscomposing(
utf_ptr2char(fword
+ sp->ts_fcharstart)))
sp->ts_score -=
SCORE_SUBST - SCORE_SUBCOMP;
// For a similar character adjust score from
// SCORE_SUBST to SCORE_SIMILAR.
else if (!soundfold
&& slang->sl_has_map
&& similar_chars(slang,
mb_ptr2char(tword
+ sp->ts_twordlen
- sp->ts_tcharlen),
mb_ptr2char(fword
+ sp->ts_fcharstart)))
sp->ts_score -=
SCORE_SUBST - SCORE_SIMILAR;
}
else if (sp->ts_isdiff == DIFF_INSERT
&& sp->ts_twordlen > sp->ts_tcharlen)
{
p = tword + sp->ts_twordlen - sp->ts_tcharlen;
c = mb_ptr2char(p);
if (enc_utf8 && utf_iscomposing(c))
{
// Inserting a composing char doesn't
// count that much.
sp->ts_score -= SCORE_INS - SCORE_INSCOMP;
}
else
{
// If the previous character was the same,
// thus doubling a character, give a bonus
// to the score. Also for the soundfold
// tree (might seem illogical but does
// give better scores).
MB_PTR_BACK(tword, p);
if (c == mb_ptr2char(p))
sp->ts_score -= SCORE_INS
- SCORE_INSDUP;
}
}
// Starting a new char, reset the length.
sp->ts_tcharlen = 0;
}
}
else
{
// If we found a similar char adjust the score.
// We do this after calling go_deeper() because
// it's slow.
if (newscore != 0
&& !soundfold
&& slang->sl_has_map
&& similar_chars(slang,
c, fword[sp->ts_fidx - 1]))
sp->ts_score -= SCORE_SUBST - SCORE_SIMILAR;
}
}
}
break;
case STATE_DEL:
// When past the first byte of a multi-byte char don't try
// delete/insert/swap a character.
if (has_mbyte && sp->ts_tcharlen > 0)
{
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_FINAL;
break;
}
// Try skipping one character in the bad word (delete it).
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_INS_PREP;
sp->ts_curi = 1;
if (soundfold && sp->ts_fidx == 0 && fword[sp->ts_fidx] == '*')
// Deleting a vowel at the start of a word counts less, see
// soundalike_score().
newscore = 2 * SCORE_DEL / 3;
else
newscore = SCORE_DEL;
if (fword[sp->ts_fidx] != NUL
&& TRY_DEEPER(su, stack, depth, newscore))
{
go_deeper(stack, depth, newscore);
#ifdef DEBUG_TRIEWALK
sprintf(changename[depth], "%.*s-%s: delete %c",
sp->ts_twordlen, tword, fword + sp->ts_fidx,
fword[sp->ts_fidx]);
#endif
++depth;
// Remember what character we deleted, so that we can avoid
// inserting it again.
stack[depth].ts_flags |= TSF_DIDDEL;
stack[depth].ts_delidx = sp->ts_fidx;
// Advance over the character in fword[]. Give a bonus to the
// score if the same character is following "nn" -> "n". It's
// a bit illogical for soundfold tree but it does give better
// results.
if (has_mbyte)
{
c = mb_ptr2char(fword + sp->ts_fidx);
stack[depth].ts_fidx += mb_ptr2len(fword + sp->ts_fidx);
if (enc_utf8 && utf_iscomposing(c))
stack[depth].ts_score -= SCORE_DEL - SCORE_DELCOMP;
else if (c == mb_ptr2char(fword + stack[depth].ts_fidx))
stack[depth].ts_score -= SCORE_DEL - SCORE_DELDUP;
}
else
{
++stack[depth].ts_fidx;
if (fword[sp->ts_fidx] == fword[sp->ts_fidx + 1])
stack[depth].ts_score -= SCORE_DEL - SCORE_DELDUP;
}
break;
}
// FALLTHROUGH
case STATE_INS_PREP:
if (sp->ts_flags & TSF_DIDDEL)
{
// If we just deleted a byte then inserting won't make sense,
// a substitute is always cheaper.
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_SWAP;
break;
}
// skip over NUL bytes
n = sp->ts_arridx;
for (;;)
{
if (sp->ts_curi > byts[n])
{
// Only NUL bytes at this node, go to next state.
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_SWAP;
break;
}
if (byts[n + sp->ts_curi] != NUL)
{
// Found a byte to insert.
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_INS;
break;
}
++sp->ts_curi;
}
break;
// FALLTHROUGH
case STATE_INS:
// Insert one byte. Repeat this for each possible byte at this
// node.
n = sp->ts_arridx;
if (sp->ts_curi > byts[n])
{
// Done all bytes at this node, go to next state.
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_SWAP;
break;
}
// Do one more byte at this node, but:
// - Skip NUL bytes.
// - Skip the byte if it's equal to the byte in the word,
// accepting that byte is always better.
n += sp->ts_curi++;
c = byts[n];
if (soundfold && sp->ts_twordlen == 0 && c == '*')
// Inserting a vowel at the start of a word counts less,
// see soundalike_score().
newscore = 2 * SCORE_INS / 3;
else
newscore = SCORE_INS;
if (c != fword[sp->ts_fidx]
&& TRY_DEEPER(su, stack, depth, newscore))
{
go_deeper(stack, depth, newscore);
#ifdef DEBUG_TRIEWALK
sprintf(changename[depth], "%.*s-%s: insert %c",
sp->ts_twordlen, tword, fword + sp->ts_fidx,
c);
#endif
++depth;
sp = &stack[depth];
tword[sp->ts_twordlen++] = c;
sp->ts_arridx = idxs[n];
if (has_mbyte)
{
fl = MB_BYTE2LEN(c);
if (fl > 1)
{
// There are following bytes for the same character.
// We must find all bytes before trying
// delete/insert/swap/etc.
sp->ts_tcharlen = fl;
sp->ts_tcharidx = 1;
sp->ts_isdiff = DIFF_INSERT;
}
}
else
fl = 1;
if (fl == 1)
{
// If the previous character was the same, thus doubling a
// character, give a bonus to the score. Also for
// soundfold words (illogical but does give a better
// score).
if (sp->ts_twordlen >= 2
&& tword[sp->ts_twordlen - 2] == c)
sp->ts_score -= SCORE_INS - SCORE_INSDUP;
}
}
break;
case STATE_SWAP:
// Swap two bytes in the bad word: "12" -> "21".
// We change "fword" here, it's changed back afterwards at
// STATE_UNSWAP.
p = fword + sp->ts_fidx;
c = *p;
if (c == NUL)
{
// End of word, can't swap or replace.
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_FINAL;
break;
}
// Don't swap if the first character is not a word character.
// SWAP3 etc. also don't make sense then.
if (!soundfold && !spell_iswordp(p, curwin))
{
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_REP_INI;
break;
}
if (has_mbyte)
{
n = MB_CPTR2LEN(p);
c = mb_ptr2char(p);
if (p[n] == NUL)
c2 = NUL;
else if (!soundfold && !spell_iswordp(p + n, curwin))
c2 = c; // don't swap non-word char
else
c2 = mb_ptr2char(p + n);
}
else
{
if (p[1] == NUL)
c2 = NUL;
else if (!soundfold && !spell_iswordp(p + 1, curwin))
c2 = c; // don't swap non-word char
else
c2 = p[1];
}
// When the second character is NUL we can't swap.
if (c2 == NUL)
{
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_REP_INI;
break;
}
// When characters are identical, swap won't do anything.
// Also get here if the second char is not a word character.
if (c == c2)
{
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_SWAP3;
break;
}
if (c2 != NUL && TRY_DEEPER(su, stack, depth, SCORE_SWAP))
{
go_deeper(stack, depth, SCORE_SWAP);
#ifdef DEBUG_TRIEWALK
sprintf(changename[depth], "%.*s-%s: swap %c and %c",
sp->ts_twordlen, tword, fword + sp->ts_fidx,
c, c2);
#endif
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_UNSWAP;
++depth;
if (has_mbyte)
{
fl = mb_char2len(c2);
mch_memmove(p, p + n, fl);
mb_char2bytes(c, p + fl);
stack[depth].ts_fidxtry = sp->ts_fidx + n + fl;
}
else
{
p[0] = c2;
p[1] = c;
stack[depth].ts_fidxtry = sp->ts_fidx + 2;
}
}
else
{
// If this swap doesn't work then SWAP3 won't either.
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_REP_INI;
}
break;
case STATE_UNSWAP:
// Undo the STATE_SWAP swap: "21" -> "12".
p = fword + sp->ts_fidx;
if (has_mbyte)
{
n = mb_ptr2len(p);
c = mb_ptr2char(p + n);
mch_memmove(p + mb_ptr2len(p + n), p, n);
mb_char2bytes(c, p);
}
else
{
c = *p;
*p = p[1];
p[1] = c;
}
// FALLTHROUGH
case STATE_SWAP3:
// Swap two bytes, skipping one: "123" -> "321". We change
// "fword" here, it's changed back afterwards at STATE_UNSWAP3.
p = fword + sp->ts_fidx;
if (has_mbyte)
{
n = MB_CPTR2LEN(p);
c = mb_ptr2char(p);
fl = MB_CPTR2LEN(p + n);
c2 = mb_ptr2char(p + n);
if (!soundfold && !spell_iswordp(p + n + fl, curwin))
c3 = c; // don't swap non-word char
else
c3 = mb_ptr2char(p + n + fl);
}
else
{
c = *p;
c2 = p[1];
if (!soundfold && !spell_iswordp(p + 2, curwin))
c3 = c; // don't swap non-word char
else
c3 = p[2];
}
// When characters are identical: "121" then SWAP3 result is
// identical, ROT3L result is same as SWAP: "211", ROT3L result is
// same as SWAP on next char: "112". Thus skip all swapping.
// Also skip when c3 is NUL.
// Also get here when the third character is not a word character.
// Second character may any char: "a.b" -> "b.a"
if (c == c3 || c3 == NUL)
{
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_REP_INI;
break;
}
if (TRY_DEEPER(su, stack, depth, SCORE_SWAP3))
{
go_deeper(stack, depth, SCORE_SWAP3);
#ifdef DEBUG_TRIEWALK
sprintf(changename[depth], "%.*s-%s: swap3 %c and %c",
sp->ts_twordlen, tword, fword + sp->ts_fidx,
c, c3);
#endif
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_UNSWAP3;
++depth;
if (has_mbyte)
{
tl = mb_char2len(c3);
mch_memmove(p, p + n + fl, tl);
mb_char2bytes(c2, p + tl);
mb_char2bytes(c, p + fl + tl);
stack[depth].ts_fidxtry = sp->ts_fidx + n + fl + tl;
}
else
{
p[0] = p[2];
p[2] = c;
stack[depth].ts_fidxtry = sp->ts_fidx + 3;
}
}
else
{
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_REP_INI;
}
break;
case STATE_UNSWAP3:
// Undo STATE_SWAP3: "321" -> "123"
p = fword + sp->ts_fidx;
if (has_mbyte)
{
n = mb_ptr2len(p);
c2 = mb_ptr2char(p + n);
fl = mb_ptr2len(p + n);
c = mb_ptr2char(p + n + fl);
tl = mb_ptr2len(p + n + fl);
mch_memmove(p + fl + tl, p, n);
mb_char2bytes(c, p);
mb_char2bytes(c2, p + tl);
p = p + tl;
}
else
{
c = *p;
*p = p[2];
p[2] = c;
++p;
}
if (!soundfold && !spell_iswordp(p, curwin))
{
// Middle char is not a word char, skip the rotate. First and
// third char were already checked at swap and swap3.
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_REP_INI;
break;
}
// Rotate three characters left: "123" -> "231". We change
// "fword" here, it's changed back afterwards at STATE_UNROT3L.
if (TRY_DEEPER(su, stack, depth, SCORE_SWAP3))
{
go_deeper(stack, depth, SCORE_SWAP3);
#ifdef DEBUG_TRIEWALK
p = fword + sp->ts_fidx;
sprintf(changename[depth], "%.*s-%s: rotate left %c%c%c",
sp->ts_twordlen, tword, fword + sp->ts_fidx,
p[0], p[1], p[2]);
#endif
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_UNROT3L;
++depth;
p = fword + sp->ts_fidx;
if (has_mbyte)
{
n = MB_CPTR2LEN(p);
c = mb_ptr2char(p);
fl = MB_CPTR2LEN(p + n);
fl += MB_CPTR2LEN(p + n + fl);
mch_memmove(p, p + n, fl);
mb_char2bytes(c, p + fl);
stack[depth].ts_fidxtry = sp->ts_fidx + n + fl;
}
else
{
c = *p;
*p = p[1];
p[1] = p[2];
p[2] = c;
stack[depth].ts_fidxtry = sp->ts_fidx + 3;
}
}
else
{
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_REP_INI;
}
break;
case STATE_UNROT3L:
// Undo ROT3L: "231" -> "123"
p = fword + sp->ts_fidx;
if (has_mbyte)
{
n = mb_ptr2len(p);
n += mb_ptr2len(p + n);
c = mb_ptr2char(p + n);
tl = mb_ptr2len(p + n);
mch_memmove(p + tl, p, n);
mb_char2bytes(c, p);
}
else
{
c = p[2];
p[2] = p[1];
p[1] = *p;
*p = c;
}
// Rotate three bytes right: "123" -> "312". We change "fword"
// here, it's changed back afterwards at STATE_UNROT3R.
if (TRY_DEEPER(su, stack, depth, SCORE_SWAP3))
{
go_deeper(stack, depth, SCORE_SWAP3);
#ifdef DEBUG_TRIEWALK
p = fword + sp->ts_fidx;
sprintf(changename[depth], "%.*s-%s: rotate right %c%c%c",
sp->ts_twordlen, tword, fword + sp->ts_fidx,
p[0], p[1], p[2]);
#endif
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_UNROT3R;
++depth;
p = fword + sp->ts_fidx;
if (has_mbyte)
{
n = MB_CPTR2LEN(p);
n += MB_CPTR2LEN(p + n);
c = mb_ptr2char(p + n);
tl = MB_CPTR2LEN(p + n);
mch_memmove(p + tl, p, n);
mb_char2bytes(c, p);
stack[depth].ts_fidxtry = sp->ts_fidx + n + tl;
}
else
{
c = p[2];
p[2] = p[1];
p[1] = *p;
*p = c;
stack[depth].ts_fidxtry = sp->ts_fidx + 3;
}
}
else
{
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_REP_INI;
}
break;
case STATE_UNROT3R:
// Undo ROT3R: "312" -> "123"
p = fword + sp->ts_fidx;
if (has_mbyte)
{
c = mb_ptr2char(p);
tl = mb_ptr2len(p);
n = mb_ptr2len(p + tl);
n += mb_ptr2len(p + tl + n);
mch_memmove(p, p + tl, n);
mb_char2bytes(c, p + n);
}
else
{
c = *p;
*p = p[1];
p[1] = p[2];
p[2] = c;
}
// FALLTHROUGH
case STATE_REP_INI:
// Check if matching with REP items from the .aff file would work.
// Quickly skip if:
// - there are no REP items and we are not in the soundfold trie
// - the score is going to be too high anyway
// - already applied a REP item or swapped here
if ((lp->lp_replang == NULL && !soundfold)
|| sp->ts_score + SCORE_REP >= su->su_maxscore
|| sp->ts_fidx < sp->ts_fidxtry)
{
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_FINAL;
break;
}
// Use the first byte to quickly find the first entry that may
// match. If the index is -1 there is none.
if (soundfold)
sp->ts_curi = slang->sl_repsal_first[fword[sp->ts_fidx]];
else
sp->ts_curi = lp->lp_replang->sl_rep_first[fword[sp->ts_fidx]];
if (sp->ts_curi < 0)
{
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_FINAL;
break;
}
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_REP;
// FALLTHROUGH
case STATE_REP:
// Try matching with REP items from the .aff file. For each match
// replace the characters and check if the resulting word is
// valid.
p = fword + sp->ts_fidx;
if (soundfold)
gap = &slang->sl_repsal;
else
gap = &lp->lp_replang->sl_rep;
while (sp->ts_curi < gap->ga_len)
{
ftp = (fromto_T *)gap->ga_data + sp->ts_curi++;
if (*ftp->ft_from != *p)
{
// past possible matching entries
sp->ts_curi = gap->ga_len;
break;
}
if (STRNCMP(ftp->ft_from, p, STRLEN(ftp->ft_from)) == 0
&& TRY_DEEPER(su, stack, depth, SCORE_REP))
{
go_deeper(stack, depth, SCORE_REP);
#ifdef DEBUG_TRIEWALK
sprintf(changename[depth], "%.*s-%s: replace %s with %s",
sp->ts_twordlen, tword, fword + sp->ts_fidx,
ftp->ft_from, ftp->ft_to);
#endif
// Need to undo this afterwards.
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_REP_UNDO;
// Change the "from" to the "to" string.
++depth;
fl = (int)STRLEN(ftp->ft_from);
tl = (int)STRLEN(ftp->ft_to);
if (fl != tl)
{
STRMOVE(p + tl, p + fl);
repextra += tl - fl;
}
mch_memmove(p, ftp->ft_to, tl);
stack[depth].ts_fidxtry = sp->ts_fidx + tl;
stack[depth].ts_tcharlen = 0;
break;
}
}
if (sp->ts_curi >= gap->ga_len && sp->ts_state == STATE_REP)
{
// No (more) matches.
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_FINAL;
}
break;
case STATE_REP_UNDO:
// Undo a REP replacement and continue with the next one.
if (soundfold)
gap = &slang->sl_repsal;
else
gap = &lp->lp_replang->sl_rep;
ftp = (fromto_T *)gap->ga_data + sp->ts_curi - 1;
fl = (int)STRLEN(ftp->ft_from);
tl = (int)STRLEN(ftp->ft_to);
p = fword + sp->ts_fidx;
if (fl != tl)
{
STRMOVE(p + fl, p + tl);
repextra -= tl - fl;
}
mch_memmove(p, ftp->ft_from, fl);
PROF_STORE(sp->ts_state)
sp->ts_state = STATE_REP;
break;
default:
// Did all possible states at this level, go up one level.
--depth;
if (depth >= 0 && stack[depth].ts_prefixdepth == PFD_PREFIXTREE)
{
// Continue in or go back to the prefix tree.
byts = pbyts;
idxs = pidxs;
}
// Don't check for CTRL-C too often, it takes time.
if (--breakcheckcount == 0)
{
ui_breakcheck();
breakcheckcount = 1000;
}
}
}
} | 6024 | True | 1 |
CVE-2021-3968 | False | False | False | True | AV:N/AC:M/Au:S/C:C/I:C/A:C | NETWORK | MEDIUM | SINGLE | COMPLETE | COMPLETE | COMPLETE | 8.5 | CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:H | NETWORK | LOW | LOW | REQUIRED | UNCHANGED | HIGH | HIGH | HIGH | 8.0 | HIGH | 2.1 | 5.9 | False | [{'url': 'https://huntr.dev/bounties/00d62924-a7b4-4a61-ba29-acab2eaa1528', 'name': 'https://huntr.dev/bounties/00d62924-a7b4-4a61-ba29-acab2eaa1528', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Issue Tracking', 'Patch', 'Third Party Advisory']}, {'url': 'https://github.com/vim/vim/commit/a062006b9de0b2947ab5fb376c6e67ef92a8cd69', 'name': 'https://github.com/vim/vim/commit/a062006b9de0b2947ab5fb376c6e67ef92a8cd69', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/IH2LS2DXBTYOCWGAKFMBF3HTWWXPBEFL/', 'name': 'FEDORA-2021-5cd9df120e', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/FNXY7T5OORA7UJIMGSJBGHFMU6UZWS6P/', 'name': 'FEDORA-2021-b0ac29efb1', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2022/01/15/1', 'name': "[oss-security] 20220114 Re: 3 new CVE's in vim", 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-122'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionStartIncluding': '8.2.3430', 'versionEndExcluding': '8.2.3610', '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': []}]}] | [{'lang': 'en', 'value': 'vim is vulnerable to Heap-based Buffer Overflow'}] | 2022-08-26T17:30Z | 2021-11-19T12:15Z | Heap-based Buffer Overflow | A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc(). | https://cwe.mitre.org/data/definitions/122.html | 0 | Bram Moolenaar | 2021-11-17 16:52:40+00:00 | patch 8.2.3610: crash when ModeChanged triggered too early
Problem: Crash when ModeChanged triggered too early.
Solution: Trigger ModeChanged after setting VIsual. | a062006b9de0b2947ab5fb376c6e67ef92a8cd69 | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | n_start_visual_mode | n_start_visual_mode( int c) | ['c'] | n_start_visual_mode(int c)
{
#ifdef FEAT_CONCEAL
int cursor_line_was_concealed = curwin->w_p_cole > 0
&& conceal_cursor_line(curwin);
#endif
VIsual_mode = c;
VIsual_active = TRUE;
VIsual_reselect = TRUE;
trigger_modechanged();
// Corner case: the 0 position in a tab may change when going into
// virtualedit. Recalculate curwin->w_cursor to avoid bad highlighting.
if (c == Ctrl_V && (get_ve_flags() & VE_BLOCK) && gchar_cursor() == TAB)
{
validate_virtcol();
coladvance(curwin->w_virtcol);
}
VIsual = curwin->w_cursor;
#ifdef FEAT_FOLDING
foldAdjustVisual();
#endif
setmouse();
#ifdef FEAT_CONCEAL
// Check if redraw is needed after changing the state.
conceal_check_cursor_line(cursor_line_was_concealed);
#endif
if (p_smd && msg_silent == 0)
redraw_cmdline = TRUE; // show visual mode later
#ifdef FEAT_CLIPBOARD
// Make sure the clipboard gets updated. Needed because start and
// end may still be the same, and the selection needs to be owned
clip_star.vmode = NUL;
#endif
// Only need to redraw this line, unless still need to redraw an old
// Visual area (when 'lazyredraw' is set).
if (curwin->w_redr_type < INVERTED)
{
curwin->w_old_cursor_lnum = curwin->w_cursor.lnum;
curwin->w_old_visual_lnum = curwin->w_cursor.lnum;
}
} | 137 | True | 1 |
|
CVE-2021-3973 | False | False | False | True | AV:N/AC:M/Au:N/C:C/I:C/A:C | NETWORK | MEDIUM | NONE | COMPLETE | COMPLETE | COMPLETE | 9.3 | 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/vim/vim/commit/615ddd5342b50a6878a907062aa471740bd9a847', 'name': 'https://github.com/vim/vim/commit/615ddd5342b50a6878a907062aa471740bd9a847', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://huntr.dev/bounties/ce6e8609-77c6-4e17-b9fc-a2e5abed052e', 'name': 'https://huntr.dev/bounties/ce6e8609-77c6-4e17-b9fc-a2e5abed052e', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Issue Tracking', 'Patch', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/IH2LS2DXBTYOCWGAKFMBF3HTWWXPBEFL/', 'name': 'FEDORA-2021-5cd9df120e', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/FNXY7T5OORA7UJIMGSJBGHFMU6UZWS6P/', 'name': 'FEDORA-2021-b0ac29efb1', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2022/01/15/1', 'name': "[oss-security] 20220114 Re: 3 new CVE's in vim", 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2022/03/msg00018.html', 'name': '[debian-lts-announce] 20220311 [SECURITY] [DLA 2947-1] vim security update', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-122'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.3611', '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': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:debian:debian_linux:9.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'vim is vulnerable to Heap-based Buffer Overflow'}] | 2022-08-21T07:15Z | 2021-11-19T12:15Z | Heap-based Buffer Overflow | A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc(). | https://cwe.mitre.org/data/definitions/122.html | 0 | Bram Moolenaar | 2021-11-17 18:00:31+00:00 | patch 8.2.3611: crash when using CTRL-W f without finding a file name
Problem: Crash when using CTRL-W f without finding a file name.
Solution: Bail out when the file name length is zero. | 615ddd5342b50a6878a907062aa471740bd9a847 | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | get_visual_text | get_visual_text( cmdarg_T * cap , char_u ** pp , int * lenp) | ['cap', 'pp', 'lenp'] | get_visual_text(
cmdarg_T *cap,
char_u **pp, // return: start of selected text
int *lenp) // return: length of selected text
{
if (VIsual_mode != 'V')
unadjust_for_sel();
if (VIsual.lnum != curwin->w_cursor.lnum)
{
if (cap != NULL)
clearopbeep(cap->oap);
return FAIL;
}
if (VIsual_mode == 'V')
{
*pp = ml_get_curline();
*lenp = (int)STRLEN(*pp);
}
else
{
if (LT_POS(curwin->w_cursor, VIsual))
{
*pp = ml_get_pos(&curwin->w_cursor);
*lenp = VIsual.col - curwin->w_cursor.col + 1;
}
else
{
*pp = ml_get_pos(&VIsual);
*lenp = curwin->w_cursor.col - VIsual.col + 1;
}
if (has_mbyte)
// Correct the length to include the whole last character.
*lenp += (*mb_ptr2len)(*pp + (*lenp - 1)) - 1;
}
reset_VIsual_and_resel();
return OK;
} | 184 | True | 1 |
|
CVE-2021-3984 | 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/vim/vim/commit/2de9b7c7c8791da8853a9a7ca9c467867465b655', 'name': 'https://github.com/vim/vim/commit/2de9b7c7c8791da8853a9a7ca9c467867465b655', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://huntr.dev/bounties/b114b5a2-18e2-49f0-b350-15994d71426a', 'name': 'https://huntr.dev/bounties/b114b5a2-18e2-49f0-b350-15994d71426a', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Patch', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/FNXY7T5OORA7UJIMGSJBGHFMU6UZWS6P/', 'name': 'FEDORA-2021-b0ac29efb1', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2022/01/15/1', 'name': "[oss-security] 20220114 Re: 3 new CVE's in vim", 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2022/03/msg00018.html', 'name': '[debian-lts-announce] 20220311 [SECURITY] [DLA 2947-1] vim security update', 'refsource': 'MLIST', 'tags': ['Mitigation', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-122'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.3625', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:fedoraproject:fedora:34:*:*:*:*:*:*:*', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:debian:debian_linux:9.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'vim is vulnerable to Heap-based Buffer Overflow'}] | 2022-08-26T17:48Z | 2021-12-01T11:15Z | Heap-based Buffer Overflow | A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc(). | https://cwe.mitre.org/data/definitions/122.html | 0 | Bram Moolenaar | 2021-11-19 19:41:13+00:00 | patch 8.2.3625: illegal memory access when C-indenting
Problem: Illegal memory access when C-indenting.
Solution: Also set the cursor column. | 2de9b7c7c8791da8853a9a7ca9c467867465b655 | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | find_start_brace | find_start_brace( void) | ['void'] | find_start_brace(void) // XXX
{
pos_T cursor_save;
pos_T *trypos;
pos_T *pos;
static pos_T pos_copy;
cursor_save = curwin->w_cursor;
while ((trypos = findmatchlimit(NULL, '{', FM_BLOCKSTOP, 0)) != NULL)
{
pos_copy = *trypos; // copy pos_T, next findmatch will change it
trypos = &pos_copy;
curwin->w_cursor = *trypos;
pos = NULL;
// ignore the { if it's in a // or / * * / comment
if ((colnr_T)cin_skip2pos(trypos) == trypos->col
&& (pos = ind_find_start_CORS(NULL)) == NULL) // XXX
break;
if (pos != NULL)
curwin->w_cursor.lnum = pos->lnum;
}
curwin->w_cursor = cursor_save;
return trypos;
} | 121 | True | 1 |
|
CVE-2021-4019 | 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/vim/vim/commit/bd228fd097b41a798f90944b5d1245eddd484142', 'name': 'https://github.com/vim/vim/commit/bd228fd097b41a798f90944b5d1245eddd484142', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://huntr.dev/bounties/d8798584-a6c9-4619-b18f-001b9a6fca92', 'name': 'https://huntr.dev/bounties/d8798584-a6c9-4619-b18f-001b9a6fca92', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/DRPAI5JVZLI7WHWSBR6NWAPBQAYUQREW/', 'name': 'FEDORA-2021-469afb66c9', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/FNXY7T5OORA7UJIMGSJBGHFMU6UZWS6P/', 'name': 'FEDORA-2021-b0ac29efb1', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2022/01/15/1', 'name': "[oss-security] 20220114 Re: 3 new CVE's in vim", 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2022/03/msg00018.html', 'name': '[debian-lts-announce] 20220311 [SECURITY] [DLA 2947-1] vim security update', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-122'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.3669', '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': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:debian:debian_linux:9.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'vim is vulnerable to Heap-based Buffer Overflow'}] | 2022-08-26T17:48Z | 2021-12-01T10:15Z | Heap-based Buffer Overflow | A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc(). | https://cwe.mitre.org/data/definitions/122.html | 0 | Bram Moolenaar | 2021-11-25 10:50:12+00:00 | patch 8.2.3669: buffer overflow with long help argument
Problem: Buffer overflow with long help argument.
Solution: Use snprintf(). | bd228fd097b41a798f90944b5d1245eddd484142 | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | find_help_tags | find_help_tags( char_u * arg , int * num_matches , char_u ** * matches , int keep_lang) | ['arg', 'num_matches', 'matches', 'keep_lang'] | find_help_tags(
char_u *arg,
int *num_matches,
char_u ***matches,
int keep_lang)
{
char_u *s, *d;
int i;
// Specific tags that either have a specific replacement or won't go
// through the generic rules.
static char *(except_tbl[][2]) = {
{"*", "star"},
{"g*", "gstar"},
{"[*", "[star"},
{"]*", "]star"},
{":*", ":star"},
{"/*", "/star"},
{"/\\*", "/\\\\star"},
{"\"*", "quotestar"},
{"**", "starstar"},
{"cpo-*", "cpo-star"},
{"/\\(\\)", "/\\\\(\\\\)"},
{"/\\%(\\)", "/\\\\%(\\\\)"},
{"?", "?"},
{"??", "??"},
{":?", ":?"},
{"?<CR>", "?<CR>"},
{"g?", "g?"},
{"g?g?", "g?g?"},
{"g??", "g??"},
{"-?", "-?"},
{"q?", "q?"},
{"v_g?", "v_g?"},
{"/\\?", "/\\\\?"},
{"/\\z(\\)", "/\\\\z(\\\\)"},
{"\\=", "\\\\="},
{":s\\=", ":s\\\\="},
{"[count]", "\\[count]"},
{"[quotex]", "\\[quotex]"},
{"[range]", "\\[range]"},
{":[range]", ":\\[range]"},
{"[pattern]", "\\[pattern]"},
{"\\|", "\\\\bar"},
{"\\%$", "/\\\\%\\$"},
{"s/\\~", "s/\\\\\\~"},
{"s/\\U", "s/\\\\U"},
{"s/\\L", "s/\\\\L"},
{"s/\\1", "s/\\\\1"},
{"s/\\2", "s/\\\\2"},
{"s/\\3", "s/\\\\3"},
{"s/\\9", "s/\\\\9"},
{NULL, NULL}
};
static char *(expr_table[]) = {"!=?", "!~?", "<=?", "<?", "==?", "=~?",
">=?", ">?", "is?", "isnot?"};
int flags;
d = IObuff; // assume IObuff is long enough!
d[0] = NUL;
if (STRNICMP(arg, "expr-", 5) == 0)
{
// When the string starting with "expr-" and containing '?' and matches
// the table, it is taken literally (but ~ is escaped). Otherwise '?'
// is recognized as a wildcard.
for (i = (int)ARRAY_LENGTH(expr_table); --i >= 0; )
if (STRCMP(arg + 5, expr_table[i]) == 0)
{
int si = 0, di = 0;
for (;;)
{
if (arg[si] == '~')
d[di++] = '\\';
d[di++] = arg[si];
if (arg[si] == NUL)
break;
++si;
}
break;
}
}
else
{
// Recognize a few exceptions to the rule. Some strings that contain
// '*'are changed to "star", otherwise '*' is recognized as a wildcard.
for (i = 0; except_tbl[i][0] != NULL; ++i)
if (STRCMP(arg, except_tbl[i][0]) == 0)
{
STRCPY(d, except_tbl[i][1]);
break;
}
}
if (d[0] == NUL) // no match in table
{
// Replace "\S" with "/\\S", etc. Otherwise every tag is matched.
// Also replace "\%^" and "\%(", they match every tag too.
// Also "\zs", "\z1", etc.
// Also "\@<", "\@=", "\@<=", etc.
// And also "\_$" and "\_^".
if (arg[0] == '\\'
&& ((arg[1] != NUL && arg[2] == NUL)
|| (vim_strchr((char_u *)"%_z@", arg[1]) != NULL
&& arg[2] != NUL)))
{
STRCPY(d, "/\\\\");
STRCPY(d + 3, arg + 1);
// Check for "/\\_$", should be "/\\_\$"
if (d[3] == '_' && d[4] == '$')
STRCPY(d + 4, "\\$");
}
else
{
// Replace:
// "[:...:]" with "\[:...:]"
// "[++...]" with "\[++...]"
// "\{" with "\\{" -- matching "} \}"
if ((arg[0] == '[' && (arg[1] == ':'
|| (arg[1] == '+' && arg[2] == '+')))
|| (arg[0] == '\\' && arg[1] == '{'))
*d++ = '\\';
// If tag starts with "('", skip the "(". Fixes CTRL-] on ('option'.
if (*arg == '(' && arg[1] == '\'')
arg++;
for (s = arg; *s; ++s)
{
// Replace "|" with "bar" and '"' with "quote" to match the name of
// the tags for these commands.
// Replace "*" with ".*" and "?" with "." to match command line
// completion.
// Insert a backslash before '~', '$' and '.' to avoid their
// special meaning.
if (d - IObuff > IOSIZE - 10) // getting too long!?
break;
switch (*s)
{
case '|': STRCPY(d, "bar");
d += 3;
continue;
case '"': STRCPY(d, "quote");
d += 5;
continue;
case '*': *d++ = '.';
break;
case '?': *d++ = '.';
continue;
case '$':
case '.':
case '~': *d++ = '\\';
break;
}
// Replace "^x" by "CTRL-X". Don't do this for "^_" to make
// ":help i_^_CTRL-D" work.
// Insert '-' before and after "CTRL-X" when applicable.
if (*s < ' ' || (*s == '^' && s[1] && (ASCII_ISALPHA(s[1])
|| vim_strchr((char_u *)"?@[\\]^", s[1]) != NULL)))
{
if (d > IObuff && d[-1] != '_' && d[-1] != '\\')
*d++ = '_'; // prepend a '_' to make x_CTRL-x
STRCPY(d, "CTRL-");
d += 5;
if (*s < ' ')
{
#ifdef EBCDIC
*d++ = CtrlChar(*s);
#else
*d++ = *s + '@';
#endif
if (d[-1] == '\\')
*d++ = '\\'; // double a backslash
}
else
*d++ = *++s;
if (s[1] != NUL && s[1] != '_')
*d++ = '_'; // append a '_'
continue;
}
else if (*s == '^') // "^" or "CTRL-^" or "^_"
*d++ = '\\';
// Insert a backslash before a backslash after a slash, for search
// pattern tags: "/\|" --> "/\\|".
else if (s[0] == '\\' && s[1] != '\\'
&& *arg == '/' && s == arg + 1)
*d++ = '\\';
// "CTRL-\_" -> "CTRL-\\_" to avoid the special meaning of "\_" in
// "CTRL-\_CTRL-N"
if (STRNICMP(s, "CTRL-\\_", 7) == 0)
{
STRCPY(d, "CTRL-\\\\");
d += 7;
s += 6;
}
*d++ = *s;
// If tag contains "({" or "([", tag terminates at the "(".
// This is for help on functions, e.g.: abs({expr}).
if (*s == '(' && (s[1] == '{' || s[1] =='['))
break;
// If tag starts with ', toss everything after a second '. Fixes
// CTRL-] on 'option'. (would include the trailing '.').
if (*s == '\'' && s > arg && *arg == '\'')
break;
// Also '{' and '}'.
if (*s == '}' && s > arg && *arg == '{')
break;
}
*d = NUL;
if (*IObuff == '`')
{
if (d > IObuff + 2 && d[-1] == '`')
{
// remove the backticks from `command`
mch_memmove(IObuff, IObuff + 1, STRLEN(IObuff));
d[-2] = NUL;
}
else if (d > IObuff + 3 && d[-2] == '`' && d[-1] == ',')
{
// remove the backticks and comma from `command`,
mch_memmove(IObuff, IObuff + 1, STRLEN(IObuff));
d[-3] = NUL;
}
else if (d > IObuff + 4 && d[-3] == '`'
&& d[-2] == '\\' && d[-1] == '.')
{
// remove the backticks and dot from `command`\.
mch_memmove(IObuff, IObuff + 1, STRLEN(IObuff));
d[-4] = NUL;
}
}
}
}
*matches = (char_u **)"";
*num_matches = 0;
flags = TAG_HELP | TAG_REGEXP | TAG_NAMES | TAG_VERBOSE | TAG_NO_TAGFUNC;
if (keep_lang)
flags |= TAG_KEEP_LANG;
if (find_tags(IObuff, num_matches, matches, flags, (int)MAXCOL, NULL) == OK
&& *num_matches > 0)
{
// Sort the matches found on the heuristic number that is after the
// tag name.
qsort((void *)*matches, (size_t)*num_matches,
sizeof(char_u *), help_compare);
// Delete more than TAG_MANY to reduce the size of the listing.
while (*num_matches > TAG_MANY)
vim_free((*matches)[--*num_matches]);
}
return OK;
} | 1371 | True | 1 |
|
CVE-2021-4136 | 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://huntr.dev/bounties/5c6b93c1-2d27-4e98-a931-147877b8c938', 'name': 'https://huntr.dev/bounties/5c6b93c1-2d27-4e98-a931-147877b8c938', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Patch', 'Third Party Advisory']}, {'url': 'https://github.com/vim/vim/commit/605ec91e5a7330d61be313637e495fa02a6dc264', 'name': 'https://github.com/vim/vim/commit/605ec91e5a7330d61be313637e495fa02a6dc264', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/2EY2VFBU3YGGWI5BW4XKT3F37MYGEQUD/', 'name': 'FEDORA-2022-a3d70b50f0', 'refsource': 'FEDORA', 'tags': ['Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2022/01/15/1', 'name': "[oss-security] 20220114 Re: 3 new CVE's in vim", 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/3FH2J57GDA2WMBS6J56F6QQRA6BXQQFZ/', 'name': 'FEDORA-2022-48b86d586f', 'refsource': 'FEDORA', 'tags': ['Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213183', 'name': 'https://support.apple.com/kb/HT213183', 'refsource': 'CONFIRM', 'tags': ['Release Notes', 'Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Mar/29', 'name': '20220314 APPLE-SA-2022-03-14-4 macOS Monterey 12.3', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213256', 'name': 'https://support.apple.com/kb/HT213256', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/May/35', 'name': '20220516 APPLE-SA-2022-05-16-3 macOS Big Sur 11.6.6', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213343', 'name': 'https://support.apple.com/kb/HT213343', 'refsource': 'CONFIRM', 'tags': []}, {'url': 'http://seclists.org/fulldisclosure/2022/Jul/14', 'name': '20220721 APPLE-SA-2022-07-20-4 Security Update 2022-005 Catalina', 'refsource': 'FULLDISC', 'tags': []}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-122'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.3847', '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': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionStartIncluding': '12.0', 'versionEndExcluding': '12.3', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionStartIncluding': '11.0', 'versionEndExcluding': '11.6.6', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'vim is vulnerable to Heap-based Buffer Overflow'}] | 2022-08-21T08:15Z | 2021-12-19T17:15Z | Heap-based Buffer Overflow | A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc(). | https://cwe.mitre.org/data/definitions/122.html | 0 | Bram Moolenaar | 2021-12-18 16:54:31+00:00 | patch 8.2.3847: illegal memory access when using a lambda with an error
Problem: Illegal memory access when using a lambda with an error.
Solution: Avoid skipping over the NUL after a string. | 605ec91e5a7330d61be313637e495fa02a6dc264 | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | eval_lambda | eval_lambda( char_u ** arg , typval_T * rettv , evalarg_T * evalarg , int verbose) | ['arg', 'rettv', 'evalarg', 'verbose'] | eval_lambda(
char_u **arg,
typval_T *rettv,
evalarg_T *evalarg,
int verbose) // give error messages
{
int evaluate = evalarg != NULL
&& (evalarg->eval_flags & EVAL_EVALUATE);
typval_T base = *rettv;
int ret;
rettv->v_type = VAR_UNKNOWN;
if (**arg == '{')
{
// ->{lambda}()
ret = get_lambda_tv(arg, rettv, FALSE, evalarg);
}
else
{
// ->(lambda)()
++*arg;
ret = eval1(arg, rettv, evalarg);
*arg = skipwhite_and_linebreak(*arg, evalarg);
if (**arg != ')')
{
emsg(_(e_missing_closing_paren));
ret = FAIL;
}
++*arg;
}
if (ret != OK)
return FAIL;
else if (**arg != '(')
{
if (verbose)
{
if (*skipwhite(*arg) == '(')
emsg(_(e_nowhitespace));
else
semsg(_(e_missing_parenthesis_str), "lambda");
}
clear_tv(rettv);
ret = FAIL;
}
else
ret = call_func_rettv(arg, evalarg, rettv, evaluate, NULL, &base);
// Clear the funcref afterwards, so that deleting it while
// evaluating the arguments is possible (see test55).
if (evaluate)
clear_tv(&base);
return ret;
} | 221 | True | 1 |
|
CVE-2021-4173 | 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://huntr.dev/bounties/a1b236b9-89fb-4ccf-9689-ba11b471e766', 'name': 'https://huntr.dev/bounties/a1b236b9-89fb-4ccf-9689-ba11b471e766', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/vim/vim/commit/9c23f9bb5fe435b28245ba8ac65aa0ca6b902c04', 'name': 'https://github.com/vim/vim/commit/9c23f9bb5fe435b28245ba8ac65aa0ca6b902c04', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/2EY2VFBU3YGGWI5BW4XKT3F37MYGEQUD/', 'name': 'FEDORA-2022-a3d70b50f0', 'refsource': 'FEDORA', 'tags': ['Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2022/01/15/1', 'name': "[oss-security] 20220114 Re: 3 new CVE's in vim", 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/3FH2J57GDA2WMBS6J56F6QQRA6BXQQFZ/', 'name': 'FEDORA-2022-48b86d586f', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213183', 'name': 'https://support.apple.com/kb/HT213183', 'refsource': 'CONFIRM', 'tags': ['Release Notes', 'Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Mar/29', 'name': '20220314 APPLE-SA-2022-03-14-4 macOS Monterey 12.3', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213256', 'name': 'https://support.apple.com/kb/HT213256', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/May/35', 'name': '20220516 APPLE-SA-2022-05-16-3 macOS Big Sur 11.6.6', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213343', 'name': 'https://support.apple.com/kb/HT213343', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Jul/14', 'name': '20220721 APPLE-SA-2022-07-20-4 Security Update 2022-005 Catalina', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-416'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.3902', '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': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-005:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionEndExcluding': '12.3', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2022-001:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2022-002:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2020-001:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-001:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-002:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-003:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-004:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-006:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-007:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-008:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionStartIncluding': '11.0', 'versionEndExcluding': '11.6.6', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2022-003:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2022-004:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'vim is vulnerable to Use After Free'}] | 2022-08-26T17:48Z | 2021-12-27T13: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 | Bram Moolenaar | 2021-12-26 14:23:22+00:00 | patch 8.2.3902: Vim9: double free with nested :def function
Problem: Vim9: double free with nested :def function.
Solution: Pass "line_to_free" from compile_def_function() and make sure
cmdlinep is valid. | 9c23f9bb5fe435b28245ba8ac65aa0ca6b902c04 | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | define_function | define_function( exarg_T * eap , char_u * name_arg) | ['eap', 'name_arg'] | define_function(exarg_T *eap, char_u *name_arg)
{
char_u *line_to_free = NULL;
int j;
int c;
int saved_did_emsg;
char_u *name = name_arg;
int is_global = FALSE;
char_u *p;
char_u *arg;
char_u *whitep;
char_u *line_arg = NULL;
garray_T newargs;
garray_T argtypes;
garray_T default_args;
garray_T newlines;
int varargs = FALSE;
int flags = 0;
char_u *ret_type = NULL;
ufunc_T *fp = NULL;
int fp_allocated = FALSE;
int free_fp = FALSE;
int overwrite = FALSE;
dictitem_T *v;
funcdict_T fudi;
static int func_nr = 0; // number for nameless function
int paren;
hashitem_T *hi;
linenr_T sourcing_lnum_top;
int vim9script = in_vim9script();
imported_T *import = NULL;
/*
* ":function" without argument: list functions.
*/
if (ends_excmd2(eap->cmd, eap->arg))
{
if (!eap->skip)
list_functions(NULL);
set_nextcmd(eap, eap->arg);
return NULL;
}
/*
* ":function /pat": list functions matching pattern.
*/
if (*eap->arg == '/')
{
p = skip_regexp(eap->arg + 1, '/', TRUE);
if (!eap->skip)
{
regmatch_T regmatch;
c = *p;
*p = NUL;
regmatch.regprog = vim_regcomp(eap->arg + 1, RE_MAGIC);
*p = c;
if (regmatch.regprog != NULL)
{
regmatch.rm_ic = p_ic;
list_functions(®match);
vim_regfree(regmatch.regprog);
}
}
if (*p == '/')
++p;
set_nextcmd(eap, p);
return NULL;
}
ga_init(&newargs);
ga_init(&argtypes);
ga_init(&default_args);
/*
* Get the function name. There are these situations:
* func normal function name
* "name" == func, "fudi.fd_dict" == NULL
* dict.func new dictionary entry
* "name" == NULL, "fudi.fd_dict" set,
* "fudi.fd_di" == NULL, "fudi.fd_newkey" == func
* dict.func existing dict entry with a Funcref
* "name" == func, "fudi.fd_dict" set,
* "fudi.fd_di" set, "fudi.fd_newkey" == NULL
* dict.func existing dict entry that's not a Funcref
* "name" == NULL, "fudi.fd_dict" set,
* "fudi.fd_di" set, "fudi.fd_newkey" == NULL
* s:func script-local function name
* g:func global function name, same as "func"
*/
p = eap->arg;
if (name_arg != NULL)
{
// nested function, argument is (args).
paren = TRUE;
CLEAR_FIELD(fudi);
}
else
{
name = save_function_name(&p, &is_global, eap->skip,
TFN_NO_AUTOLOAD, &fudi);
paren = (vim_strchr(p, '(') != NULL);
if (name == NULL && (fudi.fd_dict == NULL || !paren) && !eap->skip)
{
/*
* Return on an invalid expression in braces, unless the expression
* evaluation has been cancelled due to an aborting error, an
* interrupt, or an exception.
*/
if (!aborting())
{
if (!eap->skip && fudi.fd_newkey != NULL)
semsg(_(e_dictkey), fudi.fd_newkey);
vim_free(fudi.fd_newkey);
return NULL;
}
else
eap->skip = TRUE;
}
}
// An error in a function call during evaluation of an expression in magic
// braces should not cause the function not to be defined.
saved_did_emsg = did_emsg;
did_emsg = FALSE;
/*
* ":function func" with only function name: list function.
*/
if (!paren)
{
if (!ends_excmd(*skipwhite(p)))
{
semsg(_(e_trailing_arg), p);
goto ret_free;
}
set_nextcmd(eap, p);
if (eap->nextcmd != NULL)
*p = NUL;
if (!eap->skip && !got_int)
{
fp = find_func(name, is_global, NULL);
if (fp == NULL && ASCII_ISUPPER(*eap->arg))
{
char_u *up = untrans_function_name(name);
// With Vim9 script the name was made script-local, if not
// found try again with the original name.
if (up != NULL)
fp = find_func(up, FALSE, NULL);
}
if (fp != NULL)
{
list_func_head(fp, TRUE);
for (j = 0; j < fp->uf_lines.ga_len && !got_int; ++j)
{
if (FUNCLINE(fp, j) == NULL)
continue;
msg_putchar('\n');
msg_outnum((long)(j + 1));
if (j < 9)
msg_putchar(' ');
if (j < 99)
msg_putchar(' ');
msg_prt_line(FUNCLINE(fp, j), FALSE);
out_flush(); // show a line at a time
ui_breakcheck();
}
if (!got_int)
{
msg_putchar('\n');
if (fp->uf_def_status != UF_NOT_COMPILED)
msg_puts(" enddef");
else
msg_puts(" endfunction");
}
}
else
emsg_funcname(N_("E123: Undefined function: %s"), eap->arg);
}
goto ret_free;
}
/*
* ":function name(arg1, arg2)" Define function.
*/
p = skipwhite(p);
if (*p != '(')
{
if (!eap->skip)
{
semsg(_("E124: Missing '(': %s"), eap->arg);
goto ret_free;
}
// attempt to continue by skipping some text
if (vim_strchr(p, '(') != NULL)
p = vim_strchr(p, '(');
}
if ((vim9script || eap->cmdidx == CMD_def) && VIM_ISWHITE(p[-1]))
{
semsg(_(e_no_white_space_allowed_before_str_str), "(", p - 1);
goto ret_free;
}
// In Vim9 script only global functions can be redefined.
if (vim9script && eap->forceit && !is_global)
{
emsg(_(e_nobang));
goto ret_free;
}
ga_init2(&newlines, (int)sizeof(char_u *), 10);
if (!eap->skip && name_arg == NULL)
{
// Check the name of the function. Unless it's a dictionary function
// (that we are overwriting).
if (name != NULL)
arg = name;
else
arg = fudi.fd_newkey;
if (arg != NULL && (fudi.fd_di == NULL
|| (fudi.fd_di->di_tv.v_type != VAR_FUNC
&& fudi.fd_di->di_tv.v_type != VAR_PARTIAL)))
{
char_u *name_base = arg;
int i;
if (*arg == K_SPECIAL)
{
name_base = vim_strchr(arg, '_');
if (name_base == NULL)
name_base = arg + 3;
else
++name_base;
}
for (i = 0; name_base[i] != NUL && (i == 0
? eval_isnamec1(name_base[i])
: eval_isnamec(name_base[i])); ++i)
;
if (name_base[i] != NUL)
emsg_funcname((char *)e_invarg2, arg);
// In Vim9 script a function cannot have the same name as a
// variable.
if (vim9script && *arg == K_SPECIAL
&& eval_variable(name_base, (int)STRLEN(name_base), NULL, NULL,
EVAL_VAR_NOAUTOLOAD + EVAL_VAR_IMPORT
+ EVAL_VAR_NO_FUNC) == OK)
{
semsg(_(e_redefining_script_item_str), name_base);
goto ret_free;
}
}
// Disallow using the g: dict.
if (fudi.fd_dict != NULL && fudi.fd_dict->dv_scope == VAR_DEF_SCOPE)
{
emsg(_("E862: Cannot use g: here"));
goto ret_free;
}
}
// This may get more lines and make the pointers into the first line
// invalid.
++p;
if (get_function_args(&p, ')', &newargs,
eap->cmdidx == CMD_def ? &argtypes : NULL, FALSE,
NULL, &varargs, &default_args, eap->skip,
eap, &line_to_free) == FAIL)
goto errret_2;
whitep = p;
if (eap->cmdidx == CMD_def)
{
// find the return type: :def Func(): type
if (*skipwhite(p) == ':')
{
if (*p != ':')
{
semsg(_(e_no_white_space_allowed_before_colon_str), p);
p = skipwhite(p);
}
else if (!IS_WHITE_OR_NUL(p[1]))
semsg(_(e_white_space_required_after_str_str), ":", p);
ret_type = skipwhite(p + 1);
p = skip_type(ret_type, FALSE);
if (p > ret_type)
{
ret_type = vim_strnsave(ret_type, p - ret_type);
whitep = p;
p = skipwhite(p);
}
else
{
semsg(_(e_expected_type_str), ret_type);
ret_type = NULL;
}
}
p = skipwhite(p);
}
else
// find extra arguments "range", "dict", "abort" and "closure"
for (;;)
{
whitep = p;
p = skipwhite(p);
if (STRNCMP(p, "range", 5) == 0)
{
flags |= FC_RANGE;
p += 5;
}
else if (STRNCMP(p, "dict", 4) == 0)
{
flags |= FC_DICT;
p += 4;
}
else if (STRNCMP(p, "abort", 5) == 0)
{
flags |= FC_ABORT;
p += 5;
}
else if (STRNCMP(p, "closure", 7) == 0)
{
flags |= FC_CLOSURE;
p += 7;
if (current_funccal == NULL)
{
emsg_funcname(N_("E932: Closure function should not be at top level: %s"),
name == NULL ? (char_u *)"" : name);
goto erret;
}
}
else
break;
}
// When there is a line break use what follows for the function body.
// Makes 'exe "func Test()\n...\nendfunc"' work.
if (*p == '\n')
line_arg = p + 1;
else if (*p != NUL
&& !(*p == '"' && (!vim9script || eap->cmdidx == CMD_function)
&& eap->cmdidx != CMD_def)
&& !(VIM_ISWHITE(*whitep) && *p == '#'
&& (vim9script || eap->cmdidx == CMD_def))
&& !eap->skip
&& !did_emsg)
semsg(_(e_trailing_arg), p);
/*
* Read the body of the function, until "}", ":endfunction" or ":enddef" is
* found.
*/
if (KeyTyped)
{
// Check if the function already exists, don't let the user type the
// whole function before telling him it doesn't work! For a script we
// need to skip the body to be able to find what follows.
if (!eap->skip && !eap->forceit)
{
if (fudi.fd_dict != NULL && fudi.fd_newkey == NULL)
emsg(_(e_funcdict));
else if (name != NULL && find_func(name, is_global, NULL) != NULL)
emsg_funcname(e_funcexts, name);
}
if (!eap->skip && did_emsg)
goto erret;
msg_putchar('\n'); // don't overwrite the function name
cmdline_row = msg_row;
}
// Save the starting line number.
sourcing_lnum_top = SOURCING_LNUM;
// Do not define the function when getting the body fails and when
// skipping.
if (get_function_body(eap, &newlines, line_arg, &line_to_free) == FAIL
|| eap->skip)
goto erret;
/*
* If there are no errors, add the function
*/
if (fudi.fd_dict == NULL)
{
hashtab_T *ht;
v = find_var(name, &ht, TRUE);
if (v != NULL && v->di_tv.v_type == VAR_FUNC)
{
emsg_funcname(N_("E707: Function name conflicts with variable: %s"),
name);
goto erret;
}
fp = find_func_even_dead(name, is_global, NULL);
if (vim9script)
{
char_u *uname = untrans_function_name(name);
import = find_imported(uname == NULL ? name : uname, 0, NULL);
}
if (fp != NULL || import != NULL)
{
int dead = fp != NULL && (fp->uf_flags & FC_DEAD);
// Function can be replaced with "function!" and when sourcing the
// same script again, but only once.
// A name that is used by an import can not be overruled.
if (import != NULL
|| (!dead && !eap->forceit
&& (fp->uf_script_ctx.sc_sid != current_sctx.sc_sid
|| fp->uf_script_ctx.sc_seq == current_sctx.sc_seq)))
{
SOURCING_LNUM = sourcing_lnum_top;
if (vim9script)
emsg_funcname(e_name_already_defined_str, name);
else
emsg_funcname(e_funcexts, name);
goto erret;
}
if (fp->uf_calls > 0)
{
emsg_funcname(
N_("E127: Cannot redefine function %s: It is in use"),
name);
goto erret;
}
if (fp->uf_refcount > 1)
{
// This function is referenced somewhere, don't redefine it but
// create a new one.
--fp->uf_refcount;
fp->uf_flags |= FC_REMOVED;
fp = NULL;
overwrite = TRUE;
}
else
{
char_u *exp_name = fp->uf_name_exp;
// redefine existing function, keep the expanded name
VIM_CLEAR(name);
fp->uf_name_exp = NULL;
func_clear_items(fp);
fp->uf_name_exp = exp_name;
fp->uf_flags &= ~FC_DEAD;
#ifdef FEAT_PROFILE
fp->uf_profiling = FALSE;
fp->uf_prof_initialized = FALSE;
#endif
fp->uf_def_status = UF_NOT_COMPILED;
}
}
}
else
{
char numbuf[20];
fp = NULL;
if (fudi.fd_newkey == NULL && !eap->forceit)
{
emsg(_(e_funcdict));
goto erret;
}
if (fudi.fd_di == NULL)
{
// Can't add a function to a locked dictionary
if (value_check_lock(fudi.fd_dict->dv_lock, eap->arg, FALSE))
goto erret;
}
// Can't change an existing function if it is locked
else if (value_check_lock(fudi.fd_di->di_tv.v_lock, eap->arg, FALSE))
goto erret;
// Give the function a sequential number. Can only be used with a
// Funcref!
vim_free(name);
sprintf(numbuf, "%d", ++func_nr);
name = vim_strsave((char_u *)numbuf);
if (name == NULL)
goto erret;
}
if (fp == NULL)
{
if (fudi.fd_dict == NULL && vim_strchr(name, AUTOLOAD_CHAR) != NULL)
{
int slen, plen;
char_u *scriptname;
// Check that the autoload name matches the script name.
j = FAIL;
if (SOURCING_NAME != NULL)
{
scriptname = autoload_name(name);
if (scriptname != NULL)
{
p = vim_strchr(scriptname, '/');
plen = (int)STRLEN(p);
slen = (int)STRLEN(SOURCING_NAME);
if (slen > plen && fnamecmp(p,
SOURCING_NAME + slen - plen) == 0)
j = OK;
vim_free(scriptname);
}
}
if (j == FAIL)
{
linenr_T save_lnum = SOURCING_LNUM;
SOURCING_LNUM = sourcing_lnum_top;
semsg(_("E746: Function name does not match script file name: %s"), name);
SOURCING_LNUM = save_lnum;
goto erret;
}
}
fp = alloc_clear(offsetof(ufunc_T, uf_name) + STRLEN(name) + 1);
if (fp == NULL)
goto erret;
fp_allocated = TRUE;
if (fudi.fd_dict != NULL)
{
if (fudi.fd_di == NULL)
{
// add new dict entry
fudi.fd_di = dictitem_alloc(fudi.fd_newkey);
if (fudi.fd_di == NULL)
{
vim_free(fp);
fp = NULL;
goto erret;
}
if (dict_add(fudi.fd_dict, fudi.fd_di) == FAIL)
{
vim_free(fudi.fd_di);
vim_free(fp);
fp = NULL;
goto erret;
}
}
else
// overwrite existing dict entry
clear_tv(&fudi.fd_di->di_tv);
fudi.fd_di->di_tv.v_type = VAR_FUNC;
fudi.fd_di->di_tv.vval.v_string = vim_strsave(name);
// behave like "dict" was used
flags |= FC_DICT;
}
}
fp->uf_args = newargs;
fp->uf_def_args = default_args;
fp->uf_ret_type = &t_any;
fp->uf_func_type = &t_func_any;
if (eap->cmdidx == CMD_def)
{
int lnum_save = SOURCING_LNUM;
cstack_T *cstack = eap->cstack;
fp->uf_def_status = UF_TO_BE_COMPILED;
// error messages are for the first function line
SOURCING_LNUM = sourcing_lnum_top;
// The function may use script variables from the context.
function_using_block_scopes(fp, cstack);
if (parse_argument_types(fp, &argtypes, varargs) == FAIL)
{
SOURCING_LNUM = lnum_save;
free_fp = fp_allocated;
goto erret;
}
varargs = FALSE;
// parse the return type, if any
if (parse_return_type(fp, ret_type) == FAIL)
{
SOURCING_LNUM = lnum_save;
free_fp = fp_allocated;
goto erret;
}
SOURCING_LNUM = lnum_save;
}
else
fp->uf_def_status = UF_NOT_COMPILED;
if (fp_allocated)
{
// insert the new function in the function list
set_ufunc_name(fp, name);
if (overwrite)
{
hi = hash_find(&func_hashtab, name);
hi->hi_key = UF2HIKEY(fp);
}
else if (hash_add(&func_hashtab, UF2HIKEY(fp)) == FAIL)
{
free_fp = TRUE;
goto erret;
}
fp->uf_refcount = 1;
}
fp->uf_lines = newlines;
newlines.ga_data = NULL;
if ((flags & FC_CLOSURE) != 0)
{
if (register_closure(fp) == FAIL)
goto erret;
}
else
fp->uf_scoped = NULL;
#ifdef FEAT_PROFILE
if (prof_def_func())
func_do_profile(fp);
#endif
fp->uf_varargs = varargs;
if (sandbox)
flags |= FC_SANDBOX;
if (vim9script && !ASCII_ISUPPER(*fp->uf_name))
flags |= FC_VIM9;
fp->uf_flags = flags;
fp->uf_calls = 0;
fp->uf_cleared = FALSE;
fp->uf_script_ctx = current_sctx;
fp->uf_script_ctx_version = current_sctx.sc_version;
fp->uf_script_ctx.sc_lnum += sourcing_lnum_top;
if (is_export)
{
fp->uf_flags |= FC_EXPORT;
// let ex_export() know the export worked.
is_export = FALSE;
}
if (eap->cmdidx == CMD_def)
set_function_type(fp);
else if (fp->uf_script_ctx.sc_version == SCRIPT_VERSION_VIM9)
// :func does not use Vim9 script syntax, even in a Vim9 script file
fp->uf_script_ctx.sc_version = SCRIPT_VERSION_MAX;
goto ret_free;
erret:
ga_clear_strings(&newargs);
ga_clear_strings(&default_args);
if (fp != NULL)
{
ga_init(&fp->uf_args);
ga_init(&fp->uf_def_args);
}
errret_2:
ga_clear_strings(&newlines);
if (fp != NULL)
VIM_CLEAR(fp->uf_arg_types);
if (free_fp)
{
vim_free(fp);
fp = NULL;
}
ret_free:
ga_clear_strings(&argtypes);
vim_free(line_to_free);
vim_free(fudi.fd_newkey);
if (name != name_arg)
vim_free(name);
vim_free(ret_type);
did_emsg |= saved_did_emsg;
return fp;
} | 2908 | True | 1 |
CVE-2021-4173 | 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://huntr.dev/bounties/a1b236b9-89fb-4ccf-9689-ba11b471e766', 'name': 'https://huntr.dev/bounties/a1b236b9-89fb-4ccf-9689-ba11b471e766', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/vim/vim/commit/9c23f9bb5fe435b28245ba8ac65aa0ca6b902c04', 'name': 'https://github.com/vim/vim/commit/9c23f9bb5fe435b28245ba8ac65aa0ca6b902c04', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/2EY2VFBU3YGGWI5BW4XKT3F37MYGEQUD/', 'name': 'FEDORA-2022-a3d70b50f0', 'refsource': 'FEDORA', 'tags': ['Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2022/01/15/1', 'name': "[oss-security] 20220114 Re: 3 new CVE's in vim", 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/3FH2J57GDA2WMBS6J56F6QQRA6BXQQFZ/', 'name': 'FEDORA-2022-48b86d586f', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213183', 'name': 'https://support.apple.com/kb/HT213183', 'refsource': 'CONFIRM', 'tags': ['Release Notes', 'Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Mar/29', 'name': '20220314 APPLE-SA-2022-03-14-4 macOS Monterey 12.3', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213256', 'name': 'https://support.apple.com/kb/HT213256', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/May/35', 'name': '20220516 APPLE-SA-2022-05-16-3 macOS Big Sur 11.6.6', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213343', 'name': 'https://support.apple.com/kb/HT213343', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Jul/14', 'name': '20220721 APPLE-SA-2022-07-20-4 Security Update 2022-005 Catalina', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-416'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.3902', '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': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-005:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionEndExcluding': '12.3', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2022-001:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2022-002:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2020-001:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-001:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-002:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-003:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-004:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-006:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-007:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-008:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionStartIncluding': '11.0', 'versionEndExcluding': '11.6.6', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2022-003:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2022-004:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'vim is vulnerable to Use After Free'}] | 2022-08-26T17:48Z | 2021-12-27T13: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 | Bram Moolenaar | 2021-12-26 14:23:22+00:00 | patch 8.2.3902: Vim9: double free with nested :def function
Problem: Vim9: double free with nested :def function.
Solution: Pass "line_to_free" from compile_def_function() and make sure
cmdlinep is valid. | 9c23f9bb5fe435b28245ba8ac65aa0ca6b902c04 | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | ex_function | ex_function( exarg_T * eap) | ['eap'] | ex_function(exarg_T *eap)
{
(void)define_function(eap, NULL);
} | 18 | True | 1 |
CVE-2021-4173 | 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://huntr.dev/bounties/a1b236b9-89fb-4ccf-9689-ba11b471e766', 'name': 'https://huntr.dev/bounties/a1b236b9-89fb-4ccf-9689-ba11b471e766', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/vim/vim/commit/9c23f9bb5fe435b28245ba8ac65aa0ca6b902c04', 'name': 'https://github.com/vim/vim/commit/9c23f9bb5fe435b28245ba8ac65aa0ca6b902c04', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/2EY2VFBU3YGGWI5BW4XKT3F37MYGEQUD/', 'name': 'FEDORA-2022-a3d70b50f0', 'refsource': 'FEDORA', 'tags': ['Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2022/01/15/1', 'name': "[oss-security] 20220114 Re: 3 new CVE's in vim", 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/3FH2J57GDA2WMBS6J56F6QQRA6BXQQFZ/', 'name': 'FEDORA-2022-48b86d586f', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213183', 'name': 'https://support.apple.com/kb/HT213183', 'refsource': 'CONFIRM', 'tags': ['Release Notes', 'Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Mar/29', 'name': '20220314 APPLE-SA-2022-03-14-4 macOS Monterey 12.3', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213256', 'name': 'https://support.apple.com/kb/HT213256', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/May/35', 'name': '20220516 APPLE-SA-2022-05-16-3 macOS Big Sur 11.6.6', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213343', 'name': 'https://support.apple.com/kb/HT213343', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Jul/14', 'name': '20220721 APPLE-SA-2022-07-20-4 Security Update 2022-005 Catalina', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-416'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.3902', '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': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-005:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionEndExcluding': '12.3', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2022-001:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2022-002:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2020-001:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-001:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-002:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-003:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-004:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-006:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-007:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-008:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionStartIncluding': '11.0', 'versionEndExcluding': '11.6.6', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2022-003:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2022-004:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'vim is vulnerable to Use After Free'}] | 2022-08-26T17:48Z | 2021-12-27T13: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 | Bram Moolenaar | 2021-12-26 14:23:22+00:00 | patch 8.2.3902: Vim9: double free with nested :def function
Problem: Vim9: double free with nested :def function.
Solution: Pass "line_to_free" from compile_def_function() and make sure
cmdlinep is valid. | 9c23f9bb5fe435b28245ba8ac65aa0ca6b902c04 | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | get_function_body | get_function_body( exarg_T * eap , garray_T * newlines , char_u * line_arg_in , char_u ** line_to_free) | ['eap', 'newlines', 'line_arg_in', 'line_to_free'] | get_function_body(
exarg_T *eap,
garray_T *newlines,
char_u *line_arg_in,
char_u **line_to_free)
{
linenr_T sourcing_lnum_top = SOURCING_LNUM;
linenr_T sourcing_lnum_off;
int saved_wait_return = need_wait_return;
char_u *line_arg = line_arg_in;
int vim9_function = eap->cmdidx == CMD_def
|| eap->cmdidx == CMD_block;
#define MAX_FUNC_NESTING 50
char nesting_def[MAX_FUNC_NESTING];
char nesting_inline[MAX_FUNC_NESTING];
int nesting = 0;
getline_opt_T getline_options;
int indent = 2;
char_u *skip_until = NULL;
int ret = FAIL;
int is_heredoc = FALSE;
int heredoc_concat_len = 0;
garray_T heredoc_ga;
char_u *heredoc_trimmed = NULL;
ga_init2(&heredoc_ga, 1, 500);
// Detect having skipped over comment lines to find the return
// type. Add NULL lines to keep the line count correct.
sourcing_lnum_off = get_sourced_lnum(eap->getline, eap->cookie);
if (SOURCING_LNUM < sourcing_lnum_off)
{
sourcing_lnum_off -= SOURCING_LNUM;
if (ga_grow(newlines, sourcing_lnum_off) == FAIL)
goto theend;
while (sourcing_lnum_off-- > 0)
((char_u **)(newlines->ga_data))[newlines->ga_len++] = NULL;
}
nesting_def[0] = vim9_function;
nesting_inline[0] = eap->cmdidx == CMD_block;
getline_options = vim9_function
? GETLINE_CONCAT_CONTBAR : GETLINE_CONCAT_CONT;
for (;;)
{
char_u *theline;
char_u *p;
char_u *arg;
if (KeyTyped)
{
msg_scroll = TRUE;
saved_wait_return = FALSE;
}
need_wait_return = FALSE;
if (line_arg != NULL)
{
// Use eap->arg, split up in parts by line breaks.
theline = line_arg;
p = vim_strchr(theline, '\n');
if (p == NULL)
line_arg += STRLEN(line_arg);
else
{
*p = NUL;
line_arg = p + 1;
}
}
else
{
vim_free(*line_to_free);
if (eap->getline == NULL)
theline = getcmdline(':', 0L, indent, getline_options);
else
theline = eap->getline(':', eap->cookie, indent,
getline_options);
*line_to_free = theline;
}
if (KeyTyped)
lines_left = Rows - 1;
if (theline == NULL)
{
// Use the start of the function for the line number.
SOURCING_LNUM = sourcing_lnum_top;
if (skip_until != NULL)
semsg(_(e_missing_heredoc_end_marker_str), skip_until);
else if (nesting_inline[nesting])
emsg(_(e_missing_end_block));
else if (eap->cmdidx == CMD_def)
emsg(_(e_missing_enddef));
else
emsg(_("E126: Missing :endfunction"));
goto theend;
}
// Detect line continuation: SOURCING_LNUM increased more than one.
sourcing_lnum_off = get_sourced_lnum(eap->getline, eap->cookie);
if (SOURCING_LNUM < sourcing_lnum_off)
sourcing_lnum_off -= SOURCING_LNUM;
else
sourcing_lnum_off = 0;
if (skip_until != NULL)
{
// Don't check for ":endfunc"/":enddef" between
// * ":append" and "."
// * ":python <<EOF" and "EOF"
// * ":let {var-name} =<< [trim] {marker}" and "{marker}"
if (heredoc_trimmed == NULL
|| (is_heredoc && skipwhite(theline) == theline)
|| STRNCMP(theline, heredoc_trimmed,
STRLEN(heredoc_trimmed)) == 0)
{
if (heredoc_trimmed == NULL)
p = theline;
else if (is_heredoc)
p = skipwhite(theline) == theline
? theline : theline + STRLEN(heredoc_trimmed);
else
p = theline + STRLEN(heredoc_trimmed);
if (STRCMP(p, skip_until) == 0)
{
VIM_CLEAR(skip_until);
VIM_CLEAR(heredoc_trimmed);
getline_options = vim9_function
? GETLINE_CONCAT_CONTBAR : GETLINE_CONCAT_CONT;
is_heredoc = FALSE;
if (heredoc_concat_len > 0)
{
// Replace the starting line with all the concatenated
// lines.
ga_concat(&heredoc_ga, theline);
vim_free(((char_u **)(newlines->ga_data))[
heredoc_concat_len - 1]);
((char_u **)(newlines->ga_data))[
heredoc_concat_len - 1] = heredoc_ga.ga_data;
ga_init(&heredoc_ga);
heredoc_concat_len = 0;
theline += STRLEN(theline); // skip the "EOF"
}
}
}
}
else
{
int c;
char_u *end;
// skip ':' and blanks
for (p = theline; VIM_ISWHITE(*p) || *p == ':'; ++p)
;
// Check for "endfunction", "enddef" or "}".
// When a ":" follows it must be a dict key; "enddef: value,"
if (nesting_inline[nesting]
? *p == '}'
: (checkforcmd(&p, nesting_def[nesting]
? "enddef" : "endfunction", 4)
&& *p != ':'))
{
if (nesting-- == 0)
{
char_u *nextcmd = NULL;
if (*p == '|' || *p == '}')
nextcmd = p + 1;
else if (line_arg != NULL && *skipwhite(line_arg) != NUL)
nextcmd = line_arg;
else if (*p != NUL && *p != (vim9_function ? '#' : '"')
&& (vim9_function || p_verbose > 0))
{
SOURCING_LNUM = sourcing_lnum_top
+ newlines->ga_len + 1;
if (eap->cmdidx == CMD_def)
semsg(_(e_text_found_after_enddef_str), p);
else
give_warning2((char_u *)
_("W22: Text found after :endfunction: %s"),
p, TRUE);
}
if (nextcmd != NULL && *skipwhite(nextcmd) != NUL)
{
// Another command follows. If the line came from "eap"
// we can simply point into it, otherwise we need to
// change "eap->cmdlinep".
eap->nextcmd = nextcmd;
if (*line_to_free != NULL)
{
vim_free(*eap->cmdlinep);
*eap->cmdlinep = *line_to_free;
*line_to_free = NULL;
}
}
break;
}
}
// Check for mismatched "endfunc" or "enddef".
// We don't check for "def" inside "func" thus we also can't check
// for "enddef".
// We continue to find the end of the function, although we might
// not find it.
else if (nesting_def[nesting])
{
if (checkforcmd(&p, "endfunction", 4) && *p != ':')
emsg(_(e_mismatched_endfunction));
}
else if (eap->cmdidx == CMD_def && checkforcmd(&p, "enddef", 4))
emsg(_(e_mismatched_enddef));
// Increase indent inside "if", "while", "for" and "try", decrease
// at "end".
if (indent > 2 && (*p == '}' || STRNCMP(p, "end", 3) == 0))
indent -= 2;
else if (STRNCMP(p, "if", 2) == 0
|| STRNCMP(p, "wh", 2) == 0
|| STRNCMP(p, "for", 3) == 0
|| STRNCMP(p, "try", 3) == 0)
indent += 2;
// Check for defining a function inside this function.
// Only recognize "def" inside "def", not inside "function",
// For backwards compatibility, see Test_function_python().
c = *p;
if (is_function_cmd(&p)
|| (eap->cmdidx == CMD_def && checkforcmd(&p, "def", 3)))
{
if (*p == '!')
p = skipwhite(p + 1);
p += eval_fname_script(p);
vim_free(trans_function_name(&p, NULL, TRUE, 0, NULL,
NULL, NULL));
if (*skipwhite(p) == '(')
{
if (nesting == MAX_FUNC_NESTING - 1)
emsg(_(e_function_nesting_too_deep));
else
{
++nesting;
nesting_def[nesting] = (c == 'd');
nesting_inline[nesting] = FALSE;
indent += 2;
}
}
}
if (nesting_def[nesting] ? *p != '#' : *p != '"')
{
// Not a comment line: check for nested inline function.
end = p + STRLEN(p) - 1;
while (end > p && VIM_ISWHITE(*end))
--end;
if (end > p + 1 && *end == '{' && VIM_ISWHITE(end[-1]))
{
int is_block;
// check for trailing "=> {": start of an inline function
--end;
while (end > p && VIM_ISWHITE(*end))
--end;
is_block = end > p + 2 && end[-1] == '=' && end[0] == '>';
if (!is_block)
{
char_u *s = p;
// check for line starting with "au" for :autocmd or
// "com" for :command, these can use a {} block
is_block = checkforcmd_noparen(&s, "autocmd", 2)
|| checkforcmd_noparen(&s, "command", 3);
}
if (is_block)
{
if (nesting == MAX_FUNC_NESTING - 1)
emsg(_(e_function_nesting_too_deep));
else
{
++nesting;
nesting_def[nesting] = TRUE;
nesting_inline[nesting] = TRUE;
indent += 2;
}
}
}
}
// Check for ":append", ":change", ":insert". Not for :def.
p = skip_range(p, FALSE, NULL);
if (!vim9_function
&& ((p[0] == 'a' && (!ASCII_ISALPHA(p[1]) || p[1] == 'p'))
|| (p[0] == 'c'
&& (!ASCII_ISALPHA(p[1]) || (p[1] == 'h'
&& (!ASCII_ISALPHA(p[2]) || (p[2] == 'a'
&& (STRNCMP(&p[3], "nge", 3) != 0
|| !ASCII_ISALPHA(p[6])))))))
|| (p[0] == 'i'
&& (!ASCII_ISALPHA(p[1]) || (p[1] == 'n'
&& (!ASCII_ISALPHA(p[2])
|| (p[2] == 's'
&& (!ASCII_ISALPHA(p[3])
|| p[3] == 'e'))))))))
skip_until = vim_strsave((char_u *)".");
// Check for ":python <<EOF", ":tcl <<EOF", etc.
arg = skipwhite(skiptowhite(p));
if (arg[0] == '<' && arg[1] =='<'
&& ((p[0] == 'p' && p[1] == 'y'
&& (!ASCII_ISALNUM(p[2]) || p[2] == 't'
|| ((p[2] == '3' || p[2] == 'x')
&& !ASCII_ISALPHA(p[3]))))
|| (p[0] == 'p' && p[1] == 'e'
&& (!ASCII_ISALPHA(p[2]) || p[2] == 'r'))
|| (p[0] == 't' && p[1] == 'c'
&& (!ASCII_ISALPHA(p[2]) || p[2] == 'l'))
|| (p[0] == 'l' && p[1] == 'u' && p[2] == 'a'
&& !ASCII_ISALPHA(p[3]))
|| (p[0] == 'r' && p[1] == 'u' && p[2] == 'b'
&& (!ASCII_ISALPHA(p[3]) || p[3] == 'y'))
|| (p[0] == 'm' && p[1] == 'z'
&& (!ASCII_ISALPHA(p[2]) || p[2] == 's'))
))
{
// ":python <<" continues until a dot, like ":append"
p = skipwhite(arg + 2);
if (STRNCMP(p, "trim", 4) == 0)
{
// Ignore leading white space.
p = skipwhite(p + 4);
heredoc_trimmed = vim_strnsave(theline,
skipwhite(theline) - theline);
}
if (*p == NUL)
skip_until = vim_strsave((char_u *)".");
else
skip_until = vim_strnsave(p, skiptowhite(p) - p);
getline_options = GETLINE_NONE;
is_heredoc = TRUE;
if (eap->cmdidx == CMD_def)
heredoc_concat_len = newlines->ga_len + 1;
}
// Check for ":cmd v =<< [trim] EOF"
// and ":cmd [a, b] =<< [trim] EOF"
// and "lines =<< [trim] EOF" for Vim9
// Where "cmd" can be "let", "var", "final" or "const".
arg = skipwhite(skiptowhite(p));
if (*arg == '[')
arg = vim_strchr(arg, ']');
if (arg != NULL)
{
int found = (eap->cmdidx == CMD_def && arg[0] == '='
&& arg[1] == '<' && arg[2] =='<');
if (!found)
// skip over the argument after "cmd"
arg = skipwhite(skiptowhite(arg));
if (found || (arg[0] == '=' && arg[1] == '<' && arg[2] =='<'
&& (checkforcmd(&p, "let", 2)
|| checkforcmd(&p, "var", 3)
|| checkforcmd(&p, "final", 5)
|| checkforcmd(&p, "const", 5))))
{
p = skipwhite(arg + 3);
if (STRNCMP(p, "trim", 4) == 0)
{
// Ignore leading white space.
p = skipwhite(p + 4);
heredoc_trimmed = vim_strnsave(theline,
skipwhite(theline) - theline);
}
skip_until = vim_strnsave(p, skiptowhite(p) - p);
getline_options = GETLINE_NONE;
is_heredoc = TRUE;
}
}
}
// Add the line to the function.
if (ga_grow(newlines, 1 + sourcing_lnum_off) == FAIL)
goto theend;
if (heredoc_concat_len > 0)
{
// For a :def function "python << EOF" concatenats all the lines,
// to be used for the instruction later.
ga_concat(&heredoc_ga, theline);
ga_concat(&heredoc_ga, (char_u *)"\n");
p = vim_strsave((char_u *)"");
}
else
{
// Copy the line to newly allocated memory. get_one_sourceline()
// allocates 250 bytes per line, this saves 80% on average. The
// cost is an extra alloc/free.
p = vim_strsave(theline);
}
if (p == NULL)
goto theend;
((char_u **)(newlines->ga_data))[newlines->ga_len++] = p;
// Add NULL lines for continuation lines, so that the line count is
// equal to the index in the growarray.
while (sourcing_lnum_off-- > 0)
((char_u **)(newlines->ga_data))[newlines->ga_len++] = NULL;
// Check for end of eap->arg.
if (line_arg != NULL && *line_arg == NUL)
line_arg = NULL;
}
// Return OK when no error was detected.
if (!did_emsg)
ret = OK;
theend:
vim_free(skip_until);
vim_free(heredoc_trimmed);
vim_free(heredoc_ga.ga_data);
need_wait_return |= saved_wait_return;
return ret;
} | 2330 | True | 1 |
CVE-2021-4173 | 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://huntr.dev/bounties/a1b236b9-89fb-4ccf-9689-ba11b471e766', 'name': 'https://huntr.dev/bounties/a1b236b9-89fb-4ccf-9689-ba11b471e766', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/vim/vim/commit/9c23f9bb5fe435b28245ba8ac65aa0ca6b902c04', 'name': 'https://github.com/vim/vim/commit/9c23f9bb5fe435b28245ba8ac65aa0ca6b902c04', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/2EY2VFBU3YGGWI5BW4XKT3F37MYGEQUD/', 'name': 'FEDORA-2022-a3d70b50f0', 'refsource': 'FEDORA', 'tags': ['Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2022/01/15/1', 'name': "[oss-security] 20220114 Re: 3 new CVE's in vim", 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/3FH2J57GDA2WMBS6J56F6QQRA6BXQQFZ/', 'name': 'FEDORA-2022-48b86d586f', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213183', 'name': 'https://support.apple.com/kb/HT213183', 'refsource': 'CONFIRM', 'tags': ['Release Notes', 'Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Mar/29', 'name': '20220314 APPLE-SA-2022-03-14-4 macOS Monterey 12.3', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213256', 'name': 'https://support.apple.com/kb/HT213256', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/May/35', 'name': '20220516 APPLE-SA-2022-05-16-3 macOS Big Sur 11.6.6', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213343', 'name': 'https://support.apple.com/kb/HT213343', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Jul/14', 'name': '20220721 APPLE-SA-2022-07-20-4 Security Update 2022-005 Catalina', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-416'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.3902', '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': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-005:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionEndExcluding': '12.3', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2022-001:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2022-002:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2020-001:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-001:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-002:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-003:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-004:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-006:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-007:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-008:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionStartIncluding': '11.0', 'versionEndExcluding': '11.6.6', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2022-003:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2022-004:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'vim is vulnerable to Use After Free'}] | 2022-08-26T17:48Z | 2021-12-27T13: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 | Bram Moolenaar | 2021-12-26 14:23:22+00:00 | patch 8.2.3902: Vim9: double free with nested :def function
Problem: Vim9: double free with nested :def function.
Solution: Pass "line_to_free" from compile_def_function() and make sure
cmdlinep is valid. | 9c23f9bb5fe435b28245ba8ac65aa0ca6b902c04 | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | lambda_function_body | lambda_function_body( char_u ** arg , typval_T * rettv , evalarg_T * evalarg , garray_T * newargs , garray_T * argtypes , int varargs , garray_T * default_args , char_u * ret_type) | ['arg', 'rettv', 'evalarg', 'newargs', 'argtypes', 'varargs', 'default_args', 'ret_type'] | lambda_function_body(
char_u **arg,
typval_T *rettv,
evalarg_T *evalarg,
garray_T *newargs,
garray_T *argtypes,
int varargs,
garray_T *default_args,
char_u *ret_type)
{
int evaluate = (evalarg->eval_flags & EVAL_EVALUATE);
garray_T *gap = &evalarg->eval_ga;
garray_T *freegap = &evalarg->eval_freega;
ufunc_T *ufunc = NULL;
exarg_T eap;
garray_T newlines;
char_u *cmdline = NULL;
int ret = FAIL;
char_u *line_to_free = NULL;
partial_T *pt;
char_u *name;
int lnum_save = -1;
linenr_T sourcing_lnum_top = SOURCING_LNUM;
if (!ends_excmd2(*arg, skipwhite(*arg + 1)))
{
semsg(_(e_trailing_arg), *arg + 1);
return FAIL;
}
CLEAR_FIELD(eap);
eap.cmdidx = CMD_block;
eap.forceit = FALSE;
eap.cmdlinep = &cmdline;
eap.skip = !evaluate;
if (evalarg->eval_cctx != NULL)
fill_exarg_from_cctx(&eap, evalarg->eval_cctx);
else
{
eap.getline = evalarg->eval_getline;
eap.cookie = evalarg->eval_cookie;
}
ga_init2(&newlines, (int)sizeof(char_u *), 10);
if (get_function_body(&eap, &newlines, NULL, &line_to_free) == FAIL)
{
vim_free(cmdline);
goto erret;
}
// When inside a lambda must add the function lines to evalarg.eval_ga.
evalarg->eval_break_count += newlines.ga_len;
if (gap->ga_itemsize > 0)
{
int idx;
char_u *last;
size_t plen;
char_u *pnl;
for (idx = 0; idx < newlines.ga_len; ++idx)
{
char_u *p = skipwhite(((char_u **)newlines.ga_data)[idx]);
if (ga_grow(gap, 1) == FAIL || ga_grow(freegap, 1) == FAIL)
goto erret;
// Going to concatenate the lines after parsing. For an empty or
// comment line use an empty string.
// Insert NL characters at the start of each line, the string will
// be split again later in .get_lambda_tv().
if (*p == NUL || vim9_comment_start(p))
p = (char_u *)"";
plen = STRLEN(p);
pnl = vim_strnsave((char_u *)"\n", plen + 1);
if (pnl != NULL)
mch_memmove(pnl + 1, p, plen + 1);
((char_u **)gap->ga_data)[gap->ga_len++] = pnl;
((char_u **)freegap->ga_data)[freegap->ga_len++] = pnl;
}
if (ga_grow(gap, 1) == FAIL || ga_grow(freegap, 1) == FAIL)
goto erret;
if (cmdline != NULL)
// more is following after the "}", which was skipped
last = cmdline;
else
// nothing is following the "}"
last = (char_u *)"}";
plen = STRLEN(last);
pnl = vim_strnsave((char_u *)"\n", plen + 1);
if (pnl != NULL)
mch_memmove(pnl + 1, last, plen + 1);
((char_u **)gap->ga_data)[gap->ga_len++] = pnl;
((char_u **)freegap->ga_data)[freegap->ga_len++] = pnl;
}
if (cmdline != NULL)
{
garray_T *tfgap = &evalarg->eval_tofree_ga;
// Something comes after the "}".
*arg = eap.nextcmd;
// "arg" points into cmdline, need to keep the line and free it later.
if (ga_grow(tfgap, 1) == OK)
{
((char_u **)(tfgap->ga_data))[tfgap->ga_len++] = cmdline;
evalarg->eval_using_cmdline = TRUE;
}
}
else
*arg = (char_u *)"";
if (!evaluate)
{
ret = OK;
goto erret;
}
name = get_lambda_name();
ufunc = alloc_clear(offsetof(ufunc_T, uf_name) + STRLEN(name) + 1);
if (ufunc == NULL)
goto erret;
set_ufunc_name(ufunc, name);
if (hash_add(&func_hashtab, UF2HIKEY(ufunc)) == FAIL)
goto erret;
ufunc->uf_flags = FC_LAMBDA;
ufunc->uf_refcount = 1;
ufunc->uf_args = *newargs;
newargs->ga_data = NULL;
ufunc->uf_def_args = *default_args;
default_args->ga_data = NULL;
ufunc->uf_func_type = &t_func_any;
// error messages are for the first function line
lnum_save = SOURCING_LNUM;
SOURCING_LNUM = sourcing_lnum_top;
// parse argument types
if (parse_argument_types(ufunc, argtypes, varargs) == FAIL)
{
SOURCING_LNUM = lnum_save;
goto erret;
}
// parse the return type, if any
if (parse_return_type(ufunc, ret_type) == FAIL)
goto erret;
pt = ALLOC_CLEAR_ONE(partial_T);
if (pt == NULL)
goto erret;
pt->pt_func = ufunc;
pt->pt_refcount = 1;
ufunc->uf_lines = newlines;
newlines.ga_data = NULL;
if (sandbox)
ufunc->uf_flags |= FC_SANDBOX;
if (!ASCII_ISUPPER(*ufunc->uf_name))
ufunc->uf_flags |= FC_VIM9;
ufunc->uf_script_ctx = current_sctx;
ufunc->uf_script_ctx_version = current_sctx.sc_version;
ufunc->uf_script_ctx.sc_lnum += sourcing_lnum_top;
set_function_type(ufunc);
function_using_block_scopes(ufunc, evalarg->eval_cstack);
rettv->vval.v_partial = pt;
rettv->v_type = VAR_PARTIAL;
ufunc = NULL;
ret = OK;
erret:
if (lnum_save >= 0)
SOURCING_LNUM = lnum_save;
vim_free(line_to_free);
ga_clear_strings(&newlines);
if (newargs != NULL)
ga_clear_strings(newargs);
ga_clear_strings(default_args);
if (ufunc != NULL)
{
func_clear(ufunc, TRUE);
func_free(ufunc, TRUE);
}
return ret;
} | 992 | True | 1 |
CVE-2021-4173 | 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://huntr.dev/bounties/a1b236b9-89fb-4ccf-9689-ba11b471e766', 'name': 'https://huntr.dev/bounties/a1b236b9-89fb-4ccf-9689-ba11b471e766', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/vim/vim/commit/9c23f9bb5fe435b28245ba8ac65aa0ca6b902c04', 'name': 'https://github.com/vim/vim/commit/9c23f9bb5fe435b28245ba8ac65aa0ca6b902c04', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/2EY2VFBU3YGGWI5BW4XKT3F37MYGEQUD/', 'name': 'FEDORA-2022-a3d70b50f0', 'refsource': 'FEDORA', 'tags': ['Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2022/01/15/1', 'name': "[oss-security] 20220114 Re: 3 new CVE's in vim", 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/3FH2J57GDA2WMBS6J56F6QQRA6BXQQFZ/', 'name': 'FEDORA-2022-48b86d586f', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213183', 'name': 'https://support.apple.com/kb/HT213183', 'refsource': 'CONFIRM', 'tags': ['Release Notes', 'Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Mar/29', 'name': '20220314 APPLE-SA-2022-03-14-4 macOS Monterey 12.3', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213256', 'name': 'https://support.apple.com/kb/HT213256', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/May/35', 'name': '20220516 APPLE-SA-2022-05-16-3 macOS Big Sur 11.6.6', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213343', 'name': 'https://support.apple.com/kb/HT213343', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Jul/14', 'name': '20220721 APPLE-SA-2022-07-20-4 Security Update 2022-005 Catalina', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-416'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.3902', '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': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-005:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionEndExcluding': '12.3', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2022-001:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2022-002:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2020-001:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-001:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-002:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-003:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-004:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-006:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-007:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-008:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionStartIncluding': '11.0', 'versionEndExcluding': '11.6.6', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2022-003:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2022-004:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'vim is vulnerable to Use After Free'}] | 2022-08-26T17:48Z | 2021-12-27T13: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 | Bram Moolenaar | 2021-12-26 14:23:22+00:00 | patch 8.2.3902: Vim9: double free with nested :def function
Problem: Vim9: double free with nested :def function.
Solution: Pass "line_to_free" from compile_def_function() and make sure
cmdlinep is valid. | 9c23f9bb5fe435b28245ba8ac65aa0ca6b902c04 | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | compile_def_function | compile_def_function( ufunc_T * ufunc , int check_return_type , compiletype_T compile_type , cctx_T * outer_cctx) | ['ufunc', 'check_return_type', 'compile_type', 'outer_cctx'] | compile_def_function(
ufunc_T *ufunc,
int check_return_type,
compiletype_T compile_type,
cctx_T *outer_cctx)
{
char_u *line = NULL;
char_u *line_to_free = NULL;
char_u *p;
char *errormsg = NULL; // error message
cctx_T cctx;
garray_T *instr;
int did_emsg_before = did_emsg;
int did_emsg_silent_before = did_emsg_silent;
int ret = FAIL;
sctx_T save_current_sctx = current_sctx;
int save_estack_compiling = estack_compiling;
int save_cmod_flags = cmdmod.cmod_flags;
int do_estack_push;
int new_def_function = FALSE;
#ifdef FEAT_PROFILE
int prof_lnum = -1;
#endif
int debug_lnum = -1;
// When using a function that was compiled before: Free old instructions.
// The index is reused. Otherwise add a new entry in "def_functions".
if (ufunc->uf_dfunc_idx > 0)
{
dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data)
+ ufunc->uf_dfunc_idx;
isn_T *instr_dest = NULL;
switch (compile_type)
{
case CT_PROFILE:
#ifdef FEAT_PROFILE
instr_dest = dfunc->df_instr_prof; break;
#endif
case CT_NONE: instr_dest = dfunc->df_instr; break;
case CT_DEBUG: instr_dest = dfunc->df_instr_debug; break;
}
if (instr_dest != NULL)
// Was compiled in this mode before: Free old instructions.
delete_def_function_contents(dfunc, FALSE);
ga_clear_strings(&dfunc->df_var_names);
}
else
{
if (add_def_function(ufunc) == FAIL)
return FAIL;
new_def_function = TRUE;
}
ufunc->uf_def_status = UF_COMPILING;
CLEAR_FIELD(cctx);
cctx.ctx_compile_type = compile_type;
cctx.ctx_ufunc = ufunc;
cctx.ctx_lnum = -1;
cctx.ctx_outer = outer_cctx;
ga_init2(&cctx.ctx_locals, sizeof(lvar_T), 10);
ga_init2(&cctx.ctx_type_stack, sizeof(type_T *), 50);
ga_init2(&cctx.ctx_imports, sizeof(imported_T), 10);
cctx.ctx_type_list = &ufunc->uf_type_list;
ga_init2(&cctx.ctx_instr, sizeof(isn_T), 50);
instr = &cctx.ctx_instr;
// Set the context to the function, it may be compiled when called from
// another script. Set the script version to the most modern one.
// The line number will be set in next_line_from_context().
current_sctx = ufunc->uf_script_ctx;
current_sctx.sc_version = SCRIPT_VERSION_VIM9;
// Don't use the flag from ":legacy" here.
cmdmod.cmod_flags &= ~CMOD_LEGACY;
// Make sure error messages are OK.
do_estack_push = !estack_top_is_ufunc(ufunc, 1);
if (do_estack_push)
estack_push_ufunc(ufunc, 1);
estack_compiling = TRUE;
if (ufunc->uf_def_args.ga_len > 0)
{
int count = ufunc->uf_def_args.ga_len;
int first_def_arg = ufunc->uf_args.ga_len - count;
int i;
char_u *arg;
int off = STACK_FRAME_SIZE + (ufunc->uf_va_name != NULL ? 1 : 0);
int did_set_arg_type = FALSE;
// Produce instructions for the default values of optional arguments.
SOURCING_LNUM = 0; // line number unknown
for (i = 0; i < count; ++i)
{
garray_T *stack = &cctx.ctx_type_stack;
type_T *val_type;
int arg_idx = first_def_arg + i;
where_T where = WHERE_INIT;
int r;
int jump_instr_idx = instr->ga_len;
isn_T *isn;
// Use a JUMP_IF_ARG_SET instruction to skip if the value was given.
if (generate_JUMP_IF_ARG_SET(&cctx, i - count - off) == FAIL)
goto erret;
// Make sure later arguments are not found.
ufunc->uf_args_visible = arg_idx;
arg = ((char_u **)(ufunc->uf_def_args.ga_data))[i];
r = compile_expr0(&arg, &cctx);
if (r == FAIL)
goto erret;
// If no type specified use the type of the default value.
// Otherwise check that the default value type matches the
// specified type.
val_type = ((type_T **)stack->ga_data)[stack->ga_len - 1];
where.wt_index = arg_idx + 1;
if (ufunc->uf_arg_types[arg_idx] == &t_unknown)
{
did_set_arg_type = TRUE;
ufunc->uf_arg_types[arg_idx] = val_type;
}
else if (need_type_where(val_type, ufunc->uf_arg_types[arg_idx],
-1, where, &cctx, FALSE, FALSE) == FAIL)
goto erret;
if (generate_STORE(&cctx, ISN_STORE, i - count - off, NULL) == FAIL)
goto erret;
// set instruction index in JUMP_IF_ARG_SET to here
isn = ((isn_T *)instr->ga_data) + jump_instr_idx;
isn->isn_arg.jumparg.jump_where = instr->ga_len;
}
if (did_set_arg_type)
set_function_type(ufunc);
}
ufunc->uf_args_visible = ufunc->uf_args.ga_len;
/*
* Loop over all the lines of the function and generate instructions.
*/
for (;;)
{
exarg_T ea;
int starts_with_colon = FALSE;
char_u *cmd;
cmdmod_T local_cmdmod;
// Bail out on the first error to avoid a flood of errors and report
// the right line number when inside try/catch.
if (did_emsg_before != did_emsg)
goto erret;
if (line != NULL && *line == '|')
// the line continues after a '|'
++line;
else if (line != NULL && *skipwhite(line) != NUL
&& !(*line == '#' && (line == cctx.ctx_line_start
|| VIM_ISWHITE(line[-1]))))
{
semsg(_(e_trailing_arg), line);
goto erret;
}
else if (line != NULL && vim9_bad_comment(skipwhite(line)))
goto erret;
else
{
line = next_line_from_context(&cctx, FALSE);
if (cctx.ctx_lnum >= ufunc->uf_lines.ga_len)
{
// beyond the last line
#ifdef FEAT_PROFILE
if (cctx.ctx_skip != SKIP_YES)
may_generate_prof_end(&cctx, prof_lnum);
#endif
break;
}
// Make a copy, splitting off nextcmd and removing trailing spaces
// may change it.
if (line != NULL)
{
line = vim_strsave(line);
vim_free(line_to_free);
line_to_free = line;
}
}
CLEAR_FIELD(ea);
ea.cmdlinep = &line;
ea.cmd = skipwhite(line);
if (*ea.cmd == '#')
{
// "#" starts a comment
line = (char_u *)"";
continue;
}
#ifdef FEAT_PROFILE
if (cctx.ctx_compile_type == CT_PROFILE && cctx.ctx_lnum != prof_lnum
&& cctx.ctx_skip != SKIP_YES)
{
may_generate_prof_end(&cctx, prof_lnum);
prof_lnum = cctx.ctx_lnum;
generate_instr(&cctx, ISN_PROF_START);
}
#endif
if (cctx.ctx_compile_type == CT_DEBUG && cctx.ctx_lnum != debug_lnum
&& cctx.ctx_skip != SKIP_YES)
{
debug_lnum = cctx.ctx_lnum;
generate_instr_debug(&cctx);
}
cctx.ctx_prev_lnum = cctx.ctx_lnum + 1;
// Some things can be recognized by the first character.
switch (*ea.cmd)
{
case '}':
{
// "}" ends a block scope
scopetype_T stype = cctx.ctx_scope == NULL
? NO_SCOPE : cctx.ctx_scope->se_type;
if (stype == BLOCK_SCOPE)
{
compile_endblock(&cctx);
line = ea.cmd;
}
else
{
emsg(_(e_using_rcurly_outside_if_block_scope));
goto erret;
}
if (line != NULL)
line = skipwhite(ea.cmd + 1);
continue;
}
case '{':
// "{" starts a block scope
// "{'a': 1}->func() is something else
if (ends_excmd(*skipwhite(ea.cmd + 1)))
{
line = compile_block(ea.cmd, &cctx);
continue;
}
break;
}
/*
* COMMAND MODIFIERS
*/
cctx.ctx_has_cmdmod = FALSE;
if (parse_command_modifiers(&ea, &errormsg, &local_cmdmod, FALSE)
== FAIL)
{
if (errormsg != NULL)
goto erret;
// empty line or comment
line = (char_u *)"";
continue;
}
generate_cmdmods(&cctx, &local_cmdmod);
undo_cmdmod(&local_cmdmod);
// Check if there was a colon after the last command modifier or before
// the current position.
for (p = ea.cmd; p >= line; --p)
{
if (*p == ':')
starts_with_colon = TRUE;
if (p < ea.cmd && !VIM_ISWHITE(*p))
break;
}
// Skip ":call" to get to the function name, unless using :legacy
p = ea.cmd;
if (!(local_cmdmod.cmod_flags & CMOD_LEGACY))
{
if (checkforcmd(&ea.cmd, "call", 3))
{
if (*ea.cmd == '(')
// not for "call()"
ea.cmd = p;
else
ea.cmd = skipwhite(ea.cmd);
}
if (!starts_with_colon)
{
int assign;
// Check for assignment after command modifiers.
assign = may_compile_assignment(&ea, &line, &cctx);
if (assign == OK)
goto nextline;
if (assign == FAIL)
goto erret;
}
}
/*
* COMMAND after range
* 'text'->func() should not be confused with 'a mark
* "++nr" and "--nr" are eval commands
* in "$ENV->func()" the "$" is not a range
*/
cmd = ea.cmd;
if ((*cmd != '$' || starts_with_colon)
&& (starts_with_colon || !(*cmd == '\''
|| (cmd[0] == cmd[1] && (*cmd == '+' || *cmd == '-')))))
{
ea.cmd = skip_range(ea.cmd, TRUE, NULL);
if (ea.cmd > cmd)
{
if (!starts_with_colon
&& !(local_cmdmod.cmod_flags & CMOD_LEGACY))
{
semsg(_(e_colon_required_before_range_str), cmd);
goto erret;
}
ea.addr_count = 1;
if (ends_excmd2(line, ea.cmd))
{
// A range without a command: jump to the line.
generate_EXEC(&cctx, ISN_EXECRANGE,
vim_strnsave(cmd, ea.cmd - cmd));
line = ea.cmd;
goto nextline;
}
}
}
p = find_ex_command(&ea, NULL,
starts_with_colon || (local_cmdmod.cmod_flags & CMOD_LEGACY)
? NULL : item_exists, &cctx);
if (p == NULL)
{
if (cctx.ctx_skip != SKIP_YES)
emsg(_(e_ambiguous_use_of_user_defined_command));
goto erret;
}
// When using ":legacy cmd" always use compile_exec().
if (local_cmdmod.cmod_flags & CMOD_LEGACY)
{
char_u *start = ea.cmd;
switch (ea.cmdidx)
{
case CMD_if:
case CMD_elseif:
case CMD_else:
case CMD_endif:
case CMD_for:
case CMD_endfor:
case CMD_continue:
case CMD_break:
case CMD_while:
case CMD_endwhile:
case CMD_try:
case CMD_catch:
case CMD_finally:
case CMD_endtry:
semsg(_(e_cannot_use_legacy_with_command_str), ea.cmd);
goto erret;
default: break;
}
// ":legacy return expr" needs to be handled differently.
if (checkforcmd(&start, "return", 4))
ea.cmdidx = CMD_return;
else
ea.cmdidx = CMD_legacy;
}
if (p == ea.cmd && ea.cmdidx != CMD_SIZE)
{
if (cctx.ctx_skip == SKIP_YES && ea.cmdidx != CMD_eval)
{
line += STRLEN(line);
goto nextline;
}
else if (ea.cmdidx != CMD_eval)
{
// CMD_var cannot happen, compile_assignment() above would be
// used. Most likely an assignment to a non-existing variable.
semsg(_(e_command_not_recognized_str), ea.cmd);
goto erret;
}
}
if (cctx.ctx_had_return
&& ea.cmdidx != CMD_elseif
&& ea.cmdidx != CMD_else
&& ea.cmdidx != CMD_endif
&& ea.cmdidx != CMD_endfor
&& ea.cmdidx != CMD_endwhile
&& ea.cmdidx != CMD_catch
&& ea.cmdidx != CMD_finally
&& ea.cmdidx != CMD_endtry)
{
emsg(_(e_unreachable_code_after_return));
goto erret;
}
p = skipwhite(p);
if (ea.cmdidx != CMD_SIZE
&& ea.cmdidx != CMD_write && ea.cmdidx != CMD_read)
{
if (ea.cmdidx >= 0)
ea.argt = excmd_get_argt(ea.cmdidx);
if ((ea.argt & EX_BANG) && *p == '!')
{
ea.forceit = TRUE;
p = skipwhite(p + 1);
}
}
switch (ea.cmdidx)
{
case CMD_def:
case CMD_function:
ea.arg = p;
line = compile_nested_function(&ea, &cctx);
break;
case CMD_return:
line = compile_return(p, check_return_type,
local_cmdmod.cmod_flags & CMOD_LEGACY, &cctx);
cctx.ctx_had_return = TRUE;
break;
case CMD_let:
emsg(_(e_cannot_use_let_in_vim9_script));
break;
case CMD_var:
case CMD_final:
case CMD_const:
case CMD_increment:
case CMD_decrement:
line = compile_assignment(p, &ea, ea.cmdidx, &cctx);
if (line == p)
line = NULL;
break;
case CMD_unlet:
case CMD_unlockvar:
case CMD_lockvar:
line = compile_unletlock(p, &ea, &cctx);
break;
case CMD_import:
emsg(_(e_import_can_only_be_used_in_script));
line = NULL;
break;
case CMD_if:
line = compile_if(p, &cctx);
break;
case CMD_elseif:
line = compile_elseif(p, &cctx);
cctx.ctx_had_return = FALSE;
break;
case CMD_else:
line = compile_else(p, &cctx);
cctx.ctx_had_return = FALSE;
break;
case CMD_endif:
line = compile_endif(p, &cctx);
break;
case CMD_while:
line = compile_while(p, &cctx);
break;
case CMD_endwhile:
line = compile_endwhile(p, &cctx);
cctx.ctx_had_return = FALSE;
break;
case CMD_for:
line = compile_for(p, &cctx);
break;
case CMD_endfor:
line = compile_endfor(p, &cctx);
cctx.ctx_had_return = FALSE;
break;
case CMD_continue:
line = compile_continue(p, &cctx);
break;
case CMD_break:
line = compile_break(p, &cctx);
break;
case CMD_try:
line = compile_try(p, &cctx);
break;
case CMD_catch:
line = compile_catch(p, &cctx);
cctx.ctx_had_return = FALSE;
break;
case CMD_finally:
line = compile_finally(p, &cctx);
cctx.ctx_had_return = FALSE;
break;
case CMD_endtry:
line = compile_endtry(p, &cctx);
cctx.ctx_had_return = FALSE;
break;
case CMD_throw:
line = compile_throw(p, &cctx);
break;
case CMD_eval:
line = compile_eval(p, &cctx);
break;
case CMD_echo:
case CMD_echon:
case CMD_execute:
case CMD_echomsg:
case CMD_echoerr:
case CMD_echoconsole:
line = compile_mult_expr(p, ea.cmdidx, &cctx);
break;
case CMD_put:
ea.cmd = cmd;
line = compile_put(p, &ea, &cctx);
break;
case CMD_substitute:
if (check_global_and_subst(ea.cmd, p) == FAIL)
goto erret;
if (cctx.ctx_skip == SKIP_YES)
line = (char_u *)"";
else
{
ea.arg = p;
line = compile_substitute(line, &ea, &cctx);
}
break;
case CMD_redir:
ea.arg = p;
line = compile_redir(line, &ea, &cctx);
break;
case CMD_cexpr:
case CMD_lexpr:
case CMD_caddexpr:
case CMD_laddexpr:
case CMD_cgetexpr:
case CMD_lgetexpr:
#ifdef FEAT_QUICKFIX
ea.arg = p;
line = compile_cexpr(line, &ea, &cctx);
#else
ex_ni(&ea);
line = NULL;
#endif
break;
case CMD_append:
case CMD_change:
case CMD_insert:
case CMD_k:
case CMD_t:
case CMD_xit:
not_in_vim9(&ea);
goto erret;
case CMD_SIZE:
if (cctx.ctx_skip != SKIP_YES)
{
semsg(_(e_invalid_command_str), ea.cmd);
goto erret;
}
// We don't check for a next command here.
line = (char_u *)"";
break;
case CMD_lua:
case CMD_mzscheme:
case CMD_perl:
case CMD_py3:
case CMD_python3:
case CMD_python:
case CMD_pythonx:
case CMD_ruby:
case CMD_tcl:
ea.arg = p;
if (vim_strchr(line, '\n') == NULL)
line = compile_exec(line, &ea, &cctx);
else
// heredoc lines have been concatenated with NL
// characters in get_function_body()
line = compile_script(line, &cctx);
break;
case CMD_global:
if (check_global_and_subst(ea.cmd, p) == FAIL)
goto erret;
// FALLTHROUGH
default:
// Not recognized, execute with do_cmdline_cmd().
ea.arg = p;
line = compile_exec(line, &ea, &cctx);
break;
}
nextline:
if (line == NULL)
goto erret;
line = skipwhite(line);
// Undo any command modifiers.
generate_undo_cmdmods(&cctx);
if (cctx.ctx_type_stack.ga_len < 0)
{
iemsg("Type stack underflow");
goto erret;
}
}
if (cctx.ctx_scope != NULL)
{
if (cctx.ctx_scope->se_type == IF_SCOPE)
emsg(_(e_endif));
else if (cctx.ctx_scope->se_type == WHILE_SCOPE)
emsg(_(e_endwhile));
else if (cctx.ctx_scope->se_type == FOR_SCOPE)
emsg(_(e_endfor));
else
emsg(_(e_missing_rcurly));
goto erret;
}
if (!cctx.ctx_had_return)
{
if (ufunc->uf_ret_type->tt_type == VAR_UNKNOWN)
ufunc->uf_ret_type = &t_void;
else if (ufunc->uf_ret_type->tt_type != VAR_VOID)
{
emsg(_(e_missing_return_statement));
goto erret;
}
// Return void if there is no return at the end.
generate_instr(&cctx, ISN_RETURN_VOID);
}
// When compiled with ":silent!" and there was an error don't consider the
// function compiled.
if (emsg_silent == 0 || did_emsg_silent == did_emsg_silent_before)
{
dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data)
+ ufunc->uf_dfunc_idx;
dfunc->df_deleted = FALSE;
dfunc->df_script_seq = current_sctx.sc_seq;
#ifdef FEAT_PROFILE
if (cctx.ctx_compile_type == CT_PROFILE)
{
dfunc->df_instr_prof = instr->ga_data;
dfunc->df_instr_prof_count = instr->ga_len;
}
else
#endif
if (cctx.ctx_compile_type == CT_DEBUG)
{
dfunc->df_instr_debug = instr->ga_data;
dfunc->df_instr_debug_count = instr->ga_len;
}
else
{
dfunc->df_instr = instr->ga_data;
dfunc->df_instr_count = instr->ga_len;
}
dfunc->df_varcount = dfunc->df_var_names.ga_len;
dfunc->df_has_closure = cctx.ctx_has_closure;
if (cctx.ctx_outer_used)
ufunc->uf_flags |= FC_CLOSURE;
ufunc->uf_def_status = UF_COMPILED;
}
ret = OK;
erret:
if (ufunc->uf_def_status == UF_COMPILING)
{
dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data)
+ ufunc->uf_dfunc_idx;
// Compiling aborted, free the generated instructions.
clear_instr_ga(instr);
VIM_CLEAR(dfunc->df_name);
ga_clear_strings(&dfunc->df_var_names);
// If using the last entry in the table and it was added above, we
// might as well remove it.
if (!dfunc->df_deleted && new_def_function
&& ufunc->uf_dfunc_idx == def_functions.ga_len - 1)
{
--def_functions.ga_len;
ufunc->uf_dfunc_idx = 0;
}
ufunc->uf_def_status = UF_COMPILE_ERROR;
while (cctx.ctx_scope != NULL)
drop_scope(&cctx);
if (errormsg != NULL)
emsg(errormsg);
else if (did_emsg == did_emsg_before)
emsg(_(e_compiling_def_function_failed));
}
if (cctx.ctx_redir_lhs.lhs_name != NULL)
{
if (ret == OK)
{
emsg(_(e_missing_redir_end));
ret = FAIL;
}
vim_free(cctx.ctx_redir_lhs.lhs_name);
vim_free(cctx.ctx_redir_lhs.lhs_whole);
}
current_sctx = save_current_sctx;
estack_compiling = save_estack_compiling;
cmdmod.cmod_flags = save_cmod_flags;
if (do_estack_push)
estack_pop();
vim_free(line_to_free);
free_imported(&cctx);
free_locals(&cctx);
ga_clear(&cctx.ctx_type_stack);
return ret;
} | 3261 | True | 1 |
CVE-2021-4173 | 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://huntr.dev/bounties/a1b236b9-89fb-4ccf-9689-ba11b471e766', 'name': 'https://huntr.dev/bounties/a1b236b9-89fb-4ccf-9689-ba11b471e766', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/vim/vim/commit/9c23f9bb5fe435b28245ba8ac65aa0ca6b902c04', 'name': 'https://github.com/vim/vim/commit/9c23f9bb5fe435b28245ba8ac65aa0ca6b902c04', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/2EY2VFBU3YGGWI5BW4XKT3F37MYGEQUD/', 'name': 'FEDORA-2022-a3d70b50f0', 'refsource': 'FEDORA', 'tags': ['Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2022/01/15/1', 'name': "[oss-security] 20220114 Re: 3 new CVE's in vim", 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/3FH2J57GDA2WMBS6J56F6QQRA6BXQQFZ/', 'name': 'FEDORA-2022-48b86d586f', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213183', 'name': 'https://support.apple.com/kb/HT213183', 'refsource': 'CONFIRM', 'tags': ['Release Notes', 'Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Mar/29', 'name': '20220314 APPLE-SA-2022-03-14-4 macOS Monterey 12.3', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213256', 'name': 'https://support.apple.com/kb/HT213256', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/May/35', 'name': '20220516 APPLE-SA-2022-05-16-3 macOS Big Sur 11.6.6', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213343', 'name': 'https://support.apple.com/kb/HT213343', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Jul/14', 'name': '20220721 APPLE-SA-2022-07-20-4 Security Update 2022-005 Catalina', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-416'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.3902', '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': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-005:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionEndExcluding': '12.3', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2022-001:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2022-002:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2020-001:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-001:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-002:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-003:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-004:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-006:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-007:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-008:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionStartIncluding': '11.0', 'versionEndExcluding': '11.6.6', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2022-003:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2022-004:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'vim is vulnerable to Use After Free'}] | 2022-08-26T17:48Z | 2021-12-27T13: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 | Bram Moolenaar | 2021-12-26 14:23:22+00:00 | patch 8.2.3902: Vim9: double free with nested :def function
Problem: Vim9: double free with nested :def function.
Solution: Pass "line_to_free" from compile_def_function() and make sure
cmdlinep is valid. | 9c23f9bb5fe435b28245ba8ac65aa0ca6b902c04 | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | compile_nested_function | compile_nested_function( exarg_T * eap , cctx_T * cctx) | ['eap', 'cctx'] | compile_nested_function(exarg_T *eap, cctx_T *cctx)
{
int is_global = *eap->arg == 'g' && eap->arg[1] == ':';
char_u *name_start = eap->arg;
char_u *name_end = to_name_end(eap->arg, TRUE);
char_u *lambda_name;
ufunc_T *ufunc;
int r = FAIL;
compiletype_T compile_type;
if (eap->forceit)
{
emsg(_(e_cannot_use_bang_with_nested_def));
return NULL;
}
if (*name_start == '/')
{
name_end = skip_regexp(name_start + 1, '/', TRUE);
if (*name_end == '/')
++name_end;
set_nextcmd(eap, name_end);
}
if (name_end == name_start || *skipwhite(name_end) != '(')
{
if (!ends_excmd2(name_start, name_end))
{
semsg(_(e_invalid_command_str), eap->cmd);
return NULL;
}
// "def" or "def Name": list functions
if (generate_DEF(cctx, name_start, name_end - name_start) == FAIL)
return NULL;
return eap->nextcmd == NULL ? (char_u *)"" : eap->nextcmd;
}
// Only g:Func() can use a namespace.
if (name_start[1] == ':' && !is_global)
{
semsg(_(e_namespace_not_supported_str), name_start);
return NULL;
}
if (check_defined(name_start, name_end - name_start, cctx, FALSE) == FAIL)
return NULL;
eap->arg = name_end;
fill_exarg_from_cctx(eap, cctx);
eap->forceit = FALSE;
// We use the special <Lamba>99 name, but it's not really a lambda.
lambda_name = vim_strsave(get_lambda_name());
if (lambda_name == NULL)
return NULL;
ufunc = define_function(eap, lambda_name);
if (ufunc == NULL)
{
r = eap->skip ? OK : FAIL;
goto theend;
}
// copy over the block scope IDs before compiling
if (!is_global && cctx->ctx_ufunc->uf_block_depth > 0)
{
int block_depth = cctx->ctx_ufunc->uf_block_depth;
ufunc->uf_block_ids = ALLOC_MULT(int, block_depth);
if (ufunc->uf_block_ids != NULL)
{
mch_memmove(ufunc->uf_block_ids, cctx->ctx_ufunc->uf_block_ids,
sizeof(int) * block_depth);
ufunc->uf_block_depth = block_depth;
}
}
compile_type = COMPILE_TYPE(ufunc);
#ifdef FEAT_PROFILE
// If the outer function is profiled, also compile the nested function for
// profiling.
if (cctx->ctx_compile_type == CT_PROFILE)
compile_type = CT_PROFILE;
#endif
if (func_needs_compiling(ufunc, compile_type)
&& compile_def_function(ufunc, TRUE, compile_type, cctx) == FAIL)
{
func_ptr_unref(ufunc);
goto theend;
}
#ifdef FEAT_PROFILE
// When the outer function is compiled for profiling, the nested function
// may be called without profiling. Compile it here in the right context.
if (compile_type == CT_PROFILE && func_needs_compiling(ufunc, CT_NONE))
compile_def_function(ufunc, FALSE, CT_NONE, cctx);
#endif
if (is_global)
{
char_u *func_name = vim_strnsave(name_start + 2,
name_end - name_start - 2);
if (func_name == NULL)
r = FAIL;
else
{
r = generate_NEWFUNC(cctx, lambda_name, func_name);
lambda_name = NULL;
}
}
else
{
// Define a local variable for the function reference.
lvar_T *lvar = reserve_local(cctx, name_start, name_end - name_start,
TRUE, ufunc->uf_func_type);
if (lvar == NULL)
goto theend;
if (generate_FUNCREF(cctx, ufunc) == FAIL)
goto theend;
r = generate_STORE(cctx, ISN_STORE, lvar->lv_idx, NULL);
}
theend:
vim_free(lambda_name);
return r == FAIL ? NULL : (char_u *)"";
} | 597 | True | 1 |
CVE-2021-4173 | 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://huntr.dev/bounties/a1b236b9-89fb-4ccf-9689-ba11b471e766', 'name': 'https://huntr.dev/bounties/a1b236b9-89fb-4ccf-9689-ba11b471e766', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/vim/vim/commit/9c23f9bb5fe435b28245ba8ac65aa0ca6b902c04', 'name': 'https://github.com/vim/vim/commit/9c23f9bb5fe435b28245ba8ac65aa0ca6b902c04', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/2EY2VFBU3YGGWI5BW4XKT3F37MYGEQUD/', 'name': 'FEDORA-2022-a3d70b50f0', 'refsource': 'FEDORA', 'tags': ['Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2022/01/15/1', 'name': "[oss-security] 20220114 Re: 3 new CVE's in vim", 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/3FH2J57GDA2WMBS6J56F6QQRA6BXQQFZ/', 'name': 'FEDORA-2022-48b86d586f', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213183', 'name': 'https://support.apple.com/kb/HT213183', 'refsource': 'CONFIRM', 'tags': ['Release Notes', 'Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Mar/29', 'name': '20220314 APPLE-SA-2022-03-14-4 macOS Monterey 12.3', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213256', 'name': 'https://support.apple.com/kb/HT213256', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/May/35', 'name': '20220516 APPLE-SA-2022-05-16-3 macOS Big Sur 11.6.6', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213343', 'name': 'https://support.apple.com/kb/HT213343', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Jul/14', 'name': '20220721 APPLE-SA-2022-07-20-4 Security Update 2022-005 Catalina', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-416'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.3902', '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': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-005:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionEndExcluding': '12.3', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2022-001:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2022-002:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2020-001:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-001:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-002:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-003:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-004:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-006:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-007:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-008:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionStartIncluding': '11.0', 'versionEndExcluding': '11.6.6', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2022-003:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2022-004:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'vim is vulnerable to Use After Free'}] | 2022-08-26T17:48Z | 2021-12-27T13: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 | Bram Moolenaar | 2021-12-26 14:23:22+00:00 | patch 8.2.3902: Vim9: double free with nested :def function
Problem: Vim9: double free with nested :def function.
Solution: Pass "line_to_free" from compile_def_function() and make sure
cmdlinep is valid. | 9c23f9bb5fe435b28245ba8ac65aa0ca6b902c04 | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | exec_instructions | exec_instructions( ectx_T * ectx) | ['ectx'] | exec_instructions(ectx_T *ectx)
{
int ret = FAIL;
int save_trylevel_at_start = ectx->ec_trylevel_at_start;
int dict_stack_len_at_start = dict_stack.ga_len;
// Start execution at the first instruction.
ectx->ec_iidx = 0;
// Only catch exceptions in this instruction list.
ectx->ec_trylevel_at_start = trylevel;
for (;;)
{
static int breakcheck_count = 0; // using "static" makes it faster
isn_T *iptr;
typval_T *tv;
if (unlikely(++breakcheck_count >= 100))
{
line_breakcheck();
breakcheck_count = 0;
}
if (unlikely(got_int))
{
// Turn CTRL-C into an exception.
got_int = FALSE;
if (throw_exception("Vim:Interrupt", ET_INTERRUPT, NULL) == FAIL)
goto theend;
did_throw = TRUE;
}
if (unlikely(did_emsg && msg_list != NULL && *msg_list != NULL))
{
// Turn an error message into an exception.
did_emsg = FALSE;
if (throw_exception(*msg_list, ET_ERROR, NULL) == FAIL)
goto theend;
did_throw = TRUE;
*msg_list = NULL;
}
if (unlikely(did_throw))
{
garray_T *trystack = &ectx->ec_trystack;
trycmd_T *trycmd = NULL;
int index = trystack->ga_len;
// An exception jumps to the first catch, finally, or returns from
// the current function.
while (index > 0)
{
trycmd = ((trycmd_T *)trystack->ga_data) + index - 1;
if (!trycmd->tcd_in_catch || trycmd->tcd_finally_idx != 0)
break;
// In the catch and finally block of this try we have to go up
// one level.
--index;
trycmd = NULL;
}
if (trycmd != NULL && trycmd->tcd_frame_idx == ectx->ec_frame_idx)
{
if (trycmd->tcd_in_catch)
{
// exception inside ":catch", jump to ":finally" once
ectx->ec_iidx = trycmd->tcd_finally_idx;
trycmd->tcd_finally_idx = 0;
}
else
// jump to first ":catch"
ectx->ec_iidx = trycmd->tcd_catch_idx;
trycmd->tcd_in_catch = TRUE;
did_throw = FALSE; // don't come back here until :endtry
trycmd->tcd_did_throw = TRUE;
}
else
{
// Not inside try or need to return from current functions.
// Push a dummy return value.
if (GA_GROW_FAILS(&ectx->ec_stack, 1))
goto theend;
tv = STACK_TV_BOT(0);
tv->v_type = VAR_NUMBER;
tv->vval.v_number = 0;
++ectx->ec_stack.ga_len;
if (ectx->ec_frame_idx == ectx->ec_initial_frame_idx)
{
// At the toplevel we are done.
need_rethrow = TRUE;
if (handle_closure_in_use(ectx, FALSE) == FAIL)
goto theend;
goto done;
}
if (func_return(ectx) == FAIL)
goto theend;
}
continue;
}
iptr = &ectx->ec_instr[ectx->ec_iidx++];
switch (iptr->isn_type)
{
// execute Ex command line
case ISN_EXEC:
if (exec_command(iptr) == FAIL)
goto on_error;
break;
// execute Ex command line split at NL characters.
case ISN_EXEC_SPLIT:
{
source_cookie_T cookie;
char_u *line;
SOURCING_LNUM = iptr->isn_lnum;
CLEAR_FIELD(cookie);
cookie.sourcing_lnum = iptr->isn_lnum - 1;
cookie.nextline = iptr->isn_arg.string;
line = get_split_sourceline(0, &cookie, 0, 0);
if (do_cmdline(line,
get_split_sourceline, &cookie,
DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_KEYTYPED)
== FAIL
|| did_emsg)
{
vim_free(line);
goto on_error;
}
vim_free(line);
}
break;
// execute Ex command line that is only a range
case ISN_EXECRANGE:
{
exarg_T ea;
char *error = NULL;
CLEAR_FIELD(ea);
ea.cmdidx = CMD_SIZE;
ea.addr_type = ADDR_LINES;
ea.cmd = iptr->isn_arg.string;
parse_cmd_address(&ea, &error, FALSE);
if (ea.cmd == NULL)
goto on_error;
if (error == NULL)
error = ex_range_without_command(&ea);
if (error != NULL)
{
SOURCING_LNUM = iptr->isn_lnum;
emsg(error);
goto on_error;
}
}
break;
// Evaluate an expression with legacy syntax, push it onto the
// stack.
case ISN_LEGACY_EVAL:
{
char_u *arg = iptr->isn_arg.string;
int res;
int save_flags = cmdmod.cmod_flags;
if (GA_GROW_FAILS(&ectx->ec_stack, 1))
goto theend;
tv = STACK_TV_BOT(0);
init_tv(tv);
cmdmod.cmod_flags |= CMOD_LEGACY;
res = eval0(arg, tv, NULL, &EVALARG_EVALUATE);
cmdmod.cmod_flags = save_flags;
if (res == FAIL)
goto on_error;
++ectx->ec_stack.ga_len;
}
break;
// push typeval VAR_INSTR with instructions to be executed
case ISN_INSTR:
{
if (GA_GROW_FAILS(&ectx->ec_stack, 1))
goto theend;
tv = STACK_TV_BOT(0);
tv->vval.v_instr = ALLOC_ONE(instr_T);
if (tv->vval.v_instr == NULL)
goto on_error;
++ectx->ec_stack.ga_len;
tv->v_type = VAR_INSTR;
tv->vval.v_instr->instr_ectx = ectx;
tv->vval.v_instr->instr_instr = iptr->isn_arg.instr;
}
break;
// execute :substitute with an expression
case ISN_SUBSTITUTE:
{
subs_T *subs = &iptr->isn_arg.subs;
source_cookie_T cookie;
struct subs_expr_S *save_instr = substitute_instr;
struct subs_expr_S subs_instr;
int res;
subs_instr.subs_ectx = ectx;
subs_instr.subs_instr = subs->subs_instr;
subs_instr.subs_status = OK;
substitute_instr = &subs_instr;
SOURCING_LNUM = iptr->isn_lnum;
// This is very much like ISN_EXEC
CLEAR_FIELD(cookie);
cookie.sourcing_lnum = iptr->isn_lnum - 1;
res = do_cmdline(subs->subs_cmd,
getsourceline, &cookie,
DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_KEYTYPED);
substitute_instr = save_instr;
if (res == FAIL || did_emsg
|| subs_instr.subs_status == FAIL)
goto on_error;
}
break;
case ISN_FINISH:
goto done;
case ISN_REDIRSTART:
// create a dummy entry for var_redir_str()
if (alloc_redir_lval() == FAIL)
goto on_error;
// The output is stored in growarray "redir_ga" until
// redirection ends.
init_redir_ga();
redir_vname = 1;
break;
case ISN_REDIREND:
{
char_u *res = get_clear_redir_ga();
// End redirection, put redirected text on the stack.
clear_redir_lval();
redir_vname = 0;
if (GA_GROW_FAILS(&ectx->ec_stack, 1))
{
vim_free(res);
goto theend;
}
tv = STACK_TV_BOT(0);
tv->v_type = VAR_STRING;
tv->vval.v_string = res;
++ectx->ec_stack.ga_len;
}
break;
case ISN_CEXPR_AUCMD:
#ifdef FEAT_QUICKFIX
if (trigger_cexpr_autocmd(iptr->isn_arg.number) == FAIL)
goto on_error;
#endif
break;
case ISN_CEXPR_CORE:
#ifdef FEAT_QUICKFIX
{
exarg_T ea;
int res;
CLEAR_FIELD(ea);
ea.cmdidx = iptr->isn_arg.cexpr.cexpr_ref->cer_cmdidx;
ea.forceit = iptr->isn_arg.cexpr.cexpr_ref->cer_forceit;
ea.cmdlinep = &iptr->isn_arg.cexpr.cexpr_ref->cer_cmdline;
--ectx->ec_stack.ga_len;
tv = STACK_TV_BOT(0);
res = cexpr_core(&ea, tv);
clear_tv(tv);
if (res == FAIL)
goto on_error;
}
#endif
break;
// execute Ex command from pieces on the stack
case ISN_EXECCONCAT:
{
int count = iptr->isn_arg.number;
size_t len = 0;
int pass;
int i;
char_u *cmd = NULL;
char_u *str;
for (pass = 1; pass <= 2; ++pass)
{
for (i = 0; i < count; ++i)
{
tv = STACK_TV_BOT(i - count);
str = tv->vval.v_string;
if (str != NULL && *str != NUL)
{
if (pass == 2)
STRCPY(cmd + len, str);
len += STRLEN(str);
}
if (pass == 2)
clear_tv(tv);
}
if (pass == 1)
{
cmd = alloc(len + 1);
if (unlikely(cmd == NULL))
goto theend;
len = 0;
}
}
SOURCING_LNUM = iptr->isn_lnum;
do_cmdline_cmd(cmd);
vim_free(cmd);
}
break;
// execute :echo {string} ...
case ISN_ECHO:
{
int count = iptr->isn_arg.echo.echo_count;
int atstart = TRUE;
int needclr = TRUE;
int idx;
for (idx = 0; idx < count; ++idx)
{
tv = STACK_TV_BOT(idx - count);
echo_one(tv, iptr->isn_arg.echo.echo_with_white,
&atstart, &needclr);
clear_tv(tv);
}
if (needclr)
msg_clr_eos();
ectx->ec_stack.ga_len -= count;
}
break;
// :execute {string} ...
// :echomsg {string} ...
// :echoconsole {string} ...
// :echoerr {string} ...
case ISN_EXECUTE:
case ISN_ECHOMSG:
case ISN_ECHOCONSOLE:
case ISN_ECHOERR:
{
int count = iptr->isn_arg.number;
garray_T ga;
char_u buf[NUMBUFLEN];
char_u *p;
int len;
int failed = FALSE;
int idx;
ga_init2(&ga, 1, 80);
for (idx = 0; idx < count; ++idx)
{
tv = STACK_TV_BOT(idx - count);
if (iptr->isn_type == ISN_EXECUTE)
{
if (tv->v_type == VAR_CHANNEL
|| tv->v_type == VAR_JOB)
{
SOURCING_LNUM = iptr->isn_lnum;
semsg(_(e_using_invalid_value_as_string_str),
vartype_name(tv->v_type));
break;
}
else
p = tv_get_string_buf(tv, buf);
}
else
p = tv_stringify(tv, buf);
len = (int)STRLEN(p);
if (GA_GROW_FAILS(&ga, len + 2))
failed = TRUE;
else
{
if (ga.ga_len > 0)
((char_u *)(ga.ga_data))[ga.ga_len++] = ' ';
STRCPY((char_u *)(ga.ga_data) + ga.ga_len, p);
ga.ga_len += len;
}
clear_tv(tv);
}
ectx->ec_stack.ga_len -= count;
if (failed)
{
ga_clear(&ga);
goto on_error;
}
if (ga.ga_data != NULL)
{
if (iptr->isn_type == ISN_EXECUTE)
{
SOURCING_LNUM = iptr->isn_lnum;
do_cmdline_cmd((char_u *)ga.ga_data);
if (did_emsg)
{
ga_clear(&ga);
goto on_error;
}
}
else
{
msg_sb_eol();
if (iptr->isn_type == ISN_ECHOMSG)
{
msg_attr(ga.ga_data, echo_attr);
out_flush();
}
else if (iptr->isn_type == ISN_ECHOCONSOLE)
{
ui_write(ga.ga_data, (int)STRLEN(ga.ga_data),
TRUE);
ui_write((char_u *)"\r\n", 2, TRUE);
}
else
{
SOURCING_LNUM = iptr->isn_lnum;
emsg(ga.ga_data);
}
}
}
ga_clear(&ga);
}
break;
// load local variable or argument
case ISN_LOAD:
if (GA_GROW_FAILS(&ectx->ec_stack, 1))
goto theend;
copy_tv(STACK_TV_VAR(iptr->isn_arg.number), STACK_TV_BOT(0));
++ectx->ec_stack.ga_len;
break;
// load v: variable
case ISN_LOADV:
if (GA_GROW_FAILS(&ectx->ec_stack, 1))
goto theend;
copy_tv(get_vim_var_tv(iptr->isn_arg.number), STACK_TV_BOT(0));
++ectx->ec_stack.ga_len;
break;
// load s: variable in Vim9 script
case ISN_LOADSCRIPT:
{
scriptref_T *sref = iptr->isn_arg.script.scriptref;
svar_T *sv;
sv = get_script_svar(sref, ectx->ec_dfunc_idx);
if (sv == NULL)
goto theend;
allocate_if_null(sv->sv_tv);
if (GA_GROW_FAILS(&ectx->ec_stack, 1))
goto theend;
copy_tv(sv->sv_tv, STACK_TV_BOT(0));
++ectx->ec_stack.ga_len;
}
break;
// load s: variable in old script
case ISN_LOADS:
{
hashtab_T *ht = &SCRIPT_VARS(
iptr->isn_arg.loadstore.ls_sid);
char_u *name = iptr->isn_arg.loadstore.ls_name;
dictitem_T *di = find_var_in_ht(ht, 0, name, TRUE);
if (di == NULL)
{
SOURCING_LNUM = iptr->isn_lnum;
semsg(_(e_undefined_variable_str), name);
goto on_error;
}
else
{
if (GA_GROW_FAILS(&ectx->ec_stack, 1))
goto theend;
copy_tv(&di->di_tv, STACK_TV_BOT(0));
++ectx->ec_stack.ga_len;
}
}
break;
// load g:/b:/w:/t: variable
case ISN_LOADG:
case ISN_LOADB:
case ISN_LOADW:
case ISN_LOADT:
{
dictitem_T *di = NULL;
hashtab_T *ht = NULL;
char namespace;
switch (iptr->isn_type)
{
case ISN_LOADG:
ht = get_globvar_ht();
namespace = 'g';
break;
case ISN_LOADB:
ht = &curbuf->b_vars->dv_hashtab;
namespace = 'b';
break;
case ISN_LOADW:
ht = &curwin->w_vars->dv_hashtab;
namespace = 'w';
break;
case ISN_LOADT:
ht = &curtab->tp_vars->dv_hashtab;
namespace = 't';
break;
default: // Cannot reach here
goto theend;
}
di = find_var_in_ht(ht, 0, iptr->isn_arg.string, TRUE);
if (di == NULL)
{
SOURCING_LNUM = iptr->isn_lnum;
semsg(_(e_undefined_variable_char_str),
namespace, iptr->isn_arg.string);
goto on_error;
}
else
{
if (GA_GROW_FAILS(&ectx->ec_stack, 1))
goto theend;
copy_tv(&di->di_tv, STACK_TV_BOT(0));
++ectx->ec_stack.ga_len;
}
}
break;
// load autoload variable
case ISN_LOADAUTO:
{
char_u *name = iptr->isn_arg.string;
if (GA_GROW_FAILS(&ectx->ec_stack, 1))
goto theend;
SOURCING_LNUM = iptr->isn_lnum;
if (eval_variable(name, (int)STRLEN(name),
STACK_TV_BOT(0), NULL, EVAL_VAR_VERBOSE) == FAIL)
goto on_error;
++ectx->ec_stack.ga_len;
}
break;
// load g:/b:/w:/t: namespace
case ISN_LOADGDICT:
case ISN_LOADBDICT:
case ISN_LOADWDICT:
case ISN_LOADTDICT:
{
dict_T *d = NULL;
switch (iptr->isn_type)
{
case ISN_LOADGDICT: d = get_globvar_dict(); break;
case ISN_LOADBDICT: d = curbuf->b_vars; break;
case ISN_LOADWDICT: d = curwin->w_vars; break;
case ISN_LOADTDICT: d = curtab->tp_vars; break;
default: // Cannot reach here
goto theend;
}
if (GA_GROW_FAILS(&ectx->ec_stack, 1))
goto theend;
tv = STACK_TV_BOT(0);
tv->v_type = VAR_DICT;
tv->v_lock = 0;
tv->vval.v_dict = d;
++d->dv_refcount;
++ectx->ec_stack.ga_len;
}
break;
// load &option
case ISN_LOADOPT:
{
typval_T optval;
char_u *name = iptr->isn_arg.string;
// This is not expected to fail, name is checked during
// compilation: don't set SOURCING_LNUM.
if (GA_GROW_FAILS(&ectx->ec_stack, 1))
goto theend;
if (eval_option(&name, &optval, TRUE) == FAIL)
goto theend;
*STACK_TV_BOT(0) = optval;
++ectx->ec_stack.ga_len;
}
break;
// load $ENV
case ISN_LOADENV:
{
typval_T optval;
char_u *name = iptr->isn_arg.string;
if (GA_GROW_FAILS(&ectx->ec_stack, 1))
goto theend;
// name is always valid, checked when compiling
(void)eval_env_var(&name, &optval, TRUE);
*STACK_TV_BOT(0) = optval;
++ectx->ec_stack.ga_len;
}
break;
// load @register
case ISN_LOADREG:
if (GA_GROW_FAILS(&ectx->ec_stack, 1))
goto theend;
tv = STACK_TV_BOT(0);
tv->v_type = VAR_STRING;
tv->v_lock = 0;
// This may result in NULL, which should be equivalent to an
// empty string.
tv->vval.v_string = get_reg_contents(
iptr->isn_arg.number, GREG_EXPR_SRC);
++ectx->ec_stack.ga_len;
break;
// store local variable
case ISN_STORE:
--ectx->ec_stack.ga_len;
tv = STACK_TV_VAR(iptr->isn_arg.number);
clear_tv(tv);
*tv = *STACK_TV_BOT(0);
break;
// store s: variable in old script
case ISN_STORES:
{
hashtab_T *ht = &SCRIPT_VARS(
iptr->isn_arg.loadstore.ls_sid);
char_u *name = iptr->isn_arg.loadstore.ls_name;
dictitem_T *di = find_var_in_ht(ht, 0, name + 2, TRUE);
--ectx->ec_stack.ga_len;
if (di == NULL)
store_var(name, STACK_TV_BOT(0));
else
{
SOURCING_LNUM = iptr->isn_lnum;
if (var_check_permission(di, name) == FAIL)
{
clear_tv(STACK_TV_BOT(0));
goto on_error;
}
clear_tv(&di->di_tv);
di->di_tv = *STACK_TV_BOT(0);
}
}
break;
// store script-local variable in Vim9 script
case ISN_STORESCRIPT:
{
scriptref_T *sref = iptr->isn_arg.script.scriptref;
svar_T *sv;
sv = get_script_svar(sref, ectx->ec_dfunc_idx);
if (sv == NULL)
goto theend;
--ectx->ec_stack.ga_len;
// "const" and "final" are checked at compile time, locking
// the value needs to be checked here.
SOURCING_LNUM = iptr->isn_lnum;
if (value_check_lock(sv->sv_tv->v_lock, sv->sv_name, FALSE))
{
clear_tv(STACK_TV_BOT(0));
goto on_error;
}
clear_tv(sv->sv_tv);
*sv->sv_tv = *STACK_TV_BOT(0);
}
break;
// store option
case ISN_STOREOPT:
case ISN_STOREFUNCOPT:
{
char_u *opt_name = iptr->isn_arg.storeopt.so_name;
int opt_flags = iptr->isn_arg.storeopt.so_flags;
long n = 0;
char_u *s = NULL;
char *msg;
char_u numbuf[NUMBUFLEN];
char_u *tofree = NULL;
--ectx->ec_stack.ga_len;
tv = STACK_TV_BOT(0);
if (tv->v_type == VAR_STRING)
{
s = tv->vval.v_string;
if (s == NULL)
s = (char_u *)"";
}
else if (iptr->isn_type == ISN_STOREFUNCOPT)
{
SOURCING_LNUM = iptr->isn_lnum;
// If the option can be set to a function reference or
// a lambda and the passed value is a function
// reference, then convert it to the name (string) of
// the function reference.
s = tv2string(tv, &tofree, numbuf, 0);
if (s == NULL || *s == NUL)
{
clear_tv(tv);
goto on_error;
}
}
else
// must be VAR_NUMBER, CHECKTYPE makes sure
n = tv->vval.v_number;
msg = set_option_value(opt_name, n, s, opt_flags);
clear_tv(tv);
vim_free(tofree);
if (msg != NULL)
{
SOURCING_LNUM = iptr->isn_lnum;
emsg(_(msg));
goto on_error;
}
}
break;
// store $ENV
case ISN_STOREENV:
--ectx->ec_stack.ga_len;
tv = STACK_TV_BOT(0);
vim_setenv_ext(iptr->isn_arg.string, tv_get_string(tv));
clear_tv(tv);
break;
// store @r
case ISN_STOREREG:
{
int reg = iptr->isn_arg.number;
--ectx->ec_stack.ga_len;
tv = STACK_TV_BOT(0);
write_reg_contents(reg, tv_get_string(tv), -1, FALSE);
clear_tv(tv);
}
break;
// store v: variable
case ISN_STOREV:
--ectx->ec_stack.ga_len;
if (set_vim_var_tv(iptr->isn_arg.number, STACK_TV_BOT(0))
== FAIL)
// should not happen, type is checked when compiling
goto on_error;
break;
// store g:/b:/w:/t: variable
case ISN_STOREG:
case ISN_STOREB:
case ISN_STOREW:
case ISN_STORET:
{
dictitem_T *di;
hashtab_T *ht;
char_u *name = iptr->isn_arg.string + 2;
switch (iptr->isn_type)
{
case ISN_STOREG:
ht = get_globvar_ht();
break;
case ISN_STOREB:
ht = &curbuf->b_vars->dv_hashtab;
break;
case ISN_STOREW:
ht = &curwin->w_vars->dv_hashtab;
break;
case ISN_STORET:
ht = &curtab->tp_vars->dv_hashtab;
break;
default: // Cannot reach here
goto theend;
}
--ectx->ec_stack.ga_len;
di = find_var_in_ht(ht, 0, name, TRUE);
if (di == NULL)
store_var(iptr->isn_arg.string, STACK_TV_BOT(0));
else
{
SOURCING_LNUM = iptr->isn_lnum;
if (var_check_permission(di, name) == FAIL)
goto on_error;
clear_tv(&di->di_tv);
di->di_tv = *STACK_TV_BOT(0);
}
}
break;
// store an autoload variable
case ISN_STOREAUTO:
SOURCING_LNUM = iptr->isn_lnum;
set_var(iptr->isn_arg.string, STACK_TV_BOT(-1), TRUE);
clear_tv(STACK_TV_BOT(-1));
--ectx->ec_stack.ga_len;
break;
// store number in local variable
case ISN_STORENR:
tv = STACK_TV_VAR(iptr->isn_arg.storenr.stnr_idx);
clear_tv(tv);
tv->v_type = VAR_NUMBER;
tv->vval.v_number = iptr->isn_arg.storenr.stnr_val;
break;
// store value in list or dict variable
case ISN_STOREINDEX:
{
vartype_T dest_type = iptr->isn_arg.vartype;
typval_T *tv_idx = STACK_TV_BOT(-2);
typval_T *tv_dest = STACK_TV_BOT(-1);
int status = OK;
// Stack contains:
// -3 value to be stored
// -2 index
// -1 dict or list
tv = STACK_TV_BOT(-3);
SOURCING_LNUM = iptr->isn_lnum;
if (dest_type == VAR_ANY)
{
dest_type = tv_dest->v_type;
if (dest_type == VAR_DICT)
status = do_2string(tv_idx, TRUE, FALSE);
else if (dest_type == VAR_LIST
&& tv_idx->v_type != VAR_NUMBER)
{
emsg(_(e_number_expected));
status = FAIL;
}
}
else if (dest_type != tv_dest->v_type)
{
// just in case, should be OK
semsg(_(e_expected_str_but_got_str),
vartype_name(dest_type),
vartype_name(tv_dest->v_type));
status = FAIL;
}
if (status == OK && dest_type == VAR_LIST)
{
long lidx = (long)tv_idx->vval.v_number;
list_T *list = tv_dest->vval.v_list;
if (list == NULL)
{
emsg(_(e_list_not_set));
goto on_error;
}
if (lidx < 0 && list->lv_len + lidx >= 0)
// negative index is relative to the end
lidx = list->lv_len + lidx;
if (lidx < 0 || lidx > list->lv_len)
{
semsg(_(e_listidx), lidx);
goto on_error;
}
if (lidx < list->lv_len)
{
listitem_T *li = list_find(list, lidx);
if (error_if_locked(li->li_tv.v_lock,
e_cannot_change_list_item))
goto on_error;
// overwrite existing list item
clear_tv(&li->li_tv);
li->li_tv = *tv;
}
else
{
if (error_if_locked(list->lv_lock,
e_cannot_change_list))
goto on_error;
// append to list, only fails when out of memory
if (list_append_tv(list, tv) == FAIL)
goto theend;
clear_tv(tv);
}
}
else if (status == OK && dest_type == VAR_DICT)
{
char_u *key = tv_idx->vval.v_string;
dict_T *dict = tv_dest->vval.v_dict;
dictitem_T *di;
SOURCING_LNUM = iptr->isn_lnum;
if (dict == NULL)
{
emsg(_(e_dictionary_not_set));
goto on_error;
}
if (key == NULL)
key = (char_u *)"";
di = dict_find(dict, key, -1);
if (di != NULL)
{
if (error_if_locked(di->di_tv.v_lock,
e_cannot_change_dict_item))
goto on_error;
// overwrite existing value
clear_tv(&di->di_tv);
di->di_tv = *tv;
}
else
{
if (error_if_locked(dict->dv_lock,
e_cannot_change_dict))
goto on_error;
// add to dict, only fails when out of memory
if (dict_add_tv(dict, (char *)key, tv) == FAIL)
goto theend;
clear_tv(tv);
}
}
else if (status == OK && dest_type == VAR_BLOB)
{
long lidx = (long)tv_idx->vval.v_number;
blob_T *blob = tv_dest->vval.v_blob;
varnumber_T nr;
int error = FALSE;
int len;
if (blob == NULL)
{
emsg(_(e_blob_not_set));
goto on_error;
}
len = blob_len(blob);
if (lidx < 0 && len + lidx >= 0)
// negative index is relative to the end
lidx = len + lidx;
// Can add one byte at the end.
if (lidx < 0 || lidx > len)
{
semsg(_(e_blobidx), lidx);
goto on_error;
}
if (value_check_lock(blob->bv_lock,
(char_u *)"blob", FALSE))
goto on_error;
nr = tv_get_number_chk(tv, &error);
if (error)
goto on_error;
blob_set_append(blob, lidx, nr);
}
else
{
status = FAIL;
semsg(_(e_cannot_index_str), vartype_name(dest_type));
}
clear_tv(tv_idx);
clear_tv(tv_dest);
ectx->ec_stack.ga_len -= 3;
if (status == FAIL)
{
clear_tv(tv);
goto on_error;
}
}
break;
// store value in blob range
case ISN_STORERANGE:
{
typval_T *tv_idx1 = STACK_TV_BOT(-3);
typval_T *tv_idx2 = STACK_TV_BOT(-2);
typval_T *tv_dest = STACK_TV_BOT(-1);
int status = OK;
// Stack contains:
// -4 value to be stored
// -3 first index or "none"
// -2 second index or "none"
// -1 destination list or blob
tv = STACK_TV_BOT(-4);
if (tv_dest->v_type == VAR_LIST)
{
long n1;
long n2;
int error = FALSE;
SOURCING_LNUM = iptr->isn_lnum;
n1 = (long)tv_get_number_chk(tv_idx1, &error);
if (error)
status = FAIL;
else
{
if (tv_idx2->v_type == VAR_SPECIAL
&& tv_idx2->vval.v_number == VVAL_NONE)
n2 = list_len(tv_dest->vval.v_list) - 1;
else
n2 = (long)tv_get_number_chk(tv_idx2, &error);
if (error)
status = FAIL;
else
{
listitem_T *li1 = check_range_index_one(
tv_dest->vval.v_list, &n1, FALSE);
if (li1 == NULL)
status = FAIL;
else
{
status = check_range_index_two(
tv_dest->vval.v_list,
&n1, li1, &n2, FALSE);
if (status != FAIL)
status = list_assign_range(
tv_dest->vval.v_list,
tv->vval.v_list,
n1,
n2,
tv_idx2->v_type == VAR_SPECIAL,
(char_u *)"=",
(char_u *)"[unknown]");
}
}
}
}
else if (tv_dest->v_type == VAR_BLOB)
{
varnumber_T n1;
varnumber_T n2;
int error = FALSE;
n1 = tv_get_number_chk(tv_idx1, &error);
if (error)
status = FAIL;
else
{
if (tv_idx2->v_type == VAR_SPECIAL
&& tv_idx2->vval.v_number == VVAL_NONE)
n2 = blob_len(tv_dest->vval.v_blob) - 1;
else
n2 = tv_get_number_chk(tv_idx2, &error);
if (error)
status = FAIL;
else
{
long bloblen = blob_len(tv_dest->vval.v_blob);
if (check_blob_index(bloblen,
n1, FALSE) == FAIL
|| check_blob_range(bloblen,
n1, n2, FALSE) == FAIL)
status = FAIL;
else
status = blob_set_range(
tv_dest->vval.v_blob, n1, n2, tv);
}
}
}
else
{
status = FAIL;
emsg(_(e_blob_required));
}
clear_tv(tv_idx1);
clear_tv(tv_idx2);
clear_tv(tv_dest);
ectx->ec_stack.ga_len -= 4;
clear_tv(tv);
if (status == FAIL)
goto on_error;
}
break;
// load or store variable or argument from outer scope
case ISN_LOADOUTER:
case ISN_STOREOUTER:
{
int depth = iptr->isn_arg.outer.outer_depth;
outer_T *outer = ectx->ec_outer_ref == NULL ? NULL
: ectx->ec_outer_ref->or_outer;
while (depth > 1 && outer != NULL)
{
outer = outer->out_up;
--depth;
}
if (outer == NULL)
{
SOURCING_LNUM = iptr->isn_lnum;
if (ectx->ec_frame_idx == ectx->ec_initial_frame_idx
|| ectx->ec_outer_ref == NULL)
// Possibly :def function called from legacy
// context.
emsg(_(e_closure_called_from_invalid_context));
else
iemsg("LOADOUTER depth more than scope levels");
goto theend;
}
tv = ((typval_T *)outer->out_stack->ga_data)
+ outer->out_frame_idx + STACK_FRAME_SIZE
+ iptr->isn_arg.outer.outer_idx;
if (iptr->isn_type == ISN_LOADOUTER)
{
if (GA_GROW_FAILS(&ectx->ec_stack, 1))
goto theend;
copy_tv(tv, STACK_TV_BOT(0));
++ectx->ec_stack.ga_len;
}
else
{
--ectx->ec_stack.ga_len;
clear_tv(tv);
*tv = *STACK_TV_BOT(0);
}
}
break;
// unlet item in list or dict variable
case ISN_UNLETINDEX:
{
typval_T *tv_idx = STACK_TV_BOT(-2);
typval_T *tv_dest = STACK_TV_BOT(-1);
int status = OK;
// Stack contains:
// -2 index
// -1 dict or list
if (tv_dest->v_type == VAR_DICT)
{
// unlet a dict item, index must be a string
if (tv_idx->v_type != VAR_STRING)
{
SOURCING_LNUM = iptr->isn_lnum;
semsg(_(e_expected_str_but_got_str),
vartype_name(VAR_STRING),
vartype_name(tv_idx->v_type));
status = FAIL;
}
else
{
dict_T *d = tv_dest->vval.v_dict;
char_u *key = tv_idx->vval.v_string;
dictitem_T *di = NULL;
if (d != NULL && value_check_lock(
d->dv_lock, NULL, FALSE))
status = FAIL;
else
{
SOURCING_LNUM = iptr->isn_lnum;
if (key == NULL)
key = (char_u *)"";
if (d != NULL)
di = dict_find(d, key, (int)STRLEN(key));
if (di == NULL)
{
// NULL dict is equivalent to empty dict
semsg(_(e_dictkey), key);
status = FAIL;
}
else if (var_check_fixed(di->di_flags,
NULL, FALSE)
|| var_check_ro(di->di_flags,
NULL, FALSE))
status = FAIL;
else
dictitem_remove(d, di);
}
}
}
else if (tv_dest->v_type == VAR_LIST)
{
// unlet a List item, index must be a number
SOURCING_LNUM = iptr->isn_lnum;
if (check_for_number(tv_idx) == FAIL)
{
status = FAIL;
}
else
{
list_T *l = tv_dest->vval.v_list;
long n = (long)tv_idx->vval.v_number;
if (l != NULL && value_check_lock(
l->lv_lock, NULL, FALSE))
status = FAIL;
else
{
listitem_T *li = list_find(l, n);
if (li == NULL)
{
SOURCING_LNUM = iptr->isn_lnum;
semsg(_(e_listidx), n);
status = FAIL;
}
else if (value_check_lock(li->li_tv.v_lock,
NULL, FALSE))
status = FAIL;
else
listitem_remove(l, li);
}
}
}
else
{
status = FAIL;
semsg(_(e_cannot_index_str),
vartype_name(tv_dest->v_type));
}
clear_tv(tv_idx);
clear_tv(tv_dest);
ectx->ec_stack.ga_len -= 2;
if (status == FAIL)
goto on_error;
}
break;
// unlet range of items in list variable
case ISN_UNLETRANGE:
{
// Stack contains:
// -3 index1
// -2 index2
// -1 dict or list
typval_T *tv_idx1 = STACK_TV_BOT(-3);
typval_T *tv_idx2 = STACK_TV_BOT(-2);
typval_T *tv_dest = STACK_TV_BOT(-1);
int status = OK;
if (tv_dest->v_type == VAR_LIST)
{
// indexes must be a number
SOURCING_LNUM = iptr->isn_lnum;
if (check_for_number(tv_idx1) == FAIL
|| (tv_idx2->v_type != VAR_SPECIAL
&& check_for_number(tv_idx2) == FAIL))
{
status = FAIL;
}
else
{
list_T *l = tv_dest->vval.v_list;
long n1 = (long)tv_idx1->vval.v_number;
long n2 = tv_idx2->v_type == VAR_SPECIAL
? 0 : (long)tv_idx2->vval.v_number;
listitem_T *li;
li = list_find_index(l, &n1);
if (li == NULL)
status = FAIL;
else
{
if (n1 < 0)
n1 = list_idx_of_item(l, li);
if (n2 < 0)
{
listitem_T *li2 = list_find(l, n2);
if (li2 == NULL)
status = FAIL;
else
n2 = list_idx_of_item(l, li2);
}
if (status != FAIL
&& tv_idx2->v_type != VAR_SPECIAL
&& n2 < n1)
{
semsg(_(e_listidx), n2);
status = FAIL;
}
if (status != FAIL
&& list_unlet_range(l, li, NULL, n1,
tv_idx2->v_type != VAR_SPECIAL, n2)
== FAIL)
status = FAIL;
}
}
}
else
{
status = FAIL;
SOURCING_LNUM = iptr->isn_lnum;
semsg(_(e_cannot_index_str),
vartype_name(tv_dest->v_type));
}
clear_tv(tv_idx1);
clear_tv(tv_idx2);
clear_tv(tv_dest);
ectx->ec_stack.ga_len -= 3;
if (status == FAIL)
goto on_error;
}
break;
// push constant
case ISN_PUSHNR:
case ISN_PUSHBOOL:
case ISN_PUSHSPEC:
case ISN_PUSHF:
case ISN_PUSHS:
case ISN_PUSHBLOB:
case ISN_PUSHFUNC:
case ISN_PUSHCHANNEL:
case ISN_PUSHJOB:
if (GA_GROW_FAILS(&ectx->ec_stack, 1))
goto theend;
tv = STACK_TV_BOT(0);
tv->v_lock = 0;
++ectx->ec_stack.ga_len;
switch (iptr->isn_type)
{
case ISN_PUSHNR:
tv->v_type = VAR_NUMBER;
tv->vval.v_number = iptr->isn_arg.number;
break;
case ISN_PUSHBOOL:
tv->v_type = VAR_BOOL;
tv->vval.v_number = iptr->isn_arg.number;
break;
case ISN_PUSHSPEC:
tv->v_type = VAR_SPECIAL;
tv->vval.v_number = iptr->isn_arg.number;
break;
#ifdef FEAT_FLOAT
case ISN_PUSHF:
tv->v_type = VAR_FLOAT;
tv->vval.v_float = iptr->isn_arg.fnumber;
break;
#endif
case ISN_PUSHBLOB:
blob_copy(iptr->isn_arg.blob, tv);
break;
case ISN_PUSHFUNC:
tv->v_type = VAR_FUNC;
if (iptr->isn_arg.string == NULL)
tv->vval.v_string = NULL;
else
tv->vval.v_string =
vim_strsave(iptr->isn_arg.string);
break;
case ISN_PUSHCHANNEL:
#ifdef FEAT_JOB_CHANNEL
tv->v_type = VAR_CHANNEL;
tv->vval.v_channel = iptr->isn_arg.channel;
if (tv->vval.v_channel != NULL)
++tv->vval.v_channel->ch_refcount;
#endif
break;
case ISN_PUSHJOB:
#ifdef FEAT_JOB_CHANNEL
tv->v_type = VAR_JOB;
tv->vval.v_job = iptr->isn_arg.job;
if (tv->vval.v_job != NULL)
++tv->vval.v_job->jv_refcount;
#endif
break;
default:
tv->v_type = VAR_STRING;
tv->vval.v_string = vim_strsave(
iptr->isn_arg.string == NULL
? (char_u *)"" : iptr->isn_arg.string);
}
break;
case ISN_UNLET:
if (do_unlet(iptr->isn_arg.unlet.ul_name,
iptr->isn_arg.unlet.ul_forceit) == FAIL)
goto on_error;
break;
case ISN_UNLETENV:
vim_unsetenv(iptr->isn_arg.unlet.ul_name);
break;
case ISN_LOCKUNLOCK:
{
typval_T *lval_root_save = lval_root;
int res;
// Stack has the local variable, argument the whole :lock
// or :unlock command, like ISN_EXEC.
--ectx->ec_stack.ga_len;
lval_root = STACK_TV_BOT(0);
res = exec_command(iptr);
clear_tv(lval_root);
lval_root = lval_root_save;
if (res == FAIL)
goto on_error;
}
break;
case ISN_LOCKCONST:
item_lock(STACK_TV_BOT(-1), 100, TRUE, TRUE);
break;
// create a list from items on the stack; uses a single allocation
// for the list header and the items
case ISN_NEWLIST:
if (exe_newlist(iptr->isn_arg.number, ectx) == FAIL)
goto theend;
break;
// create a dict from items on the stack
case ISN_NEWDICT:
{
int count = iptr->isn_arg.number;
dict_T *dict = dict_alloc();
dictitem_T *item;
char_u *key;
int idx;
if (unlikely(dict == NULL))
goto theend;
for (idx = 0; idx < count; ++idx)
{
// have already checked key type is VAR_STRING
tv = STACK_TV_BOT(2 * (idx - count));
// check key is unique
key = tv->vval.v_string == NULL
? (char_u *)"" : tv->vval.v_string;
item = dict_find(dict, key, -1);
if (item != NULL)
{
SOURCING_LNUM = iptr->isn_lnum;
semsg(_(e_duplicate_key), key);
dict_unref(dict);
goto on_error;
}
item = dictitem_alloc(key);
clear_tv(tv);
if (unlikely(item == NULL))
{
dict_unref(dict);
goto theend;
}
item->di_tv = *STACK_TV_BOT(2 * (idx - count) + 1);
item->di_tv.v_lock = 0;
if (dict_add(dict, item) == FAIL)
{
// can this ever happen?
dict_unref(dict);
goto theend;
}
}
if (count > 0)
ectx->ec_stack.ga_len -= 2 * count - 1;
else if (GA_GROW_FAILS(&ectx->ec_stack, 1))
goto theend;
else
++ectx->ec_stack.ga_len;
tv = STACK_TV_BOT(-1);
tv->v_type = VAR_DICT;
tv->v_lock = 0;
tv->vval.v_dict = dict;
++dict->dv_refcount;
}
break;
// call a :def function
case ISN_DCALL:
SOURCING_LNUM = iptr->isn_lnum;
if (call_dfunc(iptr->isn_arg.dfunc.cdf_idx,
NULL,
iptr->isn_arg.dfunc.cdf_argcount,
ectx) == FAIL)
goto on_error;
break;
// call a builtin function
case ISN_BCALL:
SOURCING_LNUM = iptr->isn_lnum;
if (call_bfunc(iptr->isn_arg.bfunc.cbf_idx,
iptr->isn_arg.bfunc.cbf_argcount,
ectx) == FAIL)
goto on_error;
break;
// call a funcref or partial
case ISN_PCALL:
{
cpfunc_T *pfunc = &iptr->isn_arg.pfunc;
int r;
typval_T partial_tv;
SOURCING_LNUM = iptr->isn_lnum;
if (pfunc->cpf_top)
{
// funcref is above the arguments
tv = STACK_TV_BOT(-pfunc->cpf_argcount - 1);
}
else
{
// Get the funcref from the stack.
--ectx->ec_stack.ga_len;
partial_tv = *STACK_TV_BOT(0);
tv = &partial_tv;
}
r = call_partial(tv, pfunc->cpf_argcount, ectx);
if (tv == &partial_tv)
clear_tv(&partial_tv);
if (r == FAIL)
goto on_error;
}
break;
case ISN_PCALL_END:
// PCALL finished, arguments have been consumed and replaced by
// the return value. Now clear the funcref from the stack,
// and move the return value in its place.
--ectx->ec_stack.ga_len;
clear_tv(STACK_TV_BOT(-1));
*STACK_TV_BOT(-1) = *STACK_TV_BOT(0);
break;
// call a user defined function or funcref/partial
case ISN_UCALL:
{
cufunc_T *cufunc = &iptr->isn_arg.ufunc;
SOURCING_LNUM = iptr->isn_lnum;
if (call_eval_func(cufunc->cuf_name, cufunc->cuf_argcount,
ectx, iptr) == FAIL)
goto on_error;
}
break;
// return from a :def function call without a value
case ISN_RETURN_VOID:
if (GA_GROW_FAILS(&ectx->ec_stack, 1))
goto theend;
tv = STACK_TV_BOT(0);
++ectx->ec_stack.ga_len;
tv->v_type = VAR_VOID;
tv->vval.v_number = 0;
tv->v_lock = 0;
// FALLTHROUGH
// return from a :def function call with what is on the stack
case ISN_RETURN:
{
garray_T *trystack = &ectx->ec_trystack;
trycmd_T *trycmd = NULL;
if (trystack->ga_len > 0)
trycmd = ((trycmd_T *)trystack->ga_data)
+ trystack->ga_len - 1;
if (trycmd != NULL
&& trycmd->tcd_frame_idx == ectx->ec_frame_idx)
{
// jump to ":finally" or ":endtry"
if (trycmd->tcd_finally_idx != 0)
ectx->ec_iidx = trycmd->tcd_finally_idx;
else
ectx->ec_iidx = trycmd->tcd_endtry_idx;
trycmd->tcd_return = TRUE;
}
else
goto func_return;
}
break;
// push a partial, a reference to a compiled function
case ISN_FUNCREF:
{
partial_T *pt = ALLOC_CLEAR_ONE(partial_T);
ufunc_T *ufunc;
funcref_T *funcref = &iptr->isn_arg.funcref;
if (pt == NULL)
goto theend;
if (GA_GROW_FAILS(&ectx->ec_stack, 1))
{
vim_free(pt);
goto theend;
}
if (funcref->fr_func_name == NULL)
{
dfunc_T *pt_dfunc = ((dfunc_T *)def_functions.ga_data)
+ funcref->fr_dfunc_idx;
ufunc = pt_dfunc->df_ufunc;
}
else
{
ufunc = find_func(funcref->fr_func_name, FALSE, NULL);
}
if (ufunc == NULL)
{
SOURCING_LNUM = iptr->isn_lnum;
emsg(_(e_function_reference_invalid));
goto theend;
}
if (fill_partial_and_closure(pt, ufunc, ectx) == FAIL)
goto theend;
tv = STACK_TV_BOT(0);
++ectx->ec_stack.ga_len;
tv->vval.v_partial = pt;
tv->v_type = VAR_PARTIAL;
tv->v_lock = 0;
}
break;
// Create a global function from a lambda.
case ISN_NEWFUNC:
{
newfunc_T *newfunc = &iptr->isn_arg.newfunc;
if (copy_func(newfunc->nf_lambda, newfunc->nf_global,
ectx) == FAIL)
goto theend;
}
break;
// List functions
case ISN_DEF:
if (iptr->isn_arg.string == NULL)
list_functions(NULL);
else
{
exarg_T ea;
CLEAR_FIELD(ea);
ea.cmd = ea.arg = iptr->isn_arg.string;
define_function(&ea, NULL);
}
break;
// jump if a condition is met
case ISN_JUMP:
{
jumpwhen_T when = iptr->isn_arg.jump.jump_when;
int error = FALSE;
int jump = TRUE;
if (when != JUMP_ALWAYS)
{
tv = STACK_TV_BOT(-1);
if (when == JUMP_IF_COND_FALSE
|| when == JUMP_IF_FALSE
|| when == JUMP_IF_COND_TRUE)
{
SOURCING_LNUM = iptr->isn_lnum;
jump = tv_get_bool_chk(tv, &error);
if (error)
goto on_error;
}
else
jump = tv2bool(tv);
if (when == JUMP_IF_FALSE
|| when == JUMP_AND_KEEP_IF_FALSE
|| when == JUMP_IF_COND_FALSE)
jump = !jump;
if (when == JUMP_IF_FALSE || !jump)
{
// drop the value from the stack
clear_tv(tv);
--ectx->ec_stack.ga_len;
}
}
if (jump)
ectx->ec_iidx = iptr->isn_arg.jump.jump_where;
}
break;
// Jump if an argument with a default value was already set and not
// v:none.
case ISN_JUMP_IF_ARG_SET:
tv = STACK_TV_VAR(iptr->isn_arg.jumparg.jump_arg_off);
if (tv->v_type != VAR_UNKNOWN
&& !(tv->v_type == VAR_SPECIAL
&& tv->vval.v_number == VVAL_NONE))
ectx->ec_iidx = iptr->isn_arg.jumparg.jump_where;
break;
// top of a for loop
case ISN_FOR:
{
typval_T *ltv = STACK_TV_BOT(-1);
typval_T *idxtv =
STACK_TV_VAR(iptr->isn_arg.forloop.for_idx);
if (GA_GROW_FAILS(&ectx->ec_stack, 1))
goto theend;
if (ltv->v_type == VAR_LIST)
{
list_T *list = ltv->vval.v_list;
// push the next item from the list
++idxtv->vval.v_number;
if (list == NULL
|| idxtv->vval.v_number >= list->lv_len)
{
// past the end of the list, jump to "endfor"
ectx->ec_iidx = iptr->isn_arg.forloop.for_end;
may_restore_cmdmod(&ectx->ec_funclocal);
}
else if (list->lv_first == &range_list_item)
{
// non-materialized range() list
tv = STACK_TV_BOT(0);
tv->v_type = VAR_NUMBER;
tv->v_lock = 0;
tv->vval.v_number = list_find_nr(
list, idxtv->vval.v_number, NULL);
++ectx->ec_stack.ga_len;
}
else
{
listitem_T *li = list_find(list,
idxtv->vval.v_number);
copy_tv(&li->li_tv, STACK_TV_BOT(0));
++ectx->ec_stack.ga_len;
}
}
else if (ltv->v_type == VAR_STRING)
{
char_u *str = ltv->vval.v_string;
// The index is for the last byte of the previous
// character.
++idxtv->vval.v_number;
if (str == NULL || str[idxtv->vval.v_number] == NUL)
{
// past the end of the string, jump to "endfor"
ectx->ec_iidx = iptr->isn_arg.forloop.for_end;
may_restore_cmdmod(&ectx->ec_funclocal);
}
else
{
int clen = mb_ptr2len(str + idxtv->vval.v_number);
// Push the next character from the string.
tv = STACK_TV_BOT(0);
tv->v_type = VAR_STRING;
tv->vval.v_string = vim_strnsave(
str + idxtv->vval.v_number, clen);
++ectx->ec_stack.ga_len;
idxtv->vval.v_number += clen - 1;
}
}
else if (ltv->v_type == VAR_BLOB)
{
blob_T *blob = ltv->vval.v_blob;
// When we get here the first time make a copy of the
// blob, so that the iteration still works when it is
// changed.
if (idxtv->vval.v_number == -1 && blob != NULL)
{
blob_copy(blob, ltv);
blob_unref(blob);
blob = ltv->vval.v_blob;
}
// The index is for the previous byte.
++idxtv->vval.v_number;
if (blob == NULL
|| idxtv->vval.v_number >= blob_len(blob))
{
// past the end of the blob, jump to "endfor"
ectx->ec_iidx = iptr->isn_arg.forloop.for_end;
may_restore_cmdmod(&ectx->ec_funclocal);
}
else
{
// Push the next byte from the blob.
tv = STACK_TV_BOT(0);
tv->v_type = VAR_NUMBER;
tv->vval.v_number = blob_get(blob,
idxtv->vval.v_number);
++ectx->ec_stack.ga_len;
}
}
else
{
semsg(_(e_for_loop_on_str_not_supported),
vartype_name(ltv->v_type));
goto theend;
}
}
break;
// start of ":try" block
case ISN_TRY:
{
trycmd_T *trycmd = NULL;
if (GA_GROW_FAILS(&ectx->ec_trystack, 1))
goto theend;
trycmd = ((trycmd_T *)ectx->ec_trystack.ga_data)
+ ectx->ec_trystack.ga_len;
++ectx->ec_trystack.ga_len;
++trylevel;
CLEAR_POINTER(trycmd);
trycmd->tcd_frame_idx = ectx->ec_frame_idx;
trycmd->tcd_stack_len = ectx->ec_stack.ga_len;
trycmd->tcd_catch_idx =
iptr->isn_arg.tryref.try_ref->try_catch;
trycmd->tcd_finally_idx =
iptr->isn_arg.tryref.try_ref->try_finally;
trycmd->tcd_endtry_idx =
iptr->isn_arg.tryref.try_ref->try_endtry;
}
break;
case ISN_PUSHEXC:
if (current_exception == NULL)
{
SOURCING_LNUM = iptr->isn_lnum;
iemsg("Evaluating catch while current_exception is NULL");
goto theend;
}
if (GA_GROW_FAILS(&ectx->ec_stack, 1))
goto theend;
tv = STACK_TV_BOT(0);
++ectx->ec_stack.ga_len;
tv->v_type = VAR_STRING;
tv->v_lock = 0;
tv->vval.v_string = vim_strsave(
(char_u *)current_exception->value);
break;
case ISN_CATCH:
{
garray_T *trystack = &ectx->ec_trystack;
may_restore_cmdmod(&ectx->ec_funclocal);
if (trystack->ga_len > 0)
{
trycmd_T *trycmd = ((trycmd_T *)trystack->ga_data)
+ trystack->ga_len - 1;
trycmd->tcd_caught = TRUE;
trycmd->tcd_did_throw = FALSE;
}
did_emsg = got_int = did_throw = FALSE;
force_abort = need_rethrow = FALSE;
catch_exception(current_exception);
}
break;
case ISN_TRYCONT:
{
garray_T *trystack = &ectx->ec_trystack;
trycont_T *trycont = &iptr->isn_arg.trycont;
int i;
trycmd_T *trycmd;
int iidx = trycont->tct_where;
if (trystack->ga_len < trycont->tct_levels)
{
siemsg("TRYCONT: expected %d levels, found %d",
trycont->tct_levels, trystack->ga_len);
goto theend;
}
// Make :endtry jump to any outer try block and the last
// :endtry inside the loop to the loop start.
for (i = trycont->tct_levels; i > 0; --i)
{
trycmd = ((trycmd_T *)trystack->ga_data)
+ trystack->ga_len - i;
// Add one to tcd_cont to be able to jump to
// instruction with index zero.
trycmd->tcd_cont = iidx + 1;
iidx = trycmd->tcd_finally_idx == 0
? trycmd->tcd_endtry_idx : trycmd->tcd_finally_idx;
}
// jump to :finally or :endtry of current try statement
ectx->ec_iidx = iidx;
}
break;
case ISN_FINALLY:
{
garray_T *trystack = &ectx->ec_trystack;
trycmd_T *trycmd = ((trycmd_T *)trystack->ga_data)
+ trystack->ga_len - 1;
// Reset the index to avoid a return statement jumps here
// again.
trycmd->tcd_finally_idx = 0;
break;
}
// end of ":try" block
case ISN_ENDTRY:
{
garray_T *trystack = &ectx->ec_trystack;
if (trystack->ga_len > 0)
{
trycmd_T *trycmd;
--trystack->ga_len;
--trylevel;
trycmd = ((trycmd_T *)trystack->ga_data)
+ trystack->ga_len;
if (trycmd->tcd_did_throw)
did_throw = TRUE;
if (trycmd->tcd_caught && current_exception != NULL)
{
// discard the exception
if (caught_stack == current_exception)
caught_stack = caught_stack->caught;
discard_current_exception();
}
if (trycmd->tcd_return)
goto func_return;
while (ectx->ec_stack.ga_len > trycmd->tcd_stack_len)
{
--ectx->ec_stack.ga_len;
clear_tv(STACK_TV_BOT(0));
}
if (trycmd->tcd_cont != 0)
// handling :continue: jump to outer try block or
// start of the loop
ectx->ec_iidx = trycmd->tcd_cont - 1;
}
}
break;
case ISN_THROW:
{
garray_T *trystack = &ectx->ec_trystack;
if (trystack->ga_len == 0 && trylevel == 0 && emsg_silent)
{
// throwing an exception while using "silent!" causes
// the function to abort but not display an error.
tv = STACK_TV_BOT(-1);
clear_tv(tv);
tv->v_type = VAR_NUMBER;
tv->vval.v_number = 0;
goto done;
}
--ectx->ec_stack.ga_len;
tv = STACK_TV_BOT(0);
if (tv->vval.v_string == NULL
|| *skipwhite(tv->vval.v_string) == NUL)
{
vim_free(tv->vval.v_string);
SOURCING_LNUM = iptr->isn_lnum;
emsg(_(e_throw_with_empty_string));
goto theend;
}
// Inside a "catch" we need to first discard the caught
// exception.
if (trystack->ga_len > 0)
{
trycmd_T *trycmd = ((trycmd_T *)trystack->ga_data)
+ trystack->ga_len - 1;
if (trycmd->tcd_caught && current_exception != NULL)
{
// discard the exception
if (caught_stack == current_exception)
caught_stack = caught_stack->caught;
discard_current_exception();
trycmd->tcd_caught = FALSE;
}
}
if (throw_exception(tv->vval.v_string, ET_USER, NULL)
== FAIL)
{
vim_free(tv->vval.v_string);
goto theend;
}
did_throw = TRUE;
}
break;
// compare with special values
case ISN_COMPAREBOOL:
case ISN_COMPARESPECIAL:
{
typval_T *tv1 = STACK_TV_BOT(-2);
typval_T *tv2 = STACK_TV_BOT(-1);
varnumber_T arg1 = tv1->vval.v_number;
varnumber_T arg2 = tv2->vval.v_number;
int res;
switch (iptr->isn_arg.op.op_type)
{
case EXPR_EQUAL: res = arg1 == arg2; break;
case EXPR_NEQUAL: res = arg1 != arg2; break;
default: res = 0; break;
}
--ectx->ec_stack.ga_len;
tv1->v_type = VAR_BOOL;
tv1->vval.v_number = res ? VVAL_TRUE : VVAL_FALSE;
}
break;
// Operation with two number arguments
case ISN_OPNR:
case ISN_COMPARENR:
{
typval_T *tv1 = STACK_TV_BOT(-2);
typval_T *tv2 = STACK_TV_BOT(-1);
varnumber_T arg1 = tv1->vval.v_number;
varnumber_T arg2 = tv2->vval.v_number;
varnumber_T res = 0;
int div_zero = FALSE;
switch (iptr->isn_arg.op.op_type)
{
case EXPR_MULT: res = arg1 * arg2; break;
case EXPR_DIV: if (arg2 == 0)
div_zero = TRUE;
else
res = arg1 / arg2;
break;
case EXPR_REM: if (arg2 == 0)
div_zero = TRUE;
else
res = arg1 % arg2;
break;
case EXPR_SUB: res = arg1 - arg2; break;
case EXPR_ADD: res = arg1 + arg2; break;
case EXPR_EQUAL: res = arg1 == arg2; break;
case EXPR_NEQUAL: res = arg1 != arg2; break;
case EXPR_GREATER: res = arg1 > arg2; break;
case EXPR_GEQUAL: res = arg1 >= arg2; break;
case EXPR_SMALLER: res = arg1 < arg2; break;
case EXPR_SEQUAL: res = arg1 <= arg2; break;
default: break;
}
--ectx->ec_stack.ga_len;
if (iptr->isn_type == ISN_COMPARENR)
{
tv1->v_type = VAR_BOOL;
tv1->vval.v_number = res ? VVAL_TRUE : VVAL_FALSE;
}
else
tv1->vval.v_number = res;
if (div_zero)
{
SOURCING_LNUM = iptr->isn_lnum;
emsg(_(e_divide_by_zero));
goto on_error;
}
}
break;
// Computation with two float arguments
case ISN_OPFLOAT:
case ISN_COMPAREFLOAT:
#ifdef FEAT_FLOAT
{
typval_T *tv1 = STACK_TV_BOT(-2);
typval_T *tv2 = STACK_TV_BOT(-1);
float_T arg1 = tv1->vval.v_float;
float_T arg2 = tv2->vval.v_float;
float_T res = 0;
int cmp = FALSE;
switch (iptr->isn_arg.op.op_type)
{
case EXPR_MULT: res = arg1 * arg2; break;
case EXPR_DIV: res = arg1 / arg2; break;
case EXPR_SUB: res = arg1 - arg2; break;
case EXPR_ADD: res = arg1 + arg2; break;
case EXPR_EQUAL: cmp = arg1 == arg2; break;
case EXPR_NEQUAL: cmp = arg1 != arg2; break;
case EXPR_GREATER: cmp = arg1 > arg2; break;
case EXPR_GEQUAL: cmp = arg1 >= arg2; break;
case EXPR_SMALLER: cmp = arg1 < arg2; break;
case EXPR_SEQUAL: cmp = arg1 <= arg2; break;
default: cmp = 0; break;
}
--ectx->ec_stack.ga_len;
if (iptr->isn_type == ISN_COMPAREFLOAT)
{
tv1->v_type = VAR_BOOL;
tv1->vval.v_number = cmp ? VVAL_TRUE : VVAL_FALSE;
}
else
tv1->vval.v_float = res;
}
#endif
break;
case ISN_COMPARELIST:
case ISN_COMPAREDICT:
case ISN_COMPAREFUNC:
case ISN_COMPARESTRING:
case ISN_COMPAREBLOB:
{
typval_T *tv1 = STACK_TV_BOT(-2);
typval_T *tv2 = STACK_TV_BOT(-1);
exprtype_T exprtype = iptr->isn_arg.op.op_type;
int ic = iptr->isn_arg.op.op_ic;
int res = FALSE;
int status = OK;
SOURCING_LNUM = iptr->isn_lnum;
if (iptr->isn_type == ISN_COMPARELIST)
{
status = typval_compare_list(tv1, tv2,
exprtype, ic, &res);
}
else if (iptr->isn_type == ISN_COMPAREDICT)
{
status = typval_compare_dict(tv1, tv2,
exprtype, ic, &res);
}
else if (iptr->isn_type == ISN_COMPAREFUNC)
{
status = typval_compare_func(tv1, tv2,
exprtype, ic, &res);
}
else if (iptr->isn_type == ISN_COMPARESTRING)
{
status = typval_compare_string(tv1, tv2,
exprtype, ic, &res);
}
else
{
status = typval_compare_blob(tv1, tv2, exprtype, &res);
}
--ectx->ec_stack.ga_len;
clear_tv(tv1);
clear_tv(tv2);
tv1->v_type = VAR_BOOL;
tv1->vval.v_number = res ? VVAL_TRUE : VVAL_FALSE;
if (status == FAIL)
goto theend;
}
break;
case ISN_COMPAREANY:
{
typval_T *tv1 = STACK_TV_BOT(-2);
typval_T *tv2 = STACK_TV_BOT(-1);
exprtype_T exprtype = iptr->isn_arg.op.op_type;
int ic = iptr->isn_arg.op.op_ic;
int status;
SOURCING_LNUM = iptr->isn_lnum;
status = typval_compare(tv1, tv2, exprtype, ic);
clear_tv(tv2);
--ectx->ec_stack.ga_len;
if (status == FAIL)
goto theend;
}
break;
case ISN_ADDLIST:
case ISN_ADDBLOB:
{
typval_T *tv1 = STACK_TV_BOT(-2);
typval_T *tv2 = STACK_TV_BOT(-1);
// add two lists or blobs
if (iptr->isn_type == ISN_ADDLIST)
{
if (iptr->isn_arg.op.op_type == EXPR_APPEND
&& tv1->vval.v_list != NULL)
list_extend(tv1->vval.v_list, tv2->vval.v_list,
NULL);
else
eval_addlist(tv1, tv2);
}
else
eval_addblob(tv1, tv2);
clear_tv(tv2);
--ectx->ec_stack.ga_len;
}
break;
case ISN_LISTAPPEND:
{
typval_T *tv1 = STACK_TV_BOT(-2);
typval_T *tv2 = STACK_TV_BOT(-1);
list_T *l = tv1->vval.v_list;
// add an item to a list
if (l == NULL)
{
SOURCING_LNUM = iptr->isn_lnum;
emsg(_(e_cannot_add_to_null_list));
goto on_error;
}
if (list_append_tv(l, tv2) == FAIL)
goto theend;
clear_tv(tv2);
--ectx->ec_stack.ga_len;
}
break;
case ISN_BLOBAPPEND:
{
typval_T *tv1 = STACK_TV_BOT(-2);
typval_T *tv2 = STACK_TV_BOT(-1);
blob_T *b = tv1->vval.v_blob;
int error = FALSE;
varnumber_T n;
// add a number to a blob
if (b == NULL)
{
SOURCING_LNUM = iptr->isn_lnum;
emsg(_(e_cannot_add_to_null_blob));
goto on_error;
}
n = tv_get_number_chk(tv2, &error);
if (error)
goto on_error;
ga_append(&b->bv_ga, (int)n);
--ectx->ec_stack.ga_len;
}
break;
// Computation with two arguments of unknown type
case ISN_OPANY:
{
typval_T *tv1 = STACK_TV_BOT(-2);
typval_T *tv2 = STACK_TV_BOT(-1);
varnumber_T n1, n2;
#ifdef FEAT_FLOAT
float_T f1 = 0, f2 = 0;
#endif
int error = FALSE;
if (iptr->isn_arg.op.op_type == EXPR_ADD)
{
if (tv1->v_type == VAR_LIST && tv2->v_type == VAR_LIST)
{
eval_addlist(tv1, tv2);
clear_tv(tv2);
--ectx->ec_stack.ga_len;
break;
}
else if (tv1->v_type == VAR_BLOB
&& tv2->v_type == VAR_BLOB)
{
eval_addblob(tv1, tv2);
clear_tv(tv2);
--ectx->ec_stack.ga_len;
break;
}
}
#ifdef FEAT_FLOAT
if (tv1->v_type == VAR_FLOAT)
{
f1 = tv1->vval.v_float;
n1 = 0;
}
else
#endif
{
SOURCING_LNUM = iptr->isn_lnum;
n1 = tv_get_number_chk(tv1, &error);
if (error)
goto on_error;
#ifdef FEAT_FLOAT
if (tv2->v_type == VAR_FLOAT)
f1 = n1;
#endif
}
#ifdef FEAT_FLOAT
if (tv2->v_type == VAR_FLOAT)
{
f2 = tv2->vval.v_float;
n2 = 0;
}
else
#endif
{
n2 = tv_get_number_chk(tv2, &error);
if (error)
goto on_error;
#ifdef FEAT_FLOAT
if (tv1->v_type == VAR_FLOAT)
f2 = n2;
#endif
}
#ifdef FEAT_FLOAT
// if there is a float on either side the result is a float
if (tv1->v_type == VAR_FLOAT || tv2->v_type == VAR_FLOAT)
{
switch (iptr->isn_arg.op.op_type)
{
case EXPR_MULT: f1 = f1 * f2; break;
case EXPR_DIV: f1 = f1 / f2; break;
case EXPR_SUB: f1 = f1 - f2; break;
case EXPR_ADD: f1 = f1 + f2; break;
default: SOURCING_LNUM = iptr->isn_lnum;
emsg(_(e_modulus));
goto on_error;
}
clear_tv(tv1);
clear_tv(tv2);
tv1->v_type = VAR_FLOAT;
tv1->vval.v_float = f1;
--ectx->ec_stack.ga_len;
}
else
#endif
{
int failed = FALSE;
switch (iptr->isn_arg.op.op_type)
{
case EXPR_MULT: n1 = n1 * n2; break;
case EXPR_DIV: n1 = num_divide(n1, n2, &failed);
if (failed)
goto on_error;
break;
case EXPR_SUB: n1 = n1 - n2; break;
case EXPR_ADD: n1 = n1 + n2; break;
default: n1 = num_modulus(n1, n2, &failed);
if (failed)
goto on_error;
break;
}
clear_tv(tv1);
clear_tv(tv2);
tv1->v_type = VAR_NUMBER;
tv1->vval.v_number = n1;
--ectx->ec_stack.ga_len;
}
}
break;
case ISN_CONCAT:
{
char_u *str1 = STACK_TV_BOT(-2)->vval.v_string;
char_u *str2 = STACK_TV_BOT(-1)->vval.v_string;
char_u *res;
res = concat_str(str1, str2);
clear_tv(STACK_TV_BOT(-2));
clear_tv(STACK_TV_BOT(-1));
--ectx->ec_stack.ga_len;
STACK_TV_BOT(-1)->vval.v_string = res;
}
break;
case ISN_STRINDEX:
case ISN_STRSLICE:
{
int is_slice = iptr->isn_type == ISN_STRSLICE;
varnumber_T n1 = 0, n2;
char_u *res;
// string index: string is at stack-2, index at stack-1
// string slice: string is at stack-3, first index at
// stack-2, second index at stack-1
if (is_slice)
{
tv = STACK_TV_BOT(-2);
n1 = tv->vval.v_number;
}
tv = STACK_TV_BOT(-1);
n2 = tv->vval.v_number;
ectx->ec_stack.ga_len -= is_slice ? 2 : 1;
tv = STACK_TV_BOT(-1);
if (is_slice)
// Slice: Select the characters from the string
res = string_slice(tv->vval.v_string, n1, n2, FALSE);
else
// Index: The resulting variable is a string of a
// single character (including composing characters).
// If the index is too big or negative the result is
// empty.
res = char_from_string(tv->vval.v_string, n2);
vim_free(tv->vval.v_string);
tv->vval.v_string = res;
}
break;
case ISN_LISTINDEX:
case ISN_LISTSLICE:
case ISN_BLOBINDEX:
case ISN_BLOBSLICE:
{
int is_slice = iptr->isn_type == ISN_LISTSLICE
|| iptr->isn_type == ISN_BLOBSLICE;
int is_blob = iptr->isn_type == ISN_BLOBINDEX
|| iptr->isn_type == ISN_BLOBSLICE;
varnumber_T n1, n2;
typval_T *val_tv;
// list index: list is at stack-2, index at stack-1
// list slice: list is at stack-3, indexes at stack-2 and
// stack-1
// Same for blob.
val_tv = is_slice ? STACK_TV_BOT(-3) : STACK_TV_BOT(-2);
tv = STACK_TV_BOT(-1);
n1 = n2 = tv->vval.v_number;
clear_tv(tv);
if (is_slice)
{
tv = STACK_TV_BOT(-2);
n1 = tv->vval.v_number;
clear_tv(tv);
}
ectx->ec_stack.ga_len -= is_slice ? 2 : 1;
tv = STACK_TV_BOT(-1);
SOURCING_LNUM = iptr->isn_lnum;
if (is_blob)
{
if (blob_slice_or_index(val_tv->vval.v_blob, is_slice,
n1, n2, FALSE, tv) == FAIL)
goto on_error;
}
else
{
if (list_slice_or_index(val_tv->vval.v_list, is_slice,
n1, n2, FALSE, tv, TRUE) == FAIL)
goto on_error;
}
}
break;
case ISN_ANYINDEX:
case ISN_ANYSLICE:
{
int is_slice = iptr->isn_type == ISN_ANYSLICE;
typval_T *var1, *var2;
int res;
// index: composite is at stack-2, index at stack-1
// slice: composite is at stack-3, indexes at stack-2 and
// stack-1
tv = is_slice ? STACK_TV_BOT(-3) : STACK_TV_BOT(-2);
SOURCING_LNUM = iptr->isn_lnum;
if (check_can_index(tv, TRUE, TRUE) == FAIL)
goto on_error;
var1 = is_slice ? STACK_TV_BOT(-2) : STACK_TV_BOT(-1);
var2 = is_slice ? STACK_TV_BOT(-1) : NULL;
res = eval_index_inner(tv, is_slice, var1, var2,
FALSE, NULL, -1, TRUE);
clear_tv(var1);
if (is_slice)
clear_tv(var2);
ectx->ec_stack.ga_len -= is_slice ? 2 : 1;
if (res == FAIL)
goto on_error;
}
break;
case ISN_SLICE:
{
list_T *list;
int count = iptr->isn_arg.number;
// type will have been checked to be a list
tv = STACK_TV_BOT(-1);
list = tv->vval.v_list;
// no error for short list, expect it to be checked earlier
if (list != NULL && list->lv_len >= count)
{
list_T *newlist = list_slice(list,
count, list->lv_len - 1);
if (newlist != NULL)
{
list_unref(list);
tv->vval.v_list = newlist;
++newlist->lv_refcount;
}
}
}
break;
case ISN_GETITEM:
{
listitem_T *li;
getitem_T *gi = &iptr->isn_arg.getitem;
// Get list item: list is at stack-1, push item.
// List type and length is checked for when compiling.
tv = STACK_TV_BOT(-1 - gi->gi_with_op);
li = list_find(tv->vval.v_list, gi->gi_index);
if (GA_GROW_FAILS(&ectx->ec_stack, 1))
goto theend;
++ectx->ec_stack.ga_len;
copy_tv(&li->li_tv, STACK_TV_BOT(-1));
// Useful when used in unpack assignment. Reset at
// ISN_DROP.
ectx->ec_where.wt_index = gi->gi_index + 1;
ectx->ec_where.wt_variable = TRUE;
}
break;
case ISN_MEMBER:
{
dict_T *dict;
char_u *key;
dictitem_T *di;
// dict member: dict is at stack-2, key at stack-1
tv = STACK_TV_BOT(-2);
// no need to check for VAR_DICT, CHECKTYPE will check.
dict = tv->vval.v_dict;
tv = STACK_TV_BOT(-1);
// no need to check for VAR_STRING, 2STRING will check.
key = tv->vval.v_string;
if (key == NULL)
key = (char_u *)"";
if ((di = dict_find(dict, key, -1)) == NULL)
{
SOURCING_LNUM = iptr->isn_lnum;
semsg(_(e_dictkey), key);
// If :silent! is used we will continue, make sure the
// stack contents makes sense and the dict stack is
// updated.
clear_tv(tv);
--ectx->ec_stack.ga_len;
tv = STACK_TV_BOT(-1);
(void) dict_stack_save(tv);
tv->v_type = VAR_NUMBER;
tv->vval.v_number = 0;
goto on_fatal_error;
}
clear_tv(tv);
--ectx->ec_stack.ga_len;
// Put the dict used on the dict stack, it might be used by
// a dict function later.
tv = STACK_TV_BOT(-1);
if (dict_stack_save(tv) == FAIL)
goto on_fatal_error;
copy_tv(&di->di_tv, tv);
}
break;
// dict member with string key
case ISN_STRINGMEMBER:
{
dict_T *dict;
dictitem_T *di;
tv = STACK_TV_BOT(-1);
if (tv->v_type != VAR_DICT || tv->vval.v_dict == NULL)
{
SOURCING_LNUM = iptr->isn_lnum;
emsg(_(e_dictreq));
goto on_error;
}
dict = tv->vval.v_dict;
if ((di = dict_find(dict, iptr->isn_arg.string, -1))
== NULL)
{
SOURCING_LNUM = iptr->isn_lnum;
semsg(_(e_dictkey), iptr->isn_arg.string);
goto on_error;
}
// Put the dict used on the dict stack, it might be used by
// a dict function later.
if (dict_stack_save(tv) == FAIL)
goto on_fatal_error;
copy_tv(&di->di_tv, tv);
}
break;
case ISN_CLEARDICT:
dict_stack_drop();
break;
case ISN_USEDICT:
{
typval_T *dict_tv = dict_stack_get_tv();
// Turn "dict.Func" into a partial for "Func" bound to
// "dict". Don't do this when "Func" is already a partial
// that was bound explicitly (pt_auto is FALSE).
tv = STACK_TV_BOT(-1);
if (dict_tv != NULL
&& dict_tv->v_type == VAR_DICT
&& dict_tv->vval.v_dict != NULL
&& (tv->v_type == VAR_FUNC
|| (tv->v_type == VAR_PARTIAL
&& (tv->vval.v_partial->pt_auto
|| tv->vval.v_partial->pt_dict == NULL))))
dict_tv->vval.v_dict =
make_partial(dict_tv->vval.v_dict, tv);
dict_stack_drop();
}
break;
case ISN_NEGATENR:
tv = STACK_TV_BOT(-1);
if (tv->v_type != VAR_NUMBER
#ifdef FEAT_FLOAT
&& tv->v_type != VAR_FLOAT
#endif
)
{
SOURCING_LNUM = iptr->isn_lnum;
emsg(_(e_number_expected));
goto on_error;
}
#ifdef FEAT_FLOAT
if (tv->v_type == VAR_FLOAT)
tv->vval.v_float = -tv->vval.v_float;
else
#endif
tv->vval.v_number = -tv->vval.v_number;
break;
case ISN_CHECKNR:
{
int error = FALSE;
tv = STACK_TV_BOT(-1);
SOURCING_LNUM = iptr->isn_lnum;
if (check_not_string(tv) == FAIL)
goto on_error;
(void)tv_get_number_chk(tv, &error);
if (error)
goto on_error;
}
break;
case ISN_CHECKTYPE:
{
checktype_T *ct = &iptr->isn_arg.type;
tv = STACK_TV_BOT((int)ct->ct_off);
SOURCING_LNUM = iptr->isn_lnum;
if (!ectx->ec_where.wt_variable)
ectx->ec_where.wt_index = ct->ct_arg_idx;
if (check_typval_type(ct->ct_type, tv, ectx->ec_where)
== FAIL)
goto on_error;
if (!ectx->ec_where.wt_variable)
ectx->ec_where.wt_index = 0;
// number 0 is FALSE, number 1 is TRUE
if (tv->v_type == VAR_NUMBER
&& ct->ct_type->tt_type == VAR_BOOL
&& (tv->vval.v_number == 0
|| tv->vval.v_number == 1))
{
tv->v_type = VAR_BOOL;
tv->vval.v_number = tv->vval.v_number
? VVAL_TRUE : VVAL_FALSE;
}
}
break;
case ISN_CHECKLEN:
{
int min_len = iptr->isn_arg.checklen.cl_min_len;
list_T *list = NULL;
tv = STACK_TV_BOT(-1);
if (tv->v_type == VAR_LIST)
list = tv->vval.v_list;
if (list == NULL || list->lv_len < min_len
|| (list->lv_len > min_len
&& !iptr->isn_arg.checklen.cl_more_OK))
{
SOURCING_LNUM = iptr->isn_lnum;
semsg(_(e_expected_nr_items_but_got_nr),
min_len, list == NULL ? 0 : list->lv_len);
goto on_error;
}
}
break;
case ISN_SETTYPE:
{
checktype_T *ct = &iptr->isn_arg.type;
tv = STACK_TV_BOT(-1);
if (tv->v_type == VAR_DICT && tv->vval.v_dict != NULL)
{
free_type(tv->vval.v_dict->dv_type);
tv->vval.v_dict->dv_type = alloc_type(ct->ct_type);
}
else if (tv->v_type == VAR_LIST && tv->vval.v_list != NULL)
{
free_type(tv->vval.v_list->lv_type);
tv->vval.v_list->lv_type = alloc_type(ct->ct_type);
}
}
break;
case ISN_2BOOL:
case ISN_COND2BOOL:
{
int n;
int error = FALSE;
if (iptr->isn_type == ISN_2BOOL)
{
tv = STACK_TV_BOT(iptr->isn_arg.tobool.offset);
n = tv2bool(tv);
if (iptr->isn_arg.tobool.invert)
n = !n;
}
else
{
tv = STACK_TV_BOT(-1);
SOURCING_LNUM = iptr->isn_lnum;
n = tv_get_bool_chk(tv, &error);
if (error)
goto on_error;
}
clear_tv(tv);
tv->v_type = VAR_BOOL;
tv->vval.v_number = n ? VVAL_TRUE : VVAL_FALSE;
}
break;
case ISN_2STRING:
case ISN_2STRING_ANY:
SOURCING_LNUM = iptr->isn_lnum;
if (do_2string(STACK_TV_BOT(iptr->isn_arg.tostring.offset),
iptr->isn_type == ISN_2STRING_ANY,
iptr->isn_arg.tostring.tolerant) == FAIL)
goto on_error;
break;
case ISN_RANGE:
{
exarg_T ea;
char *errormsg;
ea.line2 = 0;
ea.addr_count = 0;
ea.addr_type = ADDR_LINES;
ea.cmd = iptr->isn_arg.string;
ea.skip = FALSE;
if (parse_cmd_address(&ea, &errormsg, FALSE) == FAIL)
goto on_error;
if (GA_GROW_FAILS(&ectx->ec_stack, 1))
goto theend;
++ectx->ec_stack.ga_len;
tv = STACK_TV_BOT(-1);
tv->v_type = VAR_NUMBER;
tv->v_lock = 0;
if (ea.addr_count == 0)
tv->vval.v_number = curwin->w_cursor.lnum;
else
tv->vval.v_number = ea.line2;
}
break;
case ISN_PUT:
{
int regname = iptr->isn_arg.put.put_regname;
linenr_T lnum = iptr->isn_arg.put.put_lnum;
char_u *expr = NULL;
int dir = FORWARD;
if (lnum < -2)
{
// line number was put on the stack by ISN_RANGE
tv = STACK_TV_BOT(-1);
curwin->w_cursor.lnum = tv->vval.v_number;
if (lnum == LNUM_VARIABLE_RANGE_ABOVE)
dir = BACKWARD;
--ectx->ec_stack.ga_len;
}
else if (lnum == -2)
// :put! above cursor
dir = BACKWARD;
else if (lnum >= 0)
curwin->w_cursor.lnum = iptr->isn_arg.put.put_lnum;
if (regname == '=')
{
tv = STACK_TV_BOT(-1);
if (tv->v_type == VAR_STRING)
expr = tv->vval.v_string;
else
{
expr = typval2string(tv, TRUE); // allocates value
clear_tv(tv);
}
--ectx->ec_stack.ga_len;
}
check_cursor();
do_put(regname, expr, dir, 1L, PUT_LINE|PUT_CURSLINE);
vim_free(expr);
}
break;
case ISN_CMDMOD:
ectx->ec_funclocal.floc_save_cmdmod = cmdmod;
ectx->ec_funclocal.floc_restore_cmdmod = TRUE;
ectx->ec_funclocal.floc_restore_cmdmod_stacklen =
ectx->ec_stack.ga_len;
cmdmod = *iptr->isn_arg.cmdmod.cf_cmdmod;
apply_cmdmod(&cmdmod);
break;
case ISN_CMDMOD_REV:
// filter regprog is owned by the instruction, don't free it
cmdmod.cmod_filter_regmatch.regprog = NULL;
undo_cmdmod(&cmdmod);
cmdmod = ectx->ec_funclocal.floc_save_cmdmod;
ectx->ec_funclocal.floc_restore_cmdmod = FALSE;
break;
case ISN_UNPACK:
{
int count = iptr->isn_arg.unpack.unp_count;
int semicolon = iptr->isn_arg.unpack.unp_semicolon;
list_T *l;
listitem_T *li;
int i;
// Check there is a valid list to unpack.
tv = STACK_TV_BOT(-1);
if (tv->v_type != VAR_LIST)
{
SOURCING_LNUM = iptr->isn_lnum;
emsg(_(e_for_argument_must_be_sequence_of_lists));
goto on_error;
}
l = tv->vval.v_list;
if (l == NULL
|| l->lv_len < (semicolon ? count - 1 : count))
{
SOURCING_LNUM = iptr->isn_lnum;
emsg(_(e_list_value_does_not_have_enough_items));
goto on_error;
}
else if (!semicolon && l->lv_len > count)
{
SOURCING_LNUM = iptr->isn_lnum;
emsg(_(e_list_value_has_more_items_than_targets));
goto on_error;
}
CHECK_LIST_MATERIALIZE(l);
if (GA_GROW_FAILS(&ectx->ec_stack, count - 1))
goto theend;
ectx->ec_stack.ga_len += count - 1;
// Variable after semicolon gets a list with the remaining
// items.
if (semicolon)
{
list_T *rem_list =
list_alloc_with_items(l->lv_len - count + 1);
if (rem_list == NULL)
goto theend;
tv = STACK_TV_BOT(-count);
tv->vval.v_list = rem_list;
++rem_list->lv_refcount;
tv->v_lock = 0;
li = l->lv_first;
for (i = 0; i < count - 1; ++i)
li = li->li_next;
for (i = 0; li != NULL; ++i)
{
list_set_item(rem_list, i, &li->li_tv);
li = li->li_next;
}
--count;
}
// Produce the values in reverse order, first item last.
li = l->lv_first;
for (i = 0; i < count; ++i)
{
tv = STACK_TV_BOT(-i - 1);
copy_tv(&li->li_tv, tv);
li = li->li_next;
}
list_unref(l);
}
break;
case ISN_PROF_START:
case ISN_PROF_END:
{
#ifdef FEAT_PROFILE
funccall_T cookie;
ufunc_T *cur_ufunc =
(((dfunc_T *)def_functions.ga_data)
+ ectx->ec_dfunc_idx)->df_ufunc;
cookie.func = cur_ufunc;
if (iptr->isn_type == ISN_PROF_START)
{
func_line_start(&cookie, iptr->isn_lnum);
// if we get here the instruction is executed
func_line_exec(&cookie);
}
else
func_line_end(&cookie);
#endif
}
break;
case ISN_DEBUG:
handle_debug(iptr, ectx);
break;
case ISN_SHUFFLE:
{
typval_T tmp_tv;
int item = iptr->isn_arg.shuffle.shfl_item;
int up = iptr->isn_arg.shuffle.shfl_up;
tmp_tv = *STACK_TV_BOT(-item);
for ( ; up > 0 && item > 1; --up)
{
*STACK_TV_BOT(-item) = *STACK_TV_BOT(-item + 1);
--item;
}
*STACK_TV_BOT(-item) = tmp_tv;
}
break;
case ISN_DROP:
--ectx->ec_stack.ga_len;
clear_tv(STACK_TV_BOT(0));
ectx->ec_where.wt_index = 0;
ectx->ec_where.wt_variable = FALSE;
break;
}
continue;
func_return:
// Restore previous function. If the frame pointer is where we started
// then there is none and we are done.
if (ectx->ec_frame_idx == ectx->ec_initial_frame_idx)
goto done;
if (func_return(ectx) == FAIL)
// only fails when out of memory
goto theend;
continue;
on_error:
// Jump here for an error that does not require aborting execution.
// If "emsg_silent" is set then ignore the error, unless it was set
// when calling the function.
if (did_emsg_cumul + did_emsg == ectx->ec_did_emsg_before
&& emsg_silent && did_emsg_def == 0)
{
// If a sequence of instructions causes an error while ":silent!"
// was used, restore the stack length and jump ahead to restoring
// the cmdmod.
if (ectx->ec_funclocal.floc_restore_cmdmod)
{
while (ectx->ec_stack.ga_len
> ectx->ec_funclocal.floc_restore_cmdmod_stacklen)
{
--ectx->ec_stack.ga_len;
clear_tv(STACK_TV_BOT(0));
}
while (ectx->ec_instr[ectx->ec_iidx].isn_type != ISN_CMDMOD_REV)
++ectx->ec_iidx;
}
continue;
}
on_fatal_error:
// Jump here for an error that messes up the stack.
// If we are not inside a try-catch started here, abort execution.
if (trylevel <= ectx->ec_trylevel_at_start)
goto theend;
}
done:
ret = OK;
theend:
dict_stack_clear(dict_stack_len_at_start);
ectx->ec_trylevel_at_start = save_trylevel_at_start;
return ret;
} | 13596 | True | 1 |
CVE-2021-4192 | 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://huntr.dev/bounties/6dd9cb2e-a940-4093-856e-59b502429f22', 'name': 'https://huntr.dev/bounties/6dd9cb2e-a940-4093-856e-59b502429f22', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/vim/vim/commit/4c13e5e6763c6eb36a343a2b8235ea227202e952', 'name': 'https://github.com/vim/vim/commit/4c13e5e6763c6eb36a343a2b8235ea227202e952', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2022/01/15/1', 'name': "[oss-security] 20220114 Re: 3 new CVE's in vim", 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/3FH2J57GDA2WMBS6J56F6QQRA6BXQQFZ/', 'name': 'FEDORA-2022-48b86d586f', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2022/03/msg00018.html', 'name': '[debian-lts-announce] 20220311 [SECURITY] [DLA 2947-1] vim security update', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213183', 'name': 'https://support.apple.com/kb/HT213183', 'refsource': 'CONFIRM', 'tags': ['Release Notes', 'Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Mar/29', 'name': '20220314 APPLE-SA-2022-03-14-4 macOS Monterey 12.3', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213256', 'name': 'https://support.apple.com/kb/HT213256', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/May/35', 'name': '20220516 APPLE-SA-2022-05-16-3 macOS Big Sur 11.6.6', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213343', 'name': 'https://support.apple.com/kb/HT213343', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Jul/14', 'name': '20220721 APPLE-SA-2022-07-20-4 Security Update 2022-005 Catalina', 'refsource': 'FULLDISC', 'tags': ['Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-416'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.3949', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:fedoraproject:fedora:34:*:*:*:*:*:*:*', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:debian:debian_linux:9.0:*:*:*:*:*:*:*', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-005:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionEndExcluding': '12.3', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2022-001:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2022-002:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2020-001:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-001:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-002:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-003:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionStartIncluding': '11.0', 'versionEndExcluding': '11.6.6', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2022-004:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-004:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-006:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-007:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-008:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2022-003:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'vim is vulnerable to Use After Free'}] | 2022-08-21T07:15Z | 2021-12-31T15: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 | Bram Moolenaar | 2021-12-30 14:49:43+00:00 | patch 8.2.3949: using freed memory with /\%V
Problem: Using freed memory with /\%V.
Solution: Get the line again after getvvcol(). | 4c13e5e6763c6eb36a343a2b8235ea227202e952 | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | reg_match_visual | reg_match_visual( void) | ['void'] | reg_match_visual(void)
{
pos_T top, bot;
linenr_T lnum;
colnr_T col;
win_T *wp = rex.reg_win == NULL ? curwin : rex.reg_win;
int mode;
colnr_T start, end;
colnr_T start2, end2;
colnr_T cols;
colnr_T curswant;
// Check if the buffer is the current buffer.
if (rex.reg_buf != curbuf || VIsual.lnum == 0)
return FALSE;
if (VIsual_active)
{
if (LT_POS(VIsual, wp->w_cursor))
{
top = VIsual;
bot = wp->w_cursor;
}
else
{
top = wp->w_cursor;
bot = VIsual;
}
mode = VIsual_mode;
curswant = wp->w_curswant;
}
else
{
if (LT_POS(curbuf->b_visual.vi_start, curbuf->b_visual.vi_end))
{
top = curbuf->b_visual.vi_start;
bot = curbuf->b_visual.vi_end;
}
else
{
top = curbuf->b_visual.vi_end;
bot = curbuf->b_visual.vi_start;
}
mode = curbuf->b_visual.vi_mode;
curswant = curbuf->b_visual.vi_curswant;
}
lnum = rex.lnum + rex.reg_firstlnum;
if (lnum < top.lnum || lnum > bot.lnum)
return FALSE;
if (mode == 'v')
{
col = (colnr_T)(rex.input - rex.line);
if ((lnum == top.lnum && col < top.col)
|| (lnum == bot.lnum && col >= bot.col + (*p_sel != 'e')))
return FALSE;
}
else if (mode == Ctrl_V)
{
getvvcol(wp, &top, &start, NULL, &end);
getvvcol(wp, &bot, &start2, NULL, &end2);
if (start2 < start)
start = start2;
if (end2 > end)
end = end2;
if (top.col == MAXCOL || bot.col == MAXCOL || curswant == MAXCOL)
end = MAXCOL;
cols = win_linetabsize(wp, rex.line, (colnr_T)(rex.input - rex.line));
if (cols < start || cols > end - (*p_sel == 'e'))
return FALSE;
}
return TRUE;
} | 414 | True | 1 |
CVE-2021-4193 | 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:L/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:N | LOCAL | LOW | NONE | REQUIRED | UNCHANGED | HIGH | NONE | NONE | 5.5 | MEDIUM | 1.8 | 3.6 | False | [{'url': 'https://github.com/vim/vim/commit/94f3192b03ed27474db80b4d3a409e107140738b', 'name': 'https://github.com/vim/vim/commit/94f3192b03ed27474db80b4d3a409e107140738b', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://huntr.dev/bounties/92c1940d-8154-473f-84ce-0de43b0c2eb0', 'name': 'https://huntr.dev/bounties/92c1940d-8154-473f-84ce-0de43b0c2eb0', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Patch', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2022/01/15/1', 'name': "[oss-security] 20220114 Re: 3 new CVE's in vim", 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/3FH2J57GDA2WMBS6J56F6QQRA6BXQQFZ/', 'name': 'FEDORA-2022-48b86d586f', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2022/03/msg00018.html', 'name': '[debian-lts-announce] 20220311 [SECURITY] [DLA 2947-1] vim security update', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213183', 'name': 'https://support.apple.com/kb/HT213183', 'refsource': 'CONFIRM', 'tags': ['Release Notes', 'Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Mar/29', 'name': '20220314 APPLE-SA-2022-03-14-4 macOS Monterey 12.3', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213256', 'name': 'https://support.apple.com/kb/HT213256', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/May/35', 'name': '20220516 APPLE-SA-2022-05-16-3 macOS Big Sur 11.6.6', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213343', 'name': 'https://support.apple.com/kb/HT213343', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Jul/14', 'name': '20220721 APPLE-SA-2022-07-20-4 Security Update 2022-005 Catalina', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.3950', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:fedoraproject:fedora:34:*:*:*:*:*:*:*', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:debian:debian_linux:9.0:*:*:*:*:*:*:*', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-005:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionEndExcluding': '12.3', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2022-001:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2022-002:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2020-001:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-001:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-002:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-003:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-004:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-006:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-007:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2021-008:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionStartIncluding': '11.0', 'versionEndExcluding': '11.6.6', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2022-003:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:10.15.7:security_update_2022-004:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'vim is vulnerable to Out-of-bounds Read'}] | 2022-08-26T17:49Z | 2021-12-31T16: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 | Bram Moolenaar | 2021-12-30 15:29:18+00:00 | patch 8.2.3950: going beyond the end of the line with /\%V
Problem: Going beyond the end of the line with /\%V.
Solution: Check for valid column in getvcol(). | 94f3192b03ed27474db80b4d3a409e107140738b | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | getvcol | getvcol( win_T * wp , pos_T * pos , colnr_T * start , colnr_T * cursor , colnr_T * end) | ['wp', 'pos', 'start', 'cursor', 'end'] | getvcol(
win_T *wp,
pos_T *pos,
colnr_T *start,
colnr_T *cursor,
colnr_T *end)
{
colnr_T vcol;
char_u *ptr; // points to current char
char_u *posptr; // points to char at pos->col
char_u *line; // start of the line
int incr;
int head;
#ifdef FEAT_VARTABS
int *vts = wp->w_buffer->b_p_vts_array;
#endif
int ts = wp->w_buffer->b_p_ts;
int c;
vcol = 0;
line = ptr = ml_get_buf(wp->w_buffer, pos->lnum, FALSE);
if (pos->col == MAXCOL)
posptr = NULL; // continue until the NUL
else
{
// Special check for an empty line, which can happen on exit, when
// ml_get_buf() always returns an empty string.
if (*ptr == NUL)
pos->col = 0;
posptr = ptr + pos->col;
if (has_mbyte)
// always start on the first byte
posptr -= (*mb_head_off)(line, posptr);
}
/*
* This function is used very often, do some speed optimizations.
* When 'list', 'linebreak', 'showbreak' and 'breakindent' are not set
* use a simple loop.
* Also use this when 'list' is set but tabs take their normal size.
*/
if ((!wp->w_p_list || wp->w_lcs_chars.tab1 != NUL)
#ifdef FEAT_LINEBREAK
&& !wp->w_p_lbr && *get_showbreak_value(wp) == NUL && !wp->w_p_bri
#endif
)
{
for (;;)
{
head = 0;
c = *ptr;
// make sure we don't go past the end of the line
if (c == NUL)
{
incr = 1; // NUL at end of line only takes one column
break;
}
// A tab gets expanded, depending on the current column
if (c == TAB)
#ifdef FEAT_VARTABS
incr = tabstop_padding(vcol, ts, vts);
#else
incr = ts - (vcol % ts);
#endif
else
{
if (has_mbyte)
{
// For utf-8, if the byte is >= 0x80, need to look at
// further bytes to find the cell width.
if (enc_utf8 && c >= 0x80)
incr = utf_ptr2cells(ptr);
else
incr = g_chartab[c] & CT_CELL_MASK;
// If a double-cell char doesn't fit at the end of a line
// it wraps to the next line, it's like this char is three
// cells wide.
if (incr == 2 && wp->w_p_wrap && MB_BYTE2LEN(*ptr) > 1
&& in_win_border(wp, vcol))
{
++incr;
head = 1;
}
}
else
incr = g_chartab[c] & CT_CELL_MASK;
}
if (posptr != NULL && ptr >= posptr) // character at pos->col
break;
vcol += incr;
MB_PTR_ADV(ptr);
}
}
else
{
for (;;)
{
// A tab gets expanded, depending on the current column
head = 0;
incr = win_lbr_chartabsize(wp, line, ptr, vcol, &head);
// make sure we don't go past the end of the line
if (*ptr == NUL)
{
incr = 1; // NUL at end of line only takes one column
break;
}
if (posptr != NULL && ptr >= posptr) // character at pos->col
break;
vcol += incr;
MB_PTR_ADV(ptr);
}
}
if (start != NULL)
*start = vcol + head;
if (end != NULL)
*end = vcol + incr - 1;
if (cursor != NULL)
{
if (*ptr == TAB
&& (State & NORMAL)
&& !wp->w_p_list
&& !virtual_active()
&& !(VIsual_active
&& (*p_sel == 'e' || LTOREQ_POS(*pos, VIsual)))
)
*cursor = vcol + incr - 1; // cursor at end
else
*cursor = vcol + head; // cursor at start
}
} | 495 | True | 1 |
CVE-2022-0128 | 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/vim/vim/commit/d3a117814d6acbf0dca3eff1a7626843b9b3734a', 'name': 'https://github.com/vim/vim/commit/d3a117814d6acbf0dca3eff1a7626843b9b3734a', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://huntr.dev/bounties/63f51299-008a-4112-b85b-1e904aadd4ba', 'name': 'https://huntr.dev/bounties/63f51299-008a-4112-b85b-1e904aadd4ba', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Issue Tracking', 'Patch', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2022/01/15/1', 'name': "[oss-security] 20220114 Re: 3 new CVE's in vim", 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213183', 'name': 'https://support.apple.com/kb/HT213183', 'refsource': 'CONFIRM', 'tags': ['Release Notes', 'Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Mar/29', 'name': '20220314 APPLE-SA-2022-03-14-4 macOS Monterey 12.3', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213256', 'name': 'https://support.apple.com/kb/HT213256', 'refsource': 'CONFIRM', 'tags': []}, {'url': 'http://seclists.org/fulldisclosure/2022/May/35', 'name': '20220516 APPLE-SA-2022-05-16-3 macOS Big Sur 11.6.6', 'refsource': 'FULLDISC', 'tags': []}, {'url': 'https://support.apple.com/kb/HT213343', 'name': 'https://support.apple.com/kb/HT213343', 'refsource': 'CONFIRM', 'tags': []}, {'url': 'http://seclists.org/fulldisclosure/2022/Jul/14', 'name': '20220721 APPLE-SA-2022-07-20-4 Security Update 2022-005 Catalina', 'refsource': 'FULLDISC', 'tags': []}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.4009', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionEndExcluding': '12.3', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'vim is vulnerable to Out-of-bounds Read'}] | 2022-08-21T06:15Z | 2022-01-06T17: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 | Bram Moolenaar | 2022-01-05 16:50:40+00:00 | patch 8.2.4009: reading one byte beyond the end of the line
Problem: Reading one byte beyond the end of the line.
Solution: Check for NUL byte first. | d3a117814d6acbf0dca3eff1a7626843b9b3734a | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | compile_def_function | compile_def_function( ufunc_T * ufunc , int check_return_type , compiletype_T compile_type , cctx_T * outer_cctx) | ['ufunc', 'check_return_type', 'compile_type', 'outer_cctx'] | compile_def_function(
ufunc_T *ufunc,
int check_return_type,
compiletype_T compile_type,
cctx_T *outer_cctx)
{
char_u *line = NULL;
char_u *line_to_free = NULL;
char_u *p;
char *errormsg = NULL; // error message
cctx_T cctx;
garray_T *instr;
int did_emsg_before = did_emsg;
int did_emsg_silent_before = did_emsg_silent;
int ret = FAIL;
sctx_T save_current_sctx = current_sctx;
int save_estack_compiling = estack_compiling;
int save_cmod_flags = cmdmod.cmod_flags;
int do_estack_push;
int new_def_function = FALSE;
#ifdef FEAT_PROFILE
int prof_lnum = -1;
#endif
int debug_lnum = -1;
// When using a function that was compiled before: Free old instructions.
// The index is reused. Otherwise add a new entry in "def_functions".
if (ufunc->uf_dfunc_idx > 0)
{
dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data)
+ ufunc->uf_dfunc_idx;
isn_T *instr_dest = NULL;
switch (compile_type)
{
case CT_PROFILE:
#ifdef FEAT_PROFILE
instr_dest = dfunc->df_instr_prof; break;
#endif
case CT_NONE: instr_dest = dfunc->df_instr; break;
case CT_DEBUG: instr_dest = dfunc->df_instr_debug; break;
}
if (instr_dest != NULL)
// Was compiled in this mode before: Free old instructions.
delete_def_function_contents(dfunc, FALSE);
ga_clear_strings(&dfunc->df_var_names);
}
else
{
if (add_def_function(ufunc) == FAIL)
return FAIL;
new_def_function = TRUE;
}
ufunc->uf_def_status = UF_COMPILING;
CLEAR_FIELD(cctx);
cctx.ctx_compile_type = compile_type;
cctx.ctx_ufunc = ufunc;
cctx.ctx_lnum = -1;
cctx.ctx_outer = outer_cctx;
ga_init2(&cctx.ctx_locals, sizeof(lvar_T), 10);
// Each entry on the type stack consists of two type pointers.
ga_init2(&cctx.ctx_type_stack, sizeof(type2_T), 50);
ga_init2(&cctx.ctx_imports, sizeof(imported_T), 10);
cctx.ctx_type_list = &ufunc->uf_type_list;
ga_init2(&cctx.ctx_instr, sizeof(isn_T), 50);
instr = &cctx.ctx_instr;
// Set the context to the function, it may be compiled when called from
// another script. Set the script version to the most modern one.
// The line number will be set in next_line_from_context().
current_sctx = ufunc->uf_script_ctx;
current_sctx.sc_version = SCRIPT_VERSION_VIM9;
// Don't use the flag from ":legacy" here.
cmdmod.cmod_flags &= ~CMOD_LEGACY;
// Make sure error messages are OK.
do_estack_push = !estack_top_is_ufunc(ufunc, 1);
if (do_estack_push)
estack_push_ufunc(ufunc, 1);
estack_compiling = TRUE;
if (check_args_shadowing(ufunc, &cctx) == FAIL)
goto erret;
if (ufunc->uf_def_args.ga_len > 0)
{
int count = ufunc->uf_def_args.ga_len;
int first_def_arg = ufunc->uf_args.ga_len - count;
int i;
char_u *arg;
int off = STACK_FRAME_SIZE + (ufunc->uf_va_name != NULL ? 1 : 0);
int did_set_arg_type = FALSE;
// Produce instructions for the default values of optional arguments.
SOURCING_LNUM = 0; // line number unknown
for (i = 0; i < count; ++i)
{
type_T *val_type;
int arg_idx = first_def_arg + i;
where_T where = WHERE_INIT;
int r;
int jump_instr_idx = instr->ga_len;
isn_T *isn;
// Use a JUMP_IF_ARG_SET instruction to skip if the value was given.
if (generate_JUMP_IF_ARG_SET(&cctx, i - count - off) == FAIL)
goto erret;
// Make sure later arguments are not found.
ufunc->uf_args_visible = arg_idx;
arg = ((char_u **)(ufunc->uf_def_args.ga_data))[i];
r = compile_expr0(&arg, &cctx);
if (r == FAIL)
goto erret;
// If no type specified use the type of the default value.
// Otherwise check that the default value type matches the
// specified type.
val_type = get_type_on_stack(&cctx, 0);
where.wt_index = arg_idx + 1;
if (ufunc->uf_arg_types[arg_idx] == &t_unknown)
{
did_set_arg_type = TRUE;
ufunc->uf_arg_types[arg_idx] = val_type;
}
else if (need_type_where(val_type, ufunc->uf_arg_types[arg_idx],
-1, where, &cctx, FALSE, FALSE) == FAIL)
goto erret;
if (generate_STORE(&cctx, ISN_STORE, i - count - off, NULL) == FAIL)
goto erret;
// set instruction index in JUMP_IF_ARG_SET to here
isn = ((isn_T *)instr->ga_data) + jump_instr_idx;
isn->isn_arg.jumparg.jump_where = instr->ga_len;
}
if (did_set_arg_type)
set_function_type(ufunc);
}
ufunc->uf_args_visible = ufunc->uf_args.ga_len;
/*
* Loop over all the lines of the function and generate instructions.
*/
for (;;)
{
exarg_T ea;
int starts_with_colon = FALSE;
char_u *cmd;
cmdmod_T local_cmdmod;
// Bail out on the first error to avoid a flood of errors and report
// the right line number when inside try/catch.
if (did_emsg_before != did_emsg)
goto erret;
if (line != NULL && *line == '|')
// the line continues after a '|'
++line;
else if (line != NULL && *skipwhite(line) != NUL
&& !(*line == '#' && (line == cctx.ctx_line_start
|| VIM_ISWHITE(line[-1]))))
{
semsg(_(e_trailing_characters_str), line);
goto erret;
}
else if (line != NULL && vim9_bad_comment(skipwhite(line)))
goto erret;
else
{
line = next_line_from_context(&cctx, FALSE);
if (cctx.ctx_lnum >= ufunc->uf_lines.ga_len)
{
// beyond the last line
#ifdef FEAT_PROFILE
if (cctx.ctx_skip != SKIP_YES)
may_generate_prof_end(&cctx, prof_lnum);
#endif
break;
}
// Make a copy, splitting off nextcmd and removing trailing spaces
// may change it.
if (line != NULL)
{
line = vim_strsave(line);
vim_free(line_to_free);
line_to_free = line;
}
}
CLEAR_FIELD(ea);
ea.cmdlinep = &line;
ea.cmd = skipwhite(line);
if (*ea.cmd == '#')
{
// "#" starts a comment
line = (char_u *)"";
continue;
}
#ifdef FEAT_PROFILE
if (cctx.ctx_compile_type == CT_PROFILE && cctx.ctx_lnum != prof_lnum
&& cctx.ctx_skip != SKIP_YES)
{
may_generate_prof_end(&cctx, prof_lnum);
prof_lnum = cctx.ctx_lnum;
generate_instr(&cctx, ISN_PROF_START);
}
#endif
if (cctx.ctx_compile_type == CT_DEBUG && cctx.ctx_lnum != debug_lnum
&& cctx.ctx_skip != SKIP_YES)
{
debug_lnum = cctx.ctx_lnum;
generate_instr_debug(&cctx);
}
cctx.ctx_prev_lnum = cctx.ctx_lnum + 1;
// Some things can be recognized by the first character.
switch (*ea.cmd)
{
case '}':
{
// "}" ends a block scope
scopetype_T stype = cctx.ctx_scope == NULL
? NO_SCOPE : cctx.ctx_scope->se_type;
if (stype == BLOCK_SCOPE)
{
compile_endblock(&cctx);
line = ea.cmd;
}
else
{
emsg(_(e_using_rcurly_outside_if_block_scope));
goto erret;
}
if (line != NULL)
line = skipwhite(ea.cmd + 1);
continue;
}
case '{':
// "{" starts a block scope
// "{'a': 1}->func() is something else
if (ends_excmd(*skipwhite(ea.cmd + 1)))
{
line = compile_block(ea.cmd, &cctx);
continue;
}
break;
}
/*
* COMMAND MODIFIERS
*/
cctx.ctx_has_cmdmod = FALSE;
if (parse_command_modifiers(&ea, &errormsg, &local_cmdmod, FALSE)
== FAIL)
{
if (errormsg != NULL)
goto erret;
// empty line or comment
line = (char_u *)"";
continue;
}
generate_cmdmods(&cctx, &local_cmdmod);
undo_cmdmod(&local_cmdmod);
// Check if there was a colon after the last command modifier or before
// the current position.
for (p = ea.cmd; p >= line; --p)
{
if (*p == ':')
starts_with_colon = TRUE;
if (p < ea.cmd && !VIM_ISWHITE(*p))
break;
}
// Skip ":call" to get to the function name, unless using :legacy
p = ea.cmd;
if (!(local_cmdmod.cmod_flags & CMOD_LEGACY))
{
if (checkforcmd(&ea.cmd, "call", 3))
{
if (*ea.cmd == '(')
// not for "call()"
ea.cmd = p;
else
ea.cmd = skipwhite(ea.cmd);
}
if (!starts_with_colon)
{
int assign;
// Check for assignment after command modifiers.
assign = may_compile_assignment(&ea, &line, &cctx);
if (assign == OK)
goto nextline;
if (assign == FAIL)
goto erret;
}
}
/*
* COMMAND after range
* 'text'->func() should not be confused with 'a mark
* "++nr" and "--nr" are eval commands
* in "$ENV->func()" the "$" is not a range
*/
cmd = ea.cmd;
if ((*cmd != '$' || starts_with_colon)
&& (starts_with_colon || !(*cmd == '\''
|| (cmd[0] == cmd[1] && (*cmd == '+' || *cmd == '-')))))
{
ea.cmd = skip_range(ea.cmd, TRUE, NULL);
if (ea.cmd > cmd)
{
if (!starts_with_colon
&& !(local_cmdmod.cmod_flags & CMOD_LEGACY))
{
semsg(_(e_colon_required_before_range_str), cmd);
goto erret;
}
ea.addr_count = 1;
if (ends_excmd2(line, ea.cmd))
{
// A range without a command: jump to the line.
generate_EXEC(&cctx, ISN_EXECRANGE,
vim_strnsave(cmd, ea.cmd - cmd));
line = ea.cmd;
goto nextline;
}
}
}
p = find_ex_command(&ea, NULL,
starts_with_colon || (local_cmdmod.cmod_flags & CMOD_LEGACY)
? NULL : item_exists, &cctx);
if (p == NULL)
{
if (cctx.ctx_skip != SKIP_YES)
emsg(_(e_ambiguous_use_of_user_defined_command));
goto erret;
}
// When using ":legacy cmd" always use compile_exec().
if (local_cmdmod.cmod_flags & CMOD_LEGACY)
{
char_u *start = ea.cmd;
switch (ea.cmdidx)
{
case CMD_if:
case CMD_elseif:
case CMD_else:
case CMD_endif:
case CMD_for:
case CMD_endfor:
case CMD_continue:
case CMD_break:
case CMD_while:
case CMD_endwhile:
case CMD_try:
case CMD_catch:
case CMD_finally:
case CMD_endtry:
semsg(_(e_cannot_use_legacy_with_command_str), ea.cmd);
goto erret;
default: break;
}
// ":legacy return expr" needs to be handled differently.
if (checkforcmd(&start, "return", 4))
ea.cmdidx = CMD_return;
else
ea.cmdidx = CMD_legacy;
}
if (p == ea.cmd && ea.cmdidx != CMD_SIZE)
{
if (cctx.ctx_skip == SKIP_YES && ea.cmdidx != CMD_eval)
{
line += STRLEN(line);
goto nextline;
}
else if (ea.cmdidx != CMD_eval)
{
// CMD_var cannot happen, compile_assignment() above would be
// used. Most likely an assignment to a non-existing variable.
semsg(_(e_command_not_recognized_str), ea.cmd);
goto erret;
}
}
if (cctx.ctx_had_return
&& ea.cmdidx != CMD_elseif
&& ea.cmdidx != CMD_else
&& ea.cmdidx != CMD_endif
&& ea.cmdidx != CMD_endfor
&& ea.cmdidx != CMD_endwhile
&& ea.cmdidx != CMD_catch
&& ea.cmdidx != CMD_finally
&& ea.cmdidx != CMD_endtry)
{
emsg(_(e_unreachable_code_after_return));
goto erret;
}
p = skipwhite(p);
if (ea.cmdidx != CMD_SIZE
&& ea.cmdidx != CMD_write && ea.cmdidx != CMD_read)
{
if (ea.cmdidx >= 0)
ea.argt = excmd_get_argt(ea.cmdidx);
if ((ea.argt & EX_BANG) && *p == '!')
{
ea.forceit = TRUE;
p = skipwhite(p + 1);
}
}
switch (ea.cmdidx)
{
case CMD_def:
case CMD_function:
ea.arg = p;
line = compile_nested_function(&ea, &cctx, &line_to_free);
break;
case CMD_return:
line = compile_return(p, check_return_type,
local_cmdmod.cmod_flags & CMOD_LEGACY, &cctx);
cctx.ctx_had_return = TRUE;
break;
case CMD_let:
emsg(_(e_cannot_use_let_in_vim9_script));
break;
case CMD_var:
case CMD_final:
case CMD_const:
case CMD_increment:
case CMD_decrement:
line = compile_assignment(p, &ea, ea.cmdidx, &cctx);
if (line == p)
line = NULL;
break;
case CMD_unlet:
case CMD_unlockvar:
case CMD_lockvar:
line = compile_unletlock(p, &ea, &cctx);
break;
case CMD_import:
emsg(_(e_import_can_only_be_used_in_script));
line = NULL;
break;
case CMD_if:
line = compile_if(p, &cctx);
break;
case CMD_elseif:
line = compile_elseif(p, &cctx);
cctx.ctx_had_return = FALSE;
break;
case CMD_else:
line = compile_else(p, &cctx);
cctx.ctx_had_return = FALSE;
break;
case CMD_endif:
line = compile_endif(p, &cctx);
break;
case CMD_while:
line = compile_while(p, &cctx);
break;
case CMD_endwhile:
line = compile_endwhile(p, &cctx);
cctx.ctx_had_return = FALSE;
break;
case CMD_for:
line = compile_for(p, &cctx);
break;
case CMD_endfor:
line = compile_endfor(p, &cctx);
cctx.ctx_had_return = FALSE;
break;
case CMD_continue:
line = compile_continue(p, &cctx);
break;
case CMD_break:
line = compile_break(p, &cctx);
break;
case CMD_try:
line = compile_try(p, &cctx);
break;
case CMD_catch:
line = compile_catch(p, &cctx);
cctx.ctx_had_return = FALSE;
break;
case CMD_finally:
line = compile_finally(p, &cctx);
cctx.ctx_had_return = FALSE;
break;
case CMD_endtry:
line = compile_endtry(p, &cctx);
cctx.ctx_had_return = FALSE;
break;
case CMD_throw:
line = compile_throw(p, &cctx);
break;
case CMD_eval:
line = compile_eval(p, &cctx);
break;
case CMD_echo:
case CMD_echon:
case CMD_execute:
case CMD_echomsg:
case CMD_echoerr:
case CMD_echoconsole:
line = compile_mult_expr(p, ea.cmdidx, &cctx);
break;
case CMD_put:
ea.cmd = cmd;
line = compile_put(p, &ea, &cctx);
break;
case CMD_substitute:
if (check_global_and_subst(ea.cmd, p) == FAIL)
goto erret;
if (cctx.ctx_skip == SKIP_YES)
line = (char_u *)"";
else
{
ea.arg = p;
line = compile_substitute(line, &ea, &cctx);
}
break;
case CMD_redir:
ea.arg = p;
line = compile_redir(line, &ea, &cctx);
break;
case CMD_cexpr:
case CMD_lexpr:
case CMD_caddexpr:
case CMD_laddexpr:
case CMD_cgetexpr:
case CMD_lgetexpr:
#ifdef FEAT_QUICKFIX
ea.arg = p;
line = compile_cexpr(line, &ea, &cctx);
#else
ex_ni(&ea);
line = NULL;
#endif
break;
case CMD_append:
case CMD_change:
case CMD_insert:
case CMD_k:
case CMD_t:
case CMD_xit:
not_in_vim9(&ea);
goto erret;
case CMD_SIZE:
if (cctx.ctx_skip != SKIP_YES)
{
semsg(_(e_invalid_command_str), ea.cmd);
goto erret;
}
// We don't check for a next command here.
line = (char_u *)"";
break;
case CMD_lua:
case CMD_mzscheme:
case CMD_perl:
case CMD_py3:
case CMD_python3:
case CMD_python:
case CMD_pythonx:
case CMD_ruby:
case CMD_tcl:
ea.arg = p;
if (vim_strchr(line, '\n') == NULL)
line = compile_exec(line, &ea, &cctx);
else
// heredoc lines have been concatenated with NL
// characters in get_function_body()
line = compile_script(line, &cctx);
break;
case CMD_global:
if (check_global_and_subst(ea.cmd, p) == FAIL)
goto erret;
// FALLTHROUGH
default:
// Not recognized, execute with do_cmdline_cmd().
ea.arg = p;
line = compile_exec(line, &ea, &cctx);
break;
}
nextline:
if (line == NULL)
goto erret;
line = skipwhite(line);
// Undo any command modifiers.
generate_undo_cmdmods(&cctx);
if (cctx.ctx_type_stack.ga_len < 0)
{
iemsg("Type stack underflow");
goto erret;
}
}
if (cctx.ctx_scope != NULL)
{
if (cctx.ctx_scope->se_type == IF_SCOPE)
emsg(_(e_missing_endif));
else if (cctx.ctx_scope->se_type == WHILE_SCOPE)
emsg(_(e_missing_endwhile));
else if (cctx.ctx_scope->se_type == FOR_SCOPE)
emsg(_(e_missing_endfor));
else
emsg(_(e_missing_rcurly));
goto erret;
}
if (!cctx.ctx_had_return)
{
if (ufunc->uf_ret_type->tt_type == VAR_UNKNOWN)
ufunc->uf_ret_type = &t_void;
else if (ufunc->uf_ret_type->tt_type != VAR_VOID)
{
emsg(_(e_missing_return_statement));
goto erret;
}
// Return void if there is no return at the end.
generate_instr(&cctx, ISN_RETURN_VOID);
}
// When compiled with ":silent!" and there was an error don't consider the
// function compiled.
if (emsg_silent == 0 || did_emsg_silent == did_emsg_silent_before)
{
dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data)
+ ufunc->uf_dfunc_idx;
dfunc->df_deleted = FALSE;
dfunc->df_script_seq = current_sctx.sc_seq;
#ifdef FEAT_PROFILE
if (cctx.ctx_compile_type == CT_PROFILE)
{
dfunc->df_instr_prof = instr->ga_data;
dfunc->df_instr_prof_count = instr->ga_len;
}
else
#endif
if (cctx.ctx_compile_type == CT_DEBUG)
{
dfunc->df_instr_debug = instr->ga_data;
dfunc->df_instr_debug_count = instr->ga_len;
}
else
{
dfunc->df_instr = instr->ga_data;
dfunc->df_instr_count = instr->ga_len;
}
dfunc->df_varcount = dfunc->df_var_names.ga_len;
dfunc->df_has_closure = cctx.ctx_has_closure;
if (cctx.ctx_outer_used)
ufunc->uf_flags |= FC_CLOSURE;
ufunc->uf_def_status = UF_COMPILED;
}
ret = OK;
erret:
if (ufunc->uf_def_status == UF_COMPILING)
{
dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data)
+ ufunc->uf_dfunc_idx;
// Compiling aborted, free the generated instructions.
clear_instr_ga(instr);
VIM_CLEAR(dfunc->df_name);
ga_clear_strings(&dfunc->df_var_names);
// If using the last entry in the table and it was added above, we
// might as well remove it.
if (!dfunc->df_deleted && new_def_function
&& ufunc->uf_dfunc_idx == def_functions.ga_len - 1)
{
--def_functions.ga_len;
ufunc->uf_dfunc_idx = 0;
}
ufunc->uf_def_status = UF_COMPILE_ERROR;
while (cctx.ctx_scope != NULL)
drop_scope(&cctx);
if (errormsg != NULL)
emsg(errormsg);
else if (did_emsg == did_emsg_before)
emsg(_(e_compiling_def_function_failed));
}
if (cctx.ctx_redir_lhs.lhs_name != NULL)
{
if (ret == OK)
{
emsg(_(e_missing_redir_end));
ret = FAIL;
}
vim_free(cctx.ctx_redir_lhs.lhs_name);
vim_free(cctx.ctx_redir_lhs.lhs_whole);
}
current_sctx = save_current_sctx;
estack_compiling = save_estack_compiling;
cmdmod.cmod_flags = save_cmod_flags;
if (do_estack_push)
estack_pop();
vim_free(line_to_free);
free_imported(&cctx);
free_locals(&cctx);
ga_clear(&cctx.ctx_type_stack);
return ret;
} | 3260 | True | 1 |
CVE-2022-0156 | 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/vim/vim/commit/9f1a39a5d1cd7989ada2d1cb32f97d84360e050f', 'name': 'https://github.com/vim/vim/commit/9f1a39a5d1cd7989ada2d1cb32f97d84360e050f', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://huntr.dev/bounties/47dded34-3767-4725-8c7c-9dcb68c70b36', 'name': 'https://huntr.dev/bounties/47dded34-3767-4725-8c7c-9dcb68c70b36', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Patch', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/HD5S2FC2HF22A7XQXK2XXIR46EARVWIM/', 'name': 'FEDORA-2022-20e66c6698', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2022/01/15/1', 'name': "[oss-security] 20220114 Re: 3 new CVE's in vim", 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/3FH2J57GDA2WMBS6J56F6QQRA6BXQQFZ/', 'name': 'FEDORA-2022-48b86d586f', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213183', 'name': 'https://support.apple.com/kb/HT213183', 'refsource': 'CONFIRM', 'tags': ['Release Notes', 'Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Mar/29', 'name': '20220314 APPLE-SA-2022-03-14-4 macOS Monterey 12.3', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213344', 'name': 'https://support.apple.com/kb/HT213344', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Jul/13', 'name': '20220721 APPLE-SA-2022-07-20-3 macOS Big Sur 11.6.8', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-416'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.4040', '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': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionEndExcluding': '12.3', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionStartIncluding': '11.0', 'versionEndExcluding': '11.6.8', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'vim is vulnerable to Use After Free'}] | 2022-08-26T17:45Z | 2022-01-10T16: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 | Bram Moolenaar | 2022-01-08 15:39:39+00:00 | patch 8.2.4040: keeping track of allocated lines is too complicated
Problem: Keeping track of allocated lines in user functions is too
complicated.
Solution: Instead of freeing individual lines keep them all until the end. | 9f1a39a5d1cd7989ada2d1cb32f97d84360e050f | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | ga_add_string | ga_add_string( garray_T * gap , char_u * p) | ['gap', 'p'] | ga_add_string(garray_T *gap, char_u *p)
{
char_u *cp = vim_strsave(p);
if (cp == NULL)
return FAIL;
if (ga_grow(gap, 1) == FAIL)
{
vim_free(cp);
return FAIL;
}
((char_u **)(gap->ga_data))[gap->ga_len++] = cp;
return OK;
} | 74 | True | 1 |
CVE-2022-0156 | 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/vim/vim/commit/9f1a39a5d1cd7989ada2d1cb32f97d84360e050f', 'name': 'https://github.com/vim/vim/commit/9f1a39a5d1cd7989ada2d1cb32f97d84360e050f', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://huntr.dev/bounties/47dded34-3767-4725-8c7c-9dcb68c70b36', 'name': 'https://huntr.dev/bounties/47dded34-3767-4725-8c7c-9dcb68c70b36', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Patch', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/HD5S2FC2HF22A7XQXK2XXIR46EARVWIM/', 'name': 'FEDORA-2022-20e66c6698', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2022/01/15/1', 'name': "[oss-security] 20220114 Re: 3 new CVE's in vim", 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/3FH2J57GDA2WMBS6J56F6QQRA6BXQQFZ/', 'name': 'FEDORA-2022-48b86d586f', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213183', 'name': 'https://support.apple.com/kb/HT213183', 'refsource': 'CONFIRM', 'tags': ['Release Notes', 'Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Mar/29', 'name': '20220314 APPLE-SA-2022-03-14-4 macOS Monterey 12.3', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213344', 'name': 'https://support.apple.com/kb/HT213344', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Jul/13', 'name': '20220721 APPLE-SA-2022-07-20-3 macOS Big Sur 11.6.8', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-416'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.4040', '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': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionEndExcluding': '12.3', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionStartIncluding': '11.0', 'versionEndExcluding': '11.6.8', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'vim is vulnerable to Use After Free'}] | 2022-08-26T17:45Z | 2022-01-10T16: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 | Bram Moolenaar | 2022-01-08 15:39:39+00:00 | patch 8.2.4040: keeping track of allocated lines is too complicated
Problem: Keeping track of allocated lines in user functions is too
complicated.
Solution: Instead of freeing individual lines keep them all until the end. | 9f1a39a5d1cd7989ada2d1cb32f97d84360e050f | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | ga_init2 | ga_init2( garray_T * gap , int itemsize , int growsize) | ['gap', 'itemsize', 'growsize'] | ga_init2(garray_T *gap, int itemsize, int growsize)
{
ga_init(gap);
gap->ga_itemsize = itemsize;
gap->ga_growsize = growsize;
} | 31 | True | 1 |
CVE-2022-0156 | 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/vim/vim/commit/9f1a39a5d1cd7989ada2d1cb32f97d84360e050f', 'name': 'https://github.com/vim/vim/commit/9f1a39a5d1cd7989ada2d1cb32f97d84360e050f', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://huntr.dev/bounties/47dded34-3767-4725-8c7c-9dcb68c70b36', 'name': 'https://huntr.dev/bounties/47dded34-3767-4725-8c7c-9dcb68c70b36', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Patch', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/HD5S2FC2HF22A7XQXK2XXIR46EARVWIM/', 'name': 'FEDORA-2022-20e66c6698', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2022/01/15/1', 'name': "[oss-security] 20220114 Re: 3 new CVE's in vim", 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/3FH2J57GDA2WMBS6J56F6QQRA6BXQQFZ/', 'name': 'FEDORA-2022-48b86d586f', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213183', 'name': 'https://support.apple.com/kb/HT213183', 'refsource': 'CONFIRM', 'tags': ['Release Notes', 'Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Mar/29', 'name': '20220314 APPLE-SA-2022-03-14-4 macOS Monterey 12.3', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213344', 'name': 'https://support.apple.com/kb/HT213344', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Jul/13', 'name': '20220721 APPLE-SA-2022-07-20-3 macOS Big Sur 11.6.8', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-416'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.4040', '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': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionEndExcluding': '12.3', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionStartIncluding': '11.0', 'versionEndExcluding': '11.6.8', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'vim is vulnerable to Use After Free'}] | 2022-08-26T17:45Z | 2022-01-10T16: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 | Bram Moolenaar | 2022-01-08 15:39:39+00:00 | patch 8.2.4040: keeping track of allocated lines is too complicated
Problem: Keeping track of allocated lines in user functions is too
complicated.
Solution: Instead of freeing individual lines keep them all until the end. | 9f1a39a5d1cd7989ada2d1cb32f97d84360e050f | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | ignore_error_for_testing | ignore_error_for_testing( char_u * error) | ['error'] | ignore_error_for_testing(char_u *error)
{
if (ignore_error_list.ga_itemsize == 0)
ga_init2(&ignore_error_list, sizeof(char_u *), 1);
if (STRCMP("RESET", error) == 0)
ga_clear_strings(&ignore_error_list);
else
ga_add_string(&ignore_error_list, error);
} | 56 | True | 1 |
CVE-2022-0156 | 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/vim/vim/commit/9f1a39a5d1cd7989ada2d1cb32f97d84360e050f', 'name': 'https://github.com/vim/vim/commit/9f1a39a5d1cd7989ada2d1cb32f97d84360e050f', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://huntr.dev/bounties/47dded34-3767-4725-8c7c-9dcb68c70b36', 'name': 'https://huntr.dev/bounties/47dded34-3767-4725-8c7c-9dcb68c70b36', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Patch', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/HD5S2FC2HF22A7XQXK2XXIR46EARVWIM/', 'name': 'FEDORA-2022-20e66c6698', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2022/01/15/1', 'name': "[oss-security] 20220114 Re: 3 new CVE's in vim", 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/3FH2J57GDA2WMBS6J56F6QQRA6BXQQFZ/', 'name': 'FEDORA-2022-48b86d586f', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213183', 'name': 'https://support.apple.com/kb/HT213183', 'refsource': 'CONFIRM', 'tags': ['Release Notes', 'Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Mar/29', 'name': '20220314 APPLE-SA-2022-03-14-4 macOS Monterey 12.3', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213344', 'name': 'https://support.apple.com/kb/HT213344', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Jul/13', 'name': '20220721 APPLE-SA-2022-07-20-3 macOS Big Sur 11.6.8', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-416'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.4040', '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': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionEndExcluding': '12.3', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionStartIncluding': '11.0', 'versionEndExcluding': '11.6.8', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'vim is vulnerable to Use After Free'}] | 2022-08-26T17:45Z | 2022-01-10T16: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 | Bram Moolenaar | 2022-01-08 15:39:39+00:00 | patch 8.2.4040: keeping track of allocated lines is too complicated
Problem: Keeping track of allocated lines in user functions is too
complicated.
Solution: Instead of freeing individual lines keep them all until the end. | 9f1a39a5d1cd7989ada2d1cb32f97d84360e050f | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | may_get_cmd_block | may_get_cmd_block( exarg_T * eap , char_u * p , char_u ** tofree , int * flags) | ['eap', 'p', 'tofree', 'flags'] | may_get_cmd_block(exarg_T *eap, char_u *p, char_u **tofree, int *flags)
{
char_u *retp = p;
if (*p == '{' && ends_excmd2(eap->arg, skipwhite(p + 1))
&& eap->getline != NULL)
{
garray_T ga;
char_u *line = NULL;
ga_init2(&ga, sizeof(char_u *), 10);
if (ga_add_string(&ga, p) == FAIL)
return retp;
// If the argument ends in "}" it must have been concatenated already
// for ISN_EXEC.
if (p[STRLEN(p) - 1] != '}')
// Read lines between '{' and '}'. Does not support nesting or
// here-doc constructs.
for (;;)
{
vim_free(line);
if ((line = eap->getline(':', eap->cookie,
0, GETLINE_CONCAT_CONTBAR)) == NULL)
{
emsg(_(e_missing_rcurly));
break;
}
if (ga_add_string(&ga, line) == FAIL)
break;
if (*skipwhite(line) == '}')
break;
}
vim_free(line);
retp = *tofree = ga_concat_strings(&ga, "\n");
ga_clear_strings(&ga);
*flags |= UC_VIM9;
}
return retp;
} | 212 | True | 1 |
CVE-2022-0156 | 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/vim/vim/commit/9f1a39a5d1cd7989ada2d1cb32f97d84360e050f', 'name': 'https://github.com/vim/vim/commit/9f1a39a5d1cd7989ada2d1cb32f97d84360e050f', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://huntr.dev/bounties/47dded34-3767-4725-8c7c-9dcb68c70b36', 'name': 'https://huntr.dev/bounties/47dded34-3767-4725-8c7c-9dcb68c70b36', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Patch', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/HD5S2FC2HF22A7XQXK2XXIR46EARVWIM/', 'name': 'FEDORA-2022-20e66c6698', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2022/01/15/1', 'name': "[oss-security] 20220114 Re: 3 new CVE's in vim", 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/3FH2J57GDA2WMBS6J56F6QQRA6BXQQFZ/', 'name': 'FEDORA-2022-48b86d586f', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213183', 'name': 'https://support.apple.com/kb/HT213183', 'refsource': 'CONFIRM', 'tags': ['Release Notes', 'Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Mar/29', 'name': '20220314 APPLE-SA-2022-03-14-4 macOS Monterey 12.3', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213344', 'name': 'https://support.apple.com/kb/HT213344', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Jul/13', 'name': '20220721 APPLE-SA-2022-07-20-3 macOS Big Sur 11.6.8', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-416'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.4040', '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': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionEndExcluding': '12.3', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionStartIncluding': '11.0', 'versionEndExcluding': '11.6.8', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'vim is vulnerable to Use After Free'}] | 2022-08-26T17:45Z | 2022-01-10T16: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 | Bram Moolenaar | 2022-01-08 15:39:39+00:00 | patch 8.2.4040: keeping track of allocated lines is too complicated
Problem: Keeping track of allocated lines in user functions is too
complicated.
Solution: Instead of freeing individual lines keep them all until the end. | 9f1a39a5d1cd7989ada2d1cb32f97d84360e050f | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | define_function | define_function( exarg_T * eap , char_u * name_arg , char_u ** line_to_free) | ['eap', 'name_arg', 'line_to_free'] | define_function(exarg_T *eap, char_u *name_arg, char_u **line_to_free)
{
int j;
int c;
int saved_did_emsg;
char_u *name = name_arg;
int is_global = FALSE;
char_u *p;
char_u *arg;
char_u *whitep;
char_u *line_arg = NULL;
garray_T newargs;
garray_T argtypes;
garray_T default_args;
garray_T newlines;
int varargs = FALSE;
int flags = 0;
char_u *ret_type = NULL;
ufunc_T *fp = NULL;
int fp_allocated = FALSE;
int free_fp = FALSE;
int overwrite = FALSE;
dictitem_T *v;
funcdict_T fudi;
static int func_nr = 0; // number for nameless function
int paren;
hashitem_T *hi;
linenr_T sourcing_lnum_top;
int vim9script = in_vim9script();
imported_T *import = NULL;
/*
* ":function" without argument: list functions.
*/
if (ends_excmd2(eap->cmd, eap->arg))
{
if (!eap->skip)
list_functions(NULL);
set_nextcmd(eap, eap->arg);
return NULL;
}
/*
* ":function /pat": list functions matching pattern.
*/
if (*eap->arg == '/')
{
p = skip_regexp(eap->arg + 1, '/', TRUE);
if (!eap->skip)
{
regmatch_T regmatch;
c = *p;
*p = NUL;
regmatch.regprog = vim_regcomp(eap->arg + 1, RE_MAGIC);
*p = c;
if (regmatch.regprog != NULL)
{
regmatch.rm_ic = p_ic;
list_functions(®match);
vim_regfree(regmatch.regprog);
}
}
if (*p == '/')
++p;
set_nextcmd(eap, p);
return NULL;
}
ga_init(&newargs);
ga_init(&argtypes);
ga_init(&default_args);
/*
* Get the function name. There are these situations:
* func normal function name
* "name" == func, "fudi.fd_dict" == NULL
* dict.func new dictionary entry
* "name" == NULL, "fudi.fd_dict" set,
* "fudi.fd_di" == NULL, "fudi.fd_newkey" == func
* dict.func existing dict entry with a Funcref
* "name" == func, "fudi.fd_dict" set,
* "fudi.fd_di" set, "fudi.fd_newkey" == NULL
* dict.func existing dict entry that's not a Funcref
* "name" == NULL, "fudi.fd_dict" set,
* "fudi.fd_di" set, "fudi.fd_newkey" == NULL
* s:func script-local function name
* g:func global function name, same as "func"
*/
p = eap->arg;
if (name_arg != NULL)
{
// nested function, argument is (args).
paren = TRUE;
CLEAR_FIELD(fudi);
}
else
{
name = save_function_name(&p, &is_global, eap->skip,
TFN_NO_AUTOLOAD, &fudi);
paren = (vim_strchr(p, '(') != NULL);
if (name == NULL && (fudi.fd_dict == NULL || !paren) && !eap->skip)
{
/*
* Return on an invalid expression in braces, unless the expression
* evaluation has been cancelled due to an aborting error, an
* interrupt, or an exception.
*/
if (!aborting())
{
if (!eap->skip && fudi.fd_newkey != NULL)
semsg(_(e_key_not_present_in_dictionary), fudi.fd_newkey);
vim_free(fudi.fd_newkey);
return NULL;
}
else
eap->skip = TRUE;
}
}
// An error in a function call during evaluation of an expression in magic
// braces should not cause the function not to be defined.
saved_did_emsg = did_emsg;
did_emsg = FALSE;
/*
* ":function func" with only function name: list function.
*/
if (!paren)
{
if (!ends_excmd(*skipwhite(p)))
{
semsg(_(e_trailing_characters_str), p);
goto ret_free;
}
set_nextcmd(eap, p);
if (eap->nextcmd != NULL)
*p = NUL;
if (!eap->skip && !got_int)
{
fp = find_func(name, is_global, NULL);
if (fp == NULL && ASCII_ISUPPER(*eap->arg))
{
char_u *up = untrans_function_name(name);
// With Vim9 script the name was made script-local, if not
// found try again with the original name.
if (up != NULL)
fp = find_func(up, FALSE, NULL);
}
if (fp != NULL)
{
list_func_head(fp, TRUE);
for (j = 0; j < fp->uf_lines.ga_len && !got_int; ++j)
{
if (FUNCLINE(fp, j) == NULL)
continue;
msg_putchar('\n');
msg_outnum((long)(j + 1));
if (j < 9)
msg_putchar(' ');
if (j < 99)
msg_putchar(' ');
msg_prt_line(FUNCLINE(fp, j), FALSE);
out_flush(); // show a line at a time
ui_breakcheck();
}
if (!got_int)
{
msg_putchar('\n');
if (fp->uf_def_status != UF_NOT_COMPILED)
msg_puts(" enddef");
else
msg_puts(" endfunction");
}
}
else
emsg_funcname(e_undefined_function_str, eap->arg);
}
goto ret_free;
}
/*
* ":function name(arg1, arg2)" Define function.
*/
p = skipwhite(p);
if (*p != '(')
{
if (!eap->skip)
{
semsg(_(e_missing_paren_str), eap->arg);
goto ret_free;
}
// attempt to continue by skipping some text
if (vim_strchr(p, '(') != NULL)
p = vim_strchr(p, '(');
}
if ((vim9script || eap->cmdidx == CMD_def) && VIM_ISWHITE(p[-1]))
{
semsg(_(e_no_white_space_allowed_before_str_str), "(", p - 1);
goto ret_free;
}
// In Vim9 script only global functions can be redefined.
if (vim9script && eap->forceit && !is_global)
{
emsg(_(e_no_bang_allowed));
goto ret_free;
}
ga_init2(&newlines, (int)sizeof(char_u *), 10);
if (!eap->skip && name_arg == NULL)
{
// Check the name of the function. Unless it's a dictionary function
// (that we are overwriting).
if (name != NULL)
arg = name;
else
arg = fudi.fd_newkey;
if (arg != NULL && (fudi.fd_di == NULL
|| (fudi.fd_di->di_tv.v_type != VAR_FUNC
&& fudi.fd_di->di_tv.v_type != VAR_PARTIAL)))
{
char_u *name_base = arg;
int i;
if (*arg == K_SPECIAL)
{
name_base = vim_strchr(arg, '_');
if (name_base == NULL)
name_base = arg + 3;
else
++name_base;
}
for (i = 0; name_base[i] != NUL && (i == 0
? eval_isnamec1(name_base[i])
: eval_isnamec(name_base[i])); ++i)
;
if (name_base[i] != NUL)
emsg_funcname(e_invalid_argument_str, arg);
// In Vim9 script a function cannot have the same name as a
// variable.
if (vim9script && *arg == K_SPECIAL
&& eval_variable(name_base, (int)STRLEN(name_base), 0, NULL,
NULL, EVAL_VAR_NOAUTOLOAD + EVAL_VAR_IMPORT
+ EVAL_VAR_NO_FUNC) == OK)
{
semsg(_(e_redefining_script_item_str), name_base);
goto ret_free;
}
}
// Disallow using the g: dict.
if (fudi.fd_dict != NULL && fudi.fd_dict->dv_scope == VAR_DEF_SCOPE)
{
emsg(_(e_cannot_use_g_here));
goto ret_free;
}
}
// This may get more lines and make the pointers into the first line
// invalid.
++p;
if (get_function_args(&p, ')', &newargs,
eap->cmdidx == CMD_def ? &argtypes : NULL, FALSE,
NULL, &varargs, &default_args, eap->skip,
eap, line_to_free) == FAIL)
goto errret_2;
whitep = p;
if (eap->cmdidx == CMD_def)
{
// find the return type: :def Func(): type
if (*skipwhite(p) == ':')
{
if (*p != ':')
{
semsg(_(e_no_white_space_allowed_before_colon_str), p);
p = skipwhite(p);
}
else if (!IS_WHITE_OR_NUL(p[1]))
semsg(_(e_white_space_required_after_str_str), ":", p);
ret_type = skipwhite(p + 1);
p = skip_type(ret_type, FALSE);
if (p > ret_type)
{
ret_type = vim_strnsave(ret_type, p - ret_type);
whitep = p;
p = skipwhite(p);
}
else
{
semsg(_(e_expected_type_str), ret_type);
ret_type = NULL;
}
}
p = skipwhite(p);
}
else
// find extra arguments "range", "dict", "abort" and "closure"
for (;;)
{
whitep = p;
p = skipwhite(p);
if (STRNCMP(p, "range", 5) == 0)
{
flags |= FC_RANGE;
p += 5;
}
else if (STRNCMP(p, "dict", 4) == 0)
{
flags |= FC_DICT;
p += 4;
}
else if (STRNCMP(p, "abort", 5) == 0)
{
flags |= FC_ABORT;
p += 5;
}
else if (STRNCMP(p, "closure", 7) == 0)
{
flags |= FC_CLOSURE;
p += 7;
if (current_funccal == NULL)
{
emsg_funcname(e_closure_function_should_not_be_at_top_level,
name == NULL ? (char_u *)"" : name);
goto erret;
}
}
else
break;
}
// When there is a line break use what follows for the function body.
// Makes 'exe "func Test()\n...\nendfunc"' work.
if (*p == '\n')
line_arg = p + 1;
else if (*p != NUL
&& !(*p == '"' && (!vim9script || eap->cmdidx == CMD_function)
&& eap->cmdidx != CMD_def)
&& !(VIM_ISWHITE(*whitep) && *p == '#'
&& (vim9script || eap->cmdidx == CMD_def))
&& !eap->skip
&& !did_emsg)
semsg(_(e_trailing_characters_str), p);
/*
* Read the body of the function, until "}", ":endfunction" or ":enddef" is
* found.
*/
if (KeyTyped)
{
// Check if the function already exists, don't let the user type the
// whole function before telling him it doesn't work! For a script we
// need to skip the body to be able to find what follows.
if (!eap->skip && !eap->forceit)
{
if (fudi.fd_dict != NULL && fudi.fd_newkey == NULL)
emsg(_(e_dictionary_entry_already_exists));
else if (name != NULL && find_func(name, is_global, NULL) != NULL)
emsg_funcname(e_function_str_already_exists_add_bang_to_replace, name);
}
if (!eap->skip && did_emsg)
goto erret;
msg_putchar('\n'); // don't overwrite the function name
cmdline_row = msg_row;
}
// Save the starting line number.
sourcing_lnum_top = SOURCING_LNUM;
// Do not define the function when getting the body fails and when
// skipping.
if (get_function_body(eap, &newlines, line_arg, line_to_free) == FAIL
|| eap->skip)
goto erret;
/*
* If there are no errors, add the function
*/
if (fudi.fd_dict == NULL)
{
hashtab_T *ht;
v = find_var(name, &ht, TRUE);
if (v != NULL && v->di_tv.v_type == VAR_FUNC)
{
emsg_funcname(e_function_name_conflicts_with_variable_str, name);
goto erret;
}
fp = find_func_even_dead(name, is_global, NULL);
if (vim9script)
{
char_u *uname = untrans_function_name(name);
import = find_imported(uname == NULL ? name : uname, 0, NULL);
}
if (fp != NULL || import != NULL)
{
int dead = fp != NULL && (fp->uf_flags & FC_DEAD);
// Function can be replaced with "function!" and when sourcing the
// same script again, but only once.
// A name that is used by an import can not be overruled.
if (import != NULL
|| (!dead && !eap->forceit
&& (fp->uf_script_ctx.sc_sid != current_sctx.sc_sid
|| fp->uf_script_ctx.sc_seq == current_sctx.sc_seq)))
{
SOURCING_LNUM = sourcing_lnum_top;
if (vim9script)
emsg_funcname(e_name_already_defined_str, name);
else
emsg_funcname(e_function_str_already_exists_add_bang_to_replace, name);
goto erret;
}
if (fp->uf_calls > 0)
{
emsg_funcname(
e_cannot_redefine_function_str_it_is_in_use, name);
goto erret;
}
if (fp->uf_refcount > 1)
{
// This function is referenced somewhere, don't redefine it but
// create a new one.
--fp->uf_refcount;
fp->uf_flags |= FC_REMOVED;
fp = NULL;
overwrite = TRUE;
}
else
{
char_u *exp_name = fp->uf_name_exp;
// redefine existing function, keep the expanded name
VIM_CLEAR(name);
fp->uf_name_exp = NULL;
func_clear_items(fp);
fp->uf_name_exp = exp_name;
fp->uf_flags &= ~FC_DEAD;
#ifdef FEAT_PROFILE
fp->uf_profiling = FALSE;
fp->uf_prof_initialized = FALSE;
#endif
fp->uf_def_status = UF_NOT_COMPILED;
}
}
}
else
{
char numbuf[20];
fp = NULL;
if (fudi.fd_newkey == NULL && !eap->forceit)
{
emsg(_(e_dictionary_entry_already_exists));
goto erret;
}
if (fudi.fd_di == NULL)
{
// Can't add a function to a locked dictionary
if (value_check_lock(fudi.fd_dict->dv_lock, eap->arg, FALSE))
goto erret;
}
// Can't change an existing function if it is locked
else if (value_check_lock(fudi.fd_di->di_tv.v_lock, eap->arg, FALSE))
goto erret;
// Give the function a sequential number. Can only be used with a
// Funcref!
vim_free(name);
sprintf(numbuf, "%d", ++func_nr);
name = vim_strsave((char_u *)numbuf);
if (name == NULL)
goto erret;
}
if (fp == NULL)
{
if (fudi.fd_dict == NULL && vim_strchr(name, AUTOLOAD_CHAR) != NULL)
{
int slen, plen;
char_u *scriptname;
// Check that the autoload name matches the script name.
j = FAIL;
if (SOURCING_NAME != NULL)
{
scriptname = autoload_name(name);
if (scriptname != NULL)
{
p = vim_strchr(scriptname, '/');
plen = (int)STRLEN(p);
slen = (int)STRLEN(SOURCING_NAME);
if (slen > plen && fnamecmp(p,
SOURCING_NAME + slen - plen) == 0)
j = OK;
vim_free(scriptname);
}
}
if (j == FAIL)
{
linenr_T save_lnum = SOURCING_LNUM;
SOURCING_LNUM = sourcing_lnum_top;
semsg(_(e_function_name_does_not_match_script_file_name_str),
name);
SOURCING_LNUM = save_lnum;
goto erret;
}
}
fp = alloc_clear(offsetof(ufunc_T, uf_name) + STRLEN(name) + 1);
if (fp == NULL)
goto erret;
fp_allocated = TRUE;
if (fudi.fd_dict != NULL)
{
if (fudi.fd_di == NULL)
{
// add new dict entry
fudi.fd_di = dictitem_alloc(fudi.fd_newkey);
if (fudi.fd_di == NULL)
{
vim_free(fp);
fp = NULL;
goto erret;
}
if (dict_add(fudi.fd_dict, fudi.fd_di) == FAIL)
{
vim_free(fudi.fd_di);
vim_free(fp);
fp = NULL;
goto erret;
}
}
else
// overwrite existing dict entry
clear_tv(&fudi.fd_di->di_tv);
fudi.fd_di->di_tv.v_type = VAR_FUNC;
fudi.fd_di->di_tv.vval.v_string = vim_strsave(name);
// behave like "dict" was used
flags |= FC_DICT;
}
}
fp->uf_args = newargs;
fp->uf_def_args = default_args;
fp->uf_ret_type = &t_any;
fp->uf_func_type = &t_func_any;
if (eap->cmdidx == CMD_def)
{
int lnum_save = SOURCING_LNUM;
cstack_T *cstack = eap->cstack;
fp->uf_def_status = UF_TO_BE_COMPILED;
// error messages are for the first function line
SOURCING_LNUM = sourcing_lnum_top;
// The function may use script variables from the context.
function_using_block_scopes(fp, cstack);
if (parse_argument_types(fp, &argtypes, varargs) == FAIL)
{
SOURCING_LNUM = lnum_save;
free_fp = fp_allocated;
goto erret;
}
varargs = FALSE;
// parse the return type, if any
if (parse_return_type(fp, ret_type) == FAIL)
{
SOURCING_LNUM = lnum_save;
free_fp = fp_allocated;
goto erret;
}
SOURCING_LNUM = lnum_save;
}
else
fp->uf_def_status = UF_NOT_COMPILED;
if (fp_allocated)
{
// insert the new function in the function list
set_ufunc_name(fp, name);
if (overwrite)
{
hi = hash_find(&func_hashtab, name);
hi->hi_key = UF2HIKEY(fp);
}
else if (hash_add(&func_hashtab, UF2HIKEY(fp)) == FAIL)
{
free_fp = TRUE;
goto erret;
}
fp->uf_refcount = 1;
}
fp->uf_lines = newlines;
newlines.ga_data = NULL;
if ((flags & FC_CLOSURE) != 0)
{
if (register_closure(fp) == FAIL)
goto erret;
}
else
fp->uf_scoped = NULL;
#ifdef FEAT_PROFILE
if (prof_def_func())
func_do_profile(fp);
#endif
fp->uf_varargs = varargs;
if (sandbox)
flags |= FC_SANDBOX;
if (vim9script && !ASCII_ISUPPER(*fp->uf_name))
flags |= FC_VIM9;
fp->uf_flags = flags;
fp->uf_calls = 0;
fp->uf_cleared = FALSE;
fp->uf_script_ctx = current_sctx;
fp->uf_script_ctx_version = current_sctx.sc_version;
fp->uf_script_ctx.sc_lnum += sourcing_lnum_top;
if (is_export)
{
fp->uf_flags |= FC_EXPORT;
// let ex_export() know the export worked.
is_export = FALSE;
}
if (eap->cmdidx == CMD_def)
set_function_type(fp);
else if (fp->uf_script_ctx.sc_version == SCRIPT_VERSION_VIM9)
// :func does not use Vim9 script syntax, even in a Vim9 script file
fp->uf_script_ctx.sc_version = SCRIPT_VERSION_MAX;
goto ret_free;
erret:
ga_clear_strings(&newargs);
ga_clear_strings(&default_args);
if (fp != NULL)
{
ga_init(&fp->uf_args);
ga_init(&fp->uf_def_args);
}
errret_2:
ga_clear_strings(&newlines);
if (fp != NULL)
VIM_CLEAR(fp->uf_arg_types);
if (free_fp)
{
vim_free(fp);
fp = NULL;
}
ret_free:
ga_clear_strings(&argtypes);
vim_free(fudi.fd_newkey);
if (name != name_arg)
vim_free(name);
vim_free(ret_type);
did_emsg |= saved_did_emsg;
return fp;
} | 2885 | True | 1 |
CVE-2022-0156 | 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/vim/vim/commit/9f1a39a5d1cd7989ada2d1cb32f97d84360e050f', 'name': 'https://github.com/vim/vim/commit/9f1a39a5d1cd7989ada2d1cb32f97d84360e050f', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://huntr.dev/bounties/47dded34-3767-4725-8c7c-9dcb68c70b36', 'name': 'https://huntr.dev/bounties/47dded34-3767-4725-8c7c-9dcb68c70b36', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Patch', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/HD5S2FC2HF22A7XQXK2XXIR46EARVWIM/', 'name': 'FEDORA-2022-20e66c6698', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2022/01/15/1', 'name': "[oss-security] 20220114 Re: 3 new CVE's in vim", 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/3FH2J57GDA2WMBS6J56F6QQRA6BXQQFZ/', 'name': 'FEDORA-2022-48b86d586f', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213183', 'name': 'https://support.apple.com/kb/HT213183', 'refsource': 'CONFIRM', 'tags': ['Release Notes', 'Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Mar/29', 'name': '20220314 APPLE-SA-2022-03-14-4 macOS Monterey 12.3', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213344', 'name': 'https://support.apple.com/kb/HT213344', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Jul/13', 'name': '20220721 APPLE-SA-2022-07-20-3 macOS Big Sur 11.6.8', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-416'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.4040', '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': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionEndExcluding': '12.3', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionStartIncluding': '11.0', 'versionEndExcluding': '11.6.8', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'vim is vulnerable to Use After Free'}] | 2022-08-26T17:45Z | 2022-01-10T16: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 | Bram Moolenaar | 2022-01-08 15:39:39+00:00 | patch 8.2.4040: keeping track of allocated lines is too complicated
Problem: Keeping track of allocated lines in user functions is too
complicated.
Solution: Instead of freeing individual lines keep them all until the end. | 9f1a39a5d1cd7989ada2d1cb32f97d84360e050f | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | ex_function | ex_function( exarg_T * eap) | ['eap'] | ex_function(exarg_T *eap)
{
char_u *line_to_free = NULL;
(void)define_function(eap, NULL, &line_to_free);
vim_free(line_to_free);
} | 32 | True | 1 |
CVE-2022-0156 | 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/vim/vim/commit/9f1a39a5d1cd7989ada2d1cb32f97d84360e050f', 'name': 'https://github.com/vim/vim/commit/9f1a39a5d1cd7989ada2d1cb32f97d84360e050f', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://huntr.dev/bounties/47dded34-3767-4725-8c7c-9dcb68c70b36', 'name': 'https://huntr.dev/bounties/47dded34-3767-4725-8c7c-9dcb68c70b36', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Patch', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/HD5S2FC2HF22A7XQXK2XXIR46EARVWIM/', 'name': 'FEDORA-2022-20e66c6698', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2022/01/15/1', 'name': "[oss-security] 20220114 Re: 3 new CVE's in vim", 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/3FH2J57GDA2WMBS6J56F6QQRA6BXQQFZ/', 'name': 'FEDORA-2022-48b86d586f', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213183', 'name': 'https://support.apple.com/kb/HT213183', 'refsource': 'CONFIRM', 'tags': ['Release Notes', 'Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Mar/29', 'name': '20220314 APPLE-SA-2022-03-14-4 macOS Monterey 12.3', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213344', 'name': 'https://support.apple.com/kb/HT213344', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Jul/13', 'name': '20220721 APPLE-SA-2022-07-20-3 macOS Big Sur 11.6.8', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-416'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.4040', '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': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionEndExcluding': '12.3', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionStartIncluding': '11.0', 'versionEndExcluding': '11.6.8', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'vim is vulnerable to Use After Free'}] | 2022-08-26T17:45Z | 2022-01-10T16: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 | Bram Moolenaar | 2022-01-08 15:39:39+00:00 | patch 8.2.4040: keeping track of allocated lines is too complicated
Problem: Keeping track of allocated lines in user functions is too
complicated.
Solution: Instead of freeing individual lines keep them all until the end. | 9f1a39a5d1cd7989ada2d1cb32f97d84360e050f | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | get_function_args | get_function_args( char_u ** argp , char_u endchar , garray_T * newargs , garray_T * argtypes , int types_optional , evalarg_T * evalarg , int * varargs , garray_T * default_args , int skip , exarg_T * eap , char_u ** line_to_free) | ['argp', 'endchar', 'newargs', 'argtypes', 'types_optional', 'evalarg', 'varargs', 'default_args', 'skip', 'eap', 'line_to_free'] | get_function_args(
char_u **argp,
char_u endchar,
garray_T *newargs,
garray_T *argtypes, // NULL unless using :def
int types_optional, // types optional if "argtypes" is not NULL
evalarg_T *evalarg, // context or NULL
int *varargs,
garray_T *default_args,
int skip,
exarg_T *eap,
char_u **line_to_free)
{
int mustend = FALSE;
char_u *arg;
char_u *p;
int c;
int any_default = FALSE;
char_u *expr;
char_u *whitep = *argp;
if (newargs != NULL)
ga_init2(newargs, (int)sizeof(char_u *), 3);
if (argtypes != NULL)
ga_init2(argtypes, (int)sizeof(char_u *), 3);
if (!skip && default_args != NULL)
ga_init2(default_args, (int)sizeof(char_u *), 3);
if (varargs != NULL)
*varargs = FALSE;
/*
* Isolate the arguments: "arg1, arg2, ...)"
*/
arg = skipwhite(*argp);
p = arg;
while (*p != endchar)
{
while (eap != NULL && eap->getline != NULL
&& (*p == NUL || (VIM_ISWHITE(*whitep) && *p == '#')))
{
// End of the line, get the next one.
char_u *theline = get_function_line(eap, line_to_free, 0,
GETLINE_CONCAT_CONT);
if (theline == NULL)
break;
whitep = (char_u *)" ";
p = skipwhite(theline);
}
if (mustend && *p != endchar)
{
if (!skip)
semsg(_(e_invalid_argument_str), *argp);
goto err_ret;
}
if (*p == endchar)
break;
if (p[0] == '.' && p[1] == '.' && p[2] == '.')
{
if (varargs != NULL)
*varargs = TRUE;
p += 3;
mustend = TRUE;
if (argtypes != NULL)
{
// ...name: list<type>
if (!eval_isnamec1(*p))
{
if (!skip)
emsg(_(e_missing_name_after_dots));
goto err_ret;
}
arg = p;
p = one_function_arg(p, newargs, argtypes, types_optional,
evalarg, TRUE, skip);
if (p == arg)
break;
if (*skipwhite(p) == '=')
{
emsg(_(e_cannot_use_default_for_variable_arguments));
break;
}
}
}
else
{
char_u *np;
arg = p;
p = one_function_arg(p, newargs, argtypes, types_optional,
evalarg, FALSE, skip);
if (p == arg)
break;
// Recognize " = expr" but not " == expr". A lambda can have
// "(a = expr" but "(a == expr" and "(a =~ expr" are not a lambda.
np = skipwhite(p);
if (*np == '=' && np[1] != '=' && np[1] != '~'
&& default_args != NULL)
{
typval_T rettv;
// find the end of the expression (doesn't evaluate it)
any_default = TRUE;
p = skipwhite(p) + 1;
whitep = p;
p = skipwhite(p);
expr = p;
if (eval1(&p, &rettv, NULL) != FAIL)
{
if (!skip)
{
if (ga_grow(default_args, 1) == FAIL)
goto err_ret;
// trim trailing whitespace
while (p > expr && VIM_ISWHITE(p[-1]))
p--;
c = *p;
*p = NUL;
expr = vim_strsave(expr);
if (expr == NULL)
{
*p = c;
goto err_ret;
}
((char_u **)(default_args->ga_data))
[default_args->ga_len] = expr;
default_args->ga_len++;
*p = c;
}
}
else
mustend = TRUE;
}
else if (any_default)
{
emsg(_(e_non_default_argument_follows_default_argument));
goto err_ret;
}
if (VIM_ISWHITE(*p) && *skipwhite(p) == ',')
{
// Be tolerant when skipping
if (!skip)
{
semsg(_(e_no_white_space_allowed_before_str_str), ",", p);
goto err_ret;
}
p = skipwhite(p);
}
if (*p == ',')
{
++p;
// Don't give this error when skipping, it makes the "->" not
// found in "{k,v -> x}" and give a confusing error.
// Allow missing space after comma in legacy functions.
if (!skip && argtypes != NULL
&& !IS_WHITE_OR_NUL(*p) && *p != endchar)
{
semsg(_(e_white_space_required_after_str_str), ",", p - 1);
goto err_ret;
}
}
else
mustend = TRUE;
}
whitep = p;
p = skipwhite(p);
}
if (*p != endchar)
goto err_ret;
++p; // skip "endchar"
*argp = p;
return OK;
err_ret:
if (newargs != NULL)
ga_clear_strings(newargs);
if (!skip && default_args != NULL)
ga_clear_strings(default_args);
return FAIL;
} | 831 | True | 1 |
CVE-2022-0156 | 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/vim/vim/commit/9f1a39a5d1cd7989ada2d1cb32f97d84360e050f', 'name': 'https://github.com/vim/vim/commit/9f1a39a5d1cd7989ada2d1cb32f97d84360e050f', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://huntr.dev/bounties/47dded34-3767-4725-8c7c-9dcb68c70b36', 'name': 'https://huntr.dev/bounties/47dded34-3767-4725-8c7c-9dcb68c70b36', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Patch', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/HD5S2FC2HF22A7XQXK2XXIR46EARVWIM/', 'name': 'FEDORA-2022-20e66c6698', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2022/01/15/1', 'name': "[oss-security] 20220114 Re: 3 new CVE's in vim", 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/3FH2J57GDA2WMBS6J56F6QQRA6BXQQFZ/', 'name': 'FEDORA-2022-48b86d586f', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213183', 'name': 'https://support.apple.com/kb/HT213183', 'refsource': 'CONFIRM', 'tags': ['Release Notes', 'Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Mar/29', 'name': '20220314 APPLE-SA-2022-03-14-4 macOS Monterey 12.3', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213344', 'name': 'https://support.apple.com/kb/HT213344', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Jul/13', 'name': '20220721 APPLE-SA-2022-07-20-3 macOS Big Sur 11.6.8', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-416'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.4040', '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': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionEndExcluding': '12.3', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionStartIncluding': '11.0', 'versionEndExcluding': '11.6.8', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'vim is vulnerable to Use After Free'}] | 2022-08-26T17:45Z | 2022-01-10T16: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 | Bram Moolenaar | 2022-01-08 15:39:39+00:00 | patch 8.2.4040: keeping track of allocated lines is too complicated
Problem: Keeping track of allocated lines in user functions is too
complicated.
Solution: Instead of freeing individual lines keep them all until the end. | 9f1a39a5d1cd7989ada2d1cb32f97d84360e050f | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | get_function_body | get_function_body( exarg_T * eap , garray_T * newlines , char_u * line_arg_in , char_u ** line_to_free) | ['eap', 'newlines', 'line_arg_in', 'line_to_free'] | get_function_body(
exarg_T *eap,
garray_T *newlines,
char_u *line_arg_in,
char_u **line_to_free)
{
linenr_T sourcing_lnum_top = SOURCING_LNUM;
linenr_T sourcing_lnum_off;
int saved_wait_return = need_wait_return;
char_u *line_arg = line_arg_in;
int vim9_function = eap->cmdidx == CMD_def
|| eap->cmdidx == CMD_block;
#define MAX_FUNC_NESTING 50
char nesting_def[MAX_FUNC_NESTING];
char nesting_inline[MAX_FUNC_NESTING];
int nesting = 0;
getline_opt_T getline_options;
int indent = 2;
char_u *skip_until = NULL;
int ret = FAIL;
int is_heredoc = FALSE;
int heredoc_concat_len = 0;
garray_T heredoc_ga;
char_u *heredoc_trimmed = NULL;
ga_init2(&heredoc_ga, 1, 500);
// Detect having skipped over comment lines to find the return
// type. Add NULL lines to keep the line count correct.
sourcing_lnum_off = get_sourced_lnum(eap->getline, eap->cookie);
if (SOURCING_LNUM < sourcing_lnum_off)
{
sourcing_lnum_off -= SOURCING_LNUM;
if (ga_grow(newlines, sourcing_lnum_off) == FAIL)
goto theend;
while (sourcing_lnum_off-- > 0)
((char_u **)(newlines->ga_data))[newlines->ga_len++] = NULL;
}
nesting_def[0] = vim9_function;
nesting_inline[0] = eap->cmdidx == CMD_block;
getline_options = vim9_function
? GETLINE_CONCAT_CONTBAR : GETLINE_CONCAT_CONT;
for (;;)
{
char_u *theline;
char_u *p;
char_u *arg;
if (KeyTyped)
{
msg_scroll = TRUE;
saved_wait_return = FALSE;
}
need_wait_return = FALSE;
if (line_arg != NULL)
{
// Use eap->arg, split up in parts by line breaks.
theline = line_arg;
p = vim_strchr(theline, '\n');
if (p == NULL)
line_arg += STRLEN(line_arg);
else
{
*p = NUL;
line_arg = p + 1;
}
}
else
{
theline = get_function_line(eap, line_to_free, indent,
getline_options);
}
if (KeyTyped)
lines_left = Rows - 1;
if (theline == NULL)
{
// Use the start of the function for the line number.
SOURCING_LNUM = sourcing_lnum_top;
if (skip_until != NULL)
semsg(_(e_missing_heredoc_end_marker_str), skip_until);
else if (nesting_inline[nesting])
emsg(_(e_missing_end_block));
else if (eap->cmdidx == CMD_def)
emsg(_(e_missing_enddef));
else
emsg(_(e_missing_endfunction));
goto theend;
}
// Detect line continuation: SOURCING_LNUM increased more than one.
sourcing_lnum_off = get_sourced_lnum(eap->getline, eap->cookie);
if (SOURCING_LNUM < sourcing_lnum_off)
sourcing_lnum_off -= SOURCING_LNUM;
else
sourcing_lnum_off = 0;
if (skip_until != NULL)
{
// Don't check for ":endfunc"/":enddef" between
// * ":append" and "."
// * ":python <<EOF" and "EOF"
// * ":let {var-name} =<< [trim] {marker}" and "{marker}"
if (heredoc_trimmed == NULL
|| (is_heredoc && skipwhite(theline) == theline)
|| STRNCMP(theline, heredoc_trimmed,
STRLEN(heredoc_trimmed)) == 0)
{
if (heredoc_trimmed == NULL)
p = theline;
else if (is_heredoc)
p = skipwhite(theline) == theline
? theline : theline + STRLEN(heredoc_trimmed);
else
p = theline + STRLEN(heredoc_trimmed);
if (STRCMP(p, skip_until) == 0)
{
VIM_CLEAR(skip_until);
VIM_CLEAR(heredoc_trimmed);
getline_options = vim9_function
? GETLINE_CONCAT_CONTBAR : GETLINE_CONCAT_CONT;
is_heredoc = FALSE;
if (heredoc_concat_len > 0)
{
// Replace the starting line with all the concatenated
// lines.
ga_concat(&heredoc_ga, theline);
vim_free(((char_u **)(newlines->ga_data))[
heredoc_concat_len - 1]);
((char_u **)(newlines->ga_data))[
heredoc_concat_len - 1] = heredoc_ga.ga_data;
ga_init(&heredoc_ga);
heredoc_concat_len = 0;
theline += STRLEN(theline); // skip the "EOF"
}
}
}
}
else
{
int c;
char_u *end;
// skip ':' and blanks
for (p = theline; VIM_ISWHITE(*p) || *p == ':'; ++p)
;
// Check for "endfunction", "enddef" or "}".
// When a ":" follows it must be a dict key; "enddef: value,"
if (nesting_inline[nesting]
? *p == '}'
: (checkforcmd(&p, nesting_def[nesting]
? "enddef" : "endfunction", 4)
&& *p != ':'))
{
if (nesting-- == 0)
{
char_u *nextcmd = NULL;
if (*p == '|' || *p == '}')
nextcmd = p + 1;
else if (line_arg != NULL && *skipwhite(line_arg) != NUL)
nextcmd = line_arg;
else if (*p != NUL && *p != (vim9_function ? '#' : '"')
&& (vim9_function || p_verbose > 0))
{
SOURCING_LNUM = sourcing_lnum_top
+ newlines->ga_len + 1;
if (eap->cmdidx == CMD_def)
semsg(_(e_text_found_after_str_str), "enddef", p);
else
give_warning2((char_u *)
_("W22: Text found after :endfunction: %s"),
p, TRUE);
}
if (nextcmd != NULL && *skipwhite(nextcmd) != NUL)
{
// Another command follows. If the line came from "eap"
// we can simply point into it, otherwise we need to
// change "eap->cmdlinep".
eap->nextcmd = nextcmd;
if (*line_to_free != NULL
&& *eap->cmdlinep != *line_to_free)
{
vim_free(*eap->cmdlinep);
*eap->cmdlinep = *line_to_free;
*line_to_free = NULL;
}
}
break;
}
}
// Check for mismatched "endfunc" or "enddef".
// We don't check for "def" inside "func" thus we also can't check
// for "enddef".
// We continue to find the end of the function, although we might
// not find it.
else if (nesting_def[nesting])
{
if (checkforcmd(&p, "endfunction", 4) && *p != ':')
emsg(_(e_mismatched_endfunction));
}
else if (eap->cmdidx == CMD_def && checkforcmd(&p, "enddef", 4))
emsg(_(e_mismatched_enddef));
// Increase indent inside "if", "while", "for" and "try", decrease
// at "end".
if (indent > 2 && (*p == '}' || STRNCMP(p, "end", 3) == 0))
indent -= 2;
else if (STRNCMP(p, "if", 2) == 0
|| STRNCMP(p, "wh", 2) == 0
|| STRNCMP(p, "for", 3) == 0
|| STRNCMP(p, "try", 3) == 0)
indent += 2;
// Check for defining a function inside this function.
// Only recognize "def" inside "def", not inside "function",
// For backwards compatibility, see Test_function_python().
c = *p;
if (is_function_cmd(&p)
|| (eap->cmdidx == CMD_def && checkforcmd(&p, "def", 3)))
{
if (*p == '!')
p = skipwhite(p + 1);
p += eval_fname_script(p);
vim_free(trans_function_name(&p, NULL, TRUE, 0, NULL,
NULL, NULL));
if (*skipwhite(p) == '(')
{
if (nesting == MAX_FUNC_NESTING - 1)
emsg(_(e_function_nesting_too_deep));
else
{
++nesting;
nesting_def[nesting] = (c == 'd');
nesting_inline[nesting] = FALSE;
indent += 2;
}
}
}
if (nesting_def[nesting] ? *p != '#' : *p != '"')
{
// Not a comment line: check for nested inline function.
end = p + STRLEN(p) - 1;
while (end > p && VIM_ISWHITE(*end))
--end;
if (end > p + 1 && *end == '{' && VIM_ISWHITE(end[-1]))
{
int is_block;
// check for trailing "=> {": start of an inline function
--end;
while (end > p && VIM_ISWHITE(*end))
--end;
is_block = end > p + 2 && end[-1] == '=' && end[0] == '>';
if (!is_block)
{
char_u *s = p;
// check for line starting with "au" for :autocmd or
// "com" for :command, these can use a {} block
is_block = checkforcmd_noparen(&s, "autocmd", 2)
|| checkforcmd_noparen(&s, "command", 3);
}
if (is_block)
{
if (nesting == MAX_FUNC_NESTING - 1)
emsg(_(e_function_nesting_too_deep));
else
{
++nesting;
nesting_def[nesting] = TRUE;
nesting_inline[nesting] = TRUE;
indent += 2;
}
}
}
}
// Check for ":append", ":change", ":insert". Not for :def.
p = skip_range(p, FALSE, NULL);
if (!vim9_function
&& ((p[0] == 'a' && (!ASCII_ISALPHA(p[1]) || p[1] == 'p'))
|| (p[0] == 'c'
&& (!ASCII_ISALPHA(p[1]) || (p[1] == 'h'
&& (!ASCII_ISALPHA(p[2]) || (p[2] == 'a'
&& (STRNCMP(&p[3], "nge", 3) != 0
|| !ASCII_ISALPHA(p[6])))))))
|| (p[0] == 'i'
&& (!ASCII_ISALPHA(p[1]) || (p[1] == 'n'
&& (!ASCII_ISALPHA(p[2])
|| (p[2] == 's'
&& (!ASCII_ISALPHA(p[3])
|| p[3] == 'e'))))))))
skip_until = vim_strsave((char_u *)".");
// Check for ":python <<EOF", ":tcl <<EOF", etc.
arg = skipwhite(skiptowhite(p));
if (arg[0] == '<' && arg[1] =='<'
&& ((p[0] == 'p' && p[1] == 'y'
&& (!ASCII_ISALNUM(p[2]) || p[2] == 't'
|| ((p[2] == '3' || p[2] == 'x')
&& !ASCII_ISALPHA(p[3]))))
|| (p[0] == 'p' && p[1] == 'e'
&& (!ASCII_ISALPHA(p[2]) || p[2] == 'r'))
|| (p[0] == 't' && p[1] == 'c'
&& (!ASCII_ISALPHA(p[2]) || p[2] == 'l'))
|| (p[0] == 'l' && p[1] == 'u' && p[2] == 'a'
&& !ASCII_ISALPHA(p[3]))
|| (p[0] == 'r' && p[1] == 'u' && p[2] == 'b'
&& (!ASCII_ISALPHA(p[3]) || p[3] == 'y'))
|| (p[0] == 'm' && p[1] == 'z'
&& (!ASCII_ISALPHA(p[2]) || p[2] == 's'))
))
{
// ":python <<" continues until a dot, like ":append"
p = skipwhite(arg + 2);
if (STRNCMP(p, "trim", 4) == 0)
{
// Ignore leading white space.
p = skipwhite(p + 4);
heredoc_trimmed = vim_strnsave(theline,
skipwhite(theline) - theline);
}
if (*p == NUL)
skip_until = vim_strsave((char_u *)".");
else
skip_until = vim_strnsave(p, skiptowhite(p) - p);
getline_options = GETLINE_NONE;
is_heredoc = TRUE;
if (eap->cmdidx == CMD_def)
heredoc_concat_len = newlines->ga_len + 1;
}
// Check for ":cmd v =<< [trim] EOF"
// and ":cmd [a, b] =<< [trim] EOF"
// and "lines =<< [trim] EOF" for Vim9
// Where "cmd" can be "let", "var", "final" or "const".
arg = skipwhite(skiptowhite(p));
if (*arg == '[')
arg = vim_strchr(arg, ']');
if (arg != NULL)
{
int found = (eap->cmdidx == CMD_def && arg[0] == '='
&& arg[1] == '<' && arg[2] =='<');
if (!found)
// skip over the argument after "cmd"
arg = skipwhite(skiptowhite(arg));
if (found || (arg[0] == '=' && arg[1] == '<' && arg[2] =='<'
&& (checkforcmd(&p, "let", 2)
|| checkforcmd(&p, "var", 3)
|| checkforcmd(&p, "final", 5)
|| checkforcmd(&p, "const", 5))))
{
p = skipwhite(arg + 3);
if (STRNCMP(p, "trim", 4) == 0)
{
// Ignore leading white space.
p = skipwhite(p + 4);
heredoc_trimmed = vim_strnsave(theline,
skipwhite(theline) - theline);
}
skip_until = vim_strnsave(p, skiptowhite(p) - p);
getline_options = GETLINE_NONE;
is_heredoc = TRUE;
}
}
}
// Add the line to the function.
if (ga_grow(newlines, 1 + sourcing_lnum_off) == FAIL)
goto theend;
if (heredoc_concat_len > 0)
{
// For a :def function "python << EOF" concatenates all the lines,
// to be used for the instruction later.
ga_concat(&heredoc_ga, theline);
ga_concat(&heredoc_ga, (char_u *)"\n");
p = vim_strsave((char_u *)"");
}
else
{
// Copy the line to newly allocated memory. get_one_sourceline()
// allocates 250 bytes per line, this saves 80% on average. The
// cost is an extra alloc/free.
p = vim_strsave(theline);
}
if (p == NULL)
goto theend;
((char_u **)(newlines->ga_data))[newlines->ga_len++] = p;
// Add NULL lines for continuation lines, so that the line count is
// equal to the index in the growarray.
while (sourcing_lnum_off-- > 0)
((char_u **)(newlines->ga_data))[newlines->ga_len++] = NULL;
// Check for end of eap->arg.
if (line_arg != NULL && *line_arg == NUL)
line_arg = NULL;
}
// Return OK when no error was detected.
if (!did_emsg)
ret = OK;
theend:
vim_free(skip_until);
vim_free(heredoc_trimmed);
vim_free(heredoc_ga.ga_data);
need_wait_return |= saved_wait_return;
return ret;
} | 2303 | True | 1 |
CVE-2022-0156 | 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/vim/vim/commit/9f1a39a5d1cd7989ada2d1cb32f97d84360e050f', 'name': 'https://github.com/vim/vim/commit/9f1a39a5d1cd7989ada2d1cb32f97d84360e050f', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://huntr.dev/bounties/47dded34-3767-4725-8c7c-9dcb68c70b36', 'name': 'https://huntr.dev/bounties/47dded34-3767-4725-8c7c-9dcb68c70b36', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Patch', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/HD5S2FC2HF22A7XQXK2XXIR46EARVWIM/', 'name': 'FEDORA-2022-20e66c6698', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2022/01/15/1', 'name': "[oss-security] 20220114 Re: 3 new CVE's in vim", 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/3FH2J57GDA2WMBS6J56F6QQRA6BXQQFZ/', 'name': 'FEDORA-2022-48b86d586f', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213183', 'name': 'https://support.apple.com/kb/HT213183', 'refsource': 'CONFIRM', 'tags': ['Release Notes', 'Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Mar/29', 'name': '20220314 APPLE-SA-2022-03-14-4 macOS Monterey 12.3', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213344', 'name': 'https://support.apple.com/kb/HT213344', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Jul/13', 'name': '20220721 APPLE-SA-2022-07-20-3 macOS Big Sur 11.6.8', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-416'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.4040', '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': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionEndExcluding': '12.3', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionStartIncluding': '11.0', 'versionEndExcluding': '11.6.8', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'vim is vulnerable to Use After Free'}] | 2022-08-26T17:45Z | 2022-01-10T16: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 | Bram Moolenaar | 2022-01-08 15:39:39+00:00 | patch 8.2.4040: keeping track of allocated lines is too complicated
Problem: Keeping track of allocated lines in user functions is too
complicated.
Solution: Instead of freeing individual lines keep them all until the end. | 9f1a39a5d1cd7989ada2d1cb32f97d84360e050f | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | get_function_line | get_function_line( exarg_T * eap , char_u ** line_to_free , int indent , getline_opt_T getline_options) | ['eap', 'line_to_free', 'indent', 'getline_options'] | get_function_line(
exarg_T *eap,
char_u **line_to_free,
int indent,
getline_opt_T getline_options)
{
char_u *theline;
if (eap->getline == NULL)
theline = getcmdline(':', 0L, indent, 0);
else
theline = eap->getline(':', eap->cookie, indent, getline_options);
if (theline != NULL)
{
if (*eap->cmdlinep == *line_to_free)
*eap->cmdlinep = theline;
vim_free(*line_to_free);
*line_to_free = theline;
}
return theline;
} | 100 | True | 1 |
CVE-2022-0156 | 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/vim/vim/commit/9f1a39a5d1cd7989ada2d1cb32f97d84360e050f', 'name': 'https://github.com/vim/vim/commit/9f1a39a5d1cd7989ada2d1cb32f97d84360e050f', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://huntr.dev/bounties/47dded34-3767-4725-8c7c-9dcb68c70b36', 'name': 'https://huntr.dev/bounties/47dded34-3767-4725-8c7c-9dcb68c70b36', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Patch', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/HD5S2FC2HF22A7XQXK2XXIR46EARVWIM/', 'name': 'FEDORA-2022-20e66c6698', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2022/01/15/1', 'name': "[oss-security] 20220114 Re: 3 new CVE's in vim", 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/3FH2J57GDA2WMBS6J56F6QQRA6BXQQFZ/', 'name': 'FEDORA-2022-48b86d586f', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213183', 'name': 'https://support.apple.com/kb/HT213183', 'refsource': 'CONFIRM', 'tags': ['Release Notes', 'Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Mar/29', 'name': '20220314 APPLE-SA-2022-03-14-4 macOS Monterey 12.3', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213344', 'name': 'https://support.apple.com/kb/HT213344', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Jul/13', 'name': '20220721 APPLE-SA-2022-07-20-3 macOS Big Sur 11.6.8', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-416'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.4040', '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': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionEndExcluding': '12.3', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionStartIncluding': '11.0', 'versionEndExcluding': '11.6.8', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'vim is vulnerable to Use After Free'}] | 2022-08-26T17:45Z | 2022-01-10T16: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 | Bram Moolenaar | 2022-01-08 15:39:39+00:00 | patch 8.2.4040: keeping track of allocated lines is too complicated
Problem: Keeping track of allocated lines in user functions is too
complicated.
Solution: Instead of freeing individual lines keep them all until the end. | 9f1a39a5d1cd7989ada2d1cb32f97d84360e050f | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | lambda_function_body | lambda_function_body( char_u ** arg , typval_T * rettv , evalarg_T * evalarg , garray_T * newargs , garray_T * argtypes , int varargs , garray_T * default_args , char_u * ret_type) | ['arg', 'rettv', 'evalarg', 'newargs', 'argtypes', 'varargs', 'default_args', 'ret_type'] | lambda_function_body(
char_u **arg,
typval_T *rettv,
evalarg_T *evalarg,
garray_T *newargs,
garray_T *argtypes,
int varargs,
garray_T *default_args,
char_u *ret_type)
{
int evaluate = (evalarg->eval_flags & EVAL_EVALUATE);
garray_T *gap = &evalarg->eval_ga;
garray_T *freegap = &evalarg->eval_freega;
ufunc_T *ufunc = NULL;
exarg_T eap;
garray_T newlines;
char_u *cmdline = NULL;
int ret = FAIL;
char_u *line_to_free = NULL;
partial_T *pt;
char_u *name;
int lnum_save = -1;
linenr_T sourcing_lnum_top = SOURCING_LNUM;
if (!ends_excmd2(*arg, skipwhite(*arg + 1)))
{
semsg(_(e_trailing_characters_str), *arg + 1);
return FAIL;
}
CLEAR_FIELD(eap);
eap.cmdidx = CMD_block;
eap.forceit = FALSE;
eap.cmdlinep = &cmdline;
eap.skip = !evaluate;
if (evalarg->eval_cctx != NULL)
fill_exarg_from_cctx(&eap, evalarg->eval_cctx);
else
{
eap.getline = evalarg->eval_getline;
eap.cookie = evalarg->eval_cookie;
}
ga_init2(&newlines, (int)sizeof(char_u *), 10);
if (get_function_body(&eap, &newlines, NULL, &line_to_free) == FAIL)
{
if (cmdline != line_to_free)
vim_free(cmdline);
goto erret;
}
// When inside a lambda must add the function lines to evalarg.eval_ga.
evalarg->eval_break_count += newlines.ga_len;
if (gap->ga_itemsize > 0)
{
int idx;
char_u *last;
size_t plen;
char_u *pnl;
for (idx = 0; idx < newlines.ga_len; ++idx)
{
char_u *p = skipwhite(((char_u **)newlines.ga_data)[idx]);
if (ga_grow(gap, 1) == FAIL || ga_grow(freegap, 1) == FAIL)
goto erret;
// Going to concatenate the lines after parsing. For an empty or
// comment line use an empty string.
// Insert NL characters at the start of each line, the string will
// be split again later in .get_lambda_tv().
if (*p == NUL || vim9_comment_start(p))
p = (char_u *)"";
plen = STRLEN(p);
pnl = vim_strnsave((char_u *)"\n", plen + 1);
if (pnl != NULL)
mch_memmove(pnl + 1, p, plen + 1);
((char_u **)gap->ga_data)[gap->ga_len++] = pnl;
((char_u **)freegap->ga_data)[freegap->ga_len++] = pnl;
}
if (ga_grow(gap, 1) == FAIL || ga_grow(freegap, 1) == FAIL)
goto erret;
if (eap.nextcmd != NULL)
// more is following after the "}", which was skipped
last = cmdline;
else
// nothing is following the "}"
last = (char_u *)"}";
plen = STRLEN(last);
pnl = vim_strnsave((char_u *)"\n", plen + 1);
if (pnl != NULL)
mch_memmove(pnl + 1, last, plen + 1);
((char_u **)gap->ga_data)[gap->ga_len++] = pnl;
((char_u **)freegap->ga_data)[freegap->ga_len++] = pnl;
}
if (eap.nextcmd != NULL)
{
garray_T *tfgap = &evalarg->eval_tofree_ga;
// Something comes after the "}".
*arg = eap.nextcmd;
// "arg" points into cmdline, need to keep the line and free it later.
if (ga_grow(tfgap, 1) == OK)
{
((char_u **)(tfgap->ga_data))[tfgap->ga_len++] = cmdline;
evalarg->eval_using_cmdline = TRUE;
if (cmdline == line_to_free)
line_to_free = NULL;
}
}
else
*arg = (char_u *)"";
if (!evaluate)
{
ret = OK;
goto erret;
}
name = get_lambda_name();
ufunc = alloc_clear(offsetof(ufunc_T, uf_name) + STRLEN(name) + 1);
if (ufunc == NULL)
goto erret;
set_ufunc_name(ufunc, name);
if (hash_add(&func_hashtab, UF2HIKEY(ufunc)) == FAIL)
goto erret;
ufunc->uf_flags = FC_LAMBDA;
ufunc->uf_refcount = 1;
ufunc->uf_args = *newargs;
newargs->ga_data = NULL;
ufunc->uf_def_args = *default_args;
default_args->ga_data = NULL;
ufunc->uf_func_type = &t_func_any;
// error messages are for the first function line
lnum_save = SOURCING_LNUM;
SOURCING_LNUM = sourcing_lnum_top;
// parse argument types
if (parse_argument_types(ufunc, argtypes, varargs) == FAIL)
{
SOURCING_LNUM = lnum_save;
goto erret;
}
// parse the return type, if any
if (parse_return_type(ufunc, ret_type) == FAIL)
goto erret;
pt = ALLOC_CLEAR_ONE(partial_T);
if (pt == NULL)
goto erret;
pt->pt_func = ufunc;
pt->pt_refcount = 1;
ufunc->uf_lines = newlines;
newlines.ga_data = NULL;
if (sandbox)
ufunc->uf_flags |= FC_SANDBOX;
if (!ASCII_ISUPPER(*ufunc->uf_name))
ufunc->uf_flags |= FC_VIM9;
ufunc->uf_script_ctx = current_sctx;
ufunc->uf_script_ctx_version = current_sctx.sc_version;
ufunc->uf_script_ctx.sc_lnum += sourcing_lnum_top;
set_function_type(ufunc);
function_using_block_scopes(ufunc, evalarg->eval_cstack);
rettv->vval.v_partial = pt;
rettv->v_type = VAR_PARTIAL;
ufunc = NULL;
ret = OK;
erret:
if (lnum_save >= 0)
SOURCING_LNUM = lnum_save;
vim_free(line_to_free);
ga_clear_strings(&newlines);
if (newargs != NULL)
ga_clear_strings(newargs);
ga_clear_strings(default_args);
if (ufunc != NULL)
{
func_clear(ufunc, TRUE);
func_free(ufunc, TRUE);
}
return ret;
} | 1012 | True | 1 |
CVE-2022-0156 | 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/vim/vim/commit/9f1a39a5d1cd7989ada2d1cb32f97d84360e050f', 'name': 'https://github.com/vim/vim/commit/9f1a39a5d1cd7989ada2d1cb32f97d84360e050f', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://huntr.dev/bounties/47dded34-3767-4725-8c7c-9dcb68c70b36', 'name': 'https://huntr.dev/bounties/47dded34-3767-4725-8c7c-9dcb68c70b36', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Patch', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/HD5S2FC2HF22A7XQXK2XXIR46EARVWIM/', 'name': 'FEDORA-2022-20e66c6698', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2022/01/15/1', 'name': "[oss-security] 20220114 Re: 3 new CVE's in vim", 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/3FH2J57GDA2WMBS6J56F6QQRA6BXQQFZ/', 'name': 'FEDORA-2022-48b86d586f', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213183', 'name': 'https://support.apple.com/kb/HT213183', 'refsource': 'CONFIRM', 'tags': ['Release Notes', 'Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Mar/29', 'name': '20220314 APPLE-SA-2022-03-14-4 macOS Monterey 12.3', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213344', 'name': 'https://support.apple.com/kb/HT213344', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Jul/13', 'name': '20220721 APPLE-SA-2022-07-20-3 macOS Big Sur 11.6.8', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-416'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.4040', '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': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionEndExcluding': '12.3', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionStartIncluding': '11.0', 'versionEndExcluding': '11.6.8', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'vim is vulnerable to Use After Free'}] | 2022-08-26T17:45Z | 2022-01-10T16: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 | Bram Moolenaar | 2022-01-08 15:39:39+00:00 | patch 8.2.4040: keeping track of allocated lines is too complicated
Problem: Keeping track of allocated lines in user functions is too
complicated.
Solution: Instead of freeing individual lines keep them all until the end. | 9f1a39a5d1cd7989ada2d1cb32f97d84360e050f | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | compile_def_function | compile_def_function( ufunc_T * ufunc , int check_return_type , compiletype_T compile_type , cctx_T * outer_cctx) | ['ufunc', 'check_return_type', 'compile_type', 'outer_cctx'] | compile_def_function(
ufunc_T *ufunc,
int check_return_type,
compiletype_T compile_type,
cctx_T *outer_cctx)
{
char_u *line = NULL;
char_u *line_to_free = NULL;
char_u *p;
char *errormsg = NULL; // error message
cctx_T cctx;
garray_T *instr;
int did_emsg_before = did_emsg;
int did_emsg_silent_before = did_emsg_silent;
int ret = FAIL;
sctx_T save_current_sctx = current_sctx;
int save_estack_compiling = estack_compiling;
int save_cmod_flags = cmdmod.cmod_flags;
int do_estack_push;
int new_def_function = FALSE;
#ifdef FEAT_PROFILE
int prof_lnum = -1;
#endif
int debug_lnum = -1;
// When using a function that was compiled before: Free old instructions.
// The index is reused. Otherwise add a new entry in "def_functions".
if (ufunc->uf_dfunc_idx > 0)
{
dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data)
+ ufunc->uf_dfunc_idx;
isn_T *instr_dest = NULL;
switch (compile_type)
{
case CT_PROFILE:
#ifdef FEAT_PROFILE
instr_dest = dfunc->df_instr_prof; break;
#endif
case CT_NONE: instr_dest = dfunc->df_instr; break;
case CT_DEBUG: instr_dest = dfunc->df_instr_debug; break;
}
if (instr_dest != NULL)
// Was compiled in this mode before: Free old instructions.
delete_def_function_contents(dfunc, FALSE);
ga_clear_strings(&dfunc->df_var_names);
}
else
{
if (add_def_function(ufunc) == FAIL)
return FAIL;
new_def_function = TRUE;
}
ufunc->uf_def_status = UF_COMPILING;
CLEAR_FIELD(cctx);
cctx.ctx_compile_type = compile_type;
cctx.ctx_ufunc = ufunc;
cctx.ctx_lnum = -1;
cctx.ctx_outer = outer_cctx;
ga_init2(&cctx.ctx_locals, sizeof(lvar_T), 10);
// Each entry on the type stack consists of two type pointers.
ga_init2(&cctx.ctx_type_stack, sizeof(type2_T), 50);
ga_init2(&cctx.ctx_imports, sizeof(imported_T), 10);
cctx.ctx_type_list = &ufunc->uf_type_list;
ga_init2(&cctx.ctx_instr, sizeof(isn_T), 50);
instr = &cctx.ctx_instr;
// Set the context to the function, it may be compiled when called from
// another script. Set the script version to the most modern one.
// The line number will be set in next_line_from_context().
current_sctx = ufunc->uf_script_ctx;
current_sctx.sc_version = SCRIPT_VERSION_VIM9;
// Don't use the flag from ":legacy" here.
cmdmod.cmod_flags &= ~CMOD_LEGACY;
// Make sure error messages are OK.
do_estack_push = !estack_top_is_ufunc(ufunc, 1);
if (do_estack_push)
estack_push_ufunc(ufunc, 1);
estack_compiling = TRUE;
if (check_args_shadowing(ufunc, &cctx) == FAIL)
goto erret;
if (ufunc->uf_def_args.ga_len > 0)
{
int count = ufunc->uf_def_args.ga_len;
int first_def_arg = ufunc->uf_args.ga_len - count;
int i;
char_u *arg;
int off = STACK_FRAME_SIZE + (ufunc->uf_va_name != NULL ? 1 : 0);
int did_set_arg_type = FALSE;
// Produce instructions for the default values of optional arguments.
SOURCING_LNUM = 0; // line number unknown
for (i = 0; i < count; ++i)
{
type_T *val_type;
int arg_idx = first_def_arg + i;
where_T where = WHERE_INIT;
int r;
int jump_instr_idx = instr->ga_len;
isn_T *isn;
// Use a JUMP_IF_ARG_SET instruction to skip if the value was given.
if (generate_JUMP_IF_ARG_SET(&cctx, i - count - off) == FAIL)
goto erret;
// Make sure later arguments are not found.
ufunc->uf_args_visible = arg_idx;
arg = ((char_u **)(ufunc->uf_def_args.ga_data))[i];
r = compile_expr0(&arg, &cctx);
if (r == FAIL)
goto erret;
// If no type specified use the type of the default value.
// Otherwise check that the default value type matches the
// specified type.
val_type = get_type_on_stack(&cctx, 0);
where.wt_index = arg_idx + 1;
if (ufunc->uf_arg_types[arg_idx] == &t_unknown)
{
did_set_arg_type = TRUE;
ufunc->uf_arg_types[arg_idx] = val_type;
}
else if (need_type_where(val_type, ufunc->uf_arg_types[arg_idx],
-1, where, &cctx, FALSE, FALSE) == FAIL)
goto erret;
if (generate_STORE(&cctx, ISN_STORE, i - count - off, NULL) == FAIL)
goto erret;
// set instruction index in JUMP_IF_ARG_SET to here
isn = ((isn_T *)instr->ga_data) + jump_instr_idx;
isn->isn_arg.jumparg.jump_where = instr->ga_len;
}
if (did_set_arg_type)
set_function_type(ufunc);
}
ufunc->uf_args_visible = ufunc->uf_args.ga_len;
/*
* Loop over all the lines of the function and generate instructions.
*/
for (;;)
{
exarg_T ea;
int starts_with_colon = FALSE;
char_u *cmd;
cmdmod_T local_cmdmod;
// Bail out on the first error to avoid a flood of errors and report
// the right line number when inside try/catch.
if (did_emsg_before != did_emsg)
goto erret;
if (line != NULL && *line == '|')
// the line continues after a '|'
++line;
else if (line != NULL && *skipwhite(line) != NUL
&& !(*line == '#' && (line == cctx.ctx_line_start
|| VIM_ISWHITE(line[-1]))))
{
semsg(_(e_trailing_characters_str), line);
goto erret;
}
else if (line != NULL && vim9_bad_comment(skipwhite(line)))
goto erret;
else
{
line = next_line_from_context(&cctx, FALSE);
if (cctx.ctx_lnum >= ufunc->uf_lines.ga_len)
{
// beyond the last line
#ifdef FEAT_PROFILE
if (cctx.ctx_skip != SKIP_YES)
may_generate_prof_end(&cctx, prof_lnum);
#endif
break;
}
// Make a copy, splitting off nextcmd and removing trailing spaces
// may change it.
if (line != NULL)
{
line = vim_strsave(line);
vim_free(line_to_free);
line_to_free = line;
}
}
CLEAR_FIELD(ea);
ea.cmdlinep = &line;
ea.cmd = skipwhite(line);
if (*ea.cmd == '#')
{
// "#" starts a comment
line = (char_u *)"";
continue;
}
#ifdef FEAT_PROFILE
if (cctx.ctx_compile_type == CT_PROFILE && cctx.ctx_lnum != prof_lnum
&& cctx.ctx_skip != SKIP_YES)
{
may_generate_prof_end(&cctx, prof_lnum);
prof_lnum = cctx.ctx_lnum;
generate_instr(&cctx, ISN_PROF_START);
}
#endif
if (cctx.ctx_compile_type == CT_DEBUG && cctx.ctx_lnum != debug_lnum
&& cctx.ctx_skip != SKIP_YES)
{
debug_lnum = cctx.ctx_lnum;
generate_instr_debug(&cctx);
}
cctx.ctx_prev_lnum = cctx.ctx_lnum + 1;
// Some things can be recognized by the first character.
switch (*ea.cmd)
{
case '}':
{
// "}" ends a block scope
scopetype_T stype = cctx.ctx_scope == NULL
? NO_SCOPE : cctx.ctx_scope->se_type;
if (stype == BLOCK_SCOPE)
{
compile_endblock(&cctx);
line = ea.cmd;
}
else
{
emsg(_(e_using_rcurly_outside_if_block_scope));
goto erret;
}
if (line != NULL)
line = skipwhite(ea.cmd + 1);
continue;
}
case '{':
// "{" starts a block scope
// "{'a': 1}->func() is something else
if (ends_excmd(*skipwhite(ea.cmd + 1)))
{
line = compile_block(ea.cmd, &cctx);
continue;
}
break;
}
/*
* COMMAND MODIFIERS
*/
cctx.ctx_has_cmdmod = FALSE;
if (parse_command_modifiers(&ea, &errormsg, &local_cmdmod, FALSE)
== FAIL)
{
if (errormsg != NULL)
goto erret;
// empty line or comment
line = (char_u *)"";
continue;
}
generate_cmdmods(&cctx, &local_cmdmod);
undo_cmdmod(&local_cmdmod);
// Check if there was a colon after the last command modifier or before
// the current position.
for (p = ea.cmd; p >= line; --p)
{
if (*p == ':')
starts_with_colon = TRUE;
if (p < ea.cmd && !VIM_ISWHITE(*p))
break;
}
// Skip ":call" to get to the function name, unless using :legacy
p = ea.cmd;
if (!(local_cmdmod.cmod_flags & CMOD_LEGACY))
{
if (checkforcmd(&ea.cmd, "call", 3))
{
if (*ea.cmd == '(')
// not for "call()"
ea.cmd = p;
else
ea.cmd = skipwhite(ea.cmd);
}
if (!starts_with_colon)
{
int assign;
// Check for assignment after command modifiers.
assign = may_compile_assignment(&ea, &line, &cctx);
if (assign == OK)
goto nextline;
if (assign == FAIL)
goto erret;
}
}
/*
* COMMAND after range
* 'text'->func() should not be confused with 'a mark
* "++nr" and "--nr" are eval commands
* in "$ENV->func()" the "$" is not a range
*/
cmd = ea.cmd;
if ((*cmd != '$' || starts_with_colon)
&& (starts_with_colon || !(*cmd == '\''
|| (cmd[0] != NUL && cmd[0] == cmd[1]
&& (*cmd == '+' || *cmd == '-')))))
{
ea.cmd = skip_range(ea.cmd, TRUE, NULL);
if (ea.cmd > cmd)
{
if (!starts_with_colon
&& !(local_cmdmod.cmod_flags & CMOD_LEGACY))
{
semsg(_(e_colon_required_before_range_str), cmd);
goto erret;
}
ea.addr_count = 1;
if (ends_excmd2(line, ea.cmd))
{
// A range without a command: jump to the line.
generate_EXEC(&cctx, ISN_EXECRANGE,
vim_strnsave(cmd, ea.cmd - cmd));
line = ea.cmd;
goto nextline;
}
}
}
p = find_ex_command(&ea, NULL,
starts_with_colon || (local_cmdmod.cmod_flags & CMOD_LEGACY)
? NULL : item_exists, &cctx);
if (p == NULL)
{
if (cctx.ctx_skip != SKIP_YES)
emsg(_(e_ambiguous_use_of_user_defined_command));
goto erret;
}
// When using ":legacy cmd" always use compile_exec().
if (local_cmdmod.cmod_flags & CMOD_LEGACY)
{
char_u *start = ea.cmd;
switch (ea.cmdidx)
{
case CMD_if:
case CMD_elseif:
case CMD_else:
case CMD_endif:
case CMD_for:
case CMD_endfor:
case CMD_continue:
case CMD_break:
case CMD_while:
case CMD_endwhile:
case CMD_try:
case CMD_catch:
case CMD_finally:
case CMD_endtry:
semsg(_(e_cannot_use_legacy_with_command_str), ea.cmd);
goto erret;
default: break;
}
// ":legacy return expr" needs to be handled differently.
if (checkforcmd(&start, "return", 4))
ea.cmdidx = CMD_return;
else
ea.cmdidx = CMD_legacy;
}
if (p == ea.cmd && ea.cmdidx != CMD_SIZE)
{
if (cctx.ctx_skip == SKIP_YES && ea.cmdidx != CMD_eval)
{
line += STRLEN(line);
goto nextline;
}
else if (ea.cmdidx != CMD_eval)
{
// CMD_var cannot happen, compile_assignment() above would be
// used. Most likely an assignment to a non-existing variable.
semsg(_(e_command_not_recognized_str), ea.cmd);
goto erret;
}
}
if (cctx.ctx_had_return
&& ea.cmdidx != CMD_elseif
&& ea.cmdidx != CMD_else
&& ea.cmdidx != CMD_endif
&& ea.cmdidx != CMD_endfor
&& ea.cmdidx != CMD_endwhile
&& ea.cmdidx != CMD_catch
&& ea.cmdidx != CMD_finally
&& ea.cmdidx != CMD_endtry)
{
emsg(_(e_unreachable_code_after_return));
goto erret;
}
p = skipwhite(p);
if (ea.cmdidx != CMD_SIZE
&& ea.cmdidx != CMD_write && ea.cmdidx != CMD_read)
{
if (ea.cmdidx >= 0)
ea.argt = excmd_get_argt(ea.cmdidx);
if ((ea.argt & EX_BANG) && *p == '!')
{
ea.forceit = TRUE;
p = skipwhite(p + 1);
}
}
switch (ea.cmdidx)
{
case CMD_def:
case CMD_function:
ea.arg = p;
line = compile_nested_function(&ea, &cctx, &line_to_free);
break;
case CMD_return:
line = compile_return(p, check_return_type,
local_cmdmod.cmod_flags & CMOD_LEGACY, &cctx);
cctx.ctx_had_return = TRUE;
break;
case CMD_let:
emsg(_(e_cannot_use_let_in_vim9_script));
break;
case CMD_var:
case CMD_final:
case CMD_const:
case CMD_increment:
case CMD_decrement:
line = compile_assignment(p, &ea, ea.cmdidx, &cctx);
if (line == p)
line = NULL;
break;
case CMD_unlet:
case CMD_unlockvar:
case CMD_lockvar:
line = compile_unletlock(p, &ea, &cctx);
break;
case CMD_import:
emsg(_(e_import_can_only_be_used_in_script));
line = NULL;
break;
case CMD_if:
line = compile_if(p, &cctx);
break;
case CMD_elseif:
line = compile_elseif(p, &cctx);
cctx.ctx_had_return = FALSE;
break;
case CMD_else:
line = compile_else(p, &cctx);
cctx.ctx_had_return = FALSE;
break;
case CMD_endif:
line = compile_endif(p, &cctx);
break;
case CMD_while:
line = compile_while(p, &cctx);
break;
case CMD_endwhile:
line = compile_endwhile(p, &cctx);
cctx.ctx_had_return = FALSE;
break;
case CMD_for:
line = compile_for(p, &cctx);
break;
case CMD_endfor:
line = compile_endfor(p, &cctx);
cctx.ctx_had_return = FALSE;
break;
case CMD_continue:
line = compile_continue(p, &cctx);
break;
case CMD_break:
line = compile_break(p, &cctx);
break;
case CMD_try:
line = compile_try(p, &cctx);
break;
case CMD_catch:
line = compile_catch(p, &cctx);
cctx.ctx_had_return = FALSE;
break;
case CMD_finally:
line = compile_finally(p, &cctx);
cctx.ctx_had_return = FALSE;
break;
case CMD_endtry:
line = compile_endtry(p, &cctx);
cctx.ctx_had_return = FALSE;
break;
case CMD_throw:
line = compile_throw(p, &cctx);
break;
case CMD_eval:
line = compile_eval(p, &cctx);
break;
case CMD_echo:
case CMD_echon:
case CMD_execute:
case CMD_echomsg:
case CMD_echoerr:
case CMD_echoconsole:
line = compile_mult_expr(p, ea.cmdidx, &cctx);
break;
case CMD_put:
ea.cmd = cmd;
line = compile_put(p, &ea, &cctx);
break;
case CMD_substitute:
if (check_global_and_subst(ea.cmd, p) == FAIL)
goto erret;
if (cctx.ctx_skip == SKIP_YES)
line = (char_u *)"";
else
{
ea.arg = p;
line = compile_substitute(line, &ea, &cctx);
}
break;
case CMD_redir:
ea.arg = p;
line = compile_redir(line, &ea, &cctx);
break;
case CMD_cexpr:
case CMD_lexpr:
case CMD_caddexpr:
case CMD_laddexpr:
case CMD_cgetexpr:
case CMD_lgetexpr:
#ifdef FEAT_QUICKFIX
ea.arg = p;
line = compile_cexpr(line, &ea, &cctx);
#else
ex_ni(&ea);
line = NULL;
#endif
break;
case CMD_append:
case CMD_change:
case CMD_insert:
case CMD_k:
case CMD_t:
case CMD_xit:
not_in_vim9(&ea);
goto erret;
case CMD_SIZE:
if (cctx.ctx_skip != SKIP_YES)
{
semsg(_(e_invalid_command_str), ea.cmd);
goto erret;
}
// We don't check for a next command here.
line = (char_u *)"";
break;
case CMD_lua:
case CMD_mzscheme:
case CMD_perl:
case CMD_py3:
case CMD_python3:
case CMD_python:
case CMD_pythonx:
case CMD_ruby:
case CMD_tcl:
ea.arg = p;
if (vim_strchr(line, '\n') == NULL)
line = compile_exec(line, &ea, &cctx);
else
// heredoc lines have been concatenated with NL
// characters in get_function_body()
line = compile_script(line, &cctx);
break;
case CMD_global:
if (check_global_and_subst(ea.cmd, p) == FAIL)
goto erret;
// FALLTHROUGH
default:
// Not recognized, execute with do_cmdline_cmd().
ea.arg = p;
line = compile_exec(line, &ea, &cctx);
break;
}
nextline:
if (line == NULL)
goto erret;
line = skipwhite(line);
// Undo any command modifiers.
generate_undo_cmdmods(&cctx);
if (cctx.ctx_type_stack.ga_len < 0)
{
iemsg("Type stack underflow");
goto erret;
}
}
if (cctx.ctx_scope != NULL)
{
if (cctx.ctx_scope->se_type == IF_SCOPE)
emsg(_(e_missing_endif));
else if (cctx.ctx_scope->se_type == WHILE_SCOPE)
emsg(_(e_missing_endwhile));
else if (cctx.ctx_scope->se_type == FOR_SCOPE)
emsg(_(e_missing_endfor));
else
emsg(_(e_missing_rcurly));
goto erret;
}
if (!cctx.ctx_had_return)
{
if (ufunc->uf_ret_type->tt_type == VAR_UNKNOWN)
ufunc->uf_ret_type = &t_void;
else if (ufunc->uf_ret_type->tt_type != VAR_VOID)
{
emsg(_(e_missing_return_statement));
goto erret;
}
// Return void if there is no return at the end.
generate_instr(&cctx, ISN_RETURN_VOID);
}
// When compiled with ":silent!" and there was an error don't consider the
// function compiled.
if (emsg_silent == 0 || did_emsg_silent == did_emsg_silent_before)
{
dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data)
+ ufunc->uf_dfunc_idx;
dfunc->df_deleted = FALSE;
dfunc->df_script_seq = current_sctx.sc_seq;
#ifdef FEAT_PROFILE
if (cctx.ctx_compile_type == CT_PROFILE)
{
dfunc->df_instr_prof = instr->ga_data;
dfunc->df_instr_prof_count = instr->ga_len;
}
else
#endif
if (cctx.ctx_compile_type == CT_DEBUG)
{
dfunc->df_instr_debug = instr->ga_data;
dfunc->df_instr_debug_count = instr->ga_len;
}
else
{
dfunc->df_instr = instr->ga_data;
dfunc->df_instr_count = instr->ga_len;
}
dfunc->df_varcount = dfunc->df_var_names.ga_len;
dfunc->df_has_closure = cctx.ctx_has_closure;
if (cctx.ctx_outer_used)
ufunc->uf_flags |= FC_CLOSURE;
ufunc->uf_def_status = UF_COMPILED;
}
ret = OK;
erret:
if (ufunc->uf_def_status == UF_COMPILING)
{
dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data)
+ ufunc->uf_dfunc_idx;
// Compiling aborted, free the generated instructions.
clear_instr_ga(instr);
VIM_CLEAR(dfunc->df_name);
ga_clear_strings(&dfunc->df_var_names);
// If using the last entry in the table and it was added above, we
// might as well remove it.
if (!dfunc->df_deleted && new_def_function
&& ufunc->uf_dfunc_idx == def_functions.ga_len - 1)
{
--def_functions.ga_len;
ufunc->uf_dfunc_idx = 0;
}
ufunc->uf_def_status = UF_COMPILE_ERROR;
while (cctx.ctx_scope != NULL)
drop_scope(&cctx);
if (errormsg != NULL)
emsg(errormsg);
else if (did_emsg == did_emsg_before)
emsg(_(e_compiling_def_function_failed));
}
if (cctx.ctx_redir_lhs.lhs_name != NULL)
{
if (ret == OK)
{
emsg(_(e_missing_redir_end));
ret = FAIL;
}
vim_free(cctx.ctx_redir_lhs.lhs_name);
vim_free(cctx.ctx_redir_lhs.lhs_whole);
}
current_sctx = save_current_sctx;
estack_compiling = save_estack_compiling;
cmdmod.cmod_flags = save_cmod_flags;
if (do_estack_push)
estack_pop();
vim_free(line_to_free);
free_imported(&cctx);
free_locals(&cctx);
ga_clear(&cctx.ctx_type_stack);
return ret;
} | 3267 | True | 1 |
CVE-2022-0156 | 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/vim/vim/commit/9f1a39a5d1cd7989ada2d1cb32f97d84360e050f', 'name': 'https://github.com/vim/vim/commit/9f1a39a5d1cd7989ada2d1cb32f97d84360e050f', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://huntr.dev/bounties/47dded34-3767-4725-8c7c-9dcb68c70b36', 'name': 'https://huntr.dev/bounties/47dded34-3767-4725-8c7c-9dcb68c70b36', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Patch', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/HD5S2FC2HF22A7XQXK2XXIR46EARVWIM/', 'name': 'FEDORA-2022-20e66c6698', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2022/01/15/1', 'name': "[oss-security] 20220114 Re: 3 new CVE's in vim", 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/3FH2J57GDA2WMBS6J56F6QQRA6BXQQFZ/', 'name': 'FEDORA-2022-48b86d586f', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213183', 'name': 'https://support.apple.com/kb/HT213183', 'refsource': 'CONFIRM', 'tags': ['Release Notes', 'Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Mar/29', 'name': '20220314 APPLE-SA-2022-03-14-4 macOS Monterey 12.3', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213344', 'name': 'https://support.apple.com/kb/HT213344', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Jul/13', 'name': '20220721 APPLE-SA-2022-07-20-3 macOS Big Sur 11.6.8', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-416'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.4040', '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': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionEndExcluding': '12.3', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionStartIncluding': '11.0', 'versionEndExcluding': '11.6.8', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'vim is vulnerable to Use After Free'}] | 2022-08-26T17:45Z | 2022-01-10T16: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 | Bram Moolenaar | 2022-01-08 15:39:39+00:00 | patch 8.2.4040: keeping track of allocated lines is too complicated
Problem: Keeping track of allocated lines in user functions is too
complicated.
Solution: Instead of freeing individual lines keep them all until the end. | 9f1a39a5d1cd7989ada2d1cb32f97d84360e050f | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | compile_nested_function | compile_nested_function( exarg_T * eap , cctx_T * cctx , char_u ** line_to_free) | ['eap', 'cctx', 'line_to_free'] | compile_nested_function(exarg_T *eap, cctx_T *cctx, char_u **line_to_free)
{
int is_global = *eap->arg == 'g' && eap->arg[1] == ':';
char_u *name_start = eap->arg;
char_u *name_end = to_name_end(eap->arg, TRUE);
int off;
char_u *func_name;
char_u *lambda_name;
ufunc_T *ufunc;
int r = FAIL;
compiletype_T compile_type;
if (eap->forceit)
{
emsg(_(e_cannot_use_bang_with_nested_def));
return NULL;
}
if (*name_start == '/')
{
name_end = skip_regexp(name_start + 1, '/', TRUE);
if (*name_end == '/')
++name_end;
set_nextcmd(eap, name_end);
}
if (name_end == name_start || *skipwhite(name_end) != '(')
{
if (!ends_excmd2(name_start, name_end))
{
semsg(_(e_invalid_command_str), eap->cmd);
return NULL;
}
// "def" or "def Name": list functions
if (generate_DEF(cctx, name_start, name_end - name_start) == FAIL)
return NULL;
return eap->nextcmd == NULL ? (char_u *)"" : eap->nextcmd;
}
// Only g:Func() can use a namespace.
if (name_start[1] == ':' && !is_global)
{
semsg(_(e_namespace_not_supported_str), name_start);
return NULL;
}
if (check_defined(name_start, name_end - name_start, cctx, FALSE) == FAIL)
return NULL;
eap->arg = name_end;
fill_exarg_from_cctx(eap, cctx);
eap->forceit = FALSE;
// We use the special <Lamba>99 name, but it's not really a lambda.
lambda_name = vim_strsave(get_lambda_name());
if (lambda_name == NULL)
return NULL;
// This may free the current line, make a copy of the name.
off = is_global ? 2 : 0;
func_name = vim_strnsave(name_start + off, name_end - name_start - off);
if (func_name == NULL)
{
r = FAIL;
goto theend;
}
ufunc = define_function(eap, lambda_name, line_to_free);
if (ufunc == NULL)
{
r = eap->skip ? OK : FAIL;
goto theend;
}
if (eap->nextcmd != NULL)
{
semsg(_(e_text_found_after_str_str),
eap->cmdidx == CMD_def ? "enddef" : "endfunction", eap->nextcmd);
r = FAIL;
func_ptr_unref(ufunc);
goto theend;
}
// copy over the block scope IDs before compiling
if (!is_global && cctx->ctx_ufunc->uf_block_depth > 0)
{
int block_depth = cctx->ctx_ufunc->uf_block_depth;
ufunc->uf_block_ids = ALLOC_MULT(int, block_depth);
if (ufunc->uf_block_ids != NULL)
{
mch_memmove(ufunc->uf_block_ids, cctx->ctx_ufunc->uf_block_ids,
sizeof(int) * block_depth);
ufunc->uf_block_depth = block_depth;
}
}
compile_type = COMPILE_TYPE(ufunc);
#ifdef FEAT_PROFILE
// If the outer function is profiled, also compile the nested function for
// profiling.
if (cctx->ctx_compile_type == CT_PROFILE)
compile_type = CT_PROFILE;
#endif
if (func_needs_compiling(ufunc, compile_type)
&& compile_def_function(ufunc, TRUE, compile_type, cctx) == FAIL)
{
func_ptr_unref(ufunc);
goto theend;
}
#ifdef FEAT_PROFILE
// When the outer function is compiled for profiling, the nested function
// may be called without profiling. Compile it here in the right context.
if (compile_type == CT_PROFILE && func_needs_compiling(ufunc, CT_NONE))
compile_def_function(ufunc, FALSE, CT_NONE, cctx);
#endif
if (is_global)
{
r = generate_NEWFUNC(cctx, lambda_name, func_name);
func_name = NULL;
lambda_name = NULL;
}
else
{
// Define a local variable for the function reference.
lvar_T *lvar = reserve_local(cctx, func_name, name_end - name_start,
TRUE, ufunc->uf_func_type);
if (lvar == NULL)
goto theend;
if (generate_FUNCREF(cctx, ufunc) == FAIL)
goto theend;
r = generate_STORE(cctx, ISN_STORE, lvar->lv_idx, NULL);
}
theend:
vim_free(lambda_name);
vim_free(func_name);
return r == FAIL ? NULL : (char_u *)"";
} | 671 | True | 1 |
CVE-2022-0156 | 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/vim/vim/commit/9f1a39a5d1cd7989ada2d1cb32f97d84360e050f', 'name': 'https://github.com/vim/vim/commit/9f1a39a5d1cd7989ada2d1cb32f97d84360e050f', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://huntr.dev/bounties/47dded34-3767-4725-8c7c-9dcb68c70b36', 'name': 'https://huntr.dev/bounties/47dded34-3767-4725-8c7c-9dcb68c70b36', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Patch', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/HD5S2FC2HF22A7XQXK2XXIR46EARVWIM/', 'name': 'FEDORA-2022-20e66c6698', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2022/01/15/1', 'name': "[oss-security] 20220114 Re: 3 new CVE's in vim", 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/3FH2J57GDA2WMBS6J56F6QQRA6BXQQFZ/', 'name': 'FEDORA-2022-48b86d586f', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213183', 'name': 'https://support.apple.com/kb/HT213183', 'refsource': 'CONFIRM', 'tags': ['Release Notes', 'Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Mar/29', 'name': '20220314 APPLE-SA-2022-03-14-4 macOS Monterey 12.3', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213344', 'name': 'https://support.apple.com/kb/HT213344', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Jul/13', 'name': '20220721 APPLE-SA-2022-07-20-3 macOS Big Sur 11.6.8', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-416'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.4040', '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': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionEndExcluding': '12.3', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionStartIncluding': '11.0', 'versionEndExcluding': '11.6.8', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'vim is vulnerable to Use After Free'}] | 2022-08-26T17:45Z | 2022-01-10T16: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 | Bram Moolenaar | 2022-01-08 15:39:39+00:00 | patch 8.2.4040: keeping track of allocated lines is too complicated
Problem: Keeping track of allocated lines in user functions is too
complicated.
Solution: Instead of freeing individual lines keep them all until the end. | 9f1a39a5d1cd7989ada2d1cb32f97d84360e050f | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | read_viminfo_barline | read_viminfo_barline( vir_T * virp , int got_encoding , int force , int writing) | ['virp', 'got_encoding', 'force', 'writing'] | read_viminfo_barline(vir_T *virp, int got_encoding, int force, int writing)
{
char_u *p = virp->vir_line + 1;
int bartype;
garray_T values;
bval_T *vp;
int i;
int read_next = TRUE;
// The format is: |{bartype},{value},...
// For a very long string:
// |{bartype},>{length of "{text}{text2}"}
// |<{text1}
// |<{text2},{value}
// For a long line not using a string
// |{bartype},{lots of values},>
// |<{value},{value}
if (*p == '<')
{
// Continuation line of an unrecognized item.
if (writing)
ga_add_string(&virp->vir_barlines, virp->vir_line);
}
else
{
ga_init2(&values, sizeof(bval_T), 20);
bartype = getdigits(&p);
switch (bartype)
{
case BARTYPE_VERSION:
// Only use the version when it comes before the encoding.
// If it comes later it was copied by a Vim version that
// doesn't understand the version.
if (!got_encoding)
{
read_next = barline_parse(virp, p, &values);
vp = (bval_T *)values.ga_data;
if (values.ga_len > 0 && vp->bv_type == BVAL_NR)
virp->vir_version = vp->bv_nr;
}
break;
case BARTYPE_HISTORY:
read_next = barline_parse(virp, p, &values);
handle_viminfo_history(&values, writing);
break;
case BARTYPE_REGISTER:
read_next = barline_parse(virp, p, &values);
handle_viminfo_register(&values, force);
break;
case BARTYPE_MARK:
read_next = barline_parse(virp, p, &values);
handle_viminfo_mark(&values, force);
break;
default:
// copy unrecognized line (for future use)
if (writing)
ga_add_string(&virp->vir_barlines, virp->vir_line);
}
for (i = 0; i < values.ga_len; ++i)
{
vp = (bval_T *)values.ga_data + i;
if (vp->bv_type == BVAL_STRING && vp->bv_allocated)
vim_free(vp->bv_string);
vim_free(vp->bv_tofree);
}
ga_clear(&values);
}
if (read_next)
return viminfo_readline(virp);
return FALSE;
} | 323 | True | 1 |
CVE-2022-0158 | 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:L/AC:L/PR:N/UI:R/S:U/C:L/I:N/A:N | LOCAL | LOW | NONE | REQUIRED | UNCHANGED | LOW | NONE | NONE | 3.3 | LOW | 1.8 | 1.4 | False | [{'url': 'https://huntr.dev/bounties/ac5d7005-07c6-4a0a-b251-ba9cdbf6738b', 'name': 'https://huntr.dev/bounties/ac5d7005-07c6-4a0a-b251-ba9cdbf6738b', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Patch', 'Third Party Advisory']}, {'url': 'https://github.com/vim/vim/commit/5f25c3855071bd7e26255c68bf458b1b5cf92f39', 'name': 'https://github.com/vim/vim/commit/5f25c3855071bd7e26255c68bf458b1b5cf92f39', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/HD5S2FC2HF22A7XQXK2XXIR46EARVWIM/', 'name': 'FEDORA-2022-20e66c6698', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2022/01/15/1', 'name': "[oss-security] 20220114 Re: 3 new CVE's in vim", 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/3FH2J57GDA2WMBS6J56F6QQRA6BXQQFZ/', 'name': 'FEDORA-2022-48b86d586f', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213183', 'name': 'https://support.apple.com/kb/HT213183', 'refsource': 'CONFIRM', 'tags': ['Release Notes', 'Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Mar/29', 'name': '20220314 APPLE-SA-2022-03-14-4 macOS Monterey 12.3', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://support.apple.com/kb/HT213344', 'name': 'https://support.apple.com/kb/HT213344', 'refsource': 'CONFIRM', 'tags': ['Third Party Advisory']}, {'url': 'http://seclists.org/fulldisclosure/2022/Jul/13', 'name': '20220721 APPLE-SA-2022-07-20-3 macOS Big Sur 11.6.8', 'refsource': 'FULLDISC', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-122'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.4049', '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': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionEndExcluding': '12.3', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:apple:macos:*:*:*:*:*:*:*:*', 'versionStartIncluding': '11.0', 'versionEndExcluding': '11.6.8', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'vim is vulnerable to Heap-based Buffer Overflow'}] | 2022-08-26T17:46Z | 2022-01-10T16:15Z | Heap-based Buffer Overflow | A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc(). | https://cwe.mitre.org/data/definitions/122.html | 0 | Bram Moolenaar | 2022-01-09 13:36:28+00:00 | patch 8.2.4049: Vim9: reading before the start of the line with "$"
Problem: Vim9: reading before the start of the line with "$" by itself.
Solution: Do not subtract one when reporting the error. | 5f25c3855071bd7e26255c68bf458b1b5cf92f39 | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | compile_get_env | compile_get_env( char_u ** arg , cctx_T * cctx) | ['arg', 'cctx'] | compile_get_env(char_u **arg, cctx_T *cctx)
{
char_u *start = *arg;
int len;
int ret;
char_u *name;
++*arg;
len = get_env_len(arg);
if (len == 0)
{
semsg(_(e_syntax_error_at_str), start - 1);
return FAIL;
}
// include the '$' in the name, eval_env_var() expects it.
name = vim_strnsave(start, len + 1);
ret = generate_LOAD(cctx, ISN_LOADENV, 0, name, &t_string);
vim_free(name);
return ret;
} | 98 | True | 1 |
|
CVE-2022-0213 | 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:L/I:L/A:H | LOCAL | LOW | NONE | REQUIRED | UNCHANGED | LOW | LOW | HIGH | 6.6 | MEDIUM | 1.8 | 4.7 | False | [{'url': 'https://huntr.dev/bounties/f3afe1a5-e6f8-4579-b68a-6e5c7e39afed', 'name': 'https://huntr.dev/bounties/f3afe1a5-e6f8-4579-b68a-6e5c7e39afed', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Patch', 'Third Party Advisory']}, {'url': 'https://github.com/vim/vim/commit/de05bb25733c3319e18dca44e9b59c6ee389eb26', 'name': 'https://github.com/vim/vim/commit/de05bb25733c3319e18dca44e9b59c6ee389eb26', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'http://www.openwall.com/lists/oss-security/2022/01/15/1', 'name': "[oss-security] 20220114 Re: 3 new CVE's in vim", 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2022/03/msg00018.html', 'name': '[debian-lts-announce] 20220311 [SECURITY] [DLA 2947-1] vim security update', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-122'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:debian:debian_linux:9.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'vim is vulnerable to Heap-based Buffer Overflow'}] | 2022-08-21T07:15Z | 2022-01-14T13:15Z | Heap-based Buffer Overflow | A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc(). | https://cwe.mitre.org/data/definitions/122.html | 0 | Bram Moolenaar | 2022-01-13 13:08:14+00:00 | patch 8.2.4074: going over the end of NameBuff
Problem: Going over the end of NameBuff.
Solution: Check length when appending a space. | de05bb25733c3319e18dca44e9b59c6ee389eb26 | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | win_redr_status | win_redr_status( win_T * wp , int ignore_pum UNUSED) | ['wp', 'UNUSED'] | win_redr_status(win_T *wp, int ignore_pum UNUSED)
{
int row;
char_u *p;
int len;
int fillchar;
int attr;
int this_ru_col;
static int busy = FALSE;
// It's possible to get here recursively when 'statusline' (indirectly)
// invokes ":redrawstatus". Simply ignore the call then.
if (busy)
return;
busy = TRUE;
row = statusline_row(wp);
wp->w_redr_status = FALSE;
if (wp->w_status_height == 0)
{
// no status line, can only be last window
redraw_cmdline = TRUE;
}
else if (!redrawing()
// don't update status line when popup menu is visible and may be
// drawn over it, unless it will be redrawn later
|| (!ignore_pum && pum_visible()))
{
// Don't redraw right now, do it later.
wp->w_redr_status = TRUE;
}
#ifdef FEAT_STL_OPT
else if (*p_stl != NUL || *wp->w_p_stl != NUL)
{
// redraw custom status line
redraw_custom_statusline(wp);
}
#endif
else
{
fillchar = fillchar_status(&attr, wp);
get_trans_bufname(wp->w_buffer);
p = NameBuff;
len = (int)STRLEN(p);
if (bt_help(wp->w_buffer)
#ifdef FEAT_QUICKFIX
|| wp->w_p_pvw
#endif
|| bufIsChanged(wp->w_buffer)
|| wp->w_buffer->b_p_ro)
*(p + len++) = ' ';
if (bt_help(wp->w_buffer))
{
vim_snprintf((char *)p + len, MAXPATHL - len, "%s", _("[Help]"));
len += (int)STRLEN(p + len);
}
#ifdef FEAT_QUICKFIX
if (wp->w_p_pvw)
{
vim_snprintf((char *)p + len, MAXPATHL - len, "%s", _("[Preview]"));
len += (int)STRLEN(p + len);
}
#endif
if (bufIsChanged(wp->w_buffer)
#ifdef FEAT_TERMINAL
&& !bt_terminal(wp->w_buffer)
#endif
)
{
vim_snprintf((char *)p + len, MAXPATHL - len, "%s", "[+]");
len += (int)STRLEN(p + len);
}
if (wp->w_buffer->b_p_ro)
{
vim_snprintf((char *)p + len, MAXPATHL - len, "%s", _("[RO]"));
len += (int)STRLEN(p + len);
}
this_ru_col = ru_col - (Columns - wp->w_width);
if (this_ru_col < (wp->w_width + 1) / 2)
this_ru_col = (wp->w_width + 1) / 2;
if (this_ru_col <= 1)
{
p = (char_u *)"<"; // No room for file name!
len = 1;
}
else if (has_mbyte)
{
int clen = 0, i;
// Count total number of display cells.
clen = mb_string2cells(p, -1);
// Find first character that will fit.
// Going from start to end is much faster for DBCS.
for (i = 0; p[i] != NUL && clen >= this_ru_col - 1;
i += (*mb_ptr2len)(p + i))
clen -= (*mb_ptr2cells)(p + i);
len = clen;
if (i > 0)
{
p = p + i - 1;
*p = '<';
++len;
}
}
else if (len > this_ru_col - 1)
{
p += len - (this_ru_col - 1);
*p = '<';
len = this_ru_col - 1;
}
screen_puts(p, row, wp->w_wincol, attr);
screen_fill(row, row + 1, len + wp->w_wincol,
this_ru_col + wp->w_wincol, fillchar, fillchar, attr);
if (get_keymap_str(wp, (char_u *)"<%s>", NameBuff, MAXPATHL)
&& (int)(this_ru_col - len) > (int)(STRLEN(NameBuff) + 1))
screen_puts(NameBuff, row, (int)(this_ru_col - STRLEN(NameBuff)
- 1 + wp->w_wincol), attr);
#ifdef FEAT_CMDL_INFO
win_redr_ruler(wp, TRUE, ignore_pum);
#endif
}
/*
* May need to draw the character below the vertical separator.
*/
if (wp->w_vsep_width != 0 && wp->w_status_height != 0 && redrawing())
{
if (stl_connected(wp))
fillchar = fillchar_status(&attr, wp);
else
fillchar = fillchar_vsep(&attr);
screen_putchar(fillchar, row, W_ENDCOL(wp), attr);
}
busy = FALSE;
} | 735 | True | 1 |
|
CVE-2022-0261 | 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/vim/vim/commit/9f8c304c8a390ade133bac29963dc8e56ab14cbc', 'name': 'https://github.com/vim/vim/commit/9f8c304c8a390ade133bac29963dc8e56ab14cbc', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://huntr.dev/bounties/fa795954-8775-4f23-98c6-d4d4d3fe8a82', 'name': 'https://huntr.dev/bounties/fa795954-8775-4f23-98c6-d4d4d3fe8a82', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Patch', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2022/05/msg00022.html', 'name': '[debian-lts-announce] 20220516 [SECURITY] [DLA 3011-1] vim security update', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-787'}, {'lang': 'en', 'value': 'CWE-122'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.4120', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:debian:debian_linux:9.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Heap-based Buffer Overflow in GitHub repository vim/vim prior to 8.2.'}] | 2022-08-26T17:42Z | 2022-01-18T16:15Z | Heap-based Buffer Overflow | A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc(). | https://cwe.mitre.org/data/definitions/122.html | 0 | Bram Moolenaar | 2022-01-17 17:30:21+00:00 | patch 8.2.4120: block insert goes over the end of the line
Problem: Block insert goes over the end of the line.
Solution: Handle invalid byte better. Fix inserting the wrong text. | 9f8c304c8a390ade133bac29963dc8e56ab14cbc | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | block_insert | block_insert( oparg_T * oap , char_u * s , int b_insert , struct block_def * bdp) | ['oap', 's', 'b_insert', 'bdp'] | block_insert(
oparg_T *oap,
char_u *s,
int b_insert,
struct block_def *bdp)
{
int ts_val;
int count = 0; // extra spaces to replace a cut TAB
int spaces = 0; // non-zero if cutting a TAB
colnr_T offset; // pointer along new line
colnr_T startcol; // column where insert starts
unsigned s_len; // STRLEN(s)
char_u *newp, *oldp; // new, old lines
linenr_T lnum; // loop var
int oldstate = State;
State = INSERT; // don't want REPLACE for State
s_len = (unsigned)STRLEN(s);
for (lnum = oap->start.lnum + 1; lnum <= oap->end.lnum; lnum++)
{
block_prep(oap, bdp, lnum, TRUE);
if (bdp->is_short && b_insert)
continue; // OP_INSERT, line ends before block start
oldp = ml_get(lnum);
if (b_insert)
{
ts_val = bdp->start_char_vcols;
spaces = bdp->startspaces;
if (spaces != 0)
count = ts_val - 1; // we're cutting a TAB
offset = bdp->textcol;
}
else // append
{
ts_val = bdp->end_char_vcols;
if (!bdp->is_short) // spaces = padding after block
{
spaces = (bdp->endspaces ? ts_val - bdp->endspaces : 0);
if (spaces != 0)
count = ts_val - 1; // we're cutting a TAB
offset = bdp->textcol + bdp->textlen - (spaces != 0);
}
else // spaces = padding to block edge
{
// if $ used, just append to EOL (ie spaces==0)
if (!bdp->is_MAX)
spaces = (oap->end_vcol - bdp->end_vcol) + 1;
count = spaces;
offset = bdp->textcol + bdp->textlen;
}
}
if (has_mbyte && spaces > 0)
{
int off;
// Avoid starting halfway a multi-byte character.
if (b_insert)
{
off = (*mb_head_off)(oldp, oldp + offset + spaces);
}
else
{
off = (*mb_off_next)(oldp, oldp + offset);
offset += off;
}
spaces -= off;
count -= off;
}
if (spaces < 0) // can happen when the cursor was moved
spaces = 0;
newp = alloc(STRLEN(oldp) + s_len + count + 1);
if (newp == NULL)
continue;
// copy up to shifted part
mch_memmove(newp, oldp, (size_t)(offset));
oldp += offset;
// insert pre-padding
vim_memset(newp + offset, ' ', (size_t)spaces);
startcol = offset + spaces;
// copy the new text
mch_memmove(newp + startcol, s, (size_t)s_len);
offset += s_len;
if (spaces && !bdp->is_short)
{
// insert post-padding
vim_memset(newp + offset + spaces, ' ', (size_t)(ts_val - spaces));
// We're splitting a TAB, don't copy it.
oldp++;
// We allowed for that TAB, remember this now
count++;
}
if (spaces > 0)
offset += count;
STRMOVE(newp + offset, oldp);
ml_replace(lnum, newp, FALSE);
if (b_insert)
// correct any text properties
inserted_bytes(lnum, startcol, s_len);
if (lnum == oap->end.lnum)
{
// Set "']" mark to the end of the block instead of the end of
// the insert in the first line.
curbuf->b_op_end.lnum = oap->end.lnum;
curbuf->b_op_end.col = offset;
}
} // for all lnum
changed_lines(oap->start.lnum + 1, 0, oap->end.lnum + 1, 0L);
State = oldstate;
} | 551 | True | 1 |
|
CVE-2022-0261 | 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/vim/vim/commit/9f8c304c8a390ade133bac29963dc8e56ab14cbc', 'name': 'https://github.com/vim/vim/commit/9f8c304c8a390ade133bac29963dc8e56ab14cbc', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://huntr.dev/bounties/fa795954-8775-4f23-98c6-d4d4d3fe8a82', 'name': 'https://huntr.dev/bounties/fa795954-8775-4f23-98c6-d4d4d3fe8a82', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Patch', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2022/05/msg00022.html', 'name': '[debian-lts-announce] 20220516 [SECURITY] [DLA 3011-1] vim security update', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-787'}, {'lang': 'en', 'value': 'CWE-122'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.4120', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:debian:debian_linux:9.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Heap-based Buffer Overflow in GitHub repository vim/vim prior to 8.2.'}] | 2022-08-26T17:42Z | 2022-01-18T16: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 | Bram Moolenaar | 2022-01-17 17:30:21+00:00 | patch 8.2.4120: block insert goes over the end of the line
Problem: Block insert goes over the end of the line.
Solution: Handle invalid byte better. Fix inserting the wrong text. | 9f8c304c8a390ade133bac29963dc8e56ab14cbc | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | block_insert | block_insert( oparg_T * oap , char_u * s , int b_insert , struct block_def * bdp) | ['oap', 's', 'b_insert', 'bdp'] | block_insert(
oparg_T *oap,
char_u *s,
int b_insert,
struct block_def *bdp)
{
int ts_val;
int count = 0; // extra spaces to replace a cut TAB
int spaces = 0; // non-zero if cutting a TAB
colnr_T offset; // pointer along new line
colnr_T startcol; // column where insert starts
unsigned s_len; // STRLEN(s)
char_u *newp, *oldp; // new, old lines
linenr_T lnum; // loop var
int oldstate = State;
State = INSERT; // don't want REPLACE for State
s_len = (unsigned)STRLEN(s);
for (lnum = oap->start.lnum + 1; lnum <= oap->end.lnum; lnum++)
{
block_prep(oap, bdp, lnum, TRUE);
if (bdp->is_short && b_insert)
continue; // OP_INSERT, line ends before block start
oldp = ml_get(lnum);
if (b_insert)
{
ts_val = bdp->start_char_vcols;
spaces = bdp->startspaces;
if (spaces != 0)
count = ts_val - 1; // we're cutting a TAB
offset = bdp->textcol;
}
else // append
{
ts_val = bdp->end_char_vcols;
if (!bdp->is_short) // spaces = padding after block
{
spaces = (bdp->endspaces ? ts_val - bdp->endspaces : 0);
if (spaces != 0)
count = ts_val - 1; // we're cutting a TAB
offset = bdp->textcol + bdp->textlen - (spaces != 0);
}
else // spaces = padding to block edge
{
// if $ used, just append to EOL (ie spaces==0)
if (!bdp->is_MAX)
spaces = (oap->end_vcol - bdp->end_vcol) + 1;
count = spaces;
offset = bdp->textcol + bdp->textlen;
}
}
if (has_mbyte && spaces > 0)
{
int off;
// Avoid starting halfway a multi-byte character.
if (b_insert)
{
off = (*mb_head_off)(oldp, oldp + offset + spaces);
}
else
{
off = (*mb_off_next)(oldp, oldp + offset);
offset += off;
}
spaces -= off;
count -= off;
}
if (spaces < 0) // can happen when the cursor was moved
spaces = 0;
newp = alloc(STRLEN(oldp) + s_len + count + 1);
if (newp == NULL)
continue;
// copy up to shifted part
mch_memmove(newp, oldp, (size_t)(offset));
oldp += offset;
// insert pre-padding
vim_memset(newp + offset, ' ', (size_t)spaces);
startcol = offset + spaces;
// copy the new text
mch_memmove(newp + startcol, s, (size_t)s_len);
offset += s_len;
if (spaces && !bdp->is_short)
{
// insert post-padding
vim_memset(newp + offset + spaces, ' ', (size_t)(ts_val - spaces));
// We're splitting a TAB, don't copy it.
oldp++;
// We allowed for that TAB, remember this now
count++;
}
if (spaces > 0)
offset += count;
STRMOVE(newp + offset, oldp);
ml_replace(lnum, newp, FALSE);
if (b_insert)
// correct any text properties
inserted_bytes(lnum, startcol, s_len);
if (lnum == oap->end.lnum)
{
// Set "']" mark to the end of the block instead of the end of
// the insert in the first line.
curbuf->b_op_end.lnum = oap->end.lnum;
curbuf->b_op_end.col = offset;
}
} // for all lnum
changed_lines(oap->start.lnum + 1, 0, oap->end.lnum + 1, 0L);
State = oldstate;
} | 551 | True | 1 |
CVE-2022-0261 | 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/vim/vim/commit/9f8c304c8a390ade133bac29963dc8e56ab14cbc', 'name': 'https://github.com/vim/vim/commit/9f8c304c8a390ade133bac29963dc8e56ab14cbc', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://huntr.dev/bounties/fa795954-8775-4f23-98c6-d4d4d3fe8a82', 'name': 'https://huntr.dev/bounties/fa795954-8775-4f23-98c6-d4d4d3fe8a82', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Patch', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2022/05/msg00022.html', 'name': '[debian-lts-announce] 20220516 [SECURITY] [DLA 3011-1] vim security update', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-787'}, {'lang': 'en', 'value': 'CWE-122'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.4120', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:debian:debian_linux:9.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Heap-based Buffer Overflow in GitHub repository vim/vim prior to 8.2.'}] | 2022-08-26T17:42Z | 2022-01-18T16:15Z | Heap-based Buffer Overflow | A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc(). | https://cwe.mitre.org/data/definitions/122.html | 0 | Bram Moolenaar | 2022-01-17 17:30:21+00:00 | patch 8.2.4120: block insert goes over the end of the line
Problem: Block insert goes over the end of the line.
Solution: Handle invalid byte better. Fix inserting the wrong text. | 9f8c304c8a390ade133bac29963dc8e56ab14cbc | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | op_insert | op_insert( oparg_T * oap , long count1) | ['oap', 'count1'] | op_insert(oparg_T *oap, long count1)
{
long ins_len, pre_textlen = 0;
char_u *firstline, *ins_text;
colnr_T ind_pre_col = 0, ind_post_col;
int ind_pre_vcol = 0, ind_post_vcol = 0;
struct block_def bd;
int i;
pos_T t1;
pos_T start_insert;
// offset when cursor was moved in insert mode
int offset = 0;
// edit() changes this - record it for OP_APPEND
bd.is_MAX = (curwin->w_curswant == MAXCOL);
// vis block is still marked. Get rid of it now.
curwin->w_cursor.lnum = oap->start.lnum;
update_screen(INVERTED);
if (oap->block_mode)
{
// When 'virtualedit' is used, need to insert the extra spaces before
// doing block_prep(). When only "block" is used, virtual edit is
// already disabled, but still need it when calling
// coladvance_force().
// coladvance_force() uses get_ve_flags() to get the 'virtualedit'
// state for the current window. To override that state, we need to
// set the window-local value of ve_flags rather than the global value.
if (curwin->w_cursor.coladd > 0)
{
int old_ve_flags = curwin->w_ve_flags;
if (u_save_cursor() == FAIL)
return;
curwin->w_ve_flags = VE_ALL;
coladvance_force(oap->op_type == OP_APPEND
? oap->end_vcol + 1 : getviscol());
if (oap->op_type == OP_APPEND)
--curwin->w_cursor.col;
curwin->w_ve_flags = old_ve_flags;
}
// Get the info about the block before entering the text
block_prep(oap, &bd, oap->start.lnum, TRUE);
// Get indent information
ind_pre_col = (colnr_T)getwhitecols_curline();
ind_pre_vcol = get_indent();
firstline = ml_get(oap->start.lnum) + bd.textcol;
if (oap->op_type == OP_APPEND)
firstline += bd.textlen;
pre_textlen = (long)STRLEN(firstline);
}
if (oap->op_type == OP_APPEND)
{
if (oap->block_mode && curwin->w_cursor.coladd == 0)
{
// Move the cursor to the character right of the block.
curwin->w_set_curswant = TRUE;
while (*ml_get_cursor() != NUL
&& (curwin->w_cursor.col < bd.textcol + bd.textlen))
++curwin->w_cursor.col;
if (bd.is_short && !bd.is_MAX)
{
// First line was too short, make it longer and adjust the
// values in "bd".
if (u_save_cursor() == FAIL)
return;
for (i = 0; i < bd.endspaces; ++i)
ins_char(' ');
bd.textlen += bd.endspaces;
}
}
else
{
curwin->w_cursor = oap->end;
check_cursor_col();
// Works just like an 'i'nsert on the next character.
if (!LINEEMPTY(curwin->w_cursor.lnum)
&& oap->start_vcol != oap->end_vcol)
inc_cursor();
}
}
t1 = oap->start;
start_insert = curwin->w_cursor;
(void)edit(NUL, FALSE, (linenr_T)count1);
// When a tab was inserted, and the characters in front of the tab
// have been converted to a tab as well, the column of the cursor
// might have actually been reduced, so need to adjust here.
if (t1.lnum == curbuf->b_op_start_orig.lnum
&& LT_POS(curbuf->b_op_start_orig, t1))
oap->start = curbuf->b_op_start_orig;
// If user has moved off this line, we don't know what to do, so do
// nothing.
// Also don't repeat the insert when Insert mode ended with CTRL-C.
if (curwin->w_cursor.lnum != oap->start.lnum || got_int)
return;
if (oap->block_mode)
{
struct block_def bd2;
int did_indent = FALSE;
size_t len;
int add;
// If indent kicked in, the firstline might have changed
// but only do that, if the indent actually increased.
ind_post_col = (colnr_T)getwhitecols_curline();
if (curbuf->b_op_start.col > ind_pre_col && ind_post_col > ind_pre_col)
{
bd.textcol += ind_post_col - ind_pre_col;
ind_post_vcol = get_indent();
bd.start_vcol += ind_post_vcol - ind_pre_vcol;
did_indent = TRUE;
}
// The user may have moved the cursor before inserting something, try
// to adjust the block for that. But only do it, if the difference
// does not come from indent kicking in.
if (oap->start.lnum == curbuf->b_op_start_orig.lnum
&& !bd.is_MAX && !did_indent)
{
int t = getviscol2(curbuf->b_op_start_orig.col,
curbuf->b_op_start_orig.coladd);
if (!bd.is_MAX)
{
if (oap->op_type == OP_INSERT
&& oap->start.col + oap->start.coladd
!= curbuf->b_op_start_orig.col
+ curbuf->b_op_start_orig.coladd)
{
oap->start.col = curbuf->b_op_start_orig.col;
pre_textlen -= t - oap->start_vcol;
oap->start_vcol = t;
}
else if (oap->op_type == OP_APPEND
&& oap->end.col + oap->end.coladd
>= curbuf->b_op_start_orig.col
+ curbuf->b_op_start_orig.coladd)
{
oap->start.col = curbuf->b_op_start_orig.col;
// reset pre_textlen to the value of OP_INSERT
pre_textlen += bd.textlen;
pre_textlen -= t - oap->start_vcol;
oap->start_vcol = t;
oap->op_type = OP_INSERT;
}
}
else if (bd.is_MAX && oap->op_type == OP_APPEND)
{
// reset pre_textlen to the value of OP_INSERT
pre_textlen += bd.textlen;
pre_textlen -= t - oap->start_vcol;
}
}
// Spaces and tabs in the indent may have changed to other spaces and
// tabs. Get the starting column again and correct the length.
// Don't do this when "$" used, end-of-line will have changed.
//
// if indent was added and the inserted text was after the indent,
// correct the selection for the new indent.
if (did_indent && bd.textcol - ind_post_col > 0)
{
oap->start.col += ind_post_col - ind_pre_col;
oap->start_vcol += ind_post_vcol - ind_pre_vcol;
oap->end.col += ind_post_col - ind_pre_col;
oap->end_vcol += ind_post_vcol - ind_pre_vcol;
}
block_prep(oap, &bd2, oap->start.lnum, TRUE);
if (did_indent && bd.textcol - ind_post_col > 0)
{
// undo for where "oap" is used below
oap->start.col -= ind_post_col - ind_pre_col;
oap->start_vcol -= ind_post_vcol - ind_pre_vcol;
oap->end.col -= ind_post_col - ind_pre_col;
oap->end_vcol -= ind_post_vcol - ind_pre_vcol;
}
if (!bd.is_MAX || bd2.textlen < bd.textlen)
{
if (oap->op_type == OP_APPEND)
{
pre_textlen += bd2.textlen - bd.textlen;
if (bd2.endspaces)
--bd2.textlen;
}
bd.textcol = bd2.textcol;
bd.textlen = bd2.textlen;
}
/*
* Subsequent calls to ml_get() flush the firstline data - take a
* copy of the required string.
*/
firstline = ml_get(oap->start.lnum);
len = STRLEN(firstline);
add = bd.textcol;
if (oap->op_type == OP_APPEND)
{
add += bd.textlen;
// account for pressing cursor in insert mode when '$' was used
if (bd.is_MAX
&& (start_insert.lnum == Insstart.lnum
&& start_insert.col > Insstart.col))
{
offset = (start_insert.col - Insstart.col);
add -= offset;
if (oap->end_vcol > offset)
oap->end_vcol -= (offset + 1);
else
// moved outside of the visual block, what to do?
return;
}
}
if ((size_t)add > len)
firstline += len; // short line, point to the NUL
else
firstline += add;
if (pre_textlen >= 0 && (ins_len =
(long)STRLEN(firstline) - pre_textlen - offset) > 0)
{
ins_text = vim_strnsave(firstline, ins_len);
if (ins_text != NULL)
{
// block handled here
if (u_save(oap->start.lnum,
(linenr_T)(oap->end.lnum + 1)) == OK)
block_insert(oap, ins_text, (oap->op_type == OP_INSERT),
&bd);
curwin->w_cursor.col = oap->start.col;
check_cursor();
vim_free(ins_text);
}
}
}
} | 1165 | True | 1 |
|
CVE-2022-0261 | 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/vim/vim/commit/9f8c304c8a390ade133bac29963dc8e56ab14cbc', 'name': 'https://github.com/vim/vim/commit/9f8c304c8a390ade133bac29963dc8e56ab14cbc', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://huntr.dev/bounties/fa795954-8775-4f23-98c6-d4d4d3fe8a82', 'name': 'https://huntr.dev/bounties/fa795954-8775-4f23-98c6-d4d4d3fe8a82', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Patch', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2022/05/msg00022.html', 'name': '[debian-lts-announce] 20220516 [SECURITY] [DLA 3011-1] vim security update', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-787'}, {'lang': 'en', 'value': 'CWE-122'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.4120', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:debian:debian_linux:9.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Heap-based Buffer Overflow in GitHub repository vim/vim prior to 8.2.'}] | 2022-08-26T17:42Z | 2022-01-18T16: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 | Bram Moolenaar | 2022-01-17 17:30:21+00:00 | patch 8.2.4120: block insert goes over the end of the line
Problem: Block insert goes over the end of the line.
Solution: Handle invalid byte better. Fix inserting the wrong text. | 9f8c304c8a390ade133bac29963dc8e56ab14cbc | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | op_insert | op_insert( oparg_T * oap , long count1) | ['oap', 'count1'] | op_insert(oparg_T *oap, long count1)
{
long ins_len, pre_textlen = 0;
char_u *firstline, *ins_text;
colnr_T ind_pre_col = 0, ind_post_col;
int ind_pre_vcol = 0, ind_post_vcol = 0;
struct block_def bd;
int i;
pos_T t1;
pos_T start_insert;
// offset when cursor was moved in insert mode
int offset = 0;
// edit() changes this - record it for OP_APPEND
bd.is_MAX = (curwin->w_curswant == MAXCOL);
// vis block is still marked. Get rid of it now.
curwin->w_cursor.lnum = oap->start.lnum;
update_screen(INVERTED);
if (oap->block_mode)
{
// When 'virtualedit' is used, need to insert the extra spaces before
// doing block_prep(). When only "block" is used, virtual edit is
// already disabled, but still need it when calling
// coladvance_force().
// coladvance_force() uses get_ve_flags() to get the 'virtualedit'
// state for the current window. To override that state, we need to
// set the window-local value of ve_flags rather than the global value.
if (curwin->w_cursor.coladd > 0)
{
int old_ve_flags = curwin->w_ve_flags;
if (u_save_cursor() == FAIL)
return;
curwin->w_ve_flags = VE_ALL;
coladvance_force(oap->op_type == OP_APPEND
? oap->end_vcol + 1 : getviscol());
if (oap->op_type == OP_APPEND)
--curwin->w_cursor.col;
curwin->w_ve_flags = old_ve_flags;
}
// Get the info about the block before entering the text
block_prep(oap, &bd, oap->start.lnum, TRUE);
// Get indent information
ind_pre_col = (colnr_T)getwhitecols_curline();
ind_pre_vcol = get_indent();
firstline = ml_get(oap->start.lnum) + bd.textcol;
if (oap->op_type == OP_APPEND)
firstline += bd.textlen;
pre_textlen = (long)STRLEN(firstline);
}
if (oap->op_type == OP_APPEND)
{
if (oap->block_mode && curwin->w_cursor.coladd == 0)
{
// Move the cursor to the character right of the block.
curwin->w_set_curswant = TRUE;
while (*ml_get_cursor() != NUL
&& (curwin->w_cursor.col < bd.textcol + bd.textlen))
++curwin->w_cursor.col;
if (bd.is_short && !bd.is_MAX)
{
// First line was too short, make it longer and adjust the
// values in "bd".
if (u_save_cursor() == FAIL)
return;
for (i = 0; i < bd.endspaces; ++i)
ins_char(' ');
bd.textlen += bd.endspaces;
}
}
else
{
curwin->w_cursor = oap->end;
check_cursor_col();
// Works just like an 'i'nsert on the next character.
if (!LINEEMPTY(curwin->w_cursor.lnum)
&& oap->start_vcol != oap->end_vcol)
inc_cursor();
}
}
t1 = oap->start;
start_insert = curwin->w_cursor;
(void)edit(NUL, FALSE, (linenr_T)count1);
// When a tab was inserted, and the characters in front of the tab
// have been converted to a tab as well, the column of the cursor
// might have actually been reduced, so need to adjust here.
if (t1.lnum == curbuf->b_op_start_orig.lnum
&& LT_POS(curbuf->b_op_start_orig, t1))
oap->start = curbuf->b_op_start_orig;
// If user has moved off this line, we don't know what to do, so do
// nothing.
// Also don't repeat the insert when Insert mode ended with CTRL-C.
if (curwin->w_cursor.lnum != oap->start.lnum || got_int)
return;
if (oap->block_mode)
{
struct block_def bd2;
int did_indent = FALSE;
size_t len;
int add;
// If indent kicked in, the firstline might have changed
// but only do that, if the indent actually increased.
ind_post_col = (colnr_T)getwhitecols_curline();
if (curbuf->b_op_start.col > ind_pre_col && ind_post_col > ind_pre_col)
{
bd.textcol += ind_post_col - ind_pre_col;
ind_post_vcol = get_indent();
bd.start_vcol += ind_post_vcol - ind_pre_vcol;
did_indent = TRUE;
}
// The user may have moved the cursor before inserting something, try
// to adjust the block for that. But only do it, if the difference
// does not come from indent kicking in.
if (oap->start.lnum == curbuf->b_op_start_orig.lnum
&& !bd.is_MAX && !did_indent)
{
int t = getviscol2(curbuf->b_op_start_orig.col,
curbuf->b_op_start_orig.coladd);
if (!bd.is_MAX)
{
if (oap->op_type == OP_INSERT
&& oap->start.col + oap->start.coladd
!= curbuf->b_op_start_orig.col
+ curbuf->b_op_start_orig.coladd)
{
oap->start.col = curbuf->b_op_start_orig.col;
pre_textlen -= t - oap->start_vcol;
oap->start_vcol = t;
}
else if (oap->op_type == OP_APPEND
&& oap->end.col + oap->end.coladd
>= curbuf->b_op_start_orig.col
+ curbuf->b_op_start_orig.coladd)
{
oap->start.col = curbuf->b_op_start_orig.col;
// reset pre_textlen to the value of OP_INSERT
pre_textlen += bd.textlen;
pre_textlen -= t - oap->start_vcol;
oap->start_vcol = t;
oap->op_type = OP_INSERT;
}
}
else if (bd.is_MAX && oap->op_type == OP_APPEND)
{
// reset pre_textlen to the value of OP_INSERT
pre_textlen += bd.textlen;
pre_textlen -= t - oap->start_vcol;
}
}
// Spaces and tabs in the indent may have changed to other spaces and
// tabs. Get the starting column again and correct the length.
// Don't do this when "$" used, end-of-line will have changed.
//
// if indent was added and the inserted text was after the indent,
// correct the selection for the new indent.
if (did_indent && bd.textcol - ind_post_col > 0)
{
oap->start.col += ind_post_col - ind_pre_col;
oap->start_vcol += ind_post_vcol - ind_pre_vcol;
oap->end.col += ind_post_col - ind_pre_col;
oap->end_vcol += ind_post_vcol - ind_pre_vcol;
}
block_prep(oap, &bd2, oap->start.lnum, TRUE);
if (did_indent && bd.textcol - ind_post_col > 0)
{
// undo for where "oap" is used below
oap->start.col -= ind_post_col - ind_pre_col;
oap->start_vcol -= ind_post_vcol - ind_pre_vcol;
oap->end.col -= ind_post_col - ind_pre_col;
oap->end_vcol -= ind_post_vcol - ind_pre_vcol;
}
if (!bd.is_MAX || bd2.textlen < bd.textlen)
{
if (oap->op_type == OP_APPEND)
{
pre_textlen += bd2.textlen - bd.textlen;
if (bd2.endspaces)
--bd2.textlen;
}
bd.textcol = bd2.textcol;
bd.textlen = bd2.textlen;
}
/*
* Subsequent calls to ml_get() flush the firstline data - take a
* copy of the required string.
*/
firstline = ml_get(oap->start.lnum);
len = STRLEN(firstline);
add = bd.textcol;
if (oap->op_type == OP_APPEND)
{
add += bd.textlen;
// account for pressing cursor in insert mode when '$' was used
if (bd.is_MAX
&& (start_insert.lnum == Insstart.lnum
&& start_insert.col > Insstart.col))
{
offset = (start_insert.col - Insstart.col);
add -= offset;
if (oap->end_vcol > offset)
oap->end_vcol -= (offset + 1);
else
// moved outside of the visual block, what to do?
return;
}
}
if ((size_t)add > len)
firstline += len; // short line, point to the NUL
else
firstline += add;
if (pre_textlen >= 0 && (ins_len =
(long)STRLEN(firstline) - pre_textlen - offset) > 0)
{
ins_text = vim_strnsave(firstline, ins_len);
if (ins_text != NULL)
{
// block handled here
if (u_save(oap->start.lnum,
(linenr_T)(oap->end.lnum + 1)) == OK)
block_insert(oap, ins_text, (oap->op_type == OP_INSERT),
&bd);
curwin->w_cursor.col = oap->start.col;
check_cursor();
vim_free(ins_text);
}
}
}
} | 1165 | True | 1 |
CVE-2022-0318 | 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/vim/vim/commit/57df9e8a9f9ae1aafdde9b86b10ad907627a87dc', 'name': 'https://github.com/vim/vim/commit/57df9e8a9f9ae1aafdde9b86b10ad907627a87dc', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://huntr.dev/bounties/0d10ba02-b138-4e68-a284-67f781a62d08', 'name': 'https://huntr.dev/bounties/0d10ba02-b138-4e68-a284-67f781a62d08', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Patch', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-122'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.4151', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Heap-based Buffer Overflow in vim/vim prior to 8.2.'}] | 2022-08-21T07:15Z | 2022-01-21T12:15Z | Heap-based Buffer Overflow | A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc(). | https://cwe.mitre.org/data/definitions/122.html | 0 | Bram Moolenaar | 2022-01-20 12:10:48+00:00 | patch 8.2.4151: reading beyond the end of a line
Problem: Reading beyond the end of a line.
Solution: For block insert only use the offset for correcting the length. | 57df9e8a9f9ae1aafdde9b86b10ad907627a87dc | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | block_insert | block_insert( oparg_T * oap , char_u * s , int b_insert , struct block_def * bdp) | ['oap', 's', 'b_insert', 'bdp'] | block_insert(
oparg_T *oap,
char_u *s,
int b_insert,
struct block_def *bdp)
{
int ts_val;
int count = 0; // extra spaces to replace a cut TAB
int spaces = 0; // non-zero if cutting a TAB
colnr_T offset; // pointer along new line
colnr_T startcol; // column where insert starts
unsigned s_len; // STRLEN(s)
char_u *newp, *oldp; // new, old lines
linenr_T lnum; // loop var
int oldstate = State;
State = INSERT; // don't want REPLACE for State
s_len = (unsigned)STRLEN(s);
for (lnum = oap->start.lnum + 1; lnum <= oap->end.lnum; lnum++)
{
block_prep(oap, bdp, lnum, TRUE);
if (bdp->is_short && b_insert)
continue; // OP_INSERT, line ends before block start
oldp = ml_get(lnum);
if (b_insert)
{
ts_val = bdp->start_char_vcols;
spaces = bdp->startspaces;
if (spaces != 0)
count = ts_val - 1; // we're cutting a TAB
offset = bdp->textcol;
}
else // append
{
ts_val = bdp->end_char_vcols;
if (!bdp->is_short) // spaces = padding after block
{
spaces = (bdp->endspaces ? ts_val - bdp->endspaces : 0);
if (spaces != 0)
count = ts_val - 1; // we're cutting a TAB
offset = bdp->textcol + bdp->textlen - (spaces != 0);
}
else // spaces = padding to block edge
{
// if $ used, just append to EOL (ie spaces==0)
if (!bdp->is_MAX)
spaces = (oap->end_vcol - bdp->end_vcol) + 1;
count = spaces;
offset = bdp->textcol + bdp->textlen;
}
}
if (has_mbyte && spaces > 0)
{
int off;
// Avoid starting halfway a multi-byte character.
if (b_insert)
{
off = (*mb_head_off)(oldp, oldp + offset + spaces);
spaces -= off;
count -= off;
}
else
{
// spaces fill the gap, the character that's at the edge moves
// right
off = (*mb_head_off)(oldp, oldp + offset);
offset -= off;
}
}
if (spaces < 0) // can happen when the cursor was moved
spaces = 0;
// Make sure the allocated size matches what is actually copied below.
newp = alloc(STRLEN(oldp) + spaces + s_len
+ (spaces > 0 && !bdp->is_short ? ts_val - spaces : 0)
+ count + 1);
if (newp == NULL)
continue;
// copy up to shifted part
mch_memmove(newp, oldp, (size_t)offset);
oldp += offset;
// insert pre-padding
vim_memset(newp + offset, ' ', (size_t)spaces);
startcol = offset + spaces;
// copy the new text
mch_memmove(newp + startcol, s, (size_t)s_len);
offset += s_len;
if (spaces > 0 && !bdp->is_short)
{
if (*oldp == TAB)
{
// insert post-padding
vim_memset(newp + offset + spaces, ' ',
(size_t)(ts_val - spaces));
// we're splitting a TAB, don't copy it
oldp++;
// We allowed for that TAB, remember this now
count++;
}
else
// Not a TAB, no extra spaces
count = spaces;
}
if (spaces > 0)
offset += count;
STRMOVE(newp + offset, oldp);
ml_replace(lnum, newp, FALSE);
if (b_insert)
// correct any text properties
inserted_bytes(lnum, startcol, s_len);
if (lnum == oap->end.lnum)
{
// Set "']" mark to the end of the block instead of the end of
// the insert in the first line.
curbuf->b_op_end.lnum = oap->end.lnum;
curbuf->b_op_end.col = offset;
}
} // for all lnum
changed_lines(oap->start.lnum + 1, 0, oap->end.lnum + 1, 0L);
State = oldstate;
} | 584 | True | 1 |
|
CVE-2022-0319 | 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:L/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:N | LOCAL | LOW | NONE | REQUIRED | UNCHANGED | HIGH | NONE | NONE | 5.5 | MEDIUM | 1.8 | 3.6 | False | [{'url': 'https://huntr.dev/bounties/ba622fd2-e6ef-4ad9-95b4-17f87b68755b', 'name': 'https://huntr.dev/bounties/ba622fd2-e6ef-4ad9-95b4-17f87b68755b', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Patch', 'Third Party Advisory']}, {'url': 'https://github.com/vim/vim/commit/05b27615481e72e3b338bb12990fb3e0c2ecc2a9', 'name': 'https://github.com/vim/vim/commit/05b27615481e72e3b338bb12990fb3e0c2ecc2a9', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2022/03/msg00018.html', 'name': '[debian-lts-announce] 20220311 [SECURITY] [DLA 2947-1] vim security update', 'refsource': 'MLIST', 'tags': ['Mitigation', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}]}] | MEDIUM | [{'operator': 'AND', 'children': [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.4154', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': False, 'cpe23Uri': 'cpe:2.3:o:canonical:ubuntu_linux:20.04:*:*:*:*:*:*:*', 'cpe_name': []}]}], 'cpe_match': []}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:debian:debian_linux:9.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Out-of-bounds Read in vim/vim prior to 8.2.'}] | 2022-08-26T17:43Z | 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 | Bram Moolenaar | 2022-01-20 13:32:50+00:00 | patch 8.2.4154: ml_get error when exchanging windows in Visual mode
Problem: ml_get error when exchanging windows in Visual mode.
Solution: Correct end of Visual area when entering another buffer. | 05b27615481e72e3b338bb12990fb3e0c2ecc2a9 | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | win_alloc_lines | win_alloc_lines( win_T * wp) | ['wp'] | win_alloc_lines(win_T *wp)
{
wp->w_lines_valid = 0;
wp->w_lines = ALLOC_CLEAR_MULT(wline_T, Rows );
if (wp->w_lines == NULL)
return FAIL;
return OK;
} | 39 | True | 1 |
CVE-2022-0359 | 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://huntr.dev/bounties/a3192d90-4f82-4a67-b7a6-37046cc88def', 'name': 'https://huntr.dev/bounties/a3192d90-4f82-4a67-b7a6-37046cc88def', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Issue Tracking', 'Patch', 'Third Party Advisory']}, {'url': 'https://github.com/vim/vim/commit/85b6747abc15a7a81086db31289cf1b8b17e6cb1', 'name': 'https://github.com/vim/vim/commit/85b6747abc15a7a81086db31289cf1b8b17e6cb1', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2022/03/msg00018.html', 'name': '[debian-lts-announce] 20220311 [SECURITY] [DLA 2947-1] vim security update', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-122'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.4214', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:debian:debian_linux:9.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Heap-based Buffer Overflow in GitHub repository vim/vim prior to 8.2.'}] | 2022-08-26T19:15Z | 2022-01-26T12:15Z | Heap-based Buffer Overflow | A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc(). | https://cwe.mitre.org/data/definitions/122.html | 0 | Bram Moolenaar | 2022-01-25 11:55:02+00:00 | patch 8.2.4214: illegal memory access with large 'tabstop' in Ex mode
Problem: Illegal memory access with large 'tabstop' in Ex mode.
Solution: Allocate enough memory. | 85b6747abc15a7a81086db31289cf1b8b17e6cb1 | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | init_ccline | init_ccline( int firstc , int indent) | ['firstc', 'indent'] | init_ccline(int firstc, int indent)
{
ccline.overstrike = FALSE; // always start in insert mode
/*
* set some variables for redrawcmd()
*/
ccline.cmdfirstc = (firstc == '@' ? 0 : firstc);
ccline.cmdindent = (firstc > 0 ? indent : 0);
// alloc initial ccline.cmdbuff
alloc_cmdbuff(exmode_active ? 250 : indent + 1);
if (ccline.cmdbuff == NULL)
return FAIL;
ccline.cmdlen = ccline.cmdpos = 0;
ccline.cmdbuff[0] = NUL;
sb_text_start_cmdline();
// autoindent for :insert and :append
if (firstc <= 0)
{
vim_memset(ccline.cmdbuff, ' ', indent);
ccline.cmdbuff[indent] = NUL;
ccline.cmdpos = indent;
ccline.cmdspos = indent;
ccline.cmdlen = indent;
}
return OK;
} | 138 | True | 1 |
|
CVE-2022-0392 | 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/vim/vim/commit/806d037671e133bd28a7864248763f643967973a', 'name': 'https://github.com/vim/vim/commit/806d037671e133bd28a7864248763f643967973a', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://huntr.dev/bounties/d00a2acd-1935-4195-9d5b-4115ef6b3126', 'name': 'https://huntr.dev/bounties/d00a2acd-1935-4195-9d5b-4115ef6b3126', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Patch', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-122'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.4218', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Heap-based Buffer Overflow in GitHub repository vim prior to 8.2.'}] | 2022-08-26T17:45Z | 2022-01-28T22:15Z | Heap-based Buffer Overflow | A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc(). | https://cwe.mitre.org/data/definitions/122.html | 0 | Bram Moolenaar | 2022-01-25 20:45:16+00:00 | patch 8.2.4218: illegal memory access with bracketed paste in Ex mode
Problem: Illegal memory access with bracketed paste in Ex mode.
Solution: Reserve space for the trailing NUL. | 806d037671e133bd28a7864248763f643967973a | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | bracketed_paste | bracketed_paste( paste_mode_T mode , int drop , garray_T * gap) | ['mode', 'drop', 'gap'] | bracketed_paste(paste_mode_T mode, int drop, garray_T *gap)
{
int c;
char_u buf[NUMBUFLEN + MB_MAXBYTES];
int idx = 0;
char_u *end = find_termcode((char_u *)"PE");
int ret_char = -1;
int save_allow_keys = allow_keys;
int save_paste = p_paste;
// If the end code is too long we can't detect it, read everything.
if (end != NULL && STRLEN(end) >= NUMBUFLEN)
end = NULL;
++no_mapping;
allow_keys = 0;
if (!p_paste)
// Also have the side effects of setting 'paste' to make it work much
// faster.
set_option_value((char_u *)"paste", TRUE, NULL, 0);
for (;;)
{
// When the end is not defined read everything there is.
if (end == NULL && vpeekc() == NUL)
break;
do
c = vgetc();
while (c == K_IGNORE || c == K_VER_SCROLLBAR || c == K_HOR_SCROLLBAR);
if (c == NUL || got_int || (ex_normal_busy > 0 && c == Ctrl_C))
// When CTRL-C was encountered the typeahead will be flushed and we
// won't get the end sequence. Except when using ":normal".
break;
if (has_mbyte)
idx += (*mb_char2bytes)(c, buf + idx);
else
buf[idx++] = c;
buf[idx] = NUL;
if (end != NULL && STRNCMP(buf, end, idx) == 0)
{
if (end[idx] == NUL)
break; // Found the end of paste code.
continue;
}
if (!drop)
{
switch (mode)
{
case PASTE_CMDLINE:
put_on_cmdline(buf, idx, TRUE);
break;
case PASTE_EX:
if (gap != NULL && ga_grow(gap, idx) == OK)
{
mch_memmove((char *)gap->ga_data + gap->ga_len,
buf, (size_t)idx);
gap->ga_len += idx;
}
break;
case PASTE_INSERT:
if (stop_arrow() == OK)
{
c = buf[0];
if (idx == 1 && (c == CAR || c == K_KENTER || c == NL))
ins_eol(c);
else
{
ins_char_bytes(buf, idx);
AppendToRedobuffLit(buf, idx);
}
}
break;
case PASTE_ONE_CHAR:
if (ret_char == -1)
{
if (has_mbyte)
ret_char = (*mb_ptr2char)(buf);
else
ret_char = buf[0];
}
break;
}
}
idx = 0;
}
--no_mapping;
allow_keys = save_allow_keys;
if (!save_paste)
set_option_value((char_u *)"paste", FALSE, NULL, 0);
return ret_char;
} | 443 | True | 1 |
|
CVE-2022-0407 | 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/vim/vim/commit/44db8213d38c39877d2148eff6a72f4beccfb94e', 'name': 'https://github.com/vim/vim/commit/44db8213d38c39877d2148eff6a72f4beccfb94e', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://huntr.dev/bounties/81822bf7-aafe-4d37-b836-1255d46e572c', 'name': 'https://huntr.dev/bounties/81822bf7-aafe-4d37-b836-1255d46e572c', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Patch', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-122'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.4219', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Heap-based Buffer Overflow in GitHub repository vim/vim prior to 8.2.'}] | 2022-08-26T17:35Z | 2022-01-30T14:15Z | Heap-based Buffer Overflow | A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc(). | https://cwe.mitre.org/data/definitions/122.html | 0 | Bram Moolenaar | 2022-01-25 21:26:17+00:00 | patch 8.2.4219: reading before the start of the line
Problem: Reading before the start of the line.
Solution: Check boundary before trying to read the character. | 44db8213d38c39877d2148eff6a72f4beccfb94e | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | yank_copy_line | yank_copy_line( struct block_def * bd , long y_idx , int exclude_trailing_space) | ['bd', 'y_idx', 'exclude_trailing_space'] | yank_copy_line(struct block_def *bd, long y_idx, int exclude_trailing_space)
{
char_u *pnew;
if (exclude_trailing_space)
bd->endspaces = 0;
if ((pnew = alloc(bd->startspaces + bd->endspaces + bd->textlen + 1))
== NULL)
return FAIL;
y_current->y_array[y_idx] = pnew;
vim_memset(pnew, ' ', (size_t)bd->startspaces);
pnew += bd->startspaces;
mch_memmove(pnew, bd->textstart, (size_t)bd->textlen);
pnew += bd->textlen;
vim_memset(pnew, ' ', (size_t)bd->endspaces);
pnew += bd->endspaces;
if (exclude_trailing_space)
{
int s = bd->textlen + bd->endspaces;
while (VIM_ISWHITE(*(bd->textstart + s - 1)) && s > 0)
{
s = s - (*mb_head_off)(bd->textstart, bd->textstart + s - 1) - 1;
pnew--;
}
}
*pnew = NUL;
return OK;
} | 202 | True | 1 |
|
CVE-2022-0393 | False | False | False | True | AV:N/AC:M/Au:N/C:P/I:N/A:P | NETWORK | MEDIUM | NONE | PARTIAL | NONE | PARTIAL | 5.8 | CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:H | LOCAL | LOW | NONE | REQUIRED | UNCHANGED | HIGH | NONE | HIGH | 7.1 | HIGH | 1.8 | 5.2 | False | [{'url': 'https://huntr.dev/bounties/ecc8f488-01a0-477f-848f-e30b8e524bba', 'name': 'https://huntr.dev/bounties/ecc8f488-01a0-477f-848f-e30b8e524bba', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Patch', 'Third Party Advisory']}, {'url': 'https://github.com/vim/vim/commit/a4bc2dd7cccf5a4a9f78b58b6f35a45d17164323', 'name': 'https://github.com/vim/vim/commit/a4bc2dd7cccf5a4a9f78b58b6f35a45d17164323', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/UFXFAILMLUIK4MBUEZO4HNBNKYZRJ5AP/', 'name': 'FEDORA-2022-da2fb07efb', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/7ZLEHVP4LNAGER4ZDGUDS5V5YVQD6INF/', 'name': 'FEDORA-2022-48bf3cb1c4', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.4233', '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': []}]}] | [{'lang': 'en', 'value': 'Out-of-bounds Read in GitHub repository vim/vim prior to 8.2.'}] | 2022-08-21T08:15Z | 2022-01-28T22: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 | Bram Moolenaar | 2022-01-27 19:27:16+00:00 | patch 8.2.4233: crash when recording and using Select mode
Problem: Crash when recording and using Select mode.
Solution: When deleting the last recorded character check there is something
to delete. | a4bc2dd7cccf5a4a9f78b58b6f35a45d17164323 | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | delete_buff_tail | delete_buff_tail( buffheader_T * buf , int slen) | ['buf', 'slen'] | delete_buff_tail(buffheader_T *buf, int slen)
{
int len = (int)STRLEN(buf->bh_curr->b_str);
if (len >= slen)
{
buf->bh_curr->b_str[len - slen] = NUL;
buf->bh_space += slen;
}
} | 53 | True | 1 |
CVE-2022-0417 | 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://huntr.dev/bounties/fc86bc8d-c866-4ade-8b7f-e49cec306d1a', 'name': 'https://huntr.dev/bounties/fc86bc8d-c866-4ade-8b7f-e49cec306d1a', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Patch', 'Third Party Advisory']}, {'url': 'https://github.com/vim/vim/commit/652dee448618589de5528a9e9a36995803f5557a', 'name': 'https://github.com/vim/vim/commit/652dee448618589de5528a9e9a36995803f5557a', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/UFXFAILMLUIK4MBUEZO4HNBNKYZRJ5AP/', 'name': 'FEDORA-2022-da2fb07efb', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/7ZLEHVP4LNAGER4ZDGUDS5V5YVQD6INF/', 'name': 'FEDORA-2022-48bf3cb1c4', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2022/06/msg00014.html', 'name': '[debian-lts-announce] 20220620 [SECURITY] [DLA 3053-1] vim security update', 'refsource': 'MLIST', 'tags': ['Mitigation', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-122'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.4245', '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': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:debian:debian_linux:9.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Heap-based Buffer Overflow GitHub repository vim/vim prior to 8.2.'}] | 2022-08-26T17:35Z | 2022-02-01T13:15Z | Heap-based Buffer Overflow | A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc(). | https://cwe.mitre.org/data/definitions/122.html | 0 | Bram Moolenaar | 2022-01-28 20:47:49+00:00 | patch 8.2.4245: ":retab 0" may cause illegal memory access
Problem: ":retab 0" may cause illegal memory access.
Solution: Limit the value of 'tabstop' to 10000. | 652dee448618589de5528a9e9a36995803f5557a | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | ex_retab | ex_retab( exarg_T * eap) | ['eap'] | ex_retab(exarg_T *eap)
{
linenr_T lnum;
int got_tab = FALSE;
long num_spaces = 0;
long num_tabs;
long len;
long col;
long vcol;
long start_col = 0; // For start of white-space string
long start_vcol = 0; // For start of white-space string
long old_len;
char_u *ptr;
char_u *new_line = (char_u *)1; // init to non-NULL
int did_undo; // called u_save for current line
#ifdef FEAT_VARTABS
int *new_vts_array = NULL;
char_u *new_ts_str; // string value of tab argument
#else
int temp;
int new_ts;
#endif
int save_list;
linenr_T first_line = 0; // first changed line
linenr_T last_line = 0; // last changed line
save_list = curwin->w_p_list;
curwin->w_p_list = 0; // don't want list mode here
#ifdef FEAT_VARTABS
new_ts_str = eap->arg;
if (tabstop_set(eap->arg, &new_vts_array) == FAIL)
return;
while (vim_isdigit(*(eap->arg)) || *(eap->arg) == ',')
++(eap->arg);
// This ensures that either new_vts_array and new_ts_str are freshly
// allocated, or new_vts_array points to an existing array and new_ts_str
// is null.
if (new_vts_array == NULL)
{
new_vts_array = curbuf->b_p_vts_array;
new_ts_str = NULL;
}
else
new_ts_str = vim_strnsave(new_ts_str, eap->arg - new_ts_str);
#else
ptr = eap->arg;
new_ts = getdigits(&ptr);
if (new_ts < 0 && *eap->arg == '-')
{
emsg(_(e_argument_must_be_positive));
return;
}
if (new_ts < 0 || new_ts > 9999)
{
semsg(_(e_invalid_argument_str), eap->arg);
return;
}
if (new_ts == 0)
new_ts = curbuf->b_p_ts;
#endif
for (lnum = eap->line1; !got_int && lnum <= eap->line2; ++lnum)
{
ptr = ml_get(lnum);
col = 0;
vcol = 0;
did_undo = FALSE;
for (;;)
{
if (VIM_ISWHITE(ptr[col]))
{
if (!got_tab && num_spaces == 0)
{
// First consecutive white-space
start_vcol = vcol;
start_col = col;
}
if (ptr[col] == ' ')
num_spaces++;
else
got_tab = TRUE;
}
else
{
if (got_tab || (eap->forceit && num_spaces > 1))
{
// Retabulate this string of white-space
// len is virtual length of white string
len = num_spaces = vcol - start_vcol;
num_tabs = 0;
if (!curbuf->b_p_et)
{
#ifdef FEAT_VARTABS
int t, s;
tabstop_fromto(start_vcol, vcol,
curbuf->b_p_ts, new_vts_array, &t, &s);
num_tabs = t;
num_spaces = s;
#else
temp = new_ts - (start_vcol % new_ts);
if (num_spaces >= temp)
{
num_spaces -= temp;
num_tabs++;
}
num_tabs += num_spaces / new_ts;
num_spaces -= (num_spaces / new_ts) * new_ts;
#endif
}
if (curbuf->b_p_et || got_tab ||
(num_spaces + num_tabs < len))
{
if (did_undo == FALSE)
{
did_undo = TRUE;
if (u_save((linenr_T)(lnum - 1),
(linenr_T)(lnum + 1)) == FAIL)
{
new_line = NULL; // flag out-of-memory
break;
}
}
// len is actual number of white characters used
len = num_spaces + num_tabs;
old_len = (long)STRLEN(ptr);
new_line = alloc(old_len - col + start_col + len + 1);
if (new_line == NULL)
break;
if (start_col > 0)
mch_memmove(new_line, ptr, (size_t)start_col);
mch_memmove(new_line + start_col + len,
ptr + col, (size_t)(old_len - col + 1));
ptr = new_line + start_col;
for (col = 0; col < len; col++)
ptr[col] = (col < num_tabs) ? '\t' : ' ';
if (ml_replace(lnum, new_line, FALSE) == OK)
// "new_line" may have been copied
new_line = curbuf->b_ml.ml_line_ptr;
if (first_line == 0)
first_line = lnum;
last_line = lnum;
ptr = new_line;
col = start_col + len;
}
}
got_tab = FALSE;
num_spaces = 0;
}
if (ptr[col] == NUL)
break;
vcol += chartabsize(ptr + col, (colnr_T)vcol);
if (has_mbyte)
col += (*mb_ptr2len)(ptr + col);
else
++col;
}
if (new_line == NULL) // out of memory
break;
line_breakcheck();
}
if (got_int)
emsg(_(e_interrupted));
#ifdef FEAT_VARTABS
// If a single value was given then it can be considered equal to
// either the value of 'tabstop' or the value of 'vartabstop'.
if (tabstop_count(curbuf->b_p_vts_array) == 0
&& tabstop_count(new_vts_array) == 1
&& curbuf->b_p_ts == tabstop_first(new_vts_array))
; // not changed
else if (tabstop_count(curbuf->b_p_vts_array) > 0
&& tabstop_eq(curbuf->b_p_vts_array, new_vts_array))
; // not changed
else
redraw_curbuf_later(NOT_VALID);
#else
if (curbuf->b_p_ts != new_ts)
redraw_curbuf_later(NOT_VALID);
#endif
if (first_line != 0)
changed_lines(first_line, 0, last_line + 1, 0L);
curwin->w_p_list = save_list; // restore 'list'
#ifdef FEAT_VARTABS
if (new_ts_str != NULL) // set the new tabstop
{
// If 'vartabstop' is in use or if the value given to retab has more
// than one tabstop then update 'vartabstop'.
int *old_vts_ary = curbuf->b_p_vts_array;
if (tabstop_count(old_vts_ary) > 0 || tabstop_count(new_vts_array) > 1)
{
set_string_option_direct((char_u *)"vts", -1, new_ts_str,
OPT_FREE|OPT_LOCAL, 0);
curbuf->b_p_vts_array = new_vts_array;
vim_free(old_vts_ary);
}
else
{
// 'vartabstop' wasn't in use and a single value was given to
// retab then update 'tabstop'.
curbuf->b_p_ts = tabstop_first(new_vts_array);
vim_free(new_vts_array);
}
vim_free(new_ts_str);
}
#else
curbuf->b_p_ts = new_ts;
#endif
coladvance(curwin->w_curswant);
u_clearline();
} | 970 | True | 1 |
|
CVE-2022-0417 | 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://huntr.dev/bounties/fc86bc8d-c866-4ade-8b7f-e49cec306d1a', 'name': 'https://huntr.dev/bounties/fc86bc8d-c866-4ade-8b7f-e49cec306d1a', 'refsource': 'CONFIRM', 'tags': ['Exploit', 'Patch', 'Third Party Advisory']}, {'url': 'https://github.com/vim/vim/commit/652dee448618589de5528a9e9a36995803f5557a', 'name': 'https://github.com/vim/vim/commit/652dee448618589de5528a9e9a36995803f5557a', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/UFXFAILMLUIK4MBUEZO4HNBNKYZRJ5AP/', 'name': 'FEDORA-2022-da2fb07efb', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.fedoraproject.org/archives/list/[email protected]/message/7ZLEHVP4LNAGER4ZDGUDS5V5YVQD6INF/', 'name': 'FEDORA-2022-48bf3cb1c4', 'refsource': 'FEDORA', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2022/06/msg00014.html', 'name': '[debian-lts-announce] 20220620 [SECURITY] [DLA 3053-1] vim security update', 'refsource': 'MLIST', 'tags': ['Mitigation', 'Third Party Advisory']}, {'url': 'https://security.gentoo.org/glsa/202208-32', 'name': 'GLSA-202208-32', 'refsource': 'GENTOO', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-122'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:vim:vim:*:*:*:*:*:*:*:*', 'versionEndExcluding': '8.2.4245', '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': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:debian:debian_linux:9.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Heap-based Buffer Overflow GitHub repository vim/vim prior to 8.2.'}] | 2022-08-26T17:35Z | 2022-02-01T13:15Z | Heap-based Buffer Overflow | A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc(). | https://cwe.mitre.org/data/definitions/122.html | 0 | Bram Moolenaar | 2022-01-28 20:47:49+00:00 | patch 8.2.4245: ":retab 0" may cause illegal memory access
Problem: ":retab 0" may cause illegal memory access.
Solution: Limit the value of 'tabstop' to 10000. | 652dee448618589de5528a9e9a36995803f5557a | False | vim/vim | The official Vim repository | 2015-08-18 21:03:56 | 2022-08-27 16:53:22 | https://www.vim.org | vim | 28298.0 | 4345.0 | tabstop_set | tabstop_set( char_u * var , int ** array) | ['var', 'array'] | tabstop_set(char_u *var, int **array)
{
int valcount = 1;
int t;
char_u *cp;
if (var[0] == NUL || (var[0] == '0' && var[1] == NUL))
{
*array = NULL;
return OK;
}
for (cp = var; *cp != NUL; ++cp)
{
if (cp == var || cp[-1] == ',')
{
char_u *end;
if (strtol((char *)cp, (char **)&end, 10) <= 0)
{
if (cp != end)
emsg(_(e_argument_must_be_positive));
else
semsg(_(e_invalid_argument_str), cp);
return FAIL;
}
}
if (VIM_ISDIGIT(*cp))
continue;
if (cp[0] == ',' && cp > var && cp[-1] != ',' && cp[1] != NUL)
{
++valcount;
continue;
}
semsg(_(e_invalid_argument_str), var);
return FAIL;
}
*array = ALLOC_MULT(int, valcount + 1);
if (*array == NULL)
return FAIL;
(*array)[0] = valcount;
t = 1;
for (cp = var; *cp != NUL;)
{
int n = atoi((char *)cp);
// Catch negative values, overflow and ridiculous big values.
if (n < 0 || n > 9999)
{
semsg(_(e_invalid_argument_str), cp);
vim_free(*array);
*array = NULL;
return FAIL;
}
(*array)[t++] = n;
while (*cp != NUL && *cp != ',')
++cp;
if (*cp != NUL)
++cp;
}
return OK;
} | 342 | True | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.