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-2018-12561 | False | False | False | False | AV:N/AC:L/Au:S/C:P/I:P/A:P | NETWORK | LOW | SINGLE | PARTIAL | PARTIAL | PARTIAL | 6.5 | CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H | NETWORK | LOW | LOW | NONE | UNCHANGED | HIGH | HIGH | HIGH | 8.8 | HIGH | 2.8 | 5.9 | nan | [{'url': 'https://github.com/CDrummond/cantata/commit/afc4f8315d3e96574925fb530a7004cc9e6ce3d3', 'name': 'https://github.com/CDrummond/cantata/commit/afc4f8315d3e96574925fb530a7004cc9e6ce3d3', 'refsource': 'MISC', 'tags': ['Patch', 'Technical Description']}, {'url': 'http://www.openwall.com/lists/oss-security/2018/06/18/1', 'name': 'http://www.openwall.com/lists/oss-security/2018/06/18/1', 'refsource': 'MISC', 'tags': ['Mailing List', 'Technical Description']}] | [{'description': [{'lang': 'en', 'value': 'CWE-20'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:cantata_project:cantata:*:*:*:*:*:*:*:*', 'versionEndIncluding': '2.3.1', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'An issue was discovered in the cantata-mounter D-Bus service in Cantata through 2.3.1. A regular user can inject additional mount options such as file_mode= by manipulating (for example) the domain parameter of the samba URL.'}] | 2018-08-10T15:06Z | 2018-06-19T05: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 | Craig Drummond | 2018-06-15 17:48:11+01:00 | Remove internal Samba shre mounting code, this had some privilege escalation issues, and is not well tested | afc4f8315d3e96574925fb530a7004cc9e6ce3d3 | False | CDrummond/cantata | Qt5 Graphical MPD Client | 2015-04-25 13:02:26 | 2022-03-02 20:07:18 | CDrummond | 999.0 | 166.0 | isValid | isValid( const RemoteFsDevice :: Details & d) | ['d'] | static inline bool isValid(const RemoteFsDevice::Details &d)
{
return d.isLocalFile() || RemoteFsDevice::constSshfsProtocol==d.url.scheme() ||
RemoteFsDevice::constSambaProtocol==d.url.scheme() || RemoteFsDevice::constSambaAvahiProtocol==d.url.scheme();
} | 54 | True | 1 |
|
CVE-2018-12562 | 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/CDrummond/cantata/commit/afc4f8315d3e96574925fb530a7004cc9e6ce3d3', 'name': 'https://github.com/CDrummond/cantata/commit/afc4f8315d3e96574925fb530a7004cc9e6ce3d3', 'refsource': 'MISC', 'tags': ['Patch', 'Technical Description']}, {'url': 'http://www.openwall.com/lists/oss-security/2018/06/18/1', 'name': 'http://www.openwall.com/lists/oss-security/2018/06/18/1', 'refsource': 'MISC', 'tags': ['Mailing List', 'Technical Description']}] | [{'description': [{'lang': 'en', 'value': 'CWE-20'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:cantata_project:cantata:*:*:*:*:*:*:*:*', 'versionEndIncluding': '2.3.1', 'cpe_name': []}]}] | [{'lang': 'en', 'value': "An issue was discovered in the cantata-mounter D-Bus service in Cantata through 2.3.1. The wrapper script 'mount.cifs.wrapper' uses the shell to forward the arguments to the actual mount.cifs binary. The shell evaluates wildcards (such as in an injected string:/home/../tmp/* string)."}] | 2018-08-10T18:05Z | 2018-06-19T05: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 | Craig Drummond | 2018-06-15 17:48:11+01:00 | Remove internal Samba shre mounting code, this had some privilege escalation issues, and is not well tested | afc4f8315d3e96574925fb530a7004cc9e6ce3d3 | False | CDrummond/cantata | Qt5 Graphical MPD Client | 2015-04-25 13:02:26 | 2022-03-02 20:07:18 | CDrummond | 999.0 | 166.0 | isValid | isValid( const RemoteFsDevice :: Details & d) | ['d'] | static inline bool isValid(const RemoteFsDevice::Details &d)
{
return d.isLocalFile() || RemoteFsDevice::constSshfsProtocol==d.url.scheme() ||
RemoteFsDevice::constSambaProtocol==d.url.scheme() || RemoteFsDevice::constSambaAvahiProtocol==d.url.scheme();
} | 54 | True | 1 |
|
CVE-2018-12713 | 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:H/I:H/A:N | NETWORK | LOW | NONE | NONE | UNCHANGED | HIGH | HIGH | NONE | 9.1 | CRITICAL | 3.9 | 5.2 | nan | [{'url': 'https://gitlab.gnome.org/GNOME/gimp/issues/1689', 'name': 'https://gitlab.gnome.org/GNOME/gimp/issues/1689', 'refsource': 'MISC', 'tags': ['Issue Tracking', 'Third Party Advisory']}, {'url': 'https://github.com/GNOME/gimp/commit/c21eff4b031acb04fb4dfce8bd5fdfecc2b6524f', 'name': 'https://github.com/GNOME/gimp/commit/c21eff4b031acb04fb4dfce8bd5fdfecc2b6524f', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'NVD-CWE-noinfo'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gimp:gimp:*:*:*:*:*:*:*:*', 'versionEndIncluding': '2.10.2', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'GIMP through 2.10.2 makes g_get_tmp_dir calls to establish temporary filenames, which may result in a filename that already exists, as demonstrated by the gimp_write_and_read_file function in app/tests/test-xcf.c. This might be leveraged by attackers to overwrite files or read file content that was intended to be private.'}] | 2022-02-07T18:42Z | 2018-06-24T22:29Z | Insufficient Information | There is insufficient information about the issue to classify it; details are unkown or unspecified. | Insufficient Information | https://nvd.nist.gov/vuln/categories | 0 | Jehan | 2018-06-24 04:48:48+02:00 | Issue #1689: create unique temporary file with g_file_open_tmp().
Not sure this is really solving the issue reported, which is that
`g_get_tmp_dir()` uses environment variables (yet as g_file_open_tmp()
uses g_get_tmp_dir()…). But at least g_file_open_tmp() should create
unique temporary files, which prevents overriding existing files (which
is most likely the only real attack possible here, or at least the only
one I can think of unless some weird vulnerabilities exist in glib). | c21eff4b031acb04fb4dfce8bd5fdfecc2b6524f | False | GNOME/gimp | Read-only mirror of https://gitlab.gnome.org/GNOME/gimp | 2012-06-03 13:37:45 | 2022-08-26 12:10:13 | https://gitlab.gnome.org/GNOME/gimp | GNOME | 3515.0 | 575.0 | gimp_write_and_read_file | gimp_write_and_read_file( Gimp * gimp , gboolean with_unusual_stuff , gboolean compat_paths , gboolean use_gimp_2_8_features) | ['gimp', 'with_unusual_stuff', 'compat_paths', 'use_gimp_2_8_features'] | gimp_write_and_read_file (Gimp *gimp,
gboolean with_unusual_stuff,
gboolean compat_paths,
gboolean use_gimp_2_8_features)
{
GimpImage *image;
GimpImage *loaded_image;
GimpPlugInProcedure *proc;
gchar *filename;
GFile *file;
/* Create the image */
image = gimp_create_mainimage (gimp,
with_unusual_stuff,
compat_paths,
use_gimp_2_8_features);
/* Assert valid state */
gimp_assert_mainimage (image,
with_unusual_stuff,
compat_paths,
use_gimp_2_8_features);
/* Write to file */
filename = g_build_filename (g_get_tmp_dir (), "gimp-test.xcf", NULL);
file = g_file_new_for_path (filename);
g_free (filename);
proc = gimp_plug_in_manager_file_procedure_find (image->gimp->plug_in_manager,
GIMP_FILE_PROCEDURE_GROUP_SAVE,
file,
NULL /*error*/);
file_save (gimp,
image,
NULL /*progress*/,
file,
proc,
GIMP_RUN_NONINTERACTIVE,
FALSE /*change_saved_state*/,
FALSE /*export_backward*/,
FALSE /*export_forward*/,
NULL /*error*/);
/* Load from file */
loaded_image = gimp_test_load_image (image->gimp, file);
/* Assert on the loaded file. If success, it means that there is no
* significant information loss when we wrote the image to a file
* and loaded it again
*/
gimp_assert_mainimage (loaded_image,
with_unusual_stuff,
compat_paths,
use_gimp_2_8_features);
g_file_delete (file, NULL, NULL);
g_object_unref (file);
} | 162 | True | 1 |
CVE-2018-1281 | False | False | False | False | AV:N/AC:L/Au:S/C:P/I:N/A:N | NETWORK | LOW | SINGLE | PARTIAL | NONE | NONE | 4.0 | CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N | NETWORK | LOW | LOW | NONE | UNCHANGED | HIGH | NONE | NONE | 6.5 | MEDIUM | 2.8 | 3.6 | nan | [{'url': 'https://github.com/dmlc/ps-lite/commit/4be817e8b03e7e92517e91f2dfcc50865e91c6ea', 'name': 'https://github.com/dmlc/ps-lite/commit/4be817e8b03e7e92517e91f2dfcc50865e91c6ea', 'refsource': 'CONFIRM', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-200'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:apache:mxnet:*:*:*:*:*:*:*:*', 'versionEndExcluding': '1.0.0', 'cpe_name': []}]}] | [{'lang': 'en', 'value': "The clustered setup of Apache MXNet allows users to specify which IP address and port the scheduler will listen on via the DMLC_PS_ROOT_URI and DMLC_PS_ROOT_PORT env variables. In versions older than 1.0.0, however, the MXNet framework will listen on 0.0.0.0 rather than user specified DMLC_PS_ROOT_URI once a scheduler node is initialized. This exposes the instance running MXNet to any attackers reachable via the interface they didn't expect to be listening on. For example: If a user wants to run a clustered setup locally, they may specify to run on 127.0.0.1. But since MXNet will listen on 0.0.0.0, it makes the port accessible on all network interfaces."}] | 2018-08-03T15:53Z | 2018-06-08T19:29Z | Exposure of Sensitive Information to an Unauthorized Actor | The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information. |
There are many different kinds of mistakes that introduce information exposures. The severity of the error can range widely, depending on the context in which the product operates, the type of sensitive information that is revealed, and the benefits it may provide to an attacker. Some kinds of sensitive information include:
private, personal information, such as personal messages, financial data, health records, geographic location, or contact details
system status and environment, such as the operating system and installed packages
business secrets and intellectual property
network status and configuration
the product's own code or internal state
metadata, e.g. logging of connections or message headers
indirect information, such as a discrepancy between two internal operations that can be observed by an outsider
Information might be sensitive to different parties, each of which may have their own expectations for whether the information should be protected. These parties include:
the product's own users
people or organizations whose information is created or used by the product, even if they are not direct product users
the product's administrators, including the admins of the system(s) and/or networks on which the product operates
the developer
Information exposures can occur in different ways:
the code explicitly inserts sensitive information into resources or messages that are intentionally made accessible to unauthorized actors, but should not contain the information - i.e., the information should have been "scrubbed" or "sanitized"
a different weakness or mistake indirectly inserts the sensitive information into resources, such as a web script error revealing the full system path of the program.
the code manages resources that intentionally contain sensitive information, but the resources are unintentionally made accessible to unauthorized actors. In this case, the information exposure is resultant - i.e., a different weakness enabled the access to the information in the first place.
It is common practice to describe any loss of confidentiality as an "information exposure," but this can lead to overuse of CWE-200 in CWE mapping. From the CWE perspective, loss of confidentiality is a technical impact that can arise from dozens of different weaknesses, such as insecure file permissions or out-of-bounds read. CWE-200 and its lower-level descendants are intended to cover the mistakes that occur in behaviors that explicitly manage, store, transfer, or cleanse sensitive information.
| https://cwe.mitre.org/data/definitions/200.html | 0 | Madan Jampani | 2017-11-21 12:07:36-08:00 | Avoid listening on all interfaces by default | 4be817e8b03e7e92517e91f2dfcc50865e91c6ea | False | dmlc/ps-lite | A lightweight parameter server interface | 2015-04-26 19:29:30 | 2022-06-16 03:09:43 | http://ps-lite.readthedocs.org | dmlc | 1382.0 | 529.0 | ps::ZMQVan::Bind | ps::ZMQVan::Bind( const Node & node , int max_retry) | ['node', 'max_retry'] | int Bind(const Node& node, int max_retry) override {
receiver_ = zmq_socket(context_, ZMQ_ROUTER);
CHECK(receiver_ != NULL)
<< "create receiver socket failed: " << zmq_strerror(errno);
int local = GetEnv("DMLC_LOCAL", 0);
std::string addr = local ? "ipc:///tmp/" : "tcp://*:";
int port = node.port;
unsigned seed = static_cast<unsigned>(time(NULL)+port);
for (int i = 0; i < max_retry+1; ++i) {
auto address = addr + std::to_string(port);
if (zmq_bind(receiver_, address.c_str()) == 0) break;
if (i == max_retry) {
port = -1;
} else {
port = 10000 + rand_r(&seed) % 40000;
}
}
return port;
} | 160 | True | 1 |
CVE-2018-20761 | 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.0/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/gpac/gpac/issues/1186', 'name': 'https://github.com/gpac/gpac/issues/1186', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/35ab4475a7df9b2a4bcab235e379c0c3ec543658', 'name': 'https://github.com/gpac/gpac/commit/35ab4475a7df9b2a4bcab235e379c0c3ec543658', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2019/02/msg00040.html', 'name': '[debian-lts-announce] 20190227 [SECURITY] [DLA 1693-1] gpac security update', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://usn.ubuntu.com/3926-1/', 'name': 'USN-3926-1', 'refsource': 'UBUNTU', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-119'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac_project:gpac:*:*:*:*:*:*:*:*', 'versionEndIncluding': '0.7.1', 'cpe_name': []}]}, {'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:o:canonical:ubuntu_linux:16.04:*:*:*:lts:*:*:*', 'cpe_name': []}, {'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': []}]}] | [{'lang': 'en', 'value': 'GPAC version 0.7.1 and earlier has a Buffer Overflow vulnerability in the gf_sm_load_init function in scene_manager.c in libgpac_static.a.'}] | 2019-04-15T18:58Z | 2019-02-06T23: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 | Aurelien David | 2019-01-11 11:32:54+01:00 | fix some overflows due to strcpy
fixes #1184, #1186, #1187 among other things | 35ab4475a7df9b2a4bcab235e379c0c3ec543658 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | GPAC_EventProc | GPAC_EventProc( void * ptr , GF_Event * evt) | ['ptr', 'evt'] | Bool GPAC_EventProc(void *ptr, GF_Event *evt)
{
if (!term) return 0;
if (gui_mode==1) {
if (evt->type==GF_EVENT_QUIT) {
Run = 0;
} else if (evt->type==GF_EVENT_KEYDOWN) {
switch (evt->key.key_code) {
case GF_KEY_C:
if (evt->key.flags & (GF_KEY_MOD_CTRL|GF_KEY_MOD_ALT)) {
hide_shell(shell_visible ? 1 : 0);
if (shell_visible) gui_mode=2;
}
break;
default:
break;
}
}
return 0;
}
switch (evt->type) {
case GF_EVENT_DURATION:
Duration = (u64) ( 1000 * (s64) evt->duration.duration);
CanSeek = evt->duration.can_seek;
break;
case GF_EVENT_MESSAGE:
{
const char *servName;
if (!evt->message.service || !strcmp(evt->message.service, the_url)) {
servName = "";
} else if (!strnicmp(evt->message.service, "data:", 5)) {
servName = "(embedded data)";
} else {
servName = evt->message.service;
}
if (!evt->message.message) return 0;
if (evt->message.error) {
if (!is_connected) last_error = evt->message.error;
if (evt->message.error==GF_SCRIPT_INFO) {
GF_LOG(GF_LOG_INFO, GF_LOG_CONSOLE, ("%s\n", evt->message.message));
} else {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONSOLE, ("%s %s: %s\n", servName, evt->message.message, gf_error_to_string(evt->message.error)));
}
} else if (!be_quiet)
GF_LOG(GF_LOG_INFO, GF_LOG_CONSOLE, ("%s %s\n", servName, evt->message.message));
}
break;
case GF_EVENT_PROGRESS:
{
char *szTitle = "";
if (evt->progress.progress_type==0) {
szTitle = "Buffer ";
if (bench_mode && (bench_mode!=3) ) {
if (evt->progress.done >= evt->progress.total) bench_buffer = 0;
else bench_buffer = 1 + 100*evt->progress.done / evt->progress.total;
break;
}
}
else if (evt->progress.progress_type==1) {
if (bench_mode) break;
szTitle = "Download ";
}
else if (evt->progress.progress_type==2) szTitle = "Import ";
gf_set_progress(szTitle, evt->progress.done, evt->progress.total);
}
break;
case GF_EVENT_DBLCLICK:
gf_term_set_option(term, GF_OPT_FULLSCREEN, !gf_term_get_option(term, GF_OPT_FULLSCREEN));
return 0;
case GF_EVENT_MOUSEDOWN:
if (evt->mouse.button==GF_MOUSE_RIGHT) {
right_down = 1;
last_x = evt->mouse.x;
last_y = evt->mouse.y;
}
return 0;
case GF_EVENT_MOUSEUP:
if (evt->mouse.button==GF_MOUSE_RIGHT) {
right_down = 0;
last_x = evt->mouse.x;
last_y = evt->mouse.y;
}
return 0;
case GF_EVENT_MOUSEMOVE:
if (right_down && (user.init_flags & GF_TERM_WINDOWLESS) ) {
GF_Event move;
move.move.x = evt->mouse.x - last_x;
move.move.y = last_y-evt->mouse.y;
move.type = GF_EVENT_MOVE;
move.move.relative = 1;
gf_term_user_event(term, &move);
}
return 0;
case GF_EVENT_KEYUP:
switch (evt->key.key_code) {
case GF_KEY_SPACE:
if (evt->key.flags & GF_KEY_MOD_CTRL) switch_bench(!bench_mode);
break;
}
break;
case GF_EVENT_KEYDOWN:
gf_term_process_shortcut(term, evt);
switch (evt->key.key_code) {
case GF_KEY_SPACE:
if (evt->key.flags & GF_KEY_MOD_CTRL) {
/*ignore key repeat*/
if (!bench_mode) switch_bench(!bench_mode);
}
break;
case GF_KEY_PAGEDOWN:
case GF_KEY_MEDIANEXTTRACK:
request_next_playlist_item = 1;
break;
case GF_KEY_MEDIAPREVIOUSTRACK:
break;
case GF_KEY_ESCAPE:
gf_term_set_option(term, GF_OPT_FULLSCREEN, !gf_term_get_option(term, GF_OPT_FULLSCREEN));
break;
case GF_KEY_C:
if (evt->key.flags & (GF_KEY_MOD_CTRL|GF_KEY_MOD_ALT)) {
hide_shell(shell_visible ? 1 : 0);
if (!shell_visible) gui_mode=1;
}
break;
case GF_KEY_F:
if (evt->key.flags & GF_KEY_MOD_CTRL) fprintf(stderr, "Rendering rate: %f FPS\n", gf_term_get_framerate(term, 0));
break;
case GF_KEY_T:
if (evt->key.flags & GF_KEY_MOD_CTRL) fprintf(stderr, "Scene Time: %f \n", gf_term_get_time_in_ms(term)/1000.0);
break;
case GF_KEY_D:
if (evt->key.flags & GF_KEY_MOD_CTRL) gf_term_set_option(term, GF_OPT_DRAW_MODE, (gf_term_get_option(term, GF_OPT_DRAW_MODE)==GF_DRAW_MODE_DEFER) ? GF_DRAW_MODE_IMMEDIATE : GF_DRAW_MODE_DEFER );
break;
case GF_KEY_4:
if (evt->key.flags & GF_KEY_MOD_CTRL)
gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_4_3);
break;
case GF_KEY_5:
if (evt->key.flags & GF_KEY_MOD_CTRL)
gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_16_9);
break;
case GF_KEY_6:
if (evt->key.flags & GF_KEY_MOD_CTRL)
gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_FILL_SCREEN);
break;
case GF_KEY_7:
if (evt->key.flags & GF_KEY_MOD_CTRL)
gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_KEEP);
break;
case GF_KEY_O:
if ((evt->key.flags & GF_KEY_MOD_CTRL) && is_connected) {
if (gf_term_get_option(term, GF_OPT_MAIN_ADDON)) {
fprintf(stderr, "Resuming to main content\n");
gf_term_set_option(term, GF_OPT_PLAY_STATE, GF_STATE_PLAY_LIVE);
} else {
fprintf(stderr, "Main addon not enabled\n");
}
}
break;
case GF_KEY_P:
if ((evt->key.flags & GF_KEY_MOD_CTRL) && is_connected) {
u32 pause_state = gf_term_get_option(term, GF_OPT_PLAY_STATE) ;
fprintf(stderr, "[Status: %s]\n", pause_state ? "Playing" : "Paused");
if ((pause_state == GF_STATE_PAUSED) && (evt->key.flags & GF_KEY_MOD_SHIFT)) {
gf_term_set_option(term, GF_OPT_PLAY_STATE, GF_STATE_PLAY_LIVE);
} else {
gf_term_set_option(term, GF_OPT_PLAY_STATE, (pause_state==GF_STATE_PAUSED) ? GF_STATE_PLAYING : GF_STATE_PAUSED);
}
}
break;
case GF_KEY_S:
if ((evt->key.flags & GF_KEY_MOD_CTRL) && is_connected) {
gf_term_set_option(term, GF_OPT_PLAY_STATE, GF_STATE_STEP_PAUSE);
fprintf(stderr, "Step time: ");
PrintTime(gf_term_get_time_in_ms(term));
fprintf(stderr, "\n");
}
break;
case GF_KEY_B:
if ((evt->key.flags & GF_KEY_MOD_CTRL) && is_connected)
ViewODs(term, 1);
break;
case GF_KEY_M:
if ((evt->key.flags & GF_KEY_MOD_CTRL) && is_connected)
ViewODs(term, 0);
break;
case GF_KEY_H:
if ((evt->key.flags & GF_KEY_MOD_CTRL) && is_connected) {
gf_term_switch_quality(term, 1);
// gf_term_set_option(term, GF_OPT_MULTIVIEW_MODE, 0);
}
break;
case GF_KEY_L:
if ((evt->key.flags & GF_KEY_MOD_CTRL) && is_connected) {
gf_term_switch_quality(term, 0);
// gf_term_set_option(term, GF_OPT_MULTIVIEW_MODE, 1);
}
break;
case GF_KEY_F5:
if (is_connected)
reload = 1;
break;
case GF_KEY_A:
addon_visible = !addon_visible;
gf_term_toggle_addons(term, addon_visible);
break;
case GF_KEY_UP:
if ((evt->key.flags & VK_MOD) && is_connected) {
do_set_speed(playback_speed * 2);
}
break;
case GF_KEY_DOWN:
if ((evt->key.flags & VK_MOD) && is_connected) {
do_set_speed(playback_speed / 2);
}
break;
case GF_KEY_LEFT:
if ((evt->key.flags & VK_MOD) && is_connected) {
do_set_speed(-1 * playback_speed );
}
break;
}
break;
case GF_EVENT_CONNECT:
if (evt->connect.is_connected) {
is_connected = 1;
fprintf(stderr, "Service Connected\n");
eos_seen = GF_FALSE;
if (playback_speed != FIX_ONE)
gf_term_set_speed(term, playback_speed);
} else if (is_connected) {
fprintf(stderr, "Service %s\n", is_connected ? "Disconnected" : "Connection Failed");
is_connected = 0;
Duration = 0;
}
if (init_w && init_h) {
gf_term_set_size(term, init_w, init_h);
}
ResetCaption();
break;
case GF_EVENT_EOS:
eos_seen = GF_TRUE;
if (playlist) {
if (Duration>1500)
request_next_playlist_item = GF_TRUE;
}
else if (loop_at_end) {
restart = 1;
}
break;
case GF_EVENT_SIZE:
if (user.init_flags & GF_TERM_WINDOWLESS) {
GF_Event move;
move.type = GF_EVENT_MOVE;
move.move.align_x = align_mode & 0xFF;
move.move.align_y = (align_mode>>8) & 0xFF;
move.move.relative = 2;
gf_term_user_event(term, &move);
}
break;
case GF_EVENT_SCENE_SIZE:
if (forced_width && forced_height) {
GF_Event size;
size.type = GF_EVENT_SIZE;
size.size.width = forced_width;
size.size.height = forced_height;
gf_term_user_event(term, &size);
}
break;
case GF_EVENT_METADATA:
ResetCaption();
break;
case GF_EVENT_RELOAD:
if (is_connected)
reload = 1;
break;
case GF_EVENT_DROPFILE:
{
u32 i, pos;
/*todo - force playlist mode*/
if (readonly_playlist) {
gf_fclose(playlist);
playlist = NULL;
}
readonly_playlist = 0;
if (!playlist) {
readonly_playlist = 0;
playlist = gf_temp_file_new(NULL);
}
pos = ftell(playlist);
i=0;
while (i<evt->open_file.nb_files) {
if (evt->open_file.files[i] != NULL) {
fprintf(playlist, "%s\n", evt->open_file.files[i]);
}
i++;
}
fseek(playlist, pos, SEEK_SET);
request_next_playlist_item = 1;
}
return 1;
case GF_EVENT_QUIT:
if (evt->message.error) {
fprintf(stderr, "A fatal error was encoutered: %s (%s) - exiting ...\n", evt->message.message ? evt->message.message : "no details", gf_error_to_string(evt->message.error) );
}
Run = 0;
break;
case GF_EVENT_DISCONNECT:
gf_term_disconnect(term);
break;
case GF_EVENT_MIGRATE:
{
}
break;
case GF_EVENT_NAVIGATE_INFO:
if (evt->navigate.to_url) fprintf(stderr, "Go to URL: \"%s\"\r", evt->navigate.to_url);
break;
case GF_EVENT_NAVIGATE:
if (gf_term_is_supported_url(term, evt->navigate.to_url, 1, no_mime_check)) {
strcpy(the_url, evt->navigate.to_url);
fprintf(stderr, "Navigating to URL %s\n", the_url);
gf_term_navigate_to(term, evt->navigate.to_url);
return 1;
} else {
fprintf(stderr, "Navigation destination not supported\nGo to URL: %s\n", evt->navigate.to_url);
}
break;
case GF_EVENT_SET_CAPTION:
gf_term_user_event(term, evt);
break;
case GF_EVENT_AUTHORIZATION:
{
int maxTries = 1;
assert( evt->type == GF_EVENT_AUTHORIZATION);
assert( evt->auth.user);
assert( evt->auth.password);
assert( evt->auth.site_url);
while ((!strlen(evt->auth.user) || !strlen(evt->auth.password)) && (maxTries--) >= 0) {
fprintf(stderr, "**** Authorization required for site %s ****\n", evt->auth.site_url);
fprintf(stderr, "login : ");
read_line_input(evt->auth.user, 50, 1);
fprintf(stderr, "\npassword: ");
read_line_input(evt->auth.password, 50, 0);
fprintf(stderr, "*********\n");
}
if (maxTries < 0) {
fprintf(stderr, "**** No User or password has been filled, aborting ***\n");
return 0;
}
return 1;
}
case GF_EVENT_ADDON_DETECTED:
if (enable_add_ons) {
fprintf(stderr, "Media Addon %s detected - enabling it\n", evt->addon_connect.addon_url);
addon_visible = 1;
}
return enable_add_ons;
}
return 0;
} | 2177 | True | 1 |
CVE-2018-20762 | 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.0/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/gpac/gpac/issues/1187', 'name': 'https://github.com/gpac/gpac/issues/1187', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/35ab4475a7df9b2a4bcab235e379c0c3ec543658', 'name': 'https://github.com/gpac/gpac/commit/35ab4475a7df9b2a4bcab235e379c0c3ec543658', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2019/02/msg00040.html', 'name': '[debian-lts-announce] 20190227 [SECURITY] [DLA 1693-1] gpac security update', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://usn.ubuntu.com/3926-1/', 'name': 'USN-3926-1', 'refsource': 'UBUNTU', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-119'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac_project:gpac:*:*:*:*:*:*:*:*', 'versionEndIncluding': '0.7.1', 'cpe_name': []}]}, {'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:o:canonical:ubuntu_linux:16.04:*:*:*:lts:*:*:*', 'cpe_name': []}, {'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': []}]}] | [{'lang': 'en', 'value': 'GPAC version 0.7.1 and earlier has a buffer overflow vulnerability in the cat_multiple_files function in applications/mp4box/fileimport.c when MP4Box is used for a local directory containing crafted filenames.'}] | 2019-04-15T18:58Z | 2019-02-06T23: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 | Aurelien David | 2019-01-11 11:32:54+01:00 | fix some overflows due to strcpy
fixes #1184, #1186, #1187 among other things | 35ab4475a7df9b2a4bcab235e379c0c3ec543658 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | GPAC_EventProc | GPAC_EventProc( void * ptr , GF_Event * evt) | ['ptr', 'evt'] | Bool GPAC_EventProc(void *ptr, GF_Event *evt)
{
if (!term) return 0;
if (gui_mode==1) {
if (evt->type==GF_EVENT_QUIT) {
Run = 0;
} else if (evt->type==GF_EVENT_KEYDOWN) {
switch (evt->key.key_code) {
case GF_KEY_C:
if (evt->key.flags & (GF_KEY_MOD_CTRL|GF_KEY_MOD_ALT)) {
hide_shell(shell_visible ? 1 : 0);
if (shell_visible) gui_mode=2;
}
break;
default:
break;
}
}
return 0;
}
switch (evt->type) {
case GF_EVENT_DURATION:
Duration = (u64) ( 1000 * (s64) evt->duration.duration);
CanSeek = evt->duration.can_seek;
break;
case GF_EVENT_MESSAGE:
{
const char *servName;
if (!evt->message.service || !strcmp(evt->message.service, the_url)) {
servName = "";
} else if (!strnicmp(evt->message.service, "data:", 5)) {
servName = "(embedded data)";
} else {
servName = evt->message.service;
}
if (!evt->message.message) return 0;
if (evt->message.error) {
if (!is_connected) last_error = evt->message.error;
if (evt->message.error==GF_SCRIPT_INFO) {
GF_LOG(GF_LOG_INFO, GF_LOG_CONSOLE, ("%s\n", evt->message.message));
} else {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONSOLE, ("%s %s: %s\n", servName, evt->message.message, gf_error_to_string(evt->message.error)));
}
} else if (!be_quiet)
GF_LOG(GF_LOG_INFO, GF_LOG_CONSOLE, ("%s %s\n", servName, evt->message.message));
}
break;
case GF_EVENT_PROGRESS:
{
char *szTitle = "";
if (evt->progress.progress_type==0) {
szTitle = "Buffer ";
if (bench_mode && (bench_mode!=3) ) {
if (evt->progress.done >= evt->progress.total) bench_buffer = 0;
else bench_buffer = 1 + 100*evt->progress.done / evt->progress.total;
break;
}
}
else if (evt->progress.progress_type==1) {
if (bench_mode) break;
szTitle = "Download ";
}
else if (evt->progress.progress_type==2) szTitle = "Import ";
gf_set_progress(szTitle, evt->progress.done, evt->progress.total);
}
break;
case GF_EVENT_DBLCLICK:
gf_term_set_option(term, GF_OPT_FULLSCREEN, !gf_term_get_option(term, GF_OPT_FULLSCREEN));
return 0;
case GF_EVENT_MOUSEDOWN:
if (evt->mouse.button==GF_MOUSE_RIGHT) {
right_down = 1;
last_x = evt->mouse.x;
last_y = evt->mouse.y;
}
return 0;
case GF_EVENT_MOUSEUP:
if (evt->mouse.button==GF_MOUSE_RIGHT) {
right_down = 0;
last_x = evt->mouse.x;
last_y = evt->mouse.y;
}
return 0;
case GF_EVENT_MOUSEMOVE:
if (right_down && (user.init_flags & GF_TERM_WINDOWLESS) ) {
GF_Event move;
move.move.x = evt->mouse.x - last_x;
move.move.y = last_y-evt->mouse.y;
move.type = GF_EVENT_MOVE;
move.move.relative = 1;
gf_term_user_event(term, &move);
}
return 0;
case GF_EVENT_KEYUP:
switch (evt->key.key_code) {
case GF_KEY_SPACE:
if (evt->key.flags & GF_KEY_MOD_CTRL) switch_bench(!bench_mode);
break;
}
break;
case GF_EVENT_KEYDOWN:
gf_term_process_shortcut(term, evt);
switch (evt->key.key_code) {
case GF_KEY_SPACE:
if (evt->key.flags & GF_KEY_MOD_CTRL) {
/*ignore key repeat*/
if (!bench_mode) switch_bench(!bench_mode);
}
break;
case GF_KEY_PAGEDOWN:
case GF_KEY_MEDIANEXTTRACK:
request_next_playlist_item = 1;
break;
case GF_KEY_MEDIAPREVIOUSTRACK:
break;
case GF_KEY_ESCAPE:
gf_term_set_option(term, GF_OPT_FULLSCREEN, !gf_term_get_option(term, GF_OPT_FULLSCREEN));
break;
case GF_KEY_C:
if (evt->key.flags & (GF_KEY_MOD_CTRL|GF_KEY_MOD_ALT)) {
hide_shell(shell_visible ? 1 : 0);
if (!shell_visible) gui_mode=1;
}
break;
case GF_KEY_F:
if (evt->key.flags & GF_KEY_MOD_CTRL) fprintf(stderr, "Rendering rate: %f FPS\n", gf_term_get_framerate(term, 0));
break;
case GF_KEY_T:
if (evt->key.flags & GF_KEY_MOD_CTRL) fprintf(stderr, "Scene Time: %f \n", gf_term_get_time_in_ms(term)/1000.0);
break;
case GF_KEY_D:
if (evt->key.flags & GF_KEY_MOD_CTRL) gf_term_set_option(term, GF_OPT_DRAW_MODE, (gf_term_get_option(term, GF_OPT_DRAW_MODE)==GF_DRAW_MODE_DEFER) ? GF_DRAW_MODE_IMMEDIATE : GF_DRAW_MODE_DEFER );
break;
case GF_KEY_4:
if (evt->key.flags & GF_KEY_MOD_CTRL)
gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_4_3);
break;
case GF_KEY_5:
if (evt->key.flags & GF_KEY_MOD_CTRL)
gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_16_9);
break;
case GF_KEY_6:
if (evt->key.flags & GF_KEY_MOD_CTRL)
gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_FILL_SCREEN);
break;
case GF_KEY_7:
if (evt->key.flags & GF_KEY_MOD_CTRL)
gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_KEEP);
break;
case GF_KEY_O:
if ((evt->key.flags & GF_KEY_MOD_CTRL) && is_connected) {
if (gf_term_get_option(term, GF_OPT_MAIN_ADDON)) {
fprintf(stderr, "Resuming to main content\n");
gf_term_set_option(term, GF_OPT_PLAY_STATE, GF_STATE_PLAY_LIVE);
} else {
fprintf(stderr, "Main addon not enabled\n");
}
}
break;
case GF_KEY_P:
if ((evt->key.flags & GF_KEY_MOD_CTRL) && is_connected) {
u32 pause_state = gf_term_get_option(term, GF_OPT_PLAY_STATE) ;
fprintf(stderr, "[Status: %s]\n", pause_state ? "Playing" : "Paused");
if ((pause_state == GF_STATE_PAUSED) && (evt->key.flags & GF_KEY_MOD_SHIFT)) {
gf_term_set_option(term, GF_OPT_PLAY_STATE, GF_STATE_PLAY_LIVE);
} else {
gf_term_set_option(term, GF_OPT_PLAY_STATE, (pause_state==GF_STATE_PAUSED) ? GF_STATE_PLAYING : GF_STATE_PAUSED);
}
}
break;
case GF_KEY_S:
if ((evt->key.flags & GF_KEY_MOD_CTRL) && is_connected) {
gf_term_set_option(term, GF_OPT_PLAY_STATE, GF_STATE_STEP_PAUSE);
fprintf(stderr, "Step time: ");
PrintTime(gf_term_get_time_in_ms(term));
fprintf(stderr, "\n");
}
break;
case GF_KEY_B:
if ((evt->key.flags & GF_KEY_MOD_CTRL) && is_connected)
ViewODs(term, 1);
break;
case GF_KEY_M:
if ((evt->key.flags & GF_KEY_MOD_CTRL) && is_connected)
ViewODs(term, 0);
break;
case GF_KEY_H:
if ((evt->key.flags & GF_KEY_MOD_CTRL) && is_connected) {
gf_term_switch_quality(term, 1);
// gf_term_set_option(term, GF_OPT_MULTIVIEW_MODE, 0);
}
break;
case GF_KEY_L:
if ((evt->key.flags & GF_KEY_MOD_CTRL) && is_connected) {
gf_term_switch_quality(term, 0);
// gf_term_set_option(term, GF_OPT_MULTIVIEW_MODE, 1);
}
break;
case GF_KEY_F5:
if (is_connected)
reload = 1;
break;
case GF_KEY_A:
addon_visible = !addon_visible;
gf_term_toggle_addons(term, addon_visible);
break;
case GF_KEY_UP:
if ((evt->key.flags & VK_MOD) && is_connected) {
do_set_speed(playback_speed * 2);
}
break;
case GF_KEY_DOWN:
if ((evt->key.flags & VK_MOD) && is_connected) {
do_set_speed(playback_speed / 2);
}
break;
case GF_KEY_LEFT:
if ((evt->key.flags & VK_MOD) && is_connected) {
do_set_speed(-1 * playback_speed );
}
break;
}
break;
case GF_EVENT_CONNECT:
if (evt->connect.is_connected) {
is_connected = 1;
fprintf(stderr, "Service Connected\n");
eos_seen = GF_FALSE;
if (playback_speed != FIX_ONE)
gf_term_set_speed(term, playback_speed);
} else if (is_connected) {
fprintf(stderr, "Service %s\n", is_connected ? "Disconnected" : "Connection Failed");
is_connected = 0;
Duration = 0;
}
if (init_w && init_h) {
gf_term_set_size(term, init_w, init_h);
}
ResetCaption();
break;
case GF_EVENT_EOS:
eos_seen = GF_TRUE;
if (playlist) {
if (Duration>1500)
request_next_playlist_item = GF_TRUE;
}
else if (loop_at_end) {
restart = 1;
}
break;
case GF_EVENT_SIZE:
if (user.init_flags & GF_TERM_WINDOWLESS) {
GF_Event move;
move.type = GF_EVENT_MOVE;
move.move.align_x = align_mode & 0xFF;
move.move.align_y = (align_mode>>8) & 0xFF;
move.move.relative = 2;
gf_term_user_event(term, &move);
}
break;
case GF_EVENT_SCENE_SIZE:
if (forced_width && forced_height) {
GF_Event size;
size.type = GF_EVENT_SIZE;
size.size.width = forced_width;
size.size.height = forced_height;
gf_term_user_event(term, &size);
}
break;
case GF_EVENT_METADATA:
ResetCaption();
break;
case GF_EVENT_RELOAD:
if (is_connected)
reload = 1;
break;
case GF_EVENT_DROPFILE:
{
u32 i, pos;
/*todo - force playlist mode*/
if (readonly_playlist) {
gf_fclose(playlist);
playlist = NULL;
}
readonly_playlist = 0;
if (!playlist) {
readonly_playlist = 0;
playlist = gf_temp_file_new(NULL);
}
pos = ftell(playlist);
i=0;
while (i<evt->open_file.nb_files) {
if (evt->open_file.files[i] != NULL) {
fprintf(playlist, "%s\n", evt->open_file.files[i]);
}
i++;
}
fseek(playlist, pos, SEEK_SET);
request_next_playlist_item = 1;
}
return 1;
case GF_EVENT_QUIT:
if (evt->message.error) {
fprintf(stderr, "A fatal error was encoutered: %s (%s) - exiting ...\n", evt->message.message ? evt->message.message : "no details", gf_error_to_string(evt->message.error) );
}
Run = 0;
break;
case GF_EVENT_DISCONNECT:
gf_term_disconnect(term);
break;
case GF_EVENT_MIGRATE:
{
}
break;
case GF_EVENT_NAVIGATE_INFO:
if (evt->navigate.to_url) fprintf(stderr, "Go to URL: \"%s\"\r", evt->navigate.to_url);
break;
case GF_EVENT_NAVIGATE:
if (gf_term_is_supported_url(term, evt->navigate.to_url, 1, no_mime_check)) {
strcpy(the_url, evt->navigate.to_url);
fprintf(stderr, "Navigating to URL %s\n", the_url);
gf_term_navigate_to(term, evt->navigate.to_url);
return 1;
} else {
fprintf(stderr, "Navigation destination not supported\nGo to URL: %s\n", evt->navigate.to_url);
}
break;
case GF_EVENT_SET_CAPTION:
gf_term_user_event(term, evt);
break;
case GF_EVENT_AUTHORIZATION:
{
int maxTries = 1;
assert( evt->type == GF_EVENT_AUTHORIZATION);
assert( evt->auth.user);
assert( evt->auth.password);
assert( evt->auth.site_url);
while ((!strlen(evt->auth.user) || !strlen(evt->auth.password)) && (maxTries--) >= 0) {
fprintf(stderr, "**** Authorization required for site %s ****\n", evt->auth.site_url);
fprintf(stderr, "login : ");
read_line_input(evt->auth.user, 50, 1);
fprintf(stderr, "\npassword: ");
read_line_input(evt->auth.password, 50, 0);
fprintf(stderr, "*********\n");
}
if (maxTries < 0) {
fprintf(stderr, "**** No User or password has been filled, aborting ***\n");
return 0;
}
return 1;
}
case GF_EVENT_ADDON_DETECTED:
if (enable_add_ons) {
fprintf(stderr, "Media Addon %s detected - enabling it\n", evt->addon_connect.addon_url);
addon_visible = 1;
}
return enable_add_ons;
}
return 0;
} | 2177 | True | 1 |
CVE-2018-20761 | 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.0/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/gpac/gpac/issues/1186', 'name': 'https://github.com/gpac/gpac/issues/1186', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/35ab4475a7df9b2a4bcab235e379c0c3ec543658', 'name': 'https://github.com/gpac/gpac/commit/35ab4475a7df9b2a4bcab235e379c0c3ec543658', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2019/02/msg00040.html', 'name': '[debian-lts-announce] 20190227 [SECURITY] [DLA 1693-1] gpac security update', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://usn.ubuntu.com/3926-1/', 'name': 'USN-3926-1', 'refsource': 'UBUNTU', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-119'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac_project:gpac:*:*:*:*:*:*:*:*', 'versionEndIncluding': '0.7.1', 'cpe_name': []}]}, {'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:o:canonical:ubuntu_linux:16.04:*:*:*:lts:*:*:*', 'cpe_name': []}, {'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': []}]}] | [{'lang': 'en', 'value': 'GPAC version 0.7.1 and earlier has a Buffer Overflow vulnerability in the gf_sm_load_init function in scene_manager.c in libgpac_static.a.'}] | 2019-04-15T18:58Z | 2019-02-06T23: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 | Aurelien David | 2019-01-11 11:32:54+01:00 | fix some overflows due to strcpy
fixes #1184, #1186, #1187 among other things | 35ab4475a7df9b2a4bcab235e379c0c3ec543658 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | mp4client_main | mp4client_main( int argc , char ** argv) | ['argc', 'argv'] | int mp4client_main(int argc, char **argv)
{
char c;
const char *str;
int ret_val = 0;
u32 i, times[100], nb_times, dump_mode;
u32 simulation_time_in_ms = 0;
u32 initial_service_id = 0;
Bool auto_exit = GF_FALSE;
Bool logs_set = GF_FALSE;
Bool start_fs = GF_FALSE;
Bool use_rtix = GF_FALSE;
Bool pause_at_first = GF_FALSE;
Bool no_cfg_save = GF_FALSE;
Bool is_cfg_only = GF_FALSE;
Double play_from = 0;
#ifdef GPAC_MEMORY_TRACKING
GF_MemTrackerType mem_track = GF_MemTrackerNone;
#endif
Double fps = GF_IMPORT_DEFAULT_FPS;
Bool fill_ar, visible, do_uncache, has_command;
char *url_arg, *out_arg, *the_cfg, *rti_file, *views, *mosaic;
FILE *logfile = NULL;
Float scale = 1;
#ifndef WIN32
dlopen(NULL, RTLD_NOW|RTLD_GLOBAL);
#endif
/*by default use current dir*/
strcpy(the_url, ".");
memset(&user, 0, sizeof(GF_User));
dump_mode = DUMP_NONE;
fill_ar = visible = do_uncache = has_command = GF_FALSE;
url_arg = out_arg = the_cfg = rti_file = views = mosaic = NULL;
nb_times = 0;
times[0] = 0;
/*first locate config file if specified*/
for (i=1; i<(u32) argc; i++) {
char *arg = argv[i];
if (!strcmp(arg, "-c") || !strcmp(arg, "-cfg")) {
the_cfg = argv[i+1];
i++;
}
else if (!strcmp(arg, "-mem-track") || !strcmp(arg, "-mem-track-stack")) {
#ifdef GPAC_MEMORY_TRACKING
mem_track = !strcmp(arg, "-mem-track-stack") ? GF_MemTrackerBackTrace : GF_MemTrackerSimple;
#else
fprintf(stderr, "WARNING - GPAC not compiled with Memory Tracker - ignoring \"%s\"\n", arg);
#endif
} else if (!strcmp(arg, "-gui")) {
gui_mode = 1;
} else if (!strcmp(arg, "-guid")) {
gui_mode = 2;
} else if (!strcmp(arg, "-h") || !strcmp(arg, "-help")) {
PrintUsage();
return 0;
}
}
#ifdef GPAC_MEMORY_TRACKING
gf_sys_init(mem_track);
#else
gf_sys_init(GF_MemTrackerNone);
#endif
gf_sys_set_args(argc, (const char **) argv);
cfg_file = gf_cfg_init(the_cfg, NULL);
if (!cfg_file) {
fprintf(stderr, "Error: Configuration File not found\n");
return 1;
}
/*if logs are specified, use them*/
if (gf_log_set_tools_levels( gf_cfg_get_key(cfg_file, "General", "Logs") ) != GF_OK) {
return 1;
}
if( gf_cfg_get_key(cfg_file, "General", "Logs") != NULL ) {
logs_set = GF_TRUE;
}
if (!gui_mode) {
str = gf_cfg_get_key(cfg_file, "General", "ForceGUI");
if (str && !strcmp(str, "yes")) gui_mode = 1;
}
for (i=1; i<(u32) argc; i++) {
char *arg = argv[i];
if (!strcmp(arg, "-rti")) {
rti_file = argv[i+1];
i++;
} else if (!strcmp(arg, "-rtix")) {
rti_file = argv[i+1];
i++;
use_rtix = GF_TRUE;
} else if (!stricmp(arg, "-size")) {
/*usage of %ud breaks sscanf on MSVC*/
if (sscanf(argv[i+1], "%dx%d", &forced_width, &forced_height) != 2) {
forced_width = forced_height = 0;
}
i++;
} else if (!strcmp(arg, "-quiet")) {
be_quiet = 1;
} else if (!strcmp(arg, "-strict-error")) {
gf_log_set_strict_error(1);
} else if (!strcmp(arg, "-log-file") || !strcmp(arg, "-lf")) {
logfile = gf_fopen(argv[i+1], "wt");
gf_log_set_callback(logfile, on_gpac_log);
i++;
} else if (!strcmp(arg, "-logs") ) {
if (gf_log_set_tools_levels(argv[i+1]) != GF_OK) {
return 1;
}
logs_set = GF_TRUE;
i++;
} else if (!strcmp(arg, "-log-clock") || !strcmp(arg, "-lc")) {
log_time_start = 1;
} else if (!strcmp(arg, "-log-utc") || !strcmp(arg, "-lu")) {
log_utc_time = 1;
}
#if defined(__DARWIN__) || defined(__APPLE__)
else if (!strcmp(arg, "-thread")) threading_flags = 0;
#else
else if (!strcmp(arg, "-no-thread")) threading_flags = GF_TERM_NO_DECODER_THREAD | GF_TERM_NO_COMPOSITOR_THREAD | GF_TERM_WINDOW_NO_THREAD;
#endif
else if (!strcmp(arg, "-no-cthread") || !strcmp(arg, "-no-compositor-thread")) threading_flags |= GF_TERM_NO_COMPOSITOR_THREAD;
else if (!strcmp(arg, "-no-audio")) no_audio = 1;
else if (!strcmp(arg, "-no-regulation")) no_regulation = 1;
else if (!strcmp(arg, "-fs")) start_fs = 1;
else if (!strcmp(arg, "-opt")) {
set_cfg_option(argv[i+1]);
i++;
} else if (!strcmp(arg, "-conf")) {
set_cfg_option(argv[i+1]);
is_cfg_only=GF_TRUE;
i++;
}
else if (!strcmp(arg, "-ifce")) {
gf_cfg_set_key(cfg_file, "Network", "DefaultMCastInterface", argv[i+1]);
i++;
}
else if (!stricmp(arg, "-help")) {
PrintUsage();
return 1;
}
else if (!stricmp(arg, "-noprog")) {
no_prog=1;
gf_set_progress_callback(NULL, progress_quiet);
}
else if (!stricmp(arg, "-no-save") || !stricmp(arg, "--no-save") /*old versions used --n-save ...*/) {
no_cfg_save=1;
}
else if (!stricmp(arg, "-ntp-shift")) {
s32 shift = atoi(argv[i+1]);
i++;
gf_net_set_ntp_shift(shift);
}
else if (!stricmp(arg, "-run-for")) {
simulation_time_in_ms = atoi(argv[i+1]) * 1000;
if (!simulation_time_in_ms)
simulation_time_in_ms = 1; /*1ms*/
i++;
}
else if (!strcmp(arg, "-out")) {
out_arg = argv[i+1];
i++;
}
else if (!stricmp(arg, "-fps")) {
fps = atof(argv[i+1]);
i++;
} else if (!strcmp(arg, "-avi") || !strcmp(arg, "-sha")) {
dump_mode &= 0xFFFF0000;
if (!strcmp(arg, "-sha")) dump_mode |= DUMP_SHA1;
else dump_mode |= DUMP_AVI;
if ((url_arg || (i+2<(u32)argc)) && get_time_list(argv[i+1], times, &nb_times)) {
if (!strcmp(arg, "-avi") && (nb_times!=2) ) {
fprintf(stderr, "Only one time arg found for -avi - check usage\n");
return 1;
}
i++;
}
} else if (!strcmp(arg, "-rgbds")) { /*get dump in rgbds pixel format*/
dump_mode |= DUMP_RGB_DEPTH_SHAPE;
} else if (!strcmp(arg, "-rgbd")) { /*get dump in rgbd pixel format*/
dump_mode |= DUMP_RGB_DEPTH;
} else if (!strcmp(arg, "-depth")) {
dump_mode |= DUMP_DEPTH_ONLY;
} else if (!strcmp(arg, "-bmp")) {
dump_mode &= 0xFFFF0000;
dump_mode |= DUMP_BMP;
if ((url_arg || (i+2<(u32)argc)) && get_time_list(argv[i+1], times, &nb_times)) i++;
} else if (!strcmp(arg, "-png")) {
dump_mode &= 0xFFFF0000;
dump_mode |= DUMP_PNG;
if ((url_arg || (i+2<(u32)argc)) && get_time_list(argv[i+1], times, &nb_times)) i++;
} else if (!strcmp(arg, "-raw")) {
dump_mode &= 0xFFFF0000;
dump_mode |= DUMP_RAW;
if ((url_arg || (i+2<(u32)argc)) && get_time_list(argv[i+1], times, &nb_times)) i++;
} else if (!stricmp(arg, "-scale")) {
sscanf(argv[i+1], "%f", &scale);
i++;
}
else if (!strcmp(arg, "-c") || !strcmp(arg, "-cfg")) {
/* already parsed */
i++;
}
/*arguments only used in non-gui mode*/
if (!gui_mode) {
if (arg[0] != '-') {
if (url_arg) {
fprintf(stderr, "Several input URLs provided (\"%s\", \"%s\"). Check your command-line.\n", url_arg, arg);
return 1;
}
url_arg = arg;
}
else if (!strcmp(arg, "-loop")) loop_at_end = 1;
else if (!strcmp(arg, "-bench")) bench_mode = 1;
else if (!strcmp(arg, "-vbench")) bench_mode = 2;
else if (!strcmp(arg, "-sbench")) bench_mode = 3;
else if (!strcmp(arg, "-no-addon")) enable_add_ons = GF_FALSE;
else if (!strcmp(arg, "-pause")) pause_at_first = 1;
else if (!strcmp(arg, "-play-from")) {
play_from = atof((const char *) argv[i+1]);
i++;
}
else if (!strcmp(arg, "-speed")) {
playback_speed = FLT2FIX( atof((const char *) argv[i+1]) );
if (playback_speed <= 0) playback_speed = FIX_ONE;
i++;
}
else if (!strcmp(arg, "-no-wnd")) user.init_flags |= GF_TERM_WINDOWLESS;
else if (!strcmp(arg, "-no-back")) user.init_flags |= GF_TERM_WINDOW_TRANSPARENT;
else if (!strcmp(arg, "-align")) {
if (argv[i+1][0]=='m') align_mode = 1;
else if (argv[i+1][0]=='b') align_mode = 2;
align_mode <<= 8;
if (argv[i+1][1]=='m') align_mode |= 1;
else if (argv[i+1][1]=='r') align_mode |= 2;
i++;
} else if (!strcmp(arg, "-fill")) {
fill_ar = GF_TRUE;
} else if (!strcmp(arg, "-show")) {
visible = 1;
} else if (!strcmp(arg, "-uncache")) {
do_uncache = GF_TRUE;
}
else if (!strcmp(arg, "-exit")) auto_exit = GF_TRUE;
else if (!stricmp(arg, "-views")) {
views = argv[i+1];
i++;
}
else if (!stricmp(arg, "-mosaic")) {
mosaic = argv[i+1];
i++;
}
else if (!stricmp(arg, "-com")) {
has_command = GF_TRUE;
i++;
}
else if (!stricmp(arg, "-service")) {
initial_service_id = atoi(argv[i+1]);
i++;
}
}
}
if (is_cfg_only) {
gf_cfg_del(cfg_file);
fprintf(stderr, "GPAC Config updated\n");
return 0;
}
if (do_uncache) {
const char *cache_dir = gf_cfg_get_key(cfg_file, "General", "CacheDirectory");
do_flatten_cache(cache_dir);
fprintf(stderr, "GPAC Cache dir %s flattened\n", cache_dir);
gf_cfg_del(cfg_file);
return 0;
}
if (dump_mode && !url_arg ) {
FILE *test;
url_arg = (char *)gf_cfg_get_key(cfg_file, "General", "StartupFile");
test = url_arg ? gf_fopen(url_arg, "rt") : NULL;
if (!test) url_arg = NULL;
else gf_fclose(test);
if (!url_arg) {
fprintf(stderr, "Missing argument for dump\n");
PrintUsage();
if (logfile) gf_fclose(logfile);
return 1;
}
}
if (!gui_mode && !url_arg && (gf_cfg_get_key(cfg_file, "General", "StartupFile") != NULL)) {
gui_mode=1;
}
#ifdef WIN32
if (gui_mode==1) {
const char *opt;
TCHAR buffer[1024];
DWORD res = GetCurrentDirectory(1024, buffer);
buffer[res] = 0;
opt = gf_cfg_get_key(cfg_file, "General", "ModulesDirectory");
if (strstr(opt, buffer)) {
gui_mode=1;
} else {
gui_mode=2;
}
}
#endif
if (gui_mode==1) {
hide_shell(1);
}
if (gui_mode) {
no_prog=1;
gf_set_progress_callback(NULL, progress_quiet);
}
if (!url_arg && simulation_time_in_ms)
simulation_time_in_ms += gf_sys_clock();
#if defined(__DARWIN__) || defined(__APPLE__)
carbon_init();
#endif
if (dump_mode) rti_file = NULL;
if (!logs_set) {
gf_log_set_tool_level(GF_LOG_ALL, GF_LOG_WARNING);
}
//only override default log callback when needed
if (rti_file || logfile || log_utc_time || log_time_start)
gf_log_set_callback(NULL, on_gpac_log);
if (rti_file) init_rti_logs(rti_file, url_arg, use_rtix);
{
GF_SystemRTInfo rti;
if (gf_sys_get_rti(0, &rti, 0))
fprintf(stderr, "System info: %d MB RAM - %d cores\n", (u32) (rti.physical_memory/1024/1024), rti.nb_cores);
}
/*setup dumping options*/
if (dump_mode) {
user.init_flags |= GF_TERM_NO_DECODER_THREAD | GF_TERM_NO_COMPOSITOR_THREAD | GF_TERM_NO_REGULATION;
if (!visible)
user.init_flags |= GF_TERM_INIT_HIDE;
gf_cfg_set_key(cfg_file, "Audio", "DriverName", "Raw Audio Output");
no_cfg_save=GF_TRUE;
} else {
init_w = forced_width;
init_h = forced_height;
}
user.modules = gf_modules_new(NULL, cfg_file);
if (user.modules) i = gf_modules_get_count(user.modules);
if (!i || !user.modules) {
fprintf(stderr, "Error: no modules found - exiting\n");
if (user.modules) gf_modules_del(user.modules);
gf_cfg_del(cfg_file);
gf_sys_close();
if (logfile) gf_fclose(logfile);
return 1;
}
fprintf(stderr, "Modules Found : %d \n", i);
str = gf_cfg_get_key(cfg_file, "General", "GPACVersion");
if (!str || strcmp(str, GPAC_FULL_VERSION)) {
gf_cfg_del_section(cfg_file, "PluginsCache");
gf_cfg_set_key(cfg_file, "General", "GPACVersion", GPAC_FULL_VERSION);
}
user.config = cfg_file;
user.EventProc = GPAC_EventProc;
/*dummy in this case (global vars) but MUST be non-NULL*/
user.opaque = user.modules;
if (threading_flags) user.init_flags |= threading_flags;
if (no_audio) user.init_flags |= GF_TERM_NO_AUDIO;
if (no_regulation) user.init_flags |= GF_TERM_NO_REGULATION;
if (threading_flags & (GF_TERM_NO_DECODER_THREAD|GF_TERM_NO_COMPOSITOR_THREAD) ) term_step = GF_TRUE;
//in dump mode we don't want to rely on system clock but on the number of samples being consumed
if (dump_mode) user.init_flags |= GF_TERM_USE_AUDIO_HW_CLOCK;
if (bench_mode) {
gf_cfg_discard_changes(user.config);
auto_exit = GF_TRUE;
gf_cfg_set_key(user.config, "Audio", "DriverName", "Raw Audio Output");
if (bench_mode!=2) {
gf_cfg_set_key(user.config, "Video", "DriverName", "Raw Video Output");
gf_cfg_set_key(user.config, "RAWVideo", "RawOutput", "null");
gf_cfg_set_key(user.config, "Compositor", "OpenGLMode", "disable");
} else {
gf_cfg_set_key(user.config, "Video", "DisableVSync", "yes");
}
}
{
char dim[50];
sprintf(dim, "%d", forced_width);
gf_cfg_set_key(user.config, "Compositor", "DefaultWidth", forced_width ? dim : NULL);
sprintf(dim, "%d", forced_height);
gf_cfg_set_key(user.config, "Compositor", "DefaultHeight", forced_height ? dim : NULL);
}
fprintf(stderr, "Loading GPAC Terminal\n");
i = gf_sys_clock();
term = gf_term_new(&user);
if (!term) {
fprintf(stderr, "\nInit error - check you have at least one video out and one rasterizer...\nFound modules:\n");
list_modules(user.modules);
gf_modules_del(user.modules);
gf_cfg_discard_changes(cfg_file);
gf_cfg_del(cfg_file);
gf_sys_close();
if (logfile) gf_fclose(logfile);
return 1;
}
fprintf(stderr, "Terminal Loaded in %d ms\n", gf_sys_clock()-i);
if (bench_mode) {
display_rti = 2;
gf_term_set_option(term, GF_OPT_VIDEO_BENCH, (bench_mode==3) ? 2 : 1);
if (bench_mode==1) bench_mode=2;
}
if (dump_mode) {
// gf_term_set_option(term, GF_OPT_VISIBLE, 0);
if (fill_ar) gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_FILL_SCREEN);
} else {
/*check video output*/
str = gf_cfg_get_key(cfg_file, "Video", "DriverName");
if (!bench_mode && !strcmp(str, "Raw Video Output")) fprintf(stderr, "WARNING: using raw output video (memory only) - no display used\n");
/*check audio output*/
str = gf_cfg_get_key(cfg_file, "Audio", "DriverName");
if (!str || !strcmp(str, "No Audio Output Available")) fprintf(stderr, "WARNING: no audio output available - make sure no other program is locking the sound card\n");
str = gf_cfg_get_key(cfg_file, "General", "NoMIMETypeFetch");
no_mime_check = (str && !stricmp(str, "yes")) ? 1 : 0;
}
str = gf_cfg_get_key(cfg_file, "HTTPProxy", "Enabled");
if (str && !strcmp(str, "yes")) {
str = gf_cfg_get_key(cfg_file, "HTTPProxy", "Name");
if (str) fprintf(stderr, "HTTP Proxy %s enabled\n", str);
}
if (rti_file) {
str = gf_cfg_get_key(cfg_file, "General", "RTIRefreshPeriod");
if (str) {
rti_update_time_ms = atoi(str);
} else {
gf_cfg_set_key(cfg_file, "General", "RTIRefreshPeriod", "200");
}
UpdateRTInfo("At GPAC load time\n");
}
Run = 1;
if (dump_mode) {
if (!nb_times) {
times[0] = 0;
nb_times++;
}
ret_val = dump_file(url_arg, out_arg, dump_mode, fps, forced_width, forced_height, scale, times, nb_times);
Run = 0;
}
else if (views) {
}
/*connect if requested*/
else if (!gui_mode && url_arg) {
char *ext;
strcpy(the_url, url_arg);
ext = strrchr(the_url, '.');
if (ext && (!stricmp(ext, ".m3u") || !stricmp(ext, ".pls"))) {
GF_Err e = GF_OK;
fprintf(stderr, "Opening Playlist %s\n", the_url);
strcpy(pl_path, the_url);
/*this is not clean, we need to have a plugin handle playlist for ourselves*/
if (!strncmp("http:", the_url, 5)) {
GF_DownloadSession *sess = gf_dm_sess_new(term->downloader, the_url, GF_NETIO_SESSION_NOT_THREADED, NULL, NULL, &e);
if (sess) {
e = gf_dm_sess_process(sess);
if (!e) strcpy(the_url, gf_dm_sess_get_cache_name(sess));
gf_dm_sess_del(sess);
}
}
playlist = e ? NULL : gf_fopen(the_url, "rt");
readonly_playlist = 1;
if (playlist) {
request_next_playlist_item = GF_TRUE;
} else {
if (e)
fprintf(stderr, "Failed to open playlist %s: %s\n", the_url, gf_error_to_string(e) );
fprintf(stderr, "Hit 'h' for help\n\n");
}
} else {
fprintf(stderr, "Opening URL %s\n", the_url);
if (pause_at_first) fprintf(stderr, "[Status: Paused]\n");
gf_term_connect_from_time(term, the_url, (u64) (play_from*1000), pause_at_first);
}
} else {
fprintf(stderr, "Hit 'h' for help\n\n");
str = gf_cfg_get_key(cfg_file, "General", "StartupFile");
if (str) {
strcpy(the_url, "MP4Client "GPAC_FULL_VERSION);
gf_term_connect(term, str);
startup_file = 1;
is_connected = 1;
}
}
if (gui_mode==2) gui_mode=0;
if (start_fs) gf_term_set_option(term, GF_OPT_FULLSCREEN, 1);
if (views) {
char szTemp[4046];
sprintf(szTemp, "views://%s", views);
gf_term_connect(term, szTemp);
}
if (mosaic) {
char szTemp[4046];
sprintf(szTemp, "mosaic://%s", mosaic);
gf_term_connect(term, szTemp);
}
if (bench_mode) {
rti_update_time_ms = 500;
bench_mode_start = gf_sys_clock();
}
while (Run) {
/*we don't want getchar to block*/
if ((gui_mode==1) || !gf_prompt_has_input()) {
if (reload) {
reload = 0;
gf_term_disconnect(term);
gf_term_connect(term, startup_file ? gf_cfg_get_key(cfg_file, "General", "StartupFile") : the_url);
}
if (restart && gf_term_get_option(term, GF_OPT_IS_OVER)) {
restart = 0;
gf_term_play_from_time(term, 0, 0);
}
if (request_next_playlist_item) {
c = '\n';
request_next_playlist_item = 0;
goto force_input;
}
if (has_command && is_connected) {
has_command = GF_FALSE;
for (i=0; i<(u32)argc; i++) {
if (!strcmp(argv[i], "-com")) {
gf_term_scene_update(term, NULL, argv[i+1]);
i++;
}
}
}
if (initial_service_id && is_connected) {
GF_ObjectManager *root_od = gf_term_get_root_object(term);
if (root_od) {
gf_term_select_service(term, root_od, initial_service_id);
initial_service_id = 0;
}
}
if (!use_rtix || display_rti) UpdateRTInfo(NULL);
if (term_step) {
gf_term_process_step(term);
} else {
gf_sleep(rti_update_time_ms);
}
if (auto_exit && eos_seen && gf_term_get_option(term, GF_OPT_IS_OVER)) {
Run = GF_FALSE;
}
/*sim time*/
if (simulation_time_in_ms
&& ( (gf_term_get_elapsed_time_in_ms(term)>simulation_time_in_ms) || (!url_arg && gf_sys_clock()>simulation_time_in_ms))
) {
Run = GF_FALSE;
}
continue;
}
c = gf_prompt_get_char();
force_input:
switch (c) {
case 'q':
{
GF_Event evt;
memset(&evt, 0, sizeof(GF_Event));
evt.type = GF_EVENT_QUIT;
gf_term_send_event(term, &evt);
}
// Run = 0;
break;
case 'X':
exit(0);
break;
case 'Q':
break;
case 'o':
startup_file = 0;
gf_term_disconnect(term);
fprintf(stderr, "Enter the absolute URL\n");
if (1 > scanf("%s", the_url)) {
fprintf(stderr, "Cannot read absolute URL, aborting\n");
break;
}
if (rti_file) init_rti_logs(rti_file, the_url, use_rtix);
gf_term_connect(term, the_url);
break;
case 'O':
gf_term_disconnect(term);
fprintf(stderr, "Enter the absolute URL to the playlist\n");
if (1 > scanf("%s", the_url)) {
fprintf(stderr, "Cannot read the absolute URL, aborting.\n");
break;
}
playlist = gf_fopen(the_url, "rt");
if (playlist) {
if (1 > fscanf(playlist, "%s", the_url)) {
fprintf(stderr, "Cannot read any URL from playlist, aborting.\n");
gf_fclose( playlist);
break;
}
fprintf(stderr, "Opening URL %s\n", the_url);
gf_term_connect(term, the_url);
}
break;
case '\n':
case 'N':
if (playlist) {
int res;
gf_term_disconnect(term);
res = fscanf(playlist, "%s", the_url);
if ((res == EOF) && loop_at_end) {
fseek(playlist, 0, SEEK_SET);
res = fscanf(playlist, "%s", the_url);
}
if (res == EOF) {
fprintf(stderr, "No more items - exiting\n");
Run = 0;
} else if (the_url[0] == '#') {
request_next_playlist_item = GF_TRUE;
} else {
fprintf(stderr, "Opening URL %s\n", the_url);
gf_term_connect_with_path(term, the_url, pl_path);
}
}
break;
case 'P':
if (playlist) {
u32 count;
gf_term_disconnect(term);
if (1 > scanf("%u", &count)) {
fprintf(stderr, "Cannot read number, aborting.\n");
break;
}
while (count) {
if (fscanf(playlist, "%s", the_url)) {
fprintf(stderr, "Failed to read line, aborting\n");
break;
}
count--;
}
fprintf(stderr, "Opening URL %s\n", the_url);
gf_term_connect(term, the_url);
}
break;
case 'r':
if (is_connected)
reload = 1;
break;
case 'D':
if (is_connected) gf_term_disconnect(term);
break;
case 'p':
if (is_connected) {
Bool is_pause = gf_term_get_option(term, GF_OPT_PLAY_STATE);
fprintf(stderr, "[Status: %s]\n", is_pause ? "Playing" : "Paused");
gf_term_set_option(term, GF_OPT_PLAY_STATE, is_pause ? GF_STATE_PLAYING : GF_STATE_PAUSED);
}
break;
case 's':
if (is_connected) {
gf_term_set_option(term, GF_OPT_PLAY_STATE, GF_STATE_STEP_PAUSE);
fprintf(stderr, "Step time: ");
PrintTime(gf_term_get_time_in_ms(term));
fprintf(stderr, "\n");
}
break;
case 'z':
case 'T':
if (!CanSeek || (Duration<=2000)) {
fprintf(stderr, "scene not seekable\n");
} else {
Double res;
s32 seekTo;
fprintf(stderr, "Duration: ");
PrintTime(Duration);
res = gf_term_get_time_in_ms(term);
if (c=='z') {
res *= 100;
res /= (s64)Duration;
fprintf(stderr, " (current %.2f %%)\nEnter Seek percentage:\n", res);
if (scanf("%d", &seekTo) == 1) {
if (seekTo > 100) seekTo = 100;
res = (Double)(s64)Duration;
res /= 100;
res *= seekTo;
gf_term_play_from_time(term, (u64) (s64) res, 0);
}
} else {
u32 r, h, m, s;
fprintf(stderr, " - Current Time: ");
PrintTime((u64) res);
fprintf(stderr, "\nEnter seek time (Format: s, m:s or h:m:s):\n");
h = m = s = 0;
r =scanf("%d:%d:%d", &h, &m, &s);
if (r==2) {
s = m;
m = h;
h = 0;
}
else if (r==1) {
s = h;
m = h = 0;
}
if (r && (r<=3)) {
u64 time = h*3600 + m*60 + s;
gf_term_play_from_time(term, time*1000, 0);
}
}
}
break;
case 't':
{
if (is_connected) {
fprintf(stderr, "Current Time: ");
PrintTime(gf_term_get_time_in_ms(term));
fprintf(stderr, " - Duration: ");
PrintTime(Duration);
fprintf(stderr, "\n");
}
}
break;
case 'w':
if (is_connected) PrintWorldInfo(term);
break;
case 'v':
if (is_connected) PrintODList(term, NULL, 0, 0, "Root");
break;
case 'i':
if (is_connected) {
u32 ID;
fprintf(stderr, "Enter OD ID (0 for main OD): ");
fflush(stderr);
if (scanf("%ud", &ID) == 1) {
ViewOD(term, ID, (u32)-1, NULL);
} else {
char str_url[GF_MAX_PATH];
if (scanf("%s", str_url) == 1)
ViewOD(term, 0, (u32)-1, str_url);
}
}
break;
case 'j':
if (is_connected) {
u32 num;
do {
fprintf(stderr, "Enter OD number (0 for main OD): ");
fflush(stderr);
} while( 1 > scanf("%ud", &num));
ViewOD(term, (u32)-1, num, NULL);
}
break;
case 'b':
if (is_connected) ViewODs(term, 1);
break;
case 'm':
if (is_connected) ViewODs(term, 0);
break;
case 'l':
list_modules(user.modules);
break;
case 'n':
if (is_connected) set_navigation();
break;
case 'x':
if (is_connected) gf_term_set_option(term, GF_OPT_NAVIGATION_TYPE, 0);
break;
case 'd':
if (is_connected) {
GF_ObjectManager *odm = NULL;
char radname[GF_MAX_PATH], *sExt;
GF_Err e;
u32 i, count, odid;
Bool xml_dump, std_out;
radname[0] = 0;
do {
fprintf(stderr, "Enter Inline OD ID if any or 0 : ");
fflush(stderr);
} while( 1 > scanf("%ud", &odid));
if (odid) {
GF_ObjectManager *root_odm = gf_term_get_root_object(term);
if (!root_odm) break;
count = gf_term_get_object_count(term, root_odm);
for (i=0; i<count; i++) {
GF_MediaInfo info;
odm = gf_term_get_object(term, root_odm, i);
if (gf_term_get_object_info(term, odm, &info) == GF_OK) {
if (info.od->objectDescriptorID==odid) break;
}
odm = NULL;
}
}
do {
fprintf(stderr, "Enter file radical name (+\'.x\' for XML dumping) - \"std\" for stderr: ");
fflush(stderr);
} while( 1 > scanf("%s", radname));
sExt = strrchr(radname, '.');
xml_dump = 0;
if (sExt) {
if (!stricmp(sExt, ".x")) xml_dump = 1;
sExt[0] = 0;
}
std_out = strnicmp(radname, "std", 3) ? 0 : 1;
e = gf_term_dump_scene(term, std_out ? NULL : radname, NULL, xml_dump, 0, odm);
fprintf(stderr, "Dump done (%s)\n", gf_error_to_string(e));
}
break;
case 'c':
PrintGPACConfig();
break;
case '3':
{
Bool use_3d = !gf_term_get_option(term, GF_OPT_USE_OPENGL);
if (gf_term_set_option(term, GF_OPT_USE_OPENGL, use_3d)==GF_OK) {
fprintf(stderr, "Using %s for 2D drawing\n", use_3d ? "OpenGL" : "2D rasterizer");
}
}
break;
case 'k':
{
Bool opt = gf_term_get_option(term, GF_OPT_STRESS_MODE);
opt = !opt;
fprintf(stderr, "Turning stress mode %s\n", opt ? "on" : "off");
gf_term_set_option(term, GF_OPT_STRESS_MODE, opt);
}
break;
case '4':
gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_4_3);
break;
case '5':
gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_16_9);
break;
case '6':
gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_FILL_SCREEN);
break;
case '7':
gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_KEEP);
break;
case 'C':
switch (gf_term_get_option(term, GF_OPT_MEDIA_CACHE)) {
case GF_MEDIA_CACHE_DISABLED:
gf_term_set_option(term, GF_OPT_MEDIA_CACHE, GF_MEDIA_CACHE_ENABLED);
break;
case GF_MEDIA_CACHE_ENABLED:
gf_term_set_option(term, GF_OPT_MEDIA_CACHE, GF_MEDIA_CACHE_DISABLED);
break;
case GF_MEDIA_CACHE_RUNNING:
fprintf(stderr, "Streaming Cache is running - please stop it first\n");
continue;
}
switch (gf_term_get_option(term, GF_OPT_MEDIA_CACHE)) {
case GF_MEDIA_CACHE_ENABLED:
fprintf(stderr, "Streaming Cache Enabled\n");
break;
case GF_MEDIA_CACHE_DISABLED:
fprintf(stderr, "Streaming Cache Disabled\n");
break;
case GF_MEDIA_CACHE_RUNNING:
fprintf(stderr, "Streaming Cache Running\n");
break;
}
break;
case 'S':
case 'A':
if (gf_term_get_option(term, GF_OPT_MEDIA_CACHE)==GF_MEDIA_CACHE_RUNNING) {
gf_term_set_option(term, GF_OPT_MEDIA_CACHE, (c=='S') ? GF_MEDIA_CACHE_DISABLED : GF_MEDIA_CACHE_DISCARD);
fprintf(stderr, "Streaming Cache stopped\n");
} else {
fprintf(stderr, "Streaming Cache not running\n");
}
break;
case 'R':
display_rti = !display_rti;
ResetCaption();
break;
case 'F':
if (display_rti) display_rti = 0;
else display_rti = 2;
ResetCaption();
break;
case 'u':
{
GF_Err e;
char szCom[8192];
fprintf(stderr, "Enter command to send:\n");
fflush(stdin);
szCom[0] = 0;
if (1 > scanf("%[^\t\n]", szCom)) {
fprintf(stderr, "Cannot read command to send, aborting.\n");
break;
}
e = gf_term_scene_update(term, NULL, szCom);
if (e) fprintf(stderr, "Processing command failed: %s\n", gf_error_to_string(e));
}
break;
case 'e':
{
GF_Err e;
char jsCode[8192];
fprintf(stderr, "Enter JavaScript code to evaluate:\n");
fflush(stdin);
jsCode[0] = 0;
if (1 > scanf("%[^\t\n]", jsCode)) {
fprintf(stderr, "Cannot read code to evaluate, aborting.\n");
break;
}
e = gf_term_scene_update(term, "application/ecmascript", jsCode);
if (e) fprintf(stderr, "Processing JS code failed: %s\n", gf_error_to_string(e));
}
break;
case 'L':
{
char szLog[1024], *cur_logs;
cur_logs = gf_log_get_tools_levels();
fprintf(stderr, "Enter new log level (current tools %s):\n", cur_logs);
gf_free(cur_logs);
if (scanf("%s", szLog) < 1) {
fprintf(stderr, "Cannot read new log level, aborting.\n");
break;
}
gf_log_modify_tools_levels(szLog);
}
break;
case 'g':
{
GF_SystemRTInfo rti;
gf_sys_get_rti(rti_update_time_ms, &rti, 0);
fprintf(stderr, "GPAC allocated memory "LLD"\n", rti.gpac_memory);
}
break;
case 'M':
{
u32 size;
do {
fprintf(stderr, "Enter new video cache memory in kBytes (current %ud):\n", gf_term_get_option(term, GF_OPT_VIDEO_CACHE_SIZE));
} while (1 > scanf("%ud", &size));
gf_term_set_option(term, GF_OPT_VIDEO_CACHE_SIZE, size);
}
break;
case 'H':
{
u32 http_bitrate = gf_term_get_option(term, GF_OPT_HTTP_MAX_RATE);
do {
fprintf(stderr, "Enter new http bitrate in bps (0 for none) - current limit: %d\n", http_bitrate);
} while (1 > scanf("%ud", &http_bitrate));
gf_term_set_option(term, GF_OPT_HTTP_MAX_RATE, http_bitrate);
}
break;
case 'E':
gf_term_set_option(term, GF_OPT_RELOAD_CONFIG, 1);
break;
case 'B':
switch_bench(!bench_mode);
break;
case 'Y':
{
char szOpt[8192];
fprintf(stderr, "Enter option to set (Section:Name=Value):\n");
fflush(stdin);
szOpt[0] = 0;
if (1 > scanf("%[^\t\n]", szOpt)) {
fprintf(stderr, "Cannot read option\n");
break;
}
set_cfg_option(szOpt);
}
break;
/*extract to PNG*/
case 'Z':
{
char szFileName[100];
u32 nb_pass, nb_views, offscreen_view = 0;
GF_VideoSurface fb;
GF_Err e;
nb_pass = 1;
nb_views = gf_term_get_option(term, GF_OPT_NUM_STEREO_VIEWS);
if (nb_views>1) {
fprintf(stderr, "Auto-stereo mode detected - type number of view to dump (0 is main output, 1 to %d offscreen view, %d for all offscreen, %d for all offscreen and main)\n", nb_views, nb_views+1, nb_views+2);
if (scanf("%d", &offscreen_view) != 1) {
offscreen_view = 0;
}
if (offscreen_view==nb_views+1) {
offscreen_view = 1;
nb_pass = nb_views;
}
else if (offscreen_view==nb_views+2) {
offscreen_view = 0;
nb_pass = nb_views+1;
}
}
while (nb_pass) {
nb_pass--;
if (offscreen_view) {
sprintf(szFileName, "view%d_dump.png", offscreen_view);
e = gf_term_get_offscreen_buffer(term, &fb, offscreen_view-1, 0);
} else {
sprintf(szFileName, "gpac_video_dump_"LLU".png", gf_net_get_utc() );
e = gf_term_get_screen_buffer(term, &fb);
}
offscreen_view++;
if (e) {
fprintf(stderr, "Error dumping screen buffer %s\n", gf_error_to_string(e) );
nb_pass = 0;
} else {
#ifndef GPAC_DISABLE_AV_PARSERS
u32 dst_size = fb.width*fb.height*4;
char *dst = (char*)gf_malloc(sizeof(char)*dst_size);
e = gf_img_png_enc(fb.video_buffer, fb.width, fb.height, fb.pitch_y, fb.pixel_format, dst, &dst_size);
if (e) {
fprintf(stderr, "Error encoding PNG %s\n", gf_error_to_string(e) );
nb_pass = 0;
} else {
FILE *png = gf_fopen(szFileName, "wb");
if (!png) {
fprintf(stderr, "Error writing file %s\n", szFileName);
nb_pass = 0;
} else {
gf_fwrite(dst, dst_size, 1, png);
gf_fclose(png);
fprintf(stderr, "Dump to %s\n", szFileName);
}
}
if (dst) gf_free(dst);
gf_term_release_screen_buffer(term, &fb);
#endif //GPAC_DISABLE_AV_PARSERS
}
}
fprintf(stderr, "Done: %s\n", szFileName);
}
break;
case 'G':
{
GF_ObjectManager *root_od, *odm;
u32 index;
char szOpt[8192];
fprintf(stderr, "Enter 0-based index of object to select or service ID:\n");
fflush(stdin);
szOpt[0] = 0;
if (1 > scanf("%[^\t\n]", szOpt)) {
fprintf(stderr, "Cannot read OD ID\n");
break;
}
index = atoi(szOpt);
odm = NULL;
root_od = gf_term_get_root_object(term);
if (root_od) {
if ( gf_term_find_service(term, root_od, index)) {
gf_term_select_service(term, root_od, index);
} else {
fprintf(stderr, "Cannot find service %d - trying with object index\n", index);
odm = gf_term_get_object(term, root_od, index);
if (odm) {
gf_term_select_object(term, odm);
} else {
fprintf(stderr, "Cannot find object at index %d\n", index);
}
}
}
}
break;
case 'h':
PrintHelp();
break;
default:
break;
}
}
if (bench_mode) {
PrintAVInfo(GF_TRUE);
}
/*FIXME: we have an issue in cleaning up after playing in bench mode and run-for 0 (buildbot tests). We for now disable error checks after run-for is done*/
if (simulation_time_in_ms) {
gf_log_set_strict_error(0);
}
i = gf_sys_clock();
gf_term_disconnect(term);
if (rti_file) UpdateRTInfo("Disconnected\n");
fprintf(stderr, "Deleting terminal... ");
if (playlist) gf_fclose(playlist);
#if defined(__DARWIN__) || defined(__APPLE__)
carbon_uninit();
#endif
gf_term_del(term);
fprintf(stderr, "done (in %d ms) - ran for %d ms\n", gf_sys_clock() - i, gf_sys_clock());
fprintf(stderr, "GPAC cleanup ...\n");
gf_modules_del(user.modules);
if (no_cfg_save)
gf_cfg_discard_changes(cfg_file);
gf_cfg_del(cfg_file);
gf_sys_close();
if (rti_logs) gf_fclose(rti_logs);
if (logfile) gf_fclose(logfile);
if (gui_mode) {
hide_shell(2);
}
#ifdef GPAC_MEMORY_TRACKING
if (mem_track && (gf_memory_size() || gf_file_handles_count() )) {
gf_log_set_tool_level(GF_LOG_MEMORY, GF_LOG_INFO);
gf_memory_print();
return 2;
}
#endif
return ret_val;
} | 6867 | True | 1 |
CVE-2018-20762 | 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.0/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/gpac/gpac/issues/1187', 'name': 'https://github.com/gpac/gpac/issues/1187', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/35ab4475a7df9b2a4bcab235e379c0c3ec543658', 'name': 'https://github.com/gpac/gpac/commit/35ab4475a7df9b2a4bcab235e379c0c3ec543658', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2019/02/msg00040.html', 'name': '[debian-lts-announce] 20190227 [SECURITY] [DLA 1693-1] gpac security update', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://usn.ubuntu.com/3926-1/', 'name': 'USN-3926-1', 'refsource': 'UBUNTU', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-119'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac_project:gpac:*:*:*:*:*:*:*:*', 'versionEndIncluding': '0.7.1', 'cpe_name': []}]}, {'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:o:canonical:ubuntu_linux:16.04:*:*:*:lts:*:*:*', 'cpe_name': []}, {'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': []}]}] | [{'lang': 'en', 'value': 'GPAC version 0.7.1 and earlier has a buffer overflow vulnerability in the cat_multiple_files function in applications/mp4box/fileimport.c when MP4Box is used for a local directory containing crafted filenames.'}] | 2019-04-15T18:58Z | 2019-02-06T23: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 | Aurelien David | 2019-01-11 11:32:54+01:00 | fix some overflows due to strcpy
fixes #1184, #1186, #1187 among other things | 35ab4475a7df9b2a4bcab235e379c0c3ec543658 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | mp4client_main | mp4client_main( int argc , char ** argv) | ['argc', 'argv'] | int mp4client_main(int argc, char **argv)
{
char c;
const char *str;
int ret_val = 0;
u32 i, times[100], nb_times, dump_mode;
u32 simulation_time_in_ms = 0;
u32 initial_service_id = 0;
Bool auto_exit = GF_FALSE;
Bool logs_set = GF_FALSE;
Bool start_fs = GF_FALSE;
Bool use_rtix = GF_FALSE;
Bool pause_at_first = GF_FALSE;
Bool no_cfg_save = GF_FALSE;
Bool is_cfg_only = GF_FALSE;
Double play_from = 0;
#ifdef GPAC_MEMORY_TRACKING
GF_MemTrackerType mem_track = GF_MemTrackerNone;
#endif
Double fps = GF_IMPORT_DEFAULT_FPS;
Bool fill_ar, visible, do_uncache, has_command;
char *url_arg, *out_arg, *the_cfg, *rti_file, *views, *mosaic;
FILE *logfile = NULL;
Float scale = 1;
#ifndef WIN32
dlopen(NULL, RTLD_NOW|RTLD_GLOBAL);
#endif
/*by default use current dir*/
strcpy(the_url, ".");
memset(&user, 0, sizeof(GF_User));
dump_mode = DUMP_NONE;
fill_ar = visible = do_uncache = has_command = GF_FALSE;
url_arg = out_arg = the_cfg = rti_file = views = mosaic = NULL;
nb_times = 0;
times[0] = 0;
/*first locate config file if specified*/
for (i=1; i<(u32) argc; i++) {
char *arg = argv[i];
if (!strcmp(arg, "-c") || !strcmp(arg, "-cfg")) {
the_cfg = argv[i+1];
i++;
}
else if (!strcmp(arg, "-mem-track") || !strcmp(arg, "-mem-track-stack")) {
#ifdef GPAC_MEMORY_TRACKING
mem_track = !strcmp(arg, "-mem-track-stack") ? GF_MemTrackerBackTrace : GF_MemTrackerSimple;
#else
fprintf(stderr, "WARNING - GPAC not compiled with Memory Tracker - ignoring \"%s\"\n", arg);
#endif
} else if (!strcmp(arg, "-gui")) {
gui_mode = 1;
} else if (!strcmp(arg, "-guid")) {
gui_mode = 2;
} else if (!strcmp(arg, "-h") || !strcmp(arg, "-help")) {
PrintUsage();
return 0;
}
}
#ifdef GPAC_MEMORY_TRACKING
gf_sys_init(mem_track);
#else
gf_sys_init(GF_MemTrackerNone);
#endif
gf_sys_set_args(argc, (const char **) argv);
cfg_file = gf_cfg_init(the_cfg, NULL);
if (!cfg_file) {
fprintf(stderr, "Error: Configuration File not found\n");
return 1;
}
/*if logs are specified, use them*/
if (gf_log_set_tools_levels( gf_cfg_get_key(cfg_file, "General", "Logs") ) != GF_OK) {
return 1;
}
if( gf_cfg_get_key(cfg_file, "General", "Logs") != NULL ) {
logs_set = GF_TRUE;
}
if (!gui_mode) {
str = gf_cfg_get_key(cfg_file, "General", "ForceGUI");
if (str && !strcmp(str, "yes")) gui_mode = 1;
}
for (i=1; i<(u32) argc; i++) {
char *arg = argv[i];
if (!strcmp(arg, "-rti")) {
rti_file = argv[i+1];
i++;
} else if (!strcmp(arg, "-rtix")) {
rti_file = argv[i+1];
i++;
use_rtix = GF_TRUE;
} else if (!stricmp(arg, "-size")) {
/*usage of %ud breaks sscanf on MSVC*/
if (sscanf(argv[i+1], "%dx%d", &forced_width, &forced_height) != 2) {
forced_width = forced_height = 0;
}
i++;
} else if (!strcmp(arg, "-quiet")) {
be_quiet = 1;
} else if (!strcmp(arg, "-strict-error")) {
gf_log_set_strict_error(1);
} else if (!strcmp(arg, "-log-file") || !strcmp(arg, "-lf")) {
logfile = gf_fopen(argv[i+1], "wt");
gf_log_set_callback(logfile, on_gpac_log);
i++;
} else if (!strcmp(arg, "-logs") ) {
if (gf_log_set_tools_levels(argv[i+1]) != GF_OK) {
return 1;
}
logs_set = GF_TRUE;
i++;
} else if (!strcmp(arg, "-log-clock") || !strcmp(arg, "-lc")) {
log_time_start = 1;
} else if (!strcmp(arg, "-log-utc") || !strcmp(arg, "-lu")) {
log_utc_time = 1;
}
#if defined(__DARWIN__) || defined(__APPLE__)
else if (!strcmp(arg, "-thread")) threading_flags = 0;
#else
else if (!strcmp(arg, "-no-thread")) threading_flags = GF_TERM_NO_DECODER_THREAD | GF_TERM_NO_COMPOSITOR_THREAD | GF_TERM_WINDOW_NO_THREAD;
#endif
else if (!strcmp(arg, "-no-cthread") || !strcmp(arg, "-no-compositor-thread")) threading_flags |= GF_TERM_NO_COMPOSITOR_THREAD;
else if (!strcmp(arg, "-no-audio")) no_audio = 1;
else if (!strcmp(arg, "-no-regulation")) no_regulation = 1;
else if (!strcmp(arg, "-fs")) start_fs = 1;
else if (!strcmp(arg, "-opt")) {
set_cfg_option(argv[i+1]);
i++;
} else if (!strcmp(arg, "-conf")) {
set_cfg_option(argv[i+1]);
is_cfg_only=GF_TRUE;
i++;
}
else if (!strcmp(arg, "-ifce")) {
gf_cfg_set_key(cfg_file, "Network", "DefaultMCastInterface", argv[i+1]);
i++;
}
else if (!stricmp(arg, "-help")) {
PrintUsage();
return 1;
}
else if (!stricmp(arg, "-noprog")) {
no_prog=1;
gf_set_progress_callback(NULL, progress_quiet);
}
else if (!stricmp(arg, "-no-save") || !stricmp(arg, "--no-save") /*old versions used --n-save ...*/) {
no_cfg_save=1;
}
else if (!stricmp(arg, "-ntp-shift")) {
s32 shift = atoi(argv[i+1]);
i++;
gf_net_set_ntp_shift(shift);
}
else if (!stricmp(arg, "-run-for")) {
simulation_time_in_ms = atoi(argv[i+1]) * 1000;
if (!simulation_time_in_ms)
simulation_time_in_ms = 1; /*1ms*/
i++;
}
else if (!strcmp(arg, "-out")) {
out_arg = argv[i+1];
i++;
}
else if (!stricmp(arg, "-fps")) {
fps = atof(argv[i+1]);
i++;
} else if (!strcmp(arg, "-avi") || !strcmp(arg, "-sha")) {
dump_mode &= 0xFFFF0000;
if (!strcmp(arg, "-sha")) dump_mode |= DUMP_SHA1;
else dump_mode |= DUMP_AVI;
if ((url_arg || (i+2<(u32)argc)) && get_time_list(argv[i+1], times, &nb_times)) {
if (!strcmp(arg, "-avi") && (nb_times!=2) ) {
fprintf(stderr, "Only one time arg found for -avi - check usage\n");
return 1;
}
i++;
}
} else if (!strcmp(arg, "-rgbds")) { /*get dump in rgbds pixel format*/
dump_mode |= DUMP_RGB_DEPTH_SHAPE;
} else if (!strcmp(arg, "-rgbd")) { /*get dump in rgbd pixel format*/
dump_mode |= DUMP_RGB_DEPTH;
} else if (!strcmp(arg, "-depth")) {
dump_mode |= DUMP_DEPTH_ONLY;
} else if (!strcmp(arg, "-bmp")) {
dump_mode &= 0xFFFF0000;
dump_mode |= DUMP_BMP;
if ((url_arg || (i+2<(u32)argc)) && get_time_list(argv[i+1], times, &nb_times)) i++;
} else if (!strcmp(arg, "-png")) {
dump_mode &= 0xFFFF0000;
dump_mode |= DUMP_PNG;
if ((url_arg || (i+2<(u32)argc)) && get_time_list(argv[i+1], times, &nb_times)) i++;
} else if (!strcmp(arg, "-raw")) {
dump_mode &= 0xFFFF0000;
dump_mode |= DUMP_RAW;
if ((url_arg || (i+2<(u32)argc)) && get_time_list(argv[i+1], times, &nb_times)) i++;
} else if (!stricmp(arg, "-scale")) {
sscanf(argv[i+1], "%f", &scale);
i++;
}
else if (!strcmp(arg, "-c") || !strcmp(arg, "-cfg")) {
/* already parsed */
i++;
}
/*arguments only used in non-gui mode*/
if (!gui_mode) {
if (arg[0] != '-') {
if (url_arg) {
fprintf(stderr, "Several input URLs provided (\"%s\", \"%s\"). Check your command-line.\n", url_arg, arg);
return 1;
}
url_arg = arg;
}
else if (!strcmp(arg, "-loop")) loop_at_end = 1;
else if (!strcmp(arg, "-bench")) bench_mode = 1;
else if (!strcmp(arg, "-vbench")) bench_mode = 2;
else if (!strcmp(arg, "-sbench")) bench_mode = 3;
else if (!strcmp(arg, "-no-addon")) enable_add_ons = GF_FALSE;
else if (!strcmp(arg, "-pause")) pause_at_first = 1;
else if (!strcmp(arg, "-play-from")) {
play_from = atof((const char *) argv[i+1]);
i++;
}
else if (!strcmp(arg, "-speed")) {
playback_speed = FLT2FIX( atof((const char *) argv[i+1]) );
if (playback_speed <= 0) playback_speed = FIX_ONE;
i++;
}
else if (!strcmp(arg, "-no-wnd")) user.init_flags |= GF_TERM_WINDOWLESS;
else if (!strcmp(arg, "-no-back")) user.init_flags |= GF_TERM_WINDOW_TRANSPARENT;
else if (!strcmp(arg, "-align")) {
if (argv[i+1][0]=='m') align_mode = 1;
else if (argv[i+1][0]=='b') align_mode = 2;
align_mode <<= 8;
if (argv[i+1][1]=='m') align_mode |= 1;
else if (argv[i+1][1]=='r') align_mode |= 2;
i++;
} else if (!strcmp(arg, "-fill")) {
fill_ar = GF_TRUE;
} else if (!strcmp(arg, "-show")) {
visible = 1;
} else if (!strcmp(arg, "-uncache")) {
do_uncache = GF_TRUE;
}
else if (!strcmp(arg, "-exit")) auto_exit = GF_TRUE;
else if (!stricmp(arg, "-views")) {
views = argv[i+1];
i++;
}
else if (!stricmp(arg, "-mosaic")) {
mosaic = argv[i+1];
i++;
}
else if (!stricmp(arg, "-com")) {
has_command = GF_TRUE;
i++;
}
else if (!stricmp(arg, "-service")) {
initial_service_id = atoi(argv[i+1]);
i++;
}
}
}
if (is_cfg_only) {
gf_cfg_del(cfg_file);
fprintf(stderr, "GPAC Config updated\n");
return 0;
}
if (do_uncache) {
const char *cache_dir = gf_cfg_get_key(cfg_file, "General", "CacheDirectory");
do_flatten_cache(cache_dir);
fprintf(stderr, "GPAC Cache dir %s flattened\n", cache_dir);
gf_cfg_del(cfg_file);
return 0;
}
if (dump_mode && !url_arg ) {
FILE *test;
url_arg = (char *)gf_cfg_get_key(cfg_file, "General", "StartupFile");
test = url_arg ? gf_fopen(url_arg, "rt") : NULL;
if (!test) url_arg = NULL;
else gf_fclose(test);
if (!url_arg) {
fprintf(stderr, "Missing argument for dump\n");
PrintUsage();
if (logfile) gf_fclose(logfile);
return 1;
}
}
if (!gui_mode && !url_arg && (gf_cfg_get_key(cfg_file, "General", "StartupFile") != NULL)) {
gui_mode=1;
}
#ifdef WIN32
if (gui_mode==1) {
const char *opt;
TCHAR buffer[1024];
DWORD res = GetCurrentDirectory(1024, buffer);
buffer[res] = 0;
opt = gf_cfg_get_key(cfg_file, "General", "ModulesDirectory");
if (strstr(opt, buffer)) {
gui_mode=1;
} else {
gui_mode=2;
}
}
#endif
if (gui_mode==1) {
hide_shell(1);
}
if (gui_mode) {
no_prog=1;
gf_set_progress_callback(NULL, progress_quiet);
}
if (!url_arg && simulation_time_in_ms)
simulation_time_in_ms += gf_sys_clock();
#if defined(__DARWIN__) || defined(__APPLE__)
carbon_init();
#endif
if (dump_mode) rti_file = NULL;
if (!logs_set) {
gf_log_set_tool_level(GF_LOG_ALL, GF_LOG_WARNING);
}
//only override default log callback when needed
if (rti_file || logfile || log_utc_time || log_time_start)
gf_log_set_callback(NULL, on_gpac_log);
if (rti_file) init_rti_logs(rti_file, url_arg, use_rtix);
{
GF_SystemRTInfo rti;
if (gf_sys_get_rti(0, &rti, 0))
fprintf(stderr, "System info: %d MB RAM - %d cores\n", (u32) (rti.physical_memory/1024/1024), rti.nb_cores);
}
/*setup dumping options*/
if (dump_mode) {
user.init_flags |= GF_TERM_NO_DECODER_THREAD | GF_TERM_NO_COMPOSITOR_THREAD | GF_TERM_NO_REGULATION;
if (!visible)
user.init_flags |= GF_TERM_INIT_HIDE;
gf_cfg_set_key(cfg_file, "Audio", "DriverName", "Raw Audio Output");
no_cfg_save=GF_TRUE;
} else {
init_w = forced_width;
init_h = forced_height;
}
user.modules = gf_modules_new(NULL, cfg_file);
if (user.modules) i = gf_modules_get_count(user.modules);
if (!i || !user.modules) {
fprintf(stderr, "Error: no modules found - exiting\n");
if (user.modules) gf_modules_del(user.modules);
gf_cfg_del(cfg_file);
gf_sys_close();
if (logfile) gf_fclose(logfile);
return 1;
}
fprintf(stderr, "Modules Found : %d \n", i);
str = gf_cfg_get_key(cfg_file, "General", "GPACVersion");
if (!str || strcmp(str, GPAC_FULL_VERSION)) {
gf_cfg_del_section(cfg_file, "PluginsCache");
gf_cfg_set_key(cfg_file, "General", "GPACVersion", GPAC_FULL_VERSION);
}
user.config = cfg_file;
user.EventProc = GPAC_EventProc;
/*dummy in this case (global vars) but MUST be non-NULL*/
user.opaque = user.modules;
if (threading_flags) user.init_flags |= threading_flags;
if (no_audio) user.init_flags |= GF_TERM_NO_AUDIO;
if (no_regulation) user.init_flags |= GF_TERM_NO_REGULATION;
if (threading_flags & (GF_TERM_NO_DECODER_THREAD|GF_TERM_NO_COMPOSITOR_THREAD) ) term_step = GF_TRUE;
//in dump mode we don't want to rely on system clock but on the number of samples being consumed
if (dump_mode) user.init_flags |= GF_TERM_USE_AUDIO_HW_CLOCK;
if (bench_mode) {
gf_cfg_discard_changes(user.config);
auto_exit = GF_TRUE;
gf_cfg_set_key(user.config, "Audio", "DriverName", "Raw Audio Output");
if (bench_mode!=2) {
gf_cfg_set_key(user.config, "Video", "DriverName", "Raw Video Output");
gf_cfg_set_key(user.config, "RAWVideo", "RawOutput", "null");
gf_cfg_set_key(user.config, "Compositor", "OpenGLMode", "disable");
} else {
gf_cfg_set_key(user.config, "Video", "DisableVSync", "yes");
}
}
{
char dim[50];
sprintf(dim, "%d", forced_width);
gf_cfg_set_key(user.config, "Compositor", "DefaultWidth", forced_width ? dim : NULL);
sprintf(dim, "%d", forced_height);
gf_cfg_set_key(user.config, "Compositor", "DefaultHeight", forced_height ? dim : NULL);
}
fprintf(stderr, "Loading GPAC Terminal\n");
i = gf_sys_clock();
term = gf_term_new(&user);
if (!term) {
fprintf(stderr, "\nInit error - check you have at least one video out and one rasterizer...\nFound modules:\n");
list_modules(user.modules);
gf_modules_del(user.modules);
gf_cfg_discard_changes(cfg_file);
gf_cfg_del(cfg_file);
gf_sys_close();
if (logfile) gf_fclose(logfile);
return 1;
}
fprintf(stderr, "Terminal Loaded in %d ms\n", gf_sys_clock()-i);
if (bench_mode) {
display_rti = 2;
gf_term_set_option(term, GF_OPT_VIDEO_BENCH, (bench_mode==3) ? 2 : 1);
if (bench_mode==1) bench_mode=2;
}
if (dump_mode) {
// gf_term_set_option(term, GF_OPT_VISIBLE, 0);
if (fill_ar) gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_FILL_SCREEN);
} else {
/*check video output*/
str = gf_cfg_get_key(cfg_file, "Video", "DriverName");
if (!bench_mode && !strcmp(str, "Raw Video Output")) fprintf(stderr, "WARNING: using raw output video (memory only) - no display used\n");
/*check audio output*/
str = gf_cfg_get_key(cfg_file, "Audio", "DriverName");
if (!str || !strcmp(str, "No Audio Output Available")) fprintf(stderr, "WARNING: no audio output available - make sure no other program is locking the sound card\n");
str = gf_cfg_get_key(cfg_file, "General", "NoMIMETypeFetch");
no_mime_check = (str && !stricmp(str, "yes")) ? 1 : 0;
}
str = gf_cfg_get_key(cfg_file, "HTTPProxy", "Enabled");
if (str && !strcmp(str, "yes")) {
str = gf_cfg_get_key(cfg_file, "HTTPProxy", "Name");
if (str) fprintf(stderr, "HTTP Proxy %s enabled\n", str);
}
if (rti_file) {
str = gf_cfg_get_key(cfg_file, "General", "RTIRefreshPeriod");
if (str) {
rti_update_time_ms = atoi(str);
} else {
gf_cfg_set_key(cfg_file, "General", "RTIRefreshPeriod", "200");
}
UpdateRTInfo("At GPAC load time\n");
}
Run = 1;
if (dump_mode) {
if (!nb_times) {
times[0] = 0;
nb_times++;
}
ret_val = dump_file(url_arg, out_arg, dump_mode, fps, forced_width, forced_height, scale, times, nb_times);
Run = 0;
}
else if (views) {
}
/*connect if requested*/
else if (!gui_mode && url_arg) {
char *ext;
strcpy(the_url, url_arg);
ext = strrchr(the_url, '.');
if (ext && (!stricmp(ext, ".m3u") || !stricmp(ext, ".pls"))) {
GF_Err e = GF_OK;
fprintf(stderr, "Opening Playlist %s\n", the_url);
strcpy(pl_path, the_url);
/*this is not clean, we need to have a plugin handle playlist for ourselves*/
if (!strncmp("http:", the_url, 5)) {
GF_DownloadSession *sess = gf_dm_sess_new(term->downloader, the_url, GF_NETIO_SESSION_NOT_THREADED, NULL, NULL, &e);
if (sess) {
e = gf_dm_sess_process(sess);
if (!e) strcpy(the_url, gf_dm_sess_get_cache_name(sess));
gf_dm_sess_del(sess);
}
}
playlist = e ? NULL : gf_fopen(the_url, "rt");
readonly_playlist = 1;
if (playlist) {
request_next_playlist_item = GF_TRUE;
} else {
if (e)
fprintf(stderr, "Failed to open playlist %s: %s\n", the_url, gf_error_to_string(e) );
fprintf(stderr, "Hit 'h' for help\n\n");
}
} else {
fprintf(stderr, "Opening URL %s\n", the_url);
if (pause_at_first) fprintf(stderr, "[Status: Paused]\n");
gf_term_connect_from_time(term, the_url, (u64) (play_from*1000), pause_at_first);
}
} else {
fprintf(stderr, "Hit 'h' for help\n\n");
str = gf_cfg_get_key(cfg_file, "General", "StartupFile");
if (str) {
strcpy(the_url, "MP4Client "GPAC_FULL_VERSION);
gf_term_connect(term, str);
startup_file = 1;
is_connected = 1;
}
}
if (gui_mode==2) gui_mode=0;
if (start_fs) gf_term_set_option(term, GF_OPT_FULLSCREEN, 1);
if (views) {
char szTemp[4046];
sprintf(szTemp, "views://%s", views);
gf_term_connect(term, szTemp);
}
if (mosaic) {
char szTemp[4046];
sprintf(szTemp, "mosaic://%s", mosaic);
gf_term_connect(term, szTemp);
}
if (bench_mode) {
rti_update_time_ms = 500;
bench_mode_start = gf_sys_clock();
}
while (Run) {
/*we don't want getchar to block*/
if ((gui_mode==1) || !gf_prompt_has_input()) {
if (reload) {
reload = 0;
gf_term_disconnect(term);
gf_term_connect(term, startup_file ? gf_cfg_get_key(cfg_file, "General", "StartupFile") : the_url);
}
if (restart && gf_term_get_option(term, GF_OPT_IS_OVER)) {
restart = 0;
gf_term_play_from_time(term, 0, 0);
}
if (request_next_playlist_item) {
c = '\n';
request_next_playlist_item = 0;
goto force_input;
}
if (has_command && is_connected) {
has_command = GF_FALSE;
for (i=0; i<(u32)argc; i++) {
if (!strcmp(argv[i], "-com")) {
gf_term_scene_update(term, NULL, argv[i+1]);
i++;
}
}
}
if (initial_service_id && is_connected) {
GF_ObjectManager *root_od = gf_term_get_root_object(term);
if (root_od) {
gf_term_select_service(term, root_od, initial_service_id);
initial_service_id = 0;
}
}
if (!use_rtix || display_rti) UpdateRTInfo(NULL);
if (term_step) {
gf_term_process_step(term);
} else {
gf_sleep(rti_update_time_ms);
}
if (auto_exit && eos_seen && gf_term_get_option(term, GF_OPT_IS_OVER)) {
Run = GF_FALSE;
}
/*sim time*/
if (simulation_time_in_ms
&& ( (gf_term_get_elapsed_time_in_ms(term)>simulation_time_in_ms) || (!url_arg && gf_sys_clock()>simulation_time_in_ms))
) {
Run = GF_FALSE;
}
continue;
}
c = gf_prompt_get_char();
force_input:
switch (c) {
case 'q':
{
GF_Event evt;
memset(&evt, 0, sizeof(GF_Event));
evt.type = GF_EVENT_QUIT;
gf_term_send_event(term, &evt);
}
// Run = 0;
break;
case 'X':
exit(0);
break;
case 'Q':
break;
case 'o':
startup_file = 0;
gf_term_disconnect(term);
fprintf(stderr, "Enter the absolute URL\n");
if (1 > scanf("%s", the_url)) {
fprintf(stderr, "Cannot read absolute URL, aborting\n");
break;
}
if (rti_file) init_rti_logs(rti_file, the_url, use_rtix);
gf_term_connect(term, the_url);
break;
case 'O':
gf_term_disconnect(term);
fprintf(stderr, "Enter the absolute URL to the playlist\n");
if (1 > scanf("%s", the_url)) {
fprintf(stderr, "Cannot read the absolute URL, aborting.\n");
break;
}
playlist = gf_fopen(the_url, "rt");
if (playlist) {
if (1 > fscanf(playlist, "%s", the_url)) {
fprintf(stderr, "Cannot read any URL from playlist, aborting.\n");
gf_fclose( playlist);
break;
}
fprintf(stderr, "Opening URL %s\n", the_url);
gf_term_connect(term, the_url);
}
break;
case '\n':
case 'N':
if (playlist) {
int res;
gf_term_disconnect(term);
res = fscanf(playlist, "%s", the_url);
if ((res == EOF) && loop_at_end) {
fseek(playlist, 0, SEEK_SET);
res = fscanf(playlist, "%s", the_url);
}
if (res == EOF) {
fprintf(stderr, "No more items - exiting\n");
Run = 0;
} else if (the_url[0] == '#') {
request_next_playlist_item = GF_TRUE;
} else {
fprintf(stderr, "Opening URL %s\n", the_url);
gf_term_connect_with_path(term, the_url, pl_path);
}
}
break;
case 'P':
if (playlist) {
u32 count;
gf_term_disconnect(term);
if (1 > scanf("%u", &count)) {
fprintf(stderr, "Cannot read number, aborting.\n");
break;
}
while (count) {
if (fscanf(playlist, "%s", the_url)) {
fprintf(stderr, "Failed to read line, aborting\n");
break;
}
count--;
}
fprintf(stderr, "Opening URL %s\n", the_url);
gf_term_connect(term, the_url);
}
break;
case 'r':
if (is_connected)
reload = 1;
break;
case 'D':
if (is_connected) gf_term_disconnect(term);
break;
case 'p':
if (is_connected) {
Bool is_pause = gf_term_get_option(term, GF_OPT_PLAY_STATE);
fprintf(stderr, "[Status: %s]\n", is_pause ? "Playing" : "Paused");
gf_term_set_option(term, GF_OPT_PLAY_STATE, is_pause ? GF_STATE_PLAYING : GF_STATE_PAUSED);
}
break;
case 's':
if (is_connected) {
gf_term_set_option(term, GF_OPT_PLAY_STATE, GF_STATE_STEP_PAUSE);
fprintf(stderr, "Step time: ");
PrintTime(gf_term_get_time_in_ms(term));
fprintf(stderr, "\n");
}
break;
case 'z':
case 'T':
if (!CanSeek || (Duration<=2000)) {
fprintf(stderr, "scene not seekable\n");
} else {
Double res;
s32 seekTo;
fprintf(stderr, "Duration: ");
PrintTime(Duration);
res = gf_term_get_time_in_ms(term);
if (c=='z') {
res *= 100;
res /= (s64)Duration;
fprintf(stderr, " (current %.2f %%)\nEnter Seek percentage:\n", res);
if (scanf("%d", &seekTo) == 1) {
if (seekTo > 100) seekTo = 100;
res = (Double)(s64)Duration;
res /= 100;
res *= seekTo;
gf_term_play_from_time(term, (u64) (s64) res, 0);
}
} else {
u32 r, h, m, s;
fprintf(stderr, " - Current Time: ");
PrintTime((u64) res);
fprintf(stderr, "\nEnter seek time (Format: s, m:s or h:m:s):\n");
h = m = s = 0;
r =scanf("%d:%d:%d", &h, &m, &s);
if (r==2) {
s = m;
m = h;
h = 0;
}
else if (r==1) {
s = h;
m = h = 0;
}
if (r && (r<=3)) {
u64 time = h*3600 + m*60 + s;
gf_term_play_from_time(term, time*1000, 0);
}
}
}
break;
case 't':
{
if (is_connected) {
fprintf(stderr, "Current Time: ");
PrintTime(gf_term_get_time_in_ms(term));
fprintf(stderr, " - Duration: ");
PrintTime(Duration);
fprintf(stderr, "\n");
}
}
break;
case 'w':
if (is_connected) PrintWorldInfo(term);
break;
case 'v':
if (is_connected) PrintODList(term, NULL, 0, 0, "Root");
break;
case 'i':
if (is_connected) {
u32 ID;
fprintf(stderr, "Enter OD ID (0 for main OD): ");
fflush(stderr);
if (scanf("%ud", &ID) == 1) {
ViewOD(term, ID, (u32)-1, NULL);
} else {
char str_url[GF_MAX_PATH];
if (scanf("%s", str_url) == 1)
ViewOD(term, 0, (u32)-1, str_url);
}
}
break;
case 'j':
if (is_connected) {
u32 num;
do {
fprintf(stderr, "Enter OD number (0 for main OD): ");
fflush(stderr);
} while( 1 > scanf("%ud", &num));
ViewOD(term, (u32)-1, num, NULL);
}
break;
case 'b':
if (is_connected) ViewODs(term, 1);
break;
case 'm':
if (is_connected) ViewODs(term, 0);
break;
case 'l':
list_modules(user.modules);
break;
case 'n':
if (is_connected) set_navigation();
break;
case 'x':
if (is_connected) gf_term_set_option(term, GF_OPT_NAVIGATION_TYPE, 0);
break;
case 'd':
if (is_connected) {
GF_ObjectManager *odm = NULL;
char radname[GF_MAX_PATH], *sExt;
GF_Err e;
u32 i, count, odid;
Bool xml_dump, std_out;
radname[0] = 0;
do {
fprintf(stderr, "Enter Inline OD ID if any or 0 : ");
fflush(stderr);
} while( 1 > scanf("%ud", &odid));
if (odid) {
GF_ObjectManager *root_odm = gf_term_get_root_object(term);
if (!root_odm) break;
count = gf_term_get_object_count(term, root_odm);
for (i=0; i<count; i++) {
GF_MediaInfo info;
odm = gf_term_get_object(term, root_odm, i);
if (gf_term_get_object_info(term, odm, &info) == GF_OK) {
if (info.od->objectDescriptorID==odid) break;
}
odm = NULL;
}
}
do {
fprintf(stderr, "Enter file radical name (+\'.x\' for XML dumping) - \"std\" for stderr: ");
fflush(stderr);
} while( 1 > scanf("%s", radname));
sExt = strrchr(radname, '.');
xml_dump = 0;
if (sExt) {
if (!stricmp(sExt, ".x")) xml_dump = 1;
sExt[0] = 0;
}
std_out = strnicmp(radname, "std", 3) ? 0 : 1;
e = gf_term_dump_scene(term, std_out ? NULL : radname, NULL, xml_dump, 0, odm);
fprintf(stderr, "Dump done (%s)\n", gf_error_to_string(e));
}
break;
case 'c':
PrintGPACConfig();
break;
case '3':
{
Bool use_3d = !gf_term_get_option(term, GF_OPT_USE_OPENGL);
if (gf_term_set_option(term, GF_OPT_USE_OPENGL, use_3d)==GF_OK) {
fprintf(stderr, "Using %s for 2D drawing\n", use_3d ? "OpenGL" : "2D rasterizer");
}
}
break;
case 'k':
{
Bool opt = gf_term_get_option(term, GF_OPT_STRESS_MODE);
opt = !opt;
fprintf(stderr, "Turning stress mode %s\n", opt ? "on" : "off");
gf_term_set_option(term, GF_OPT_STRESS_MODE, opt);
}
break;
case '4':
gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_4_3);
break;
case '5':
gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_16_9);
break;
case '6':
gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_FILL_SCREEN);
break;
case '7':
gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_KEEP);
break;
case 'C':
switch (gf_term_get_option(term, GF_OPT_MEDIA_CACHE)) {
case GF_MEDIA_CACHE_DISABLED:
gf_term_set_option(term, GF_OPT_MEDIA_CACHE, GF_MEDIA_CACHE_ENABLED);
break;
case GF_MEDIA_CACHE_ENABLED:
gf_term_set_option(term, GF_OPT_MEDIA_CACHE, GF_MEDIA_CACHE_DISABLED);
break;
case GF_MEDIA_CACHE_RUNNING:
fprintf(stderr, "Streaming Cache is running - please stop it first\n");
continue;
}
switch (gf_term_get_option(term, GF_OPT_MEDIA_CACHE)) {
case GF_MEDIA_CACHE_ENABLED:
fprintf(stderr, "Streaming Cache Enabled\n");
break;
case GF_MEDIA_CACHE_DISABLED:
fprintf(stderr, "Streaming Cache Disabled\n");
break;
case GF_MEDIA_CACHE_RUNNING:
fprintf(stderr, "Streaming Cache Running\n");
break;
}
break;
case 'S':
case 'A':
if (gf_term_get_option(term, GF_OPT_MEDIA_CACHE)==GF_MEDIA_CACHE_RUNNING) {
gf_term_set_option(term, GF_OPT_MEDIA_CACHE, (c=='S') ? GF_MEDIA_CACHE_DISABLED : GF_MEDIA_CACHE_DISCARD);
fprintf(stderr, "Streaming Cache stopped\n");
} else {
fprintf(stderr, "Streaming Cache not running\n");
}
break;
case 'R':
display_rti = !display_rti;
ResetCaption();
break;
case 'F':
if (display_rti) display_rti = 0;
else display_rti = 2;
ResetCaption();
break;
case 'u':
{
GF_Err e;
char szCom[8192];
fprintf(stderr, "Enter command to send:\n");
fflush(stdin);
szCom[0] = 0;
if (1 > scanf("%[^\t\n]", szCom)) {
fprintf(stderr, "Cannot read command to send, aborting.\n");
break;
}
e = gf_term_scene_update(term, NULL, szCom);
if (e) fprintf(stderr, "Processing command failed: %s\n", gf_error_to_string(e));
}
break;
case 'e':
{
GF_Err e;
char jsCode[8192];
fprintf(stderr, "Enter JavaScript code to evaluate:\n");
fflush(stdin);
jsCode[0] = 0;
if (1 > scanf("%[^\t\n]", jsCode)) {
fprintf(stderr, "Cannot read code to evaluate, aborting.\n");
break;
}
e = gf_term_scene_update(term, "application/ecmascript", jsCode);
if (e) fprintf(stderr, "Processing JS code failed: %s\n", gf_error_to_string(e));
}
break;
case 'L':
{
char szLog[1024], *cur_logs;
cur_logs = gf_log_get_tools_levels();
fprintf(stderr, "Enter new log level (current tools %s):\n", cur_logs);
gf_free(cur_logs);
if (scanf("%s", szLog) < 1) {
fprintf(stderr, "Cannot read new log level, aborting.\n");
break;
}
gf_log_modify_tools_levels(szLog);
}
break;
case 'g':
{
GF_SystemRTInfo rti;
gf_sys_get_rti(rti_update_time_ms, &rti, 0);
fprintf(stderr, "GPAC allocated memory "LLD"\n", rti.gpac_memory);
}
break;
case 'M':
{
u32 size;
do {
fprintf(stderr, "Enter new video cache memory in kBytes (current %ud):\n", gf_term_get_option(term, GF_OPT_VIDEO_CACHE_SIZE));
} while (1 > scanf("%ud", &size));
gf_term_set_option(term, GF_OPT_VIDEO_CACHE_SIZE, size);
}
break;
case 'H':
{
u32 http_bitrate = gf_term_get_option(term, GF_OPT_HTTP_MAX_RATE);
do {
fprintf(stderr, "Enter new http bitrate in bps (0 for none) - current limit: %d\n", http_bitrate);
} while (1 > scanf("%ud", &http_bitrate));
gf_term_set_option(term, GF_OPT_HTTP_MAX_RATE, http_bitrate);
}
break;
case 'E':
gf_term_set_option(term, GF_OPT_RELOAD_CONFIG, 1);
break;
case 'B':
switch_bench(!bench_mode);
break;
case 'Y':
{
char szOpt[8192];
fprintf(stderr, "Enter option to set (Section:Name=Value):\n");
fflush(stdin);
szOpt[0] = 0;
if (1 > scanf("%[^\t\n]", szOpt)) {
fprintf(stderr, "Cannot read option\n");
break;
}
set_cfg_option(szOpt);
}
break;
/*extract to PNG*/
case 'Z':
{
char szFileName[100];
u32 nb_pass, nb_views, offscreen_view = 0;
GF_VideoSurface fb;
GF_Err e;
nb_pass = 1;
nb_views = gf_term_get_option(term, GF_OPT_NUM_STEREO_VIEWS);
if (nb_views>1) {
fprintf(stderr, "Auto-stereo mode detected - type number of view to dump (0 is main output, 1 to %d offscreen view, %d for all offscreen, %d for all offscreen and main)\n", nb_views, nb_views+1, nb_views+2);
if (scanf("%d", &offscreen_view) != 1) {
offscreen_view = 0;
}
if (offscreen_view==nb_views+1) {
offscreen_view = 1;
nb_pass = nb_views;
}
else if (offscreen_view==nb_views+2) {
offscreen_view = 0;
nb_pass = nb_views+1;
}
}
while (nb_pass) {
nb_pass--;
if (offscreen_view) {
sprintf(szFileName, "view%d_dump.png", offscreen_view);
e = gf_term_get_offscreen_buffer(term, &fb, offscreen_view-1, 0);
} else {
sprintf(szFileName, "gpac_video_dump_"LLU".png", gf_net_get_utc() );
e = gf_term_get_screen_buffer(term, &fb);
}
offscreen_view++;
if (e) {
fprintf(stderr, "Error dumping screen buffer %s\n", gf_error_to_string(e) );
nb_pass = 0;
} else {
#ifndef GPAC_DISABLE_AV_PARSERS
u32 dst_size = fb.width*fb.height*4;
char *dst = (char*)gf_malloc(sizeof(char)*dst_size);
e = gf_img_png_enc(fb.video_buffer, fb.width, fb.height, fb.pitch_y, fb.pixel_format, dst, &dst_size);
if (e) {
fprintf(stderr, "Error encoding PNG %s\n", gf_error_to_string(e) );
nb_pass = 0;
} else {
FILE *png = gf_fopen(szFileName, "wb");
if (!png) {
fprintf(stderr, "Error writing file %s\n", szFileName);
nb_pass = 0;
} else {
gf_fwrite(dst, dst_size, 1, png);
gf_fclose(png);
fprintf(stderr, "Dump to %s\n", szFileName);
}
}
if (dst) gf_free(dst);
gf_term_release_screen_buffer(term, &fb);
#endif //GPAC_DISABLE_AV_PARSERS
}
}
fprintf(stderr, "Done: %s\n", szFileName);
}
break;
case 'G':
{
GF_ObjectManager *root_od, *odm;
u32 index;
char szOpt[8192];
fprintf(stderr, "Enter 0-based index of object to select or service ID:\n");
fflush(stdin);
szOpt[0] = 0;
if (1 > scanf("%[^\t\n]", szOpt)) {
fprintf(stderr, "Cannot read OD ID\n");
break;
}
index = atoi(szOpt);
odm = NULL;
root_od = gf_term_get_root_object(term);
if (root_od) {
if ( gf_term_find_service(term, root_od, index)) {
gf_term_select_service(term, root_od, index);
} else {
fprintf(stderr, "Cannot find service %d - trying with object index\n", index);
odm = gf_term_get_object(term, root_od, index);
if (odm) {
gf_term_select_object(term, odm);
} else {
fprintf(stderr, "Cannot find object at index %d\n", index);
}
}
}
}
break;
case 'h':
PrintHelp();
break;
default:
break;
}
}
if (bench_mode) {
PrintAVInfo(GF_TRUE);
}
/*FIXME: we have an issue in cleaning up after playing in bench mode and run-for 0 (buildbot tests). We for now disable error checks after run-for is done*/
if (simulation_time_in_ms) {
gf_log_set_strict_error(0);
}
i = gf_sys_clock();
gf_term_disconnect(term);
if (rti_file) UpdateRTInfo("Disconnected\n");
fprintf(stderr, "Deleting terminal... ");
if (playlist) gf_fclose(playlist);
#if defined(__DARWIN__) || defined(__APPLE__)
carbon_uninit();
#endif
gf_term_del(term);
fprintf(stderr, "done (in %d ms) - ran for %d ms\n", gf_sys_clock() - i, gf_sys_clock());
fprintf(stderr, "GPAC cleanup ...\n");
gf_modules_del(user.modules);
if (no_cfg_save)
gf_cfg_discard_changes(cfg_file);
gf_cfg_del(cfg_file);
gf_sys_close();
if (rti_logs) gf_fclose(rti_logs);
if (logfile) gf_fclose(logfile);
if (gui_mode) {
hide_shell(2);
}
#ifdef GPAC_MEMORY_TRACKING
if (mem_track && (gf_memory_size() || gf_file_handles_count() )) {
gf_log_set_tool_level(GF_LOG_MEMORY, GF_LOG_INFO);
gf_memory_print();
return 2;
}
#endif
return ret_val;
} | 6867 | True | 1 |
CVE-2018-20761 | 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.0/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/gpac/gpac/issues/1186', 'name': 'https://github.com/gpac/gpac/issues/1186', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/35ab4475a7df9b2a4bcab235e379c0c3ec543658', 'name': 'https://github.com/gpac/gpac/commit/35ab4475a7df9b2a4bcab235e379c0c3ec543658', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2019/02/msg00040.html', 'name': '[debian-lts-announce] 20190227 [SECURITY] [DLA 1693-1] gpac security update', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://usn.ubuntu.com/3926-1/', 'name': 'USN-3926-1', 'refsource': 'UBUNTU', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-119'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac_project:gpac:*:*:*:*:*:*:*:*', 'versionEndIncluding': '0.7.1', 'cpe_name': []}]}, {'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:o:canonical:ubuntu_linux:16.04:*:*:*:lts:*:*:*', 'cpe_name': []}, {'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': []}]}] | [{'lang': 'en', 'value': 'GPAC version 0.7.1 and earlier has a Buffer Overflow vulnerability in the gf_sm_load_init function in scene_manager.c in libgpac_static.a.'}] | 2019-04-15T18:58Z | 2019-02-06T23: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 | Aurelien David | 2019-01-11 11:32:54+01:00 | fix some overflows due to strcpy
fixes #1184, #1186, #1187 among other things | 35ab4475a7df9b2a4bcab235e379c0c3ec543658 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | FFD_CanHandleURL | FFD_CanHandleURL( GF_InputService * plug , const char * url) | ['plug', 'url'] | static Bool FFD_CanHandleURL(GF_InputService *plug, const char *url)
{
Bool has_audio, has_video;
s32 i;
AVFormatContext *ctx;
AVOutputFormat *fmt_out;
Bool ret = GF_FALSE;
char *ext, szName[1000], szExt[20];
const char *szExtList;
FFDemux *ffd;
if (!plug || !url)
return GF_FALSE;
/*disable RTP/RTSP from ffmpeg*/
if (!strnicmp(url, "rtsp://", 7)) return GF_FALSE;
if (!strnicmp(url, "rtspu://", 8)) return GF_FALSE;
if (!strnicmp(url, "rtp://", 6)) return GF_FALSE;
if (!strnicmp(url, "plato://", 8)) return GF_FALSE;
if (!strnicmp(url, "udp://", 6)) return GF_FALSE;
if (!strnicmp(url, "tcp://", 6)) return GF_FALSE;
if (!strnicmp(url, "data:", 5)) return GF_FALSE;
ffd = (FFDemux*)plug->priv;
strcpy(szName, url);
ext = strrchr(szName, '#');
if (ext) ext[0] = 0;
ext = strrchr(szName, '?');
if (ext) ext[0] = 0;
ext = strrchr(szName, '.');
if (ext && strlen(ext) > 19) ext = NULL;
if (ext && strlen(ext) > 1) {
strcpy(szExt, &ext[1]);
strlwr(szExt);
#ifndef FFMPEG_DEMUX_ENABLE_MPEG2TS
if (strstr("ts m2t mts dmb trp", szExt) ) return GF_FALSE;
#endif
/*note we forbid ffmpeg to handle files we support*/
if (!strcmp(szExt, "mp4") || !strcmp(szExt, "mpg4") || !strcmp(szExt, "m4a") || !strcmp(szExt, "m21")
|| !strcmp(szExt, "m4v") || !strcmp(szExt, "m4a")
|| !strcmp(szExt, "m4s") || !strcmp(szExt, "3gs")
|| !strcmp(szExt, "3gp") || !strcmp(szExt, "3gpp") || !strcmp(szExt, "3gp2") || !strcmp(szExt, "3g2")
|| !strcmp(szExt, "mp3")
|| !strcmp(szExt, "ac3")
|| !strcmp(szExt, "amr")
|| !strcmp(szExt, "bt") || !strcmp(szExt, "wrl") || !strcmp(szExt, "x3dv")
|| !strcmp(szExt, "xmt") || !strcmp(szExt, "xmta") || !strcmp(szExt, "x3d")
|| !strcmp(szExt, "jpg") || !strcmp(szExt, "jpeg") || !strcmp(szExt, "png")
) return GF_FALSE;
/*check any default stuff that should work with ffmpeg*/
{
u32 i;
for (i = 0 ; FFD_MIME_TYPES[i]; i+=3) {
if (gf_service_check_mime_register(plug, FFD_MIME_TYPES[i], FFD_MIME_TYPES[i+1], FFD_MIME_TYPES[i+2], ext))
return GF_TRUE;
}
}
}
ffd_parse_options(ffd, url);
ctx = NULL;
if (open_file(&ctx, szName, NULL, ffd->options ? &ffd->options : NULL)<0) {
AVInputFormat *av_in = NULL;
/*some extensions not supported by ffmpeg*/
if (ext && !strcmp(szExt, "cmp")) av_in = av_find_input_format("m4v");
if (open_file(&ctx, szName, av_in, ffd->options ? &ffd->options : NULL)<0) {
return GF_FALSE;
}
}
if (!ctx) goto exit;
if (av_find_stream_info(ctx) <0) goto exit;
/*figure out if we can use codecs or not*/
has_video = has_audio = GF_FALSE;
for(i = 0; i < (s32)ctx->nb_streams; i++) {
AVCodecContext *enc = ctx->streams[i]->codec;
switch(enc->codec_type) {
case AVMEDIA_TYPE_AUDIO:
if (!has_audio) has_audio = GF_TRUE;
break;
case AVMEDIA_TYPE_VIDEO:
if (!has_video) has_video= GF_TRUE;
break;
default:
break;
}
}
if (!has_audio && !has_video) goto exit;
ret = GF_TRUE;
#if ((LIBAVFORMAT_VERSION_MAJOR == 52) && (LIBAVFORMAT_VERSION_MINOR <= 47)) || (LIBAVFORMAT_VERSION_MAJOR < 52)
fmt_out = guess_stream_format(NULL, url, NULL);
#else
fmt_out = av_guess_format(NULL, url, NULL);
#endif
if (fmt_out) gf_service_register_mime(plug, fmt_out->mime_type, fmt_out->extensions, fmt_out->name);
else {
ext = strrchr(szName, '.');
if (ext) {
strcpy(szExt, &ext[1]);
strlwr(szExt);
szExtList = gf_modules_get_option((GF_BaseInterface *)plug, "MimeTypes", "application/x-ffmpeg");
if (!szExtList) {
gf_service_register_mime(plug, "application/x-ffmpeg", szExt, "Other Movies (FFMPEG)");
} else if (!strstr(szExtList, szExt)) {
u32 len;
char *buf;
len = (u32) (strlen(szExtList) + strlen(szExt) + 10);
buf = (char*)gf_malloc(sizeof(char)*len);
sprintf(buf, "\"%s ", szExt);
strcat(buf, &szExtList[1]);
gf_modules_set_option((GF_BaseInterface *)plug, "MimeTypes", "application/x-ffmpeg", buf);
gf_free(buf);
}
}
}
exit:
#if FF_API_CLOSE_INPUT_FILE
if (ctx) av_close_input_file(ctx);
#else
if (ctx) avformat_close_input(&ctx);
#endif
return ret;
} | 981 | True | 1 |
CVE-2018-20762 | 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.0/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/gpac/gpac/issues/1187', 'name': 'https://github.com/gpac/gpac/issues/1187', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/35ab4475a7df9b2a4bcab235e379c0c3ec543658', 'name': 'https://github.com/gpac/gpac/commit/35ab4475a7df9b2a4bcab235e379c0c3ec543658', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2019/02/msg00040.html', 'name': '[debian-lts-announce] 20190227 [SECURITY] [DLA 1693-1] gpac security update', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://usn.ubuntu.com/3926-1/', 'name': 'USN-3926-1', 'refsource': 'UBUNTU', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-119'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac_project:gpac:*:*:*:*:*:*:*:*', 'versionEndIncluding': '0.7.1', 'cpe_name': []}]}, {'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:o:canonical:ubuntu_linux:16.04:*:*:*:lts:*:*:*', 'cpe_name': []}, {'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': []}]}] | [{'lang': 'en', 'value': 'GPAC version 0.7.1 and earlier has a buffer overflow vulnerability in the cat_multiple_files function in applications/mp4box/fileimport.c when MP4Box is used for a local directory containing crafted filenames.'}] | 2019-04-15T18:58Z | 2019-02-06T23: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 | Aurelien David | 2019-01-11 11:32:54+01:00 | fix some overflows due to strcpy
fixes #1184, #1186, #1187 among other things | 35ab4475a7df9b2a4bcab235e379c0c3ec543658 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | FFD_CanHandleURL | FFD_CanHandleURL( GF_InputService * plug , const char * url) | ['plug', 'url'] | static Bool FFD_CanHandleURL(GF_InputService *plug, const char *url)
{
Bool has_audio, has_video;
s32 i;
AVFormatContext *ctx;
AVOutputFormat *fmt_out;
Bool ret = GF_FALSE;
char *ext, szName[1000], szExt[20];
const char *szExtList;
FFDemux *ffd;
if (!plug || !url)
return GF_FALSE;
/*disable RTP/RTSP from ffmpeg*/
if (!strnicmp(url, "rtsp://", 7)) return GF_FALSE;
if (!strnicmp(url, "rtspu://", 8)) return GF_FALSE;
if (!strnicmp(url, "rtp://", 6)) return GF_FALSE;
if (!strnicmp(url, "plato://", 8)) return GF_FALSE;
if (!strnicmp(url, "udp://", 6)) return GF_FALSE;
if (!strnicmp(url, "tcp://", 6)) return GF_FALSE;
if (!strnicmp(url, "data:", 5)) return GF_FALSE;
ffd = (FFDemux*)plug->priv;
strcpy(szName, url);
ext = strrchr(szName, '#');
if (ext) ext[0] = 0;
ext = strrchr(szName, '?');
if (ext) ext[0] = 0;
ext = strrchr(szName, '.');
if (ext && strlen(ext) > 19) ext = NULL;
if (ext && strlen(ext) > 1) {
strcpy(szExt, &ext[1]);
strlwr(szExt);
#ifndef FFMPEG_DEMUX_ENABLE_MPEG2TS
if (strstr("ts m2t mts dmb trp", szExt) ) return GF_FALSE;
#endif
/*note we forbid ffmpeg to handle files we support*/
if (!strcmp(szExt, "mp4") || !strcmp(szExt, "mpg4") || !strcmp(szExt, "m4a") || !strcmp(szExt, "m21")
|| !strcmp(szExt, "m4v") || !strcmp(szExt, "m4a")
|| !strcmp(szExt, "m4s") || !strcmp(szExt, "3gs")
|| !strcmp(szExt, "3gp") || !strcmp(szExt, "3gpp") || !strcmp(szExt, "3gp2") || !strcmp(szExt, "3g2")
|| !strcmp(szExt, "mp3")
|| !strcmp(szExt, "ac3")
|| !strcmp(szExt, "amr")
|| !strcmp(szExt, "bt") || !strcmp(szExt, "wrl") || !strcmp(szExt, "x3dv")
|| !strcmp(szExt, "xmt") || !strcmp(szExt, "xmta") || !strcmp(szExt, "x3d")
|| !strcmp(szExt, "jpg") || !strcmp(szExt, "jpeg") || !strcmp(szExt, "png")
) return GF_FALSE;
/*check any default stuff that should work with ffmpeg*/
{
u32 i;
for (i = 0 ; FFD_MIME_TYPES[i]; i+=3) {
if (gf_service_check_mime_register(plug, FFD_MIME_TYPES[i], FFD_MIME_TYPES[i+1], FFD_MIME_TYPES[i+2], ext))
return GF_TRUE;
}
}
}
ffd_parse_options(ffd, url);
ctx = NULL;
if (open_file(&ctx, szName, NULL, ffd->options ? &ffd->options : NULL)<0) {
AVInputFormat *av_in = NULL;
/*some extensions not supported by ffmpeg*/
if (ext && !strcmp(szExt, "cmp")) av_in = av_find_input_format("m4v");
if (open_file(&ctx, szName, av_in, ffd->options ? &ffd->options : NULL)<0) {
return GF_FALSE;
}
}
if (!ctx) goto exit;
if (av_find_stream_info(ctx) <0) goto exit;
/*figure out if we can use codecs or not*/
has_video = has_audio = GF_FALSE;
for(i = 0; i < (s32)ctx->nb_streams; i++) {
AVCodecContext *enc = ctx->streams[i]->codec;
switch(enc->codec_type) {
case AVMEDIA_TYPE_AUDIO:
if (!has_audio) has_audio = GF_TRUE;
break;
case AVMEDIA_TYPE_VIDEO:
if (!has_video) has_video= GF_TRUE;
break;
default:
break;
}
}
if (!has_audio && !has_video) goto exit;
ret = GF_TRUE;
#if ((LIBAVFORMAT_VERSION_MAJOR == 52) && (LIBAVFORMAT_VERSION_MINOR <= 47)) || (LIBAVFORMAT_VERSION_MAJOR < 52)
fmt_out = guess_stream_format(NULL, url, NULL);
#else
fmt_out = av_guess_format(NULL, url, NULL);
#endif
if (fmt_out) gf_service_register_mime(plug, fmt_out->mime_type, fmt_out->extensions, fmt_out->name);
else {
ext = strrchr(szName, '.');
if (ext) {
strcpy(szExt, &ext[1]);
strlwr(szExt);
szExtList = gf_modules_get_option((GF_BaseInterface *)plug, "MimeTypes", "application/x-ffmpeg");
if (!szExtList) {
gf_service_register_mime(plug, "application/x-ffmpeg", szExt, "Other Movies (FFMPEG)");
} else if (!strstr(szExtList, szExt)) {
u32 len;
char *buf;
len = (u32) (strlen(szExtList) + strlen(szExt) + 10);
buf = (char*)gf_malloc(sizeof(char)*len);
sprintf(buf, "\"%s ", szExt);
strcat(buf, &szExtList[1]);
gf_modules_set_option((GF_BaseInterface *)plug, "MimeTypes", "application/x-ffmpeg", buf);
gf_free(buf);
}
}
}
exit:
#if FF_API_CLOSE_INPUT_FILE
if (ctx) av_close_input_file(ctx);
#else
if (ctx) avformat_close_input(&ctx);
#endif
return ret;
} | 981 | True | 1 |
CVE-2018-20763 | 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.0/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/gpac/gpac/issues/1188', 'name': 'https://github.com/gpac/gpac/issues/1188', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/1c449a34fe0b50aaffb881bfb9d7c5ab0bb18cdd', 'name': 'https://github.com/gpac/gpac/commit/1c449a34fe0b50aaffb881bfb9d7c5ab0bb18cdd', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2019/02/msg00040.html', 'name': '[debian-lts-announce] 20190227 [SECURITY] [DLA 1693-1] gpac security update', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://usn.ubuntu.com/3926-1/', 'name': 'USN-3926-1', 'refsource': 'UBUNTU', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-787'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac_project:gpac:*:*:*:*:*:*:*:*', 'versionEndIncluding': '0.7.1', 'cpe_name': []}]}, {'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:o:canonical:ubuntu_linux:16.04:*:*:*:lts:*:*:*', 'cpe_name': []}, {'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': []}]}] | [{'lang': 'en', 'value': 'In GPAC 0.7.1 and earlier, gf_text_get_utf8_line in media_tools/text_import.c in libgpac_static.a allows an out-of-bounds write because of missing szLineConv bounds checking.'}] | 2019-04-15T18:59Z | 2019-02-06T23:29Z | 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 | Aurelien David | 2019-01-11 14:05:16+01:00 | add some boundary checks on gf_text_get_utf8_line (#1188) | 1c449a34fe0b50aaffb881bfb9d7c5ab0bb18cdd | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | mp4client_main | mp4client_main( int argc , char ** argv) | ['argc', 'argv'] | int mp4client_main(int argc, char **argv)
{
char c;
const char *str;
int ret_val = 0;
u32 i, times[100], nb_times, dump_mode;
u32 simulation_time_in_ms = 0;
u32 initial_service_id = 0;
Bool auto_exit = GF_FALSE;
Bool logs_set = GF_FALSE;
Bool start_fs = GF_FALSE;
Bool use_rtix = GF_FALSE;
Bool pause_at_first = GF_FALSE;
Bool no_cfg_save = GF_FALSE;
Bool is_cfg_only = GF_FALSE;
Double play_from = 0;
#ifdef GPAC_MEMORY_TRACKING
GF_MemTrackerType mem_track = GF_MemTrackerNone;
#endif
Double fps = GF_IMPORT_DEFAULT_FPS;
Bool fill_ar, visible, do_uncache, has_command;
char *url_arg, *out_arg, *the_cfg, *rti_file, *views, *mosaic;
FILE *logfile = NULL;
Float scale = 1;
#ifndef WIN32
dlopen(NULL, RTLD_NOW|RTLD_GLOBAL);
#endif
/*by default use current dir*/
strcpy(the_url, ".");
memset(&user, 0, sizeof(GF_User));
dump_mode = DUMP_NONE;
fill_ar = visible = do_uncache = has_command = GF_FALSE;
url_arg = out_arg = the_cfg = rti_file = views = mosaic = NULL;
nb_times = 0;
times[0] = 0;
/*first locate config file if specified*/
for (i=1; i<(u32) argc; i++) {
char *arg = argv[i];
if (!strcmp(arg, "-c") || !strcmp(arg, "-cfg")) {
the_cfg = argv[i+1];
i++;
}
else if (!strcmp(arg, "-mem-track") || !strcmp(arg, "-mem-track-stack")) {
#ifdef GPAC_MEMORY_TRACKING
mem_track = !strcmp(arg, "-mem-track-stack") ? GF_MemTrackerBackTrace : GF_MemTrackerSimple;
#else
fprintf(stderr, "WARNING - GPAC not compiled with Memory Tracker - ignoring \"%s\"\n", arg);
#endif
} else if (!strcmp(arg, "-gui")) {
gui_mode = 1;
} else if (!strcmp(arg, "-guid")) {
gui_mode = 2;
} else if (!strcmp(arg, "-h") || !strcmp(arg, "-help")) {
PrintUsage();
return 0;
}
}
#ifdef GPAC_MEMORY_TRACKING
gf_sys_init(mem_track);
#else
gf_sys_init(GF_MemTrackerNone);
#endif
gf_sys_set_args(argc, (const char **) argv);
cfg_file = gf_cfg_init(the_cfg, NULL);
if (!cfg_file) {
fprintf(stderr, "Error: Configuration File not found\n");
return 1;
}
/*if logs are specified, use them*/
if (gf_log_set_tools_levels( gf_cfg_get_key(cfg_file, "General", "Logs") ) != GF_OK) {
return 1;
}
if( gf_cfg_get_key(cfg_file, "General", "Logs") != NULL ) {
logs_set = GF_TRUE;
}
if (!gui_mode) {
str = gf_cfg_get_key(cfg_file, "General", "ForceGUI");
if (str && !strcmp(str, "yes")) gui_mode = 1;
}
for (i=1; i<(u32) argc; i++) {
char *arg = argv[i];
if (!strcmp(arg, "-rti")) {
rti_file = argv[i+1];
i++;
} else if (!strcmp(arg, "-rtix")) {
rti_file = argv[i+1];
i++;
use_rtix = GF_TRUE;
} else if (!stricmp(arg, "-size")) {
/*usage of %ud breaks sscanf on MSVC*/
if (sscanf(argv[i+1], "%dx%d", &forced_width, &forced_height) != 2) {
forced_width = forced_height = 0;
}
i++;
} else if (!strcmp(arg, "-quiet")) {
be_quiet = 1;
} else if (!strcmp(arg, "-strict-error")) {
gf_log_set_strict_error(1);
} else if (!strcmp(arg, "-log-file") || !strcmp(arg, "-lf")) {
logfile = gf_fopen(argv[i+1], "wt");
gf_log_set_callback(logfile, on_gpac_log);
i++;
} else if (!strcmp(arg, "-logs") ) {
if (gf_log_set_tools_levels(argv[i+1]) != GF_OK) {
return 1;
}
logs_set = GF_TRUE;
i++;
} else if (!strcmp(arg, "-log-clock") || !strcmp(arg, "-lc")) {
log_time_start = 1;
} else if (!strcmp(arg, "-log-utc") || !strcmp(arg, "-lu")) {
log_utc_time = 1;
}
#if defined(__DARWIN__) || defined(__APPLE__)
else if (!strcmp(arg, "-thread")) threading_flags = 0;
#else
else if (!strcmp(arg, "-no-thread")) threading_flags = GF_TERM_NO_DECODER_THREAD | GF_TERM_NO_COMPOSITOR_THREAD | GF_TERM_WINDOW_NO_THREAD;
#endif
else if (!strcmp(arg, "-no-cthread") || !strcmp(arg, "-no-compositor-thread")) threading_flags |= GF_TERM_NO_COMPOSITOR_THREAD;
else if (!strcmp(arg, "-no-audio")) no_audio = 1;
else if (!strcmp(arg, "-no-regulation")) no_regulation = 1;
else if (!strcmp(arg, "-fs")) start_fs = 1;
else if (!strcmp(arg, "-opt")) {
set_cfg_option(argv[i+1]);
i++;
} else if (!strcmp(arg, "-conf")) {
set_cfg_option(argv[i+1]);
is_cfg_only=GF_TRUE;
i++;
}
else if (!strcmp(arg, "-ifce")) {
gf_cfg_set_key(cfg_file, "Network", "DefaultMCastInterface", argv[i+1]);
i++;
}
else if (!stricmp(arg, "-help")) {
PrintUsage();
return 1;
}
else if (!stricmp(arg, "-noprog")) {
no_prog=1;
gf_set_progress_callback(NULL, progress_quiet);
}
else if (!stricmp(arg, "-no-save") || !stricmp(arg, "--no-save") /*old versions used --n-save ...*/) {
no_cfg_save=1;
}
else if (!stricmp(arg, "-ntp-shift")) {
s32 shift = atoi(argv[i+1]);
i++;
gf_net_set_ntp_shift(shift);
}
else if (!stricmp(arg, "-run-for")) {
simulation_time_in_ms = atoi(argv[i+1]) * 1000;
if (!simulation_time_in_ms)
simulation_time_in_ms = 1; /*1ms*/
i++;
}
else if (!strcmp(arg, "-out")) {
out_arg = argv[i+1];
i++;
}
else if (!stricmp(arg, "-fps")) {
fps = atof(argv[i+1]);
i++;
} else if (!strcmp(arg, "-avi") || !strcmp(arg, "-sha")) {
dump_mode &= 0xFFFF0000;
if (!strcmp(arg, "-sha")) dump_mode |= DUMP_SHA1;
else dump_mode |= DUMP_AVI;
if ((url_arg || (i+2<(u32)argc)) && get_time_list(argv[i+1], times, &nb_times)) {
if (!strcmp(arg, "-avi") && (nb_times!=2) ) {
fprintf(stderr, "Only one time arg found for -avi - check usage\n");
return 1;
}
i++;
}
} else if (!strcmp(arg, "-rgbds")) { /*get dump in rgbds pixel format*/
dump_mode |= DUMP_RGB_DEPTH_SHAPE;
} else if (!strcmp(arg, "-rgbd")) { /*get dump in rgbd pixel format*/
dump_mode |= DUMP_RGB_DEPTH;
} else if (!strcmp(arg, "-depth")) {
dump_mode |= DUMP_DEPTH_ONLY;
} else if (!strcmp(arg, "-bmp")) {
dump_mode &= 0xFFFF0000;
dump_mode |= DUMP_BMP;
if ((url_arg || (i+2<(u32)argc)) && get_time_list(argv[i+1], times, &nb_times)) i++;
} else if (!strcmp(arg, "-png")) {
dump_mode &= 0xFFFF0000;
dump_mode |= DUMP_PNG;
if ((url_arg || (i+2<(u32)argc)) && get_time_list(argv[i+1], times, &nb_times)) i++;
} else if (!strcmp(arg, "-raw")) {
dump_mode &= 0xFFFF0000;
dump_mode |= DUMP_RAW;
if ((url_arg || (i+2<(u32)argc)) && get_time_list(argv[i+1], times, &nb_times)) i++;
} else if (!stricmp(arg, "-scale")) {
sscanf(argv[i+1], "%f", &scale);
i++;
}
else if (!strcmp(arg, "-c") || !strcmp(arg, "-cfg")) {
/* already parsed */
i++;
}
/*arguments only used in non-gui mode*/
if (!gui_mode) {
if (arg[0] != '-') {
if (url_arg) {
fprintf(stderr, "Several input URLs provided (\"%s\", \"%s\"). Check your command-line.\n", url_arg, arg);
return 1;
}
url_arg = arg;
}
else if (!strcmp(arg, "-loop")) loop_at_end = 1;
else if (!strcmp(arg, "-bench")) bench_mode = 1;
else if (!strcmp(arg, "-vbench")) bench_mode = 2;
else if (!strcmp(arg, "-sbench")) bench_mode = 3;
else if (!strcmp(arg, "-no-addon")) enable_add_ons = GF_FALSE;
else if (!strcmp(arg, "-pause")) pause_at_first = 1;
else if (!strcmp(arg, "-play-from")) {
play_from = atof((const char *) argv[i+1]);
i++;
}
else if (!strcmp(arg, "-speed")) {
playback_speed = FLT2FIX( atof((const char *) argv[i+1]) );
if (playback_speed <= 0) playback_speed = FIX_ONE;
i++;
}
else if (!strcmp(arg, "-no-wnd")) user.init_flags |= GF_TERM_WINDOWLESS;
else if (!strcmp(arg, "-no-back")) user.init_flags |= GF_TERM_WINDOW_TRANSPARENT;
else if (!strcmp(arg, "-align")) {
if (argv[i+1][0]=='m') align_mode = 1;
else if (argv[i+1][0]=='b') align_mode = 2;
align_mode <<= 8;
if (argv[i+1][1]=='m') align_mode |= 1;
else if (argv[i+1][1]=='r') align_mode |= 2;
i++;
} else if (!strcmp(arg, "-fill")) {
fill_ar = GF_TRUE;
} else if (!strcmp(arg, "-show")) {
visible = 1;
} else if (!strcmp(arg, "-uncache")) {
do_uncache = GF_TRUE;
}
else if (!strcmp(arg, "-exit")) auto_exit = GF_TRUE;
else if (!stricmp(arg, "-views")) {
views = argv[i+1];
i++;
}
else if (!stricmp(arg, "-mosaic")) {
mosaic = argv[i+1];
i++;
}
else if (!stricmp(arg, "-com")) {
has_command = GF_TRUE;
i++;
}
else if (!stricmp(arg, "-service")) {
initial_service_id = atoi(argv[i+1]);
i++;
}
}
}
if (is_cfg_only) {
gf_cfg_del(cfg_file);
fprintf(stderr, "GPAC Config updated\n");
return 0;
}
if (do_uncache) {
const char *cache_dir = gf_cfg_get_key(cfg_file, "General", "CacheDirectory");
do_flatten_cache(cache_dir);
fprintf(stderr, "GPAC Cache dir %s flattened\n", cache_dir);
gf_cfg_del(cfg_file);
return 0;
}
if (dump_mode && !url_arg ) {
FILE *test;
url_arg = (char *)gf_cfg_get_key(cfg_file, "General", "StartupFile");
test = url_arg ? gf_fopen(url_arg, "rt") : NULL;
if (!test) url_arg = NULL;
else gf_fclose(test);
if (!url_arg) {
fprintf(stderr, "Missing argument for dump\n");
PrintUsage();
if (logfile) gf_fclose(logfile);
return 1;
}
}
if (!gui_mode && !url_arg && (gf_cfg_get_key(cfg_file, "General", "StartupFile") != NULL)) {
gui_mode=1;
}
#ifdef WIN32
if (gui_mode==1) {
const char *opt;
TCHAR buffer[1024];
DWORD res = GetCurrentDirectory(1024, buffer);
buffer[res] = 0;
opt = gf_cfg_get_key(cfg_file, "General", "ModulesDirectory");
if (strstr(opt, buffer)) {
gui_mode=1;
} else {
gui_mode=2;
}
}
#endif
if (gui_mode==1) {
hide_shell(1);
}
if (gui_mode) {
no_prog=1;
gf_set_progress_callback(NULL, progress_quiet);
}
if (!url_arg && simulation_time_in_ms)
simulation_time_in_ms += gf_sys_clock();
#if defined(__DARWIN__) || defined(__APPLE__)
carbon_init();
#endif
if (dump_mode) rti_file = NULL;
if (!logs_set) {
gf_log_set_tool_level(GF_LOG_ALL, GF_LOG_WARNING);
}
//only override default log callback when needed
if (rti_file || logfile || log_utc_time || log_time_start)
gf_log_set_callback(NULL, on_gpac_log);
if (rti_file) init_rti_logs(rti_file, url_arg, use_rtix);
{
GF_SystemRTInfo rti;
if (gf_sys_get_rti(0, &rti, 0))
fprintf(stderr, "System info: %d MB RAM - %d cores\n", (u32) (rti.physical_memory/1024/1024), rti.nb_cores);
}
/*setup dumping options*/
if (dump_mode) {
user.init_flags |= GF_TERM_NO_DECODER_THREAD | GF_TERM_NO_COMPOSITOR_THREAD | GF_TERM_NO_REGULATION;
if (!visible)
user.init_flags |= GF_TERM_INIT_HIDE;
gf_cfg_set_key(cfg_file, "Audio", "DriverName", "Raw Audio Output");
no_cfg_save=GF_TRUE;
} else {
init_w = forced_width;
init_h = forced_height;
}
user.modules = gf_modules_new(NULL, cfg_file);
if (user.modules) i = gf_modules_get_count(user.modules);
if (!i || !user.modules) {
fprintf(stderr, "Error: no modules found - exiting\n");
if (user.modules) gf_modules_del(user.modules);
gf_cfg_del(cfg_file);
gf_sys_close();
if (logfile) gf_fclose(logfile);
return 1;
}
fprintf(stderr, "Modules Found : %d \n", i);
str = gf_cfg_get_key(cfg_file, "General", "GPACVersion");
if (!str || strcmp(str, GPAC_FULL_VERSION)) {
gf_cfg_del_section(cfg_file, "PluginsCache");
gf_cfg_set_key(cfg_file, "General", "GPACVersion", GPAC_FULL_VERSION);
}
user.config = cfg_file;
user.EventProc = GPAC_EventProc;
/*dummy in this case (global vars) but MUST be non-NULL*/
user.opaque = user.modules;
if (threading_flags) user.init_flags |= threading_flags;
if (no_audio) user.init_flags |= GF_TERM_NO_AUDIO;
if (no_regulation) user.init_flags |= GF_TERM_NO_REGULATION;
if (threading_flags & (GF_TERM_NO_DECODER_THREAD|GF_TERM_NO_COMPOSITOR_THREAD) ) term_step = GF_TRUE;
//in dump mode we don't want to rely on system clock but on the number of samples being consumed
if (dump_mode) user.init_flags |= GF_TERM_USE_AUDIO_HW_CLOCK;
if (bench_mode) {
gf_cfg_discard_changes(user.config);
auto_exit = GF_TRUE;
gf_cfg_set_key(user.config, "Audio", "DriverName", "Raw Audio Output");
if (bench_mode!=2) {
gf_cfg_set_key(user.config, "Video", "DriverName", "Raw Video Output");
gf_cfg_set_key(user.config, "RAWVideo", "RawOutput", "null");
gf_cfg_set_key(user.config, "Compositor", "OpenGLMode", "disable");
} else {
gf_cfg_set_key(user.config, "Video", "DisableVSync", "yes");
}
}
{
char dim[50];
sprintf(dim, "%d", forced_width);
gf_cfg_set_key(user.config, "Compositor", "DefaultWidth", forced_width ? dim : NULL);
sprintf(dim, "%d", forced_height);
gf_cfg_set_key(user.config, "Compositor", "DefaultHeight", forced_height ? dim : NULL);
}
fprintf(stderr, "Loading GPAC Terminal\n");
i = gf_sys_clock();
term = gf_term_new(&user);
if (!term) {
fprintf(stderr, "\nInit error - check you have at least one video out and one rasterizer...\nFound modules:\n");
list_modules(user.modules);
gf_modules_del(user.modules);
gf_cfg_discard_changes(cfg_file);
gf_cfg_del(cfg_file);
gf_sys_close();
if (logfile) gf_fclose(logfile);
return 1;
}
fprintf(stderr, "Terminal Loaded in %d ms\n", gf_sys_clock()-i);
if (bench_mode) {
display_rti = 2;
gf_term_set_option(term, GF_OPT_VIDEO_BENCH, (bench_mode==3) ? 2 : 1);
if (bench_mode==1) bench_mode=2;
}
if (dump_mode) {
// gf_term_set_option(term, GF_OPT_VISIBLE, 0);
if (fill_ar) gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_FILL_SCREEN);
} else {
/*check video output*/
str = gf_cfg_get_key(cfg_file, "Video", "DriverName");
if (!bench_mode && !strcmp(str, "Raw Video Output")) fprintf(stderr, "WARNING: using raw output video (memory only) - no display used\n");
/*check audio output*/
str = gf_cfg_get_key(cfg_file, "Audio", "DriverName");
if (!str || !strcmp(str, "No Audio Output Available")) fprintf(stderr, "WARNING: no audio output available - make sure no other program is locking the sound card\n");
str = gf_cfg_get_key(cfg_file, "General", "NoMIMETypeFetch");
no_mime_check = (str && !stricmp(str, "yes")) ? 1 : 0;
}
str = gf_cfg_get_key(cfg_file, "HTTPProxy", "Enabled");
if (str && !strcmp(str, "yes")) {
str = gf_cfg_get_key(cfg_file, "HTTPProxy", "Name");
if (str) fprintf(stderr, "HTTP Proxy %s enabled\n", str);
}
if (rti_file) {
str = gf_cfg_get_key(cfg_file, "General", "RTIRefreshPeriod");
if (str) {
rti_update_time_ms = atoi(str);
} else {
gf_cfg_set_key(cfg_file, "General", "RTIRefreshPeriod", "200");
}
UpdateRTInfo("At GPAC load time\n");
}
Run = 1;
if (dump_mode) {
if (!nb_times) {
times[0] = 0;
nb_times++;
}
ret_val = dump_file(url_arg, out_arg, dump_mode, fps, forced_width, forced_height, scale, times, nb_times);
Run = 0;
}
else if (views) {
}
/*connect if requested*/
else if (!gui_mode && url_arg) {
char *ext;
if (strlen(url_arg) >= sizeof(the_url)) {
fprintf(stderr, "Input url %s is too long, truncating to %d chars.\n", url_arg, (int)(sizeof(the_url) - 1));
strncpy(the_url, url_arg, sizeof(the_url)-1);
the_url[sizeof(the_url) - 1] = 0;
}
else {
strcpy(the_url, url_arg);
}
ext = strrchr(the_url, '.');
if (ext && (!stricmp(ext, ".m3u") || !stricmp(ext, ".pls"))) {
GF_Err e = GF_OK;
fprintf(stderr, "Opening Playlist %s\n", the_url);
strcpy(pl_path, the_url);
/*this is not clean, we need to have a plugin handle playlist for ourselves*/
if (!strncmp("http:", the_url, 5)) {
GF_DownloadSession *sess = gf_dm_sess_new(term->downloader, the_url, GF_NETIO_SESSION_NOT_THREADED, NULL, NULL, &e);
if (sess) {
e = gf_dm_sess_process(sess);
if (!e) {
strncpy(the_url, gf_dm_sess_get_cache_name(sess), sizeof(the_url) - 1);
the_url[sizeof(the_cfg) - 1] = 0;
}
gf_dm_sess_del(sess);
}
}
playlist = e ? NULL : gf_fopen(the_url, "rt");
readonly_playlist = 1;
if (playlist) {
request_next_playlist_item = GF_TRUE;
} else {
if (e)
fprintf(stderr, "Failed to open playlist %s: %s\n", the_url, gf_error_to_string(e) );
fprintf(stderr, "Hit 'h' for help\n\n");
}
} else {
fprintf(stderr, "Opening URL %s\n", the_url);
if (pause_at_first) fprintf(stderr, "[Status: Paused]\n");
gf_term_connect_from_time(term, the_url, (u64) (play_from*1000), pause_at_first);
}
} else {
fprintf(stderr, "Hit 'h' for help\n\n");
str = gf_cfg_get_key(cfg_file, "General", "StartupFile");
if (str) {
strncpy(the_url, "MP4Client "GPAC_FULL_VERSION , sizeof(the_url)-1);
the_url[sizeof(the_url) - 1] = 0;
gf_term_connect(term, str);
startup_file = 1;
is_connected = 1;
}
}
if (gui_mode==2) gui_mode=0;
if (start_fs) gf_term_set_option(term, GF_OPT_FULLSCREEN, 1);
if (views) {
char szTemp[4046];
sprintf(szTemp, "views://%s", views);
gf_term_connect(term, szTemp);
}
if (mosaic) {
char szTemp[4046];
sprintf(szTemp, "mosaic://%s", mosaic);
gf_term_connect(term, szTemp);
}
if (bench_mode) {
rti_update_time_ms = 500;
bench_mode_start = gf_sys_clock();
}
while (Run) {
/*we don't want getchar to block*/
if ((gui_mode==1) || !gf_prompt_has_input()) {
if (reload) {
reload = 0;
gf_term_disconnect(term);
gf_term_connect(term, startup_file ? gf_cfg_get_key(cfg_file, "General", "StartupFile") : the_url);
}
if (restart && gf_term_get_option(term, GF_OPT_IS_OVER)) {
restart = 0;
gf_term_play_from_time(term, 0, 0);
}
if (request_next_playlist_item) {
c = '\n';
request_next_playlist_item = 0;
goto force_input;
}
if (has_command && is_connected) {
has_command = GF_FALSE;
for (i=0; i<(u32)argc; i++) {
if (!strcmp(argv[i], "-com")) {
gf_term_scene_update(term, NULL, argv[i+1]);
i++;
}
}
}
if (initial_service_id && is_connected) {
GF_ObjectManager *root_od = gf_term_get_root_object(term);
if (root_od) {
gf_term_select_service(term, root_od, initial_service_id);
initial_service_id = 0;
}
}
if (!use_rtix || display_rti) UpdateRTInfo(NULL);
if (term_step) {
gf_term_process_step(term);
} else {
gf_sleep(rti_update_time_ms);
}
if (auto_exit && eos_seen && gf_term_get_option(term, GF_OPT_IS_OVER)) {
Run = GF_FALSE;
}
/*sim time*/
if (simulation_time_in_ms
&& ( (gf_term_get_elapsed_time_in_ms(term)>simulation_time_in_ms) || (!url_arg && gf_sys_clock()>simulation_time_in_ms))
) {
Run = GF_FALSE;
}
continue;
}
c = gf_prompt_get_char();
force_input:
switch (c) {
case 'q':
{
GF_Event evt;
memset(&evt, 0, sizeof(GF_Event));
evt.type = GF_EVENT_QUIT;
gf_term_send_event(term, &evt);
}
// Run = 0;
break;
case 'X':
exit(0);
break;
case 'Q':
break;
case 'o':
startup_file = 0;
gf_term_disconnect(term);
fprintf(stderr, "Enter the absolute URL\n");
if (1 > scanf("%s", the_url)) {
fprintf(stderr, "Cannot read absolute URL, aborting\n");
break;
}
if (rti_file) init_rti_logs(rti_file, the_url, use_rtix);
gf_term_connect(term, the_url);
break;
case 'O':
gf_term_disconnect(term);
fprintf(stderr, "Enter the absolute URL to the playlist\n");
if (1 > scanf("%s", the_url)) {
fprintf(stderr, "Cannot read the absolute URL, aborting.\n");
break;
}
playlist = gf_fopen(the_url, "rt");
if (playlist) {
if (1 > fscanf(playlist, "%s", the_url)) {
fprintf(stderr, "Cannot read any URL from playlist, aborting.\n");
gf_fclose( playlist);
break;
}
fprintf(stderr, "Opening URL %s\n", the_url);
gf_term_connect(term, the_url);
}
break;
case '\n':
case 'N':
if (playlist) {
int res;
gf_term_disconnect(term);
res = fscanf(playlist, "%s", the_url);
if ((res == EOF) && loop_at_end) {
fseek(playlist, 0, SEEK_SET);
res = fscanf(playlist, "%s", the_url);
}
if (res == EOF) {
fprintf(stderr, "No more items - exiting\n");
Run = 0;
} else if (the_url[0] == '#') {
request_next_playlist_item = GF_TRUE;
} else {
fprintf(stderr, "Opening URL %s\n", the_url);
gf_term_connect_with_path(term, the_url, pl_path);
}
}
break;
case 'P':
if (playlist) {
u32 count;
gf_term_disconnect(term);
if (1 > scanf("%u", &count)) {
fprintf(stderr, "Cannot read number, aborting.\n");
break;
}
while (count) {
if (fscanf(playlist, "%s", the_url)) {
fprintf(stderr, "Failed to read line, aborting\n");
break;
}
count--;
}
fprintf(stderr, "Opening URL %s\n", the_url);
gf_term_connect(term, the_url);
}
break;
case 'r':
if (is_connected)
reload = 1;
break;
case 'D':
if (is_connected) gf_term_disconnect(term);
break;
case 'p':
if (is_connected) {
Bool is_pause = gf_term_get_option(term, GF_OPT_PLAY_STATE);
fprintf(stderr, "[Status: %s]\n", is_pause ? "Playing" : "Paused");
gf_term_set_option(term, GF_OPT_PLAY_STATE, is_pause ? GF_STATE_PLAYING : GF_STATE_PAUSED);
}
break;
case 's':
if (is_connected) {
gf_term_set_option(term, GF_OPT_PLAY_STATE, GF_STATE_STEP_PAUSE);
fprintf(stderr, "Step time: ");
PrintTime(gf_term_get_time_in_ms(term));
fprintf(stderr, "\n");
}
break;
case 'z':
case 'T':
if (!CanSeek || (Duration<=2000)) {
fprintf(stderr, "scene not seekable\n");
} else {
Double res;
s32 seekTo;
fprintf(stderr, "Duration: ");
PrintTime(Duration);
res = gf_term_get_time_in_ms(term);
if (c=='z') {
res *= 100;
res /= (s64)Duration;
fprintf(stderr, " (current %.2f %%)\nEnter Seek percentage:\n", res);
if (scanf("%d", &seekTo) == 1) {
if (seekTo > 100) seekTo = 100;
res = (Double)(s64)Duration;
res /= 100;
res *= seekTo;
gf_term_play_from_time(term, (u64) (s64) res, 0);
}
} else {
u32 r, h, m, s;
fprintf(stderr, " - Current Time: ");
PrintTime((u64) res);
fprintf(stderr, "\nEnter seek time (Format: s, m:s or h:m:s):\n");
h = m = s = 0;
r =scanf("%d:%d:%d", &h, &m, &s);
if (r==2) {
s = m;
m = h;
h = 0;
}
else if (r==1) {
s = h;
m = h = 0;
}
if (r && (r<=3)) {
u64 time = h*3600 + m*60 + s;
gf_term_play_from_time(term, time*1000, 0);
}
}
}
break;
case 't':
{
if (is_connected) {
fprintf(stderr, "Current Time: ");
PrintTime(gf_term_get_time_in_ms(term));
fprintf(stderr, " - Duration: ");
PrintTime(Duration);
fprintf(stderr, "\n");
}
}
break;
case 'w':
if (is_connected) PrintWorldInfo(term);
break;
case 'v':
if (is_connected) PrintODList(term, NULL, 0, 0, "Root");
break;
case 'i':
if (is_connected) {
u32 ID;
fprintf(stderr, "Enter OD ID (0 for main OD): ");
fflush(stderr);
if (scanf("%ud", &ID) == 1) {
ViewOD(term, ID, (u32)-1, NULL);
} else {
char str_url[GF_MAX_PATH];
if (scanf("%s", str_url) == 1)
ViewOD(term, 0, (u32)-1, str_url);
}
}
break;
case 'j':
if (is_connected) {
u32 num;
do {
fprintf(stderr, "Enter OD number (0 for main OD): ");
fflush(stderr);
} while( 1 > scanf("%ud", &num));
ViewOD(term, (u32)-1, num, NULL);
}
break;
case 'b':
if (is_connected) ViewODs(term, 1);
break;
case 'm':
if (is_connected) ViewODs(term, 0);
break;
case 'l':
list_modules(user.modules);
break;
case 'n':
if (is_connected) set_navigation();
break;
case 'x':
if (is_connected) gf_term_set_option(term, GF_OPT_NAVIGATION_TYPE, 0);
break;
case 'd':
if (is_connected) {
GF_ObjectManager *odm = NULL;
char radname[GF_MAX_PATH], *sExt;
GF_Err e;
u32 i, count, odid;
Bool xml_dump, std_out;
radname[0] = 0;
do {
fprintf(stderr, "Enter Inline OD ID if any or 0 : ");
fflush(stderr);
} while( 1 > scanf("%ud", &odid));
if (odid) {
GF_ObjectManager *root_odm = gf_term_get_root_object(term);
if (!root_odm) break;
count = gf_term_get_object_count(term, root_odm);
for (i=0; i<count; i++) {
GF_MediaInfo info;
odm = gf_term_get_object(term, root_odm, i);
if (gf_term_get_object_info(term, odm, &info) == GF_OK) {
if (info.od->objectDescriptorID==odid) break;
}
odm = NULL;
}
}
do {
fprintf(stderr, "Enter file radical name (+\'.x\' for XML dumping) - \"std\" for stderr: ");
fflush(stderr);
} while( 1 > scanf("%s", radname));
sExt = strrchr(radname, '.');
xml_dump = 0;
if (sExt) {
if (!stricmp(sExt, ".x")) xml_dump = 1;
sExt[0] = 0;
}
std_out = strnicmp(radname, "std", 3) ? 0 : 1;
e = gf_term_dump_scene(term, std_out ? NULL : radname, NULL, xml_dump, 0, odm);
fprintf(stderr, "Dump done (%s)\n", gf_error_to_string(e));
}
break;
case 'c':
PrintGPACConfig();
break;
case '3':
{
Bool use_3d = !gf_term_get_option(term, GF_OPT_USE_OPENGL);
if (gf_term_set_option(term, GF_OPT_USE_OPENGL, use_3d)==GF_OK) {
fprintf(stderr, "Using %s for 2D drawing\n", use_3d ? "OpenGL" : "2D rasterizer");
}
}
break;
case 'k':
{
Bool opt = gf_term_get_option(term, GF_OPT_STRESS_MODE);
opt = !opt;
fprintf(stderr, "Turning stress mode %s\n", opt ? "on" : "off");
gf_term_set_option(term, GF_OPT_STRESS_MODE, opt);
}
break;
case '4':
gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_4_3);
break;
case '5':
gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_16_9);
break;
case '6':
gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_FILL_SCREEN);
break;
case '7':
gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_KEEP);
break;
case 'C':
switch (gf_term_get_option(term, GF_OPT_MEDIA_CACHE)) {
case GF_MEDIA_CACHE_DISABLED:
gf_term_set_option(term, GF_OPT_MEDIA_CACHE, GF_MEDIA_CACHE_ENABLED);
break;
case GF_MEDIA_CACHE_ENABLED:
gf_term_set_option(term, GF_OPT_MEDIA_CACHE, GF_MEDIA_CACHE_DISABLED);
break;
case GF_MEDIA_CACHE_RUNNING:
fprintf(stderr, "Streaming Cache is running - please stop it first\n");
continue;
}
switch (gf_term_get_option(term, GF_OPT_MEDIA_CACHE)) {
case GF_MEDIA_CACHE_ENABLED:
fprintf(stderr, "Streaming Cache Enabled\n");
break;
case GF_MEDIA_CACHE_DISABLED:
fprintf(stderr, "Streaming Cache Disabled\n");
break;
case GF_MEDIA_CACHE_RUNNING:
fprintf(stderr, "Streaming Cache Running\n");
break;
}
break;
case 'S':
case 'A':
if (gf_term_get_option(term, GF_OPT_MEDIA_CACHE)==GF_MEDIA_CACHE_RUNNING) {
gf_term_set_option(term, GF_OPT_MEDIA_CACHE, (c=='S') ? GF_MEDIA_CACHE_DISABLED : GF_MEDIA_CACHE_DISCARD);
fprintf(stderr, "Streaming Cache stopped\n");
} else {
fprintf(stderr, "Streaming Cache not running\n");
}
break;
case 'R':
display_rti = !display_rti;
ResetCaption();
break;
case 'F':
if (display_rti) display_rti = 0;
else display_rti = 2;
ResetCaption();
break;
case 'u':
{
GF_Err e;
char szCom[8192];
fprintf(stderr, "Enter command to send:\n");
fflush(stdin);
szCom[0] = 0;
if (1 > scanf("%[^\t\n]", szCom)) {
fprintf(stderr, "Cannot read command to send, aborting.\n");
break;
}
e = gf_term_scene_update(term, NULL, szCom);
if (e) fprintf(stderr, "Processing command failed: %s\n", gf_error_to_string(e));
}
break;
case 'e':
{
GF_Err e;
char jsCode[8192];
fprintf(stderr, "Enter JavaScript code to evaluate:\n");
fflush(stdin);
jsCode[0] = 0;
if (1 > scanf("%[^\t\n]", jsCode)) {
fprintf(stderr, "Cannot read code to evaluate, aborting.\n");
break;
}
e = gf_term_scene_update(term, "application/ecmascript", jsCode);
if (e) fprintf(stderr, "Processing JS code failed: %s\n", gf_error_to_string(e));
}
break;
case 'L':
{
char szLog[1024], *cur_logs;
cur_logs = gf_log_get_tools_levels();
fprintf(stderr, "Enter new log level (current tools %s):\n", cur_logs);
gf_free(cur_logs);
if (scanf("%s", szLog) < 1) {
fprintf(stderr, "Cannot read new log level, aborting.\n");
break;
}
gf_log_modify_tools_levels(szLog);
}
break;
case 'g':
{
GF_SystemRTInfo rti;
gf_sys_get_rti(rti_update_time_ms, &rti, 0);
fprintf(stderr, "GPAC allocated memory "LLD"\n", rti.gpac_memory);
}
break;
case 'M':
{
u32 size;
do {
fprintf(stderr, "Enter new video cache memory in kBytes (current %ud):\n", gf_term_get_option(term, GF_OPT_VIDEO_CACHE_SIZE));
} while (1 > scanf("%ud", &size));
gf_term_set_option(term, GF_OPT_VIDEO_CACHE_SIZE, size);
}
break;
case 'H':
{
u32 http_bitrate = gf_term_get_option(term, GF_OPT_HTTP_MAX_RATE);
do {
fprintf(stderr, "Enter new http bitrate in bps (0 for none) - current limit: %d\n", http_bitrate);
} while (1 > scanf("%ud", &http_bitrate));
gf_term_set_option(term, GF_OPT_HTTP_MAX_RATE, http_bitrate);
}
break;
case 'E':
gf_term_set_option(term, GF_OPT_RELOAD_CONFIG, 1);
break;
case 'B':
switch_bench(!bench_mode);
break;
case 'Y':
{
char szOpt[8192];
fprintf(stderr, "Enter option to set (Section:Name=Value):\n");
fflush(stdin);
szOpt[0] = 0;
if (1 > scanf("%[^\t\n]", szOpt)) {
fprintf(stderr, "Cannot read option\n");
break;
}
set_cfg_option(szOpt);
}
break;
/*extract to PNG*/
case 'Z':
{
char szFileName[100];
u32 nb_pass, nb_views, offscreen_view = 0;
GF_VideoSurface fb;
GF_Err e;
nb_pass = 1;
nb_views = gf_term_get_option(term, GF_OPT_NUM_STEREO_VIEWS);
if (nb_views>1) {
fprintf(stderr, "Auto-stereo mode detected - type number of view to dump (0 is main output, 1 to %d offscreen view, %d for all offscreen, %d for all offscreen and main)\n", nb_views, nb_views+1, nb_views+2);
if (scanf("%d", &offscreen_view) != 1) {
offscreen_view = 0;
}
if (offscreen_view==nb_views+1) {
offscreen_view = 1;
nb_pass = nb_views;
}
else if (offscreen_view==nb_views+2) {
offscreen_view = 0;
nb_pass = nb_views+1;
}
}
while (nb_pass) {
nb_pass--;
if (offscreen_view) {
sprintf(szFileName, "view%d_dump.png", offscreen_view);
e = gf_term_get_offscreen_buffer(term, &fb, offscreen_view-1, 0);
} else {
sprintf(szFileName, "gpac_video_dump_"LLU".png", gf_net_get_utc() );
e = gf_term_get_screen_buffer(term, &fb);
}
offscreen_view++;
if (e) {
fprintf(stderr, "Error dumping screen buffer %s\n", gf_error_to_string(e) );
nb_pass = 0;
} else {
#ifndef GPAC_DISABLE_AV_PARSERS
u32 dst_size = fb.width*fb.height*4;
char *dst = (char*)gf_malloc(sizeof(char)*dst_size);
e = gf_img_png_enc(fb.video_buffer, fb.width, fb.height, fb.pitch_y, fb.pixel_format, dst, &dst_size);
if (e) {
fprintf(stderr, "Error encoding PNG %s\n", gf_error_to_string(e) );
nb_pass = 0;
} else {
FILE *png = gf_fopen(szFileName, "wb");
if (!png) {
fprintf(stderr, "Error writing file %s\n", szFileName);
nb_pass = 0;
} else {
gf_fwrite(dst, dst_size, 1, png);
gf_fclose(png);
fprintf(stderr, "Dump to %s\n", szFileName);
}
}
if (dst) gf_free(dst);
gf_term_release_screen_buffer(term, &fb);
#endif //GPAC_DISABLE_AV_PARSERS
}
}
fprintf(stderr, "Done: %s\n", szFileName);
}
break;
case 'G':
{
GF_ObjectManager *root_od, *odm;
u32 index;
char szOpt[8192];
fprintf(stderr, "Enter 0-based index of object to select or service ID:\n");
fflush(stdin);
szOpt[0] = 0;
if (1 > scanf("%[^\t\n]", szOpt)) {
fprintf(stderr, "Cannot read OD ID\n");
break;
}
index = atoi(szOpt);
odm = NULL;
root_od = gf_term_get_root_object(term);
if (root_od) {
if ( gf_term_find_service(term, root_od, index)) {
gf_term_select_service(term, root_od, index);
} else {
fprintf(stderr, "Cannot find service %d - trying with object index\n", index);
odm = gf_term_get_object(term, root_od, index);
if (odm) {
gf_term_select_object(term, odm);
} else {
fprintf(stderr, "Cannot find object at index %d\n", index);
}
}
}
}
break;
case 'h':
PrintHelp();
break;
default:
break;
}
}
if (bench_mode) {
PrintAVInfo(GF_TRUE);
}
/*FIXME: we have an issue in cleaning up after playing in bench mode and run-for 0 (buildbot tests). We for now disable error checks after run-for is done*/
if (simulation_time_in_ms) {
gf_log_set_strict_error(0);
}
i = gf_sys_clock();
gf_term_disconnect(term);
if (rti_file) UpdateRTInfo("Disconnected\n");
fprintf(stderr, "Deleting terminal... ");
if (playlist) gf_fclose(playlist);
#if defined(__DARWIN__) || defined(__APPLE__)
carbon_uninit();
#endif
gf_term_del(term);
fprintf(stderr, "done (in %d ms) - ran for %d ms\n", gf_sys_clock() - i, gf_sys_clock());
fprintf(stderr, "GPAC cleanup ...\n");
gf_modules_del(user.modules);
if (no_cfg_save)
gf_cfg_discard_changes(cfg_file);
gf_cfg_del(cfg_file);
gf_sys_close();
if (rti_logs) gf_fclose(rti_logs);
if (logfile) gf_fclose(logfile);
if (gui_mode) {
hide_shell(2);
}
#ifdef GPAC_MEMORY_TRACKING
if (mem_track && (gf_memory_size() || gf_file_handles_count() )) {
gf_log_set_tool_level(GF_LOG_MEMORY, GF_LOG_INFO);
gf_memory_print();
return 2;
}
#endif
return ret_val;
} | 6971 | True | 1 |
CVE-2018-21017 | False | False | False | True | AV:N/AC:M/Au:N/C:N/I:N/A:P | NETWORK | MEDIUM | NONE | NONE | NONE | PARTIAL | 4.3 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H | NETWORK | LOW | NONE | REQUIRED | UNCHANGED | NONE | NONE | HIGH | 6.5 | MEDIUM | 2.8 | 3.6 | False | [{'url': 'https://github.com/gpac/gpac/commit/d2371b4b204f0a3c0af51ad4e9b491144dd1225c', 'name': 'https://github.com/gpac/gpac/commit/d2371b4b204f0a3c0af51ad4e9b491144dd1225c', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/issues/1183', 'name': 'https://github.com/gpac/gpac/issues/1183', 'refsource': 'MISC', 'tags': ['Exploit', 'Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-401'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:0.7.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'GPAC 0.7.1 has a memory leak in dinf_Read in isomedia/box_code_base.c.'}] | 2020-08-24T17:37Z | 2019-09-16T13:15Z | Missing Release of Memory after Effective Lifetime | The software does not sufficiently track and release allocated memory after it has been used, which slowly consumes remaining memory. | This is often triggered by improper handling of malformed data or unexpectedly interrupted sessions. In some languages, developers are responsible for tracking memory allocation and releasing the memory. If there are no more pointers or references to the memory, then it can no longer be tracked and identified for release.
| https://cwe.mitre.org/data/definitions/401.html | 0 | Aurelien David | 2019-04-11 12:58:25+02:00 | prevent dref memleak on invalid input (#1183) | d2371b4b204f0a3c0af51ad4e9b491144dd1225c | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | dinf_Read | dinf_Read( GF_Box * s , GF_BitStream * bs) | ['s', 'bs'] | GF_Err dinf_Read(GF_Box *s, GF_BitStream *bs)
{
GF_Err e = gf_isom_box_array_read(s, bs, dinf_AddBox);
if (e) {
return e;
}
if (!((GF_DataInformationBox *)s)->dref) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Missing dref box in dinf\n"));
((GF_DataInformationBox *)s)->dref = (GF_DataReferenceBox *)gf_isom_box_new(GF_ISOM_BOX_TYPE_DREF);
}
return GF_OK;
} | 81 | True | 1 |
CVE-2020-19488 | 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/gpac/gpac/commit/6170024568f4dda310e98ef7508477b425c58d09', 'name': 'https://github.com/gpac/gpac/commit/6170024568f4dda310e98ef7508477b425c58d09', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/issues/1263', 'name': 'https://github.com/gpac/gpac/issues/1263', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-476'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:0.8.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'An issue was discovered in box_code_apple.c:119 in Gpac MP4Box 0.8.0, allows attackers to cause a Denial of Service due to an invalid read on function ilst_item_Read.'}] | 2021-07-31T00:23Z | 2021-07-21T18: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 | jeanlf | 2019-07-07 16:51:36+02:00 | fixed potential crash - cf #1263 | 6170024568f4dda310e98ef7508477b425c58d09 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | ilst_item_box_read | ilst_item_box_read( GF_Box * s , GF_BitStream * bs) | ['s', 'bs'] | GF_Err ilst_item_box_read(GF_Box *s,GF_BitStream *bs)
{
GF_Err e;
u32 sub_type;
GF_Box *a = NULL;
GF_ListItemBox *ptr = (GF_ListItemBox *)s;
/*iTunes way: there's a data atom containing the data*/
sub_type = gf_bs_peek_bits(bs, 32, 4);
if (sub_type == GF_ISOM_BOX_TYPE_DATA ) {
e = gf_isom_box_parse(&a, bs);
if (!e && ptr->size < a->size) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[isom] not enough bytes in box %s: %d left, reading %d (file %s, line %d)\n", gf_4cc_to_str(ptr->type), ptr->size, a->size, __FILE__, __LINE__ )); \
e = GF_ISOM_INVALID_FILE;
}
if (e) {
if (a) gf_isom_box_del(a);
return e;
}
ISOM_DECREASE_SIZE(ptr, a->size);
if (a && ptr->data) gf_isom_box_del_parent(&ptr->child_boxes, (GF_Box *) ptr->data);
/* otherwise a->data will always overflow */
if (a && a->size > 4 && a->type != GF_ISOM_BOX_TYPE_VOID) {
ptr->data = (GF_DataBox *)a;
if (!ptr->child_boxes) ptr->child_boxes = gf_list_new();
gf_list_add(ptr->child_boxes, ptr->data);
} else {
ptr->data = NULL;
gf_isom_box_del(a);
}
}
/*QT way*/
else {
u64 pos = gf_bs_get_position(bs);
u64 prev_size = s->size;
/*try parsing as generic box list*/
e = gf_isom_box_array_read(s, bs, NULL);
if (e==GF_OK) return GF_OK;
//reset content and retry - this deletes ptr->data !!
gf_isom_box_array_del(s->child_boxes);
s->child_boxes=NULL;
gf_bs_seek(bs, pos);
s->size = prev_size;
ptr->data = (GF_DataBox *)gf_isom_box_new_parent(&ptr->child_boxes, GF_ISOM_BOX_TYPE_DATA);
//nope, check qt-style
ptr->data->qt_style = GF_TRUE;
ISOM_DECREASE_SIZE(ptr, 2);
ptr->data->dataSize = gf_bs_read_u16(bs);
gf_bs_read_u16(bs);
ptr->data->data = (char *) gf_malloc(sizeof(char)*(ptr->data->dataSize + 1));
gf_bs_read_data(bs, ptr->data->data, ptr->data->dataSize);
ptr->data->data[ptr->data->dataSize] = 0;
ISOM_DECREASE_SIZE(ptr, ptr->data->dataSize);
}
return GF_OK;
} | 419 | True | 1 |
CVE-2019-20629 | 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/gpac/gpac/issues/1264', 'name': 'https://github.com/gpac/gpac/issues/1264', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/2320eb73afba753b39b7147be91f7be7afc0eeb7', 'name': 'https://github.com/gpac/gpac/commit/2320eb73afba753b39b7147be91f7be7afc0eeb7', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:*:*:*:*:*:*:*:*', 'versionEndExcluding': '0.8.0', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'An issue was discovered in libgpac.a in GPAC before 0.8.0, as demonstrated by MP4Box. It contains a heap-based buffer over-read in gf_m2ts_process_pmt in media_tools/mpegts.c that can cause a denial of service via a crafted MP4 file.'}] | 2020-03-25T13:51Z | 2020-03-24T19: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 | jeanlf | 2019-07-07 16:55:12+02:00 | fixed potential crash in TS - cf #1264 | 2320eb73afba753b39b7147be91f7be7afc0eeb7 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_m2ts_process_pmt | gf_m2ts_process_pmt( GF_M2TS_Demuxer * ts , GF_M2TS_SECTION_ES * pmt , GF_List * sections , u8 table_id , u16 ex_table_id , u8 version_number , u8 last_section_number , u32 status) | ['ts', 'pmt', 'sections', 'table_id', 'ex_table_id', 'version_number', 'last_section_number', 'status'] | static void gf_m2ts_process_pmt(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *pmt, GF_List *sections, u8 table_id, u16 ex_table_id, u8 version_number, u8 last_section_number, u32 status)
{
u32 info_length, pos, desc_len, evt_type, nb_es,i;
u32 nb_sections;
u32 data_size;
u32 nb_hevc, nb_hevc_temp, nb_shvc, nb_shvc_temp, nb_mhvc, nb_mhvc_temp;
unsigned char *data;
GF_M2TS_Section *section;
GF_Err e = GF_OK;
/*wait for the last section */
if (!(status&GF_M2TS_TABLE_END)) return;
nb_es = 0;
/*skip if already received but no update detected (eg same data) */
if ((status&GF_M2TS_TABLE_REPEAT) && !(status&GF_M2TS_TABLE_UPDATE)) {
if (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_PMT_REPEAT, pmt->program);
return;
}
if (pmt->sec->demux_restarted) {
pmt->sec->demux_restarted = 0;
return;
}
GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[MPEG-2 TS] PMT Found or updated\n"));
nb_sections = gf_list_count(sections);
if (nb_sections > 1) {
GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("PMT on multiple sections not supported\n"));
}
section = (GF_M2TS_Section *)gf_list_get(sections, 0);
data = section->data;
data_size = section->data_size;
pmt->program->pcr_pid = ((data[0] & 0x1f) << 8) | data[1];
info_length = ((data[2]&0xf)<<8) | data[3];
if (info_length != 0) {
/* ...Read Descriptors ... */
u8 tag, len;
u32 first_loop_len = 0;
tag = data[4];
len = data[5];
while (info_length > first_loop_len) {
if (tag == GF_M2TS_MPEG4_IOD_DESCRIPTOR) {
u32 size;
GF_BitStream *iod_bs;
iod_bs = gf_bs_new((char *)data+8, len-2, GF_BITSTREAM_READ);
if (pmt->program->pmt_iod) gf_odf_desc_del((GF_Descriptor *)pmt->program->pmt_iod);
e = gf_odf_parse_descriptor(iod_bs , (GF_Descriptor **) &pmt->program->pmt_iod, &size);
gf_bs_del(iod_bs );
if (e==GF_OK) {
/*remember program number for service/program selection*/
if (pmt->program->pmt_iod) pmt->program->pmt_iod->ServiceID = pmt->program->number;
/*if empty IOD (freebox case), discard it and use dynamic declaration of object*/
if (!gf_list_count(pmt->program->pmt_iod->ESDescriptors)) {
gf_odf_desc_del((GF_Descriptor *)pmt->program->pmt_iod);
pmt->program->pmt_iod = NULL;
}
}
} else if (tag == GF_M2TS_METADATA_POINTER_DESCRIPTOR) {
GF_BitStream *metadatapd_bs;
GF_M2TS_MetadataPointerDescriptor *metapd;
metadatapd_bs = gf_bs_new((char *)data+6, len, GF_BITSTREAM_READ);
metapd = gf_m2ts_read_metadata_pointer_descriptor(metadatapd_bs, len);
gf_bs_del(metadatapd_bs);
if (metapd->application_format_identifier == GF_M2TS_META_ID3 &&
metapd->format_identifier == GF_M2TS_META_ID3 &&
metapd->carriage_flag == METADATA_CARRIAGE_SAME_TS) {
/*HLS ID3 Metadata */
pmt->program->metadata_pointer_descriptor = metapd;
} else {
/* don't know what to do with it for now, delete */
gf_m2ts_metadata_pointer_descriptor_del(metapd);
}
} else {
GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[MPEG-2 TS] Skipping descriptor (0x%x) and others not supported\n", tag));
}
first_loop_len += 2 + len;
}
}
if (data_size <= 4 + info_length) return;
data += 4 + info_length;
data_size -= 4 + info_length;
pos = 0;
/* count de number of program related PMT received */
for(i=0; i<gf_list_count(ts->programs); i++) {
GF_M2TS_Program *prog = (GF_M2TS_Program *)gf_list_get(ts->programs,i);
if(prog->pmt_pid == pmt->pid) {
break;
}
}
nb_hevc = nb_hevc_temp = nb_shvc = nb_shvc_temp = nb_mhvc = nb_mhvc_temp = 0;
while (pos<data_size) {
GF_M2TS_PES *pes = NULL;
GF_M2TS_SECTION_ES *ses = NULL;
GF_M2TS_ES *es = NULL;
Bool inherit_pcr = 0;
u32 pid, stream_type, reg_desc_format;
stream_type = data[0];
pid = ((data[1] & 0x1f) << 8) | data[2];
desc_len = ((data[3] & 0xf) << 8) | data[4];
GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("stream_type :%d \n",stream_type));
switch (stream_type) {
/* PES */
case GF_M2TS_VIDEO_MPEG1:
case GF_M2TS_VIDEO_MPEG2:
case GF_M2TS_VIDEO_DCII:
case GF_M2TS_VIDEO_MPEG4:
case GF_M2TS_SYSTEMS_MPEG4_PES:
case GF_M2TS_VIDEO_H264:
case GF_M2TS_VIDEO_SVC:
case GF_M2TS_VIDEO_MVCD:
case GF_M2TS_VIDEO_HEVC:
case GF_M2TS_VIDEO_HEVC_MCTS:
case GF_M2TS_VIDEO_HEVC_TEMPORAL:
case GF_M2TS_VIDEO_SHVC:
case GF_M2TS_VIDEO_SHVC_TEMPORAL:
case GF_M2TS_VIDEO_MHVC:
case GF_M2TS_VIDEO_MHVC_TEMPORAL:
inherit_pcr = 1;
case GF_M2TS_AUDIO_MPEG1:
case GF_M2TS_AUDIO_MPEG2:
case GF_M2TS_AUDIO_AAC:
case GF_M2TS_AUDIO_LATM_AAC:
case GF_M2TS_AUDIO_AC3:
case GF_M2TS_AUDIO_DTS:
case GF_M2TS_MHAS_MAIN:
case GF_M2TS_MHAS_AUX:
case GF_M2TS_SUBTITLE_DVB:
case GF_M2TS_METADATA_PES:
GF_SAFEALLOC(pes, GF_M2TS_PES);
if (!pes) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG2TS] Failed to allocate ES for pid %d\n", pid));
return;
}
pes->cc = -1;
pes->flags = GF_M2TS_ES_IS_PES;
if (inherit_pcr)
pes->flags |= GF_M2TS_INHERIT_PCR;
es = (GF_M2TS_ES *)pes;
break;
case GF_M2TS_PRIVATE_DATA:
GF_SAFEALLOC(pes, GF_M2TS_PES);
if (!pes) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG2TS] Failed to allocate ES for pid %d\n", pid));
return;
}
pes->cc = -1;
pes->flags = GF_M2TS_ES_IS_PES;
es = (GF_M2TS_ES *)pes;
break;
/* Sections */
case GF_M2TS_SYSTEMS_MPEG4_SECTIONS:
GF_SAFEALLOC(ses, GF_M2TS_SECTION_ES);
if (!ses) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG2TS] Failed to allocate ES for pid %d\n", pid));
return;
}
es = (GF_M2TS_ES *)ses;
es->flags |= GF_M2TS_ES_IS_SECTION;
/* carriage of ISO_IEC_14496 data in sections */
if (stream_type == GF_M2TS_SYSTEMS_MPEG4_SECTIONS) {
/*MPEG-4 sections need to be fully checked: if one section is lost, this means we lost
one SL packet in the AU so we must wait for the complete section again*/
ses->sec = gf_m2ts_section_filter_new(gf_m2ts_process_mpeg4section, 0);
/*create OD container*/
if (!pmt->program->additional_ods) {
pmt->program->additional_ods = gf_list_new();
ts->has_4on2 = 1;
}
}
break;
case GF_M2TS_13818_6_ANNEX_A:
case GF_M2TS_13818_6_ANNEX_B:
case GF_M2TS_13818_6_ANNEX_C:
case GF_M2TS_13818_6_ANNEX_D:
case GF_M2TS_PRIVATE_SECTION:
case GF_M2TS_QUALITY_SEC:
case GF_M2TS_MORE_SEC:
GF_SAFEALLOC(ses, GF_M2TS_SECTION_ES);
if (!ses) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG2TS] Failed to allocate ES for pid %d\n", pid));
return;
}
es = (GF_M2TS_ES *)ses;
es->flags |= GF_M2TS_ES_IS_SECTION;
es->pid = pid;
es->service_id = pmt->program->number;
if (stream_type == GF_M2TS_PRIVATE_SECTION) {
GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("AIT sections on pid %d\n", pid));
} else if (stream_type == GF_M2TS_QUALITY_SEC) {
GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("Quality metadata sections on pid %d\n", pid));
} else if (stream_type == GF_M2TS_MORE_SEC) {
GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("MORE sections on pid %d\n", pid));
} else {
GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("stream type DSM CC user private sections on pid %d \n", pid));
}
/* NULL means: trigger the call to on_event with DVB_GENERAL type and the raw section as payload */
ses->sec = gf_m2ts_section_filter_new(NULL, 1);
//ses->sec->service_id = pmt->program->number;
break;
case GF_M2TS_MPE_SECTIONS:
if (! ts->prefix_present) {
GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("stream type MPE found : pid = %d \n", pid));
#ifdef GPAC_ENABLE_MPE
es = gf_dvb_mpe_section_new();
if (es->flags & GF_M2TS_ES_IS_SECTION) {
/* NULL means: trigger the call to on_event with DVB_GENERAL type and the raw section as payload */
((GF_M2TS_SECTION_ES*)es)->sec = gf_m2ts_section_filter_new(NULL, 1);
}
#endif
break;
}
default:
GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[MPEG-2 TS] Stream type (0x%x) for PID %d not supported\n", stream_type, pid ) );
//GF_LOG(/*GF_LOG_WARNING*/GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG-2 TS] Stream type (0x%x) for PID %d not supported\n", stream_type, pid ) );
break;
}
if (es) {
es->stream_type = (stream_type==GF_M2TS_PRIVATE_DATA) ? 0 : stream_type;
es->program = pmt->program;
es->pid = pid;
es->component_tag = -1;
}
pos += 5;
data += 5;
while (desc_len) {
u8 tag = data[0];
u32 len = data[1];
if (es) {
switch (tag) {
case GF_M2TS_ISO_639_LANGUAGE_DESCRIPTOR:
if (pes)
pes->lang = GF_4CC(' ', data[2], data[3], data[4]);
break;
case GF_M2TS_MPEG4_SL_DESCRIPTOR:
es->mpeg4_es_id = ( (u32) data[2] & 0x1f) << 8 | data[3];
es->flags |= GF_M2TS_ES_IS_SL;
break;
case GF_M2TS_REGISTRATION_DESCRIPTOR:
reg_desc_format = GF_4CC(data[2], data[3], data[4], data[5]);
/*cf http://www.smpte-ra.org/mpegreg/mpegreg.html*/
switch (reg_desc_format) {
case GF_M2TS_RA_STREAM_AC3:
es->stream_type = GF_M2TS_AUDIO_AC3;
break;
case GF_M2TS_RA_STREAM_VC1:
es->stream_type = GF_M2TS_VIDEO_VC1;
break;
case GF_M2TS_RA_STREAM_GPAC:
if (len==8) {
es->stream_type = GF_4CC(data[6], data[7], data[8], data[9]);
es->flags |= GF_M2TS_GPAC_CODEC_ID;
break;
}
default:
GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("Unknown registration descriptor %s\n", gf_4cc_to_str(reg_desc_format) ));
break;
}
break;
case GF_M2TS_DVB_EAC3_DESCRIPTOR:
es->stream_type = GF_M2TS_AUDIO_EC3;
break;
case GF_M2TS_DVB_DATA_BROADCAST_ID_DESCRIPTOR:
{
u32 id = data[2]<<8 | data[3];
if ((id == 0xB) && ses && !ses->sec) {
ses->sec = gf_m2ts_section_filter_new(NULL, 1);
}
}
break;
case GF_M2TS_DVB_SUBTITLING_DESCRIPTOR:
if (pes) {
pes->sub.language[0] = data[2];
pes->sub.language[1] = data[3];
pes->sub.language[2] = data[4];
pes->sub.type = data[5];
pes->sub.composition_page_id = (data[6]<<8) | data[7];
pes->sub.ancillary_page_id = (data[8]<<8) | data[9];
}
es->stream_type = GF_M2TS_DVB_SUBTITLE;
break;
case GF_M2TS_DVB_STREAM_IDENTIFIER_DESCRIPTOR:
{
es->component_tag = data[2];
GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("Component Tag: %d on Program %d\n", es->component_tag, es->program->number));
}
break;
case GF_M2TS_DVB_TELETEXT_DESCRIPTOR:
es->stream_type = GF_M2TS_DVB_TELETEXT;
break;
case GF_M2TS_DVB_VBI_DATA_DESCRIPTOR:
es->stream_type = GF_M2TS_DVB_VBI;
break;
case GF_M2TS_HIERARCHY_DESCRIPTOR:
if (pes) {
u8 hierarchy_embedded_layer_index;
GF_BitStream *hbs = gf_bs_new((const char *)data, data_size, GF_BITSTREAM_READ);
/*u32 skip = */gf_bs_read_int(hbs, 16);
/*u8 res1 = */gf_bs_read_int(hbs, 1);
/*u8 temp_scal = */gf_bs_read_int(hbs, 1);
/*u8 spatial_scal = */gf_bs_read_int(hbs, 1);
/*u8 quality_scal = */gf_bs_read_int(hbs, 1);
/*u8 hierarchy_type = */gf_bs_read_int(hbs, 4);
/*u8 res2 = */gf_bs_read_int(hbs, 2);
/*u8 hierarchy_layer_index = */gf_bs_read_int(hbs, 6);
/*u8 tref_not_present = */gf_bs_read_int(hbs, 1);
/*u8 res3 = */gf_bs_read_int(hbs, 1);
hierarchy_embedded_layer_index = gf_bs_read_int(hbs, 6);
/*u8 res4 = */gf_bs_read_int(hbs, 2);
/*u8 hierarchy_channel = */gf_bs_read_int(hbs, 6);
gf_bs_del(hbs);
pes->depends_on_pid = 1+hierarchy_embedded_layer_index;
}
break;
case GF_M2TS_METADATA_DESCRIPTOR:
{
GF_BitStream *metadatad_bs;
GF_M2TS_MetadataDescriptor *metad;
metadatad_bs = gf_bs_new((char *)data+2, len, GF_BITSTREAM_READ);
metad = gf_m2ts_read_metadata_descriptor(metadatad_bs, len);
gf_bs_del(metadatad_bs);
if (metad->application_format_identifier == GF_M2TS_META_ID3 &&
metad->format_identifier == GF_M2TS_META_ID3) {
/*HLS ID3 Metadata */
if (pes) {
pes->metadata_descriptor = metad;
pes->stream_type = GF_M2TS_METADATA_ID3_HLS;
}
} else {
/* don't know what to do with it for now, delete */
gf_m2ts_metadata_descriptor_del(metad);
}
}
break;
default:
GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[MPEG-2 TS] skipping descriptor (0x%x) not supported\n", tag));
break;
}
}
data += len+2;
pos += len+2;
if (desc_len < len+2) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG-2 TS] Invalid PMT es descriptor size for PID %d\n", pid ) );
break;
}
desc_len-=len+2;
}
if (es && !es->stream_type) {
gf_free(es);
es = NULL;
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG-2 TS] Private Stream type (0x%x) for PID %d not supported\n", stream_type, pid ) );
}
if (!es) continue;
if (ts->ess[pid]) {
//this is component reuse across programs, overwrite the previously declared stream ...
if (status & GF_M2TS_TABLE_FOUND) {
GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[MPEG-2 TS] PID %d reused across programs %d and %d, not completely supported\n", pid, ts->ess[pid]->program->number, es->program->number ) );
//add stream to program but don't reassign the pid table until the stream is playing (>GF_M2TS_PES_FRAMING_SKIP)
gf_list_add(pmt->program->streams, es);
if (!(es->flags & GF_M2TS_ES_IS_SECTION) ) gf_m2ts_set_pes_framing(pes, GF_M2TS_PES_FRAMING_SKIP);
nb_es++;
//skip assignment below
es = NULL;
}
/*watchout for pmt update - FIXME this likely won't work in most cases*/
else {
GF_M2TS_ES *o_es = ts->ess[es->pid];
if ((o_es->stream_type == es->stream_type)
&& ((o_es->flags & GF_M2TS_ES_STATIC_FLAGS_MASK) == (es->flags & GF_M2TS_ES_STATIC_FLAGS_MASK))
&& (o_es->mpeg4_es_id == es->mpeg4_es_id)
&& ((o_es->flags & GF_M2TS_ES_IS_SECTION) || ((GF_M2TS_PES *)o_es)->lang == ((GF_M2TS_PES *)es)->lang)
) {
gf_free(es);
es = NULL;
} else {
gf_m2ts_es_del(o_es, ts);
ts->ess[es->pid] = NULL;
}
}
}
if (es) {
ts->ess[es->pid] = es;
gf_list_add(pmt->program->streams, es);
if (!(es->flags & GF_M2TS_ES_IS_SECTION) ) gf_m2ts_set_pes_framing(pes, GF_M2TS_PES_FRAMING_SKIP);
nb_es++;
}
if (es->stream_type == GF_M2TS_VIDEO_HEVC) nb_hevc++;
else if (es->stream_type == GF_M2TS_VIDEO_HEVC_TEMPORAL) nb_hevc_temp++;
else if (es->stream_type == GF_M2TS_VIDEO_SHVC) nb_shvc++;
else if (es->stream_type == GF_M2TS_VIDEO_SHVC_TEMPORAL) nb_shvc_temp++;
else if (es->stream_type == GF_M2TS_VIDEO_MHVC) nb_mhvc++;
else if (es->stream_type == GF_M2TS_VIDEO_MHVC_TEMPORAL) nb_mhvc_temp++;
}
//Table 2-139, implied hierarchy indexes
if (nb_hevc_temp + nb_shvc + nb_shvc_temp + nb_mhvc+ nb_mhvc_temp) {
for (i=0; i<gf_list_count(pmt->program->streams); i++) {
GF_M2TS_PES *es = (GF_M2TS_PES *)gf_list_get(pmt->program->streams, i);
if ( !(es->flags & GF_M2TS_ES_IS_PES)) continue;
if (es->depends_on_pid) continue;
switch (es->stream_type) {
case GF_M2TS_VIDEO_HEVC_TEMPORAL:
es->depends_on_pid = 1;
break;
case GF_M2TS_VIDEO_SHVC:
if (!nb_hevc_temp) es->depends_on_pid = 1;
else es->depends_on_pid = 2;
break;
case GF_M2TS_VIDEO_SHVC_TEMPORAL:
es->depends_on_pid = 3;
break;
case GF_M2TS_VIDEO_MHVC:
if (!nb_hevc_temp) es->depends_on_pid = 1;
else es->depends_on_pid = 2;
break;
case GF_M2TS_VIDEO_MHVC_TEMPORAL:
if (!nb_hevc_temp) es->depends_on_pid = 2;
else es->depends_on_pid = 3;
break;
}
}
}
if (nb_es) {
u32 i;
//translate hierarchy descriptors indexes into PIDs - check whether the PMT-index rules are the same for HEVC
for (i=0; i<gf_list_count(pmt->program->streams); i++) {
GF_M2TS_PES *an_es = NULL;
GF_M2TS_PES *es = (GF_M2TS_PES *)gf_list_get(pmt->program->streams, i);
if ( !(es->flags & GF_M2TS_ES_IS_PES)) continue;
if (!es->depends_on_pid) continue;
//fixeme we are not always assured that hierarchy_layer_index matches the stream index...
//+1 is because our first stream is the PMT
an_es = (GF_M2TS_PES *)gf_list_get(pmt->program->streams, es->depends_on_pid);
if (an_es) {
es->depends_on_pid = an_es->pid;
} else {
GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[M2TS] Wrong dependency index in hierarchy descriptor, assuming non-scalable stream\n"));
es->depends_on_pid = 0;
}
}
evt_type = (status&GF_M2TS_TABLE_FOUND) ? GF_M2TS_EVT_PMT_FOUND : GF_M2TS_EVT_PMT_UPDATE;
if (ts->on_event) ts->on_event(ts, evt_type, pmt->program);
} else {
/* if we found no new ES it's simply a repeat of the PMT */
if (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_PMT_REPEAT, pmt->program);
}
} | 2812 | True | 1 |
CVE-2020-19481 | 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/gpac/gpac/issues/1267', 'name': 'https://github.com/gpac/gpac/issues/1267', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/issues/1266', 'name': 'https://github.com/gpac/gpac/issues/1266', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/issues/1265', 'name': 'https://github.com/gpac/gpac/issues/1265', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/2320eb73afba753b39b7147be91f7be7afc0eeb7', 'name': 'https://github.com/gpac/gpac/commit/2320eb73afba753b39b7147be91f7be7afc0eeb7', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:*:*:*:*:*:*:*:*', 'versionEndExcluding': '0.8.0', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'An issue was discovered in GPAC before 0.8.0, as demonstrated by MP4Box. It contains an invalid memory read in gf_m2ts_process_pmt in media_tools/mpegts.c that can cause a denial of service via a crafted MP4 file.'}] | 2021-07-30T18:34Z | 2021-07-21T18: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 | jeanlf | 2019-07-07 16:55:12+02:00 | fixed potential crash in TS - cf #1264 | 2320eb73afba753b39b7147be91f7be7afc0eeb7 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_m2ts_process_pmt | gf_m2ts_process_pmt( GF_M2TS_Demuxer * ts , GF_M2TS_SECTION_ES * pmt , GF_List * sections , u8 table_id , u16 ex_table_id , u8 version_number , u8 last_section_number , u32 status) | ['ts', 'pmt', 'sections', 'table_id', 'ex_table_id', 'version_number', 'last_section_number', 'status'] | static void gf_m2ts_process_pmt(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *pmt, GF_List *sections, u8 table_id, u16 ex_table_id, u8 version_number, u8 last_section_number, u32 status)
{
u32 info_length, pos, desc_len, evt_type, nb_es,i;
u32 nb_sections;
u32 data_size;
u32 nb_hevc, nb_hevc_temp, nb_shvc, nb_shvc_temp, nb_mhvc, nb_mhvc_temp;
unsigned char *data;
GF_M2TS_Section *section;
GF_Err e = GF_OK;
/*wait for the last section */
if (!(status&GF_M2TS_TABLE_END)) return;
nb_es = 0;
/*skip if already received but no update detected (eg same data) */
if ((status&GF_M2TS_TABLE_REPEAT) && !(status&GF_M2TS_TABLE_UPDATE)) {
if (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_PMT_REPEAT, pmt->program);
return;
}
if (pmt->sec->demux_restarted) {
pmt->sec->demux_restarted = 0;
return;
}
GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[MPEG-2 TS] PMT Found or updated\n"));
nb_sections = gf_list_count(sections);
if (nb_sections > 1) {
GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("PMT on multiple sections not supported\n"));
}
section = (GF_M2TS_Section *)gf_list_get(sections, 0);
data = section->data;
data_size = section->data_size;
pmt->program->pcr_pid = ((data[0] & 0x1f) << 8) | data[1];
info_length = ((data[2]&0xf)<<8) | data[3];
if (info_length != 0) {
/* ...Read Descriptors ... */
u8 tag, len;
u32 first_loop_len = 0;
tag = data[4];
len = data[5];
while (info_length > first_loop_len) {
if (tag == GF_M2TS_MPEG4_IOD_DESCRIPTOR) {
u32 size;
GF_BitStream *iod_bs;
iod_bs = gf_bs_new((char *)data+8, len-2, GF_BITSTREAM_READ);
if (pmt->program->pmt_iod) gf_odf_desc_del((GF_Descriptor *)pmt->program->pmt_iod);
e = gf_odf_parse_descriptor(iod_bs , (GF_Descriptor **) &pmt->program->pmt_iod, &size);
gf_bs_del(iod_bs );
if (e==GF_OK) {
/*remember program number for service/program selection*/
if (pmt->program->pmt_iod) pmt->program->pmt_iod->ServiceID = pmt->program->number;
/*if empty IOD (freebox case), discard it and use dynamic declaration of object*/
if (!gf_list_count(pmt->program->pmt_iod->ESDescriptors)) {
gf_odf_desc_del((GF_Descriptor *)pmt->program->pmt_iod);
pmt->program->pmt_iod = NULL;
}
}
} else if (tag == GF_M2TS_METADATA_POINTER_DESCRIPTOR) {
GF_BitStream *metadatapd_bs;
GF_M2TS_MetadataPointerDescriptor *metapd;
metadatapd_bs = gf_bs_new((char *)data+6, len, GF_BITSTREAM_READ);
metapd = gf_m2ts_read_metadata_pointer_descriptor(metadatapd_bs, len);
gf_bs_del(metadatapd_bs);
if (metapd->application_format_identifier == GF_M2TS_META_ID3 &&
metapd->format_identifier == GF_M2TS_META_ID3 &&
metapd->carriage_flag == METADATA_CARRIAGE_SAME_TS) {
/*HLS ID3 Metadata */
pmt->program->metadata_pointer_descriptor = metapd;
} else {
/* don't know what to do with it for now, delete */
gf_m2ts_metadata_pointer_descriptor_del(metapd);
}
} else {
GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[MPEG-2 TS] Skipping descriptor (0x%x) and others not supported\n", tag));
}
first_loop_len += 2 + len;
}
}
if (data_size <= 4 + info_length) return;
data += 4 + info_length;
data_size -= 4 + info_length;
pos = 0;
/* count de number of program related PMT received */
for(i=0; i<gf_list_count(ts->programs); i++) {
GF_M2TS_Program *prog = (GF_M2TS_Program *)gf_list_get(ts->programs,i);
if(prog->pmt_pid == pmt->pid) {
break;
}
}
nb_hevc = nb_hevc_temp = nb_shvc = nb_shvc_temp = nb_mhvc = nb_mhvc_temp = 0;
while (pos<data_size) {
GF_M2TS_PES *pes = NULL;
GF_M2TS_SECTION_ES *ses = NULL;
GF_M2TS_ES *es = NULL;
Bool inherit_pcr = 0;
u32 pid, stream_type, reg_desc_format;
stream_type = data[0];
pid = ((data[1] & 0x1f) << 8) | data[2];
desc_len = ((data[3] & 0xf) << 8) | data[4];
GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("stream_type :%d \n",stream_type));
switch (stream_type) {
/* PES */
case GF_M2TS_VIDEO_MPEG1:
case GF_M2TS_VIDEO_MPEG2:
case GF_M2TS_VIDEO_DCII:
case GF_M2TS_VIDEO_MPEG4:
case GF_M2TS_SYSTEMS_MPEG4_PES:
case GF_M2TS_VIDEO_H264:
case GF_M2TS_VIDEO_SVC:
case GF_M2TS_VIDEO_MVCD:
case GF_M2TS_VIDEO_HEVC:
case GF_M2TS_VIDEO_HEVC_MCTS:
case GF_M2TS_VIDEO_HEVC_TEMPORAL:
case GF_M2TS_VIDEO_SHVC:
case GF_M2TS_VIDEO_SHVC_TEMPORAL:
case GF_M2TS_VIDEO_MHVC:
case GF_M2TS_VIDEO_MHVC_TEMPORAL:
inherit_pcr = 1;
case GF_M2TS_AUDIO_MPEG1:
case GF_M2TS_AUDIO_MPEG2:
case GF_M2TS_AUDIO_AAC:
case GF_M2TS_AUDIO_LATM_AAC:
case GF_M2TS_AUDIO_AC3:
case GF_M2TS_AUDIO_DTS:
case GF_M2TS_MHAS_MAIN:
case GF_M2TS_MHAS_AUX:
case GF_M2TS_SUBTITLE_DVB:
case GF_M2TS_METADATA_PES:
GF_SAFEALLOC(pes, GF_M2TS_PES);
if (!pes) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG2TS] Failed to allocate ES for pid %d\n", pid));
return;
}
pes->cc = -1;
pes->flags = GF_M2TS_ES_IS_PES;
if (inherit_pcr)
pes->flags |= GF_M2TS_INHERIT_PCR;
es = (GF_M2TS_ES *)pes;
break;
case GF_M2TS_PRIVATE_DATA:
GF_SAFEALLOC(pes, GF_M2TS_PES);
if (!pes) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG2TS] Failed to allocate ES for pid %d\n", pid));
return;
}
pes->cc = -1;
pes->flags = GF_M2TS_ES_IS_PES;
es = (GF_M2TS_ES *)pes;
break;
/* Sections */
case GF_M2TS_SYSTEMS_MPEG4_SECTIONS:
GF_SAFEALLOC(ses, GF_M2TS_SECTION_ES);
if (!ses) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG2TS] Failed to allocate ES for pid %d\n", pid));
return;
}
es = (GF_M2TS_ES *)ses;
es->flags |= GF_M2TS_ES_IS_SECTION;
/* carriage of ISO_IEC_14496 data in sections */
if (stream_type == GF_M2TS_SYSTEMS_MPEG4_SECTIONS) {
/*MPEG-4 sections need to be fully checked: if one section is lost, this means we lost
one SL packet in the AU so we must wait for the complete section again*/
ses->sec = gf_m2ts_section_filter_new(gf_m2ts_process_mpeg4section, 0);
/*create OD container*/
if (!pmt->program->additional_ods) {
pmt->program->additional_ods = gf_list_new();
ts->has_4on2 = 1;
}
}
break;
case GF_M2TS_13818_6_ANNEX_A:
case GF_M2TS_13818_6_ANNEX_B:
case GF_M2TS_13818_6_ANNEX_C:
case GF_M2TS_13818_6_ANNEX_D:
case GF_M2TS_PRIVATE_SECTION:
case GF_M2TS_QUALITY_SEC:
case GF_M2TS_MORE_SEC:
GF_SAFEALLOC(ses, GF_M2TS_SECTION_ES);
if (!ses) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG2TS] Failed to allocate ES for pid %d\n", pid));
return;
}
es = (GF_M2TS_ES *)ses;
es->flags |= GF_M2TS_ES_IS_SECTION;
es->pid = pid;
es->service_id = pmt->program->number;
if (stream_type == GF_M2TS_PRIVATE_SECTION) {
GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("AIT sections on pid %d\n", pid));
} else if (stream_type == GF_M2TS_QUALITY_SEC) {
GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("Quality metadata sections on pid %d\n", pid));
} else if (stream_type == GF_M2TS_MORE_SEC) {
GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("MORE sections on pid %d\n", pid));
} else {
GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("stream type DSM CC user private sections on pid %d \n", pid));
}
/* NULL means: trigger the call to on_event with DVB_GENERAL type and the raw section as payload */
ses->sec = gf_m2ts_section_filter_new(NULL, 1);
//ses->sec->service_id = pmt->program->number;
break;
case GF_M2TS_MPE_SECTIONS:
if (! ts->prefix_present) {
GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("stream type MPE found : pid = %d \n", pid));
#ifdef GPAC_ENABLE_MPE
es = gf_dvb_mpe_section_new();
if (es->flags & GF_M2TS_ES_IS_SECTION) {
/* NULL means: trigger the call to on_event with DVB_GENERAL type and the raw section as payload */
((GF_M2TS_SECTION_ES*)es)->sec = gf_m2ts_section_filter_new(NULL, 1);
}
#endif
break;
}
default:
GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[MPEG-2 TS] Stream type (0x%x) for PID %d not supported\n", stream_type, pid ) );
//GF_LOG(/*GF_LOG_WARNING*/GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG-2 TS] Stream type (0x%x) for PID %d not supported\n", stream_type, pid ) );
break;
}
if (es) {
es->stream_type = (stream_type==GF_M2TS_PRIVATE_DATA) ? 0 : stream_type;
es->program = pmt->program;
es->pid = pid;
es->component_tag = -1;
}
pos += 5;
data += 5;
while (desc_len) {
u8 tag = data[0];
u32 len = data[1];
if (es) {
switch (tag) {
case GF_M2TS_ISO_639_LANGUAGE_DESCRIPTOR:
if (pes)
pes->lang = GF_4CC(' ', data[2], data[3], data[4]);
break;
case GF_M2TS_MPEG4_SL_DESCRIPTOR:
es->mpeg4_es_id = ( (u32) data[2] & 0x1f) << 8 | data[3];
es->flags |= GF_M2TS_ES_IS_SL;
break;
case GF_M2TS_REGISTRATION_DESCRIPTOR:
reg_desc_format = GF_4CC(data[2], data[3], data[4], data[5]);
/*cf http://www.smpte-ra.org/mpegreg/mpegreg.html*/
switch (reg_desc_format) {
case GF_M2TS_RA_STREAM_AC3:
es->stream_type = GF_M2TS_AUDIO_AC3;
break;
case GF_M2TS_RA_STREAM_VC1:
es->stream_type = GF_M2TS_VIDEO_VC1;
break;
case GF_M2TS_RA_STREAM_GPAC:
if (len==8) {
es->stream_type = GF_4CC(data[6], data[7], data[8], data[9]);
es->flags |= GF_M2TS_GPAC_CODEC_ID;
break;
}
default:
GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("Unknown registration descriptor %s\n", gf_4cc_to_str(reg_desc_format) ));
break;
}
break;
case GF_M2TS_DVB_EAC3_DESCRIPTOR:
es->stream_type = GF_M2TS_AUDIO_EC3;
break;
case GF_M2TS_DVB_DATA_BROADCAST_ID_DESCRIPTOR:
{
u32 id = data[2]<<8 | data[3];
if ((id == 0xB) && ses && !ses->sec) {
ses->sec = gf_m2ts_section_filter_new(NULL, 1);
}
}
break;
case GF_M2TS_DVB_SUBTITLING_DESCRIPTOR:
if (pes) {
pes->sub.language[0] = data[2];
pes->sub.language[1] = data[3];
pes->sub.language[2] = data[4];
pes->sub.type = data[5];
pes->sub.composition_page_id = (data[6]<<8) | data[7];
pes->sub.ancillary_page_id = (data[8]<<8) | data[9];
}
es->stream_type = GF_M2TS_DVB_SUBTITLE;
break;
case GF_M2TS_DVB_STREAM_IDENTIFIER_DESCRIPTOR:
{
es->component_tag = data[2];
GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("Component Tag: %d on Program %d\n", es->component_tag, es->program->number));
}
break;
case GF_M2TS_DVB_TELETEXT_DESCRIPTOR:
es->stream_type = GF_M2TS_DVB_TELETEXT;
break;
case GF_M2TS_DVB_VBI_DATA_DESCRIPTOR:
es->stream_type = GF_M2TS_DVB_VBI;
break;
case GF_M2TS_HIERARCHY_DESCRIPTOR:
if (pes) {
u8 hierarchy_embedded_layer_index;
GF_BitStream *hbs = gf_bs_new((const char *)data, data_size, GF_BITSTREAM_READ);
/*u32 skip = */gf_bs_read_int(hbs, 16);
/*u8 res1 = */gf_bs_read_int(hbs, 1);
/*u8 temp_scal = */gf_bs_read_int(hbs, 1);
/*u8 spatial_scal = */gf_bs_read_int(hbs, 1);
/*u8 quality_scal = */gf_bs_read_int(hbs, 1);
/*u8 hierarchy_type = */gf_bs_read_int(hbs, 4);
/*u8 res2 = */gf_bs_read_int(hbs, 2);
/*u8 hierarchy_layer_index = */gf_bs_read_int(hbs, 6);
/*u8 tref_not_present = */gf_bs_read_int(hbs, 1);
/*u8 res3 = */gf_bs_read_int(hbs, 1);
hierarchy_embedded_layer_index = gf_bs_read_int(hbs, 6);
/*u8 res4 = */gf_bs_read_int(hbs, 2);
/*u8 hierarchy_channel = */gf_bs_read_int(hbs, 6);
gf_bs_del(hbs);
pes->depends_on_pid = 1+hierarchy_embedded_layer_index;
}
break;
case GF_M2TS_METADATA_DESCRIPTOR:
{
GF_BitStream *metadatad_bs;
GF_M2TS_MetadataDescriptor *metad;
metadatad_bs = gf_bs_new((char *)data+2, len, GF_BITSTREAM_READ);
metad = gf_m2ts_read_metadata_descriptor(metadatad_bs, len);
gf_bs_del(metadatad_bs);
if (metad->application_format_identifier == GF_M2TS_META_ID3 &&
metad->format_identifier == GF_M2TS_META_ID3) {
/*HLS ID3 Metadata */
if (pes) {
pes->metadata_descriptor = metad;
pes->stream_type = GF_M2TS_METADATA_ID3_HLS;
}
} else {
/* don't know what to do with it for now, delete */
gf_m2ts_metadata_descriptor_del(metad);
}
}
break;
default:
GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[MPEG-2 TS] skipping descriptor (0x%x) not supported\n", tag));
break;
}
}
data += len+2;
pos += len+2;
if (desc_len < len+2) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG-2 TS] Invalid PMT es descriptor size for PID %d\n", pid ) );
break;
}
desc_len-=len+2;
}
if (es && !es->stream_type) {
gf_free(es);
es = NULL;
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG-2 TS] Private Stream type (0x%x) for PID %d not supported\n", stream_type, pid ) );
}
if (!es) continue;
if (ts->ess[pid]) {
//this is component reuse across programs, overwrite the previously declared stream ...
if (status & GF_M2TS_TABLE_FOUND) {
GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[MPEG-2 TS] PID %d reused across programs %d and %d, not completely supported\n", pid, ts->ess[pid]->program->number, es->program->number ) );
//add stream to program but don't reassign the pid table until the stream is playing (>GF_M2TS_PES_FRAMING_SKIP)
gf_list_add(pmt->program->streams, es);
if (!(es->flags & GF_M2TS_ES_IS_SECTION) ) gf_m2ts_set_pes_framing(pes, GF_M2TS_PES_FRAMING_SKIP);
nb_es++;
//skip assignment below
es = NULL;
}
/*watchout for pmt update - FIXME this likely won't work in most cases*/
else {
GF_M2TS_ES *o_es = ts->ess[es->pid];
if ((o_es->stream_type == es->stream_type)
&& ((o_es->flags & GF_M2TS_ES_STATIC_FLAGS_MASK) == (es->flags & GF_M2TS_ES_STATIC_FLAGS_MASK))
&& (o_es->mpeg4_es_id == es->mpeg4_es_id)
&& ((o_es->flags & GF_M2TS_ES_IS_SECTION) || ((GF_M2TS_PES *)o_es)->lang == ((GF_M2TS_PES *)es)->lang)
) {
gf_free(es);
es = NULL;
} else {
gf_m2ts_es_del(o_es, ts);
ts->ess[es->pid] = NULL;
}
}
}
if (es) {
ts->ess[es->pid] = es;
gf_list_add(pmt->program->streams, es);
if (!(es->flags & GF_M2TS_ES_IS_SECTION) ) gf_m2ts_set_pes_framing(pes, GF_M2TS_PES_FRAMING_SKIP);
nb_es++;
}
if (es->stream_type == GF_M2TS_VIDEO_HEVC) nb_hevc++;
else if (es->stream_type == GF_M2TS_VIDEO_HEVC_TEMPORAL) nb_hevc_temp++;
else if (es->stream_type == GF_M2TS_VIDEO_SHVC) nb_shvc++;
else if (es->stream_type == GF_M2TS_VIDEO_SHVC_TEMPORAL) nb_shvc_temp++;
else if (es->stream_type == GF_M2TS_VIDEO_MHVC) nb_mhvc++;
else if (es->stream_type == GF_M2TS_VIDEO_MHVC_TEMPORAL) nb_mhvc_temp++;
}
//Table 2-139, implied hierarchy indexes
if (nb_hevc_temp + nb_shvc + nb_shvc_temp + nb_mhvc+ nb_mhvc_temp) {
for (i=0; i<gf_list_count(pmt->program->streams); i++) {
GF_M2TS_PES *es = (GF_M2TS_PES *)gf_list_get(pmt->program->streams, i);
if ( !(es->flags & GF_M2TS_ES_IS_PES)) continue;
if (es->depends_on_pid) continue;
switch (es->stream_type) {
case GF_M2TS_VIDEO_HEVC_TEMPORAL:
es->depends_on_pid = 1;
break;
case GF_M2TS_VIDEO_SHVC:
if (!nb_hevc_temp) es->depends_on_pid = 1;
else es->depends_on_pid = 2;
break;
case GF_M2TS_VIDEO_SHVC_TEMPORAL:
es->depends_on_pid = 3;
break;
case GF_M2TS_VIDEO_MHVC:
if (!nb_hevc_temp) es->depends_on_pid = 1;
else es->depends_on_pid = 2;
break;
case GF_M2TS_VIDEO_MHVC_TEMPORAL:
if (!nb_hevc_temp) es->depends_on_pid = 2;
else es->depends_on_pid = 3;
break;
}
}
}
if (nb_es) {
u32 i;
//translate hierarchy descriptors indexes into PIDs - check whether the PMT-index rules are the same for HEVC
for (i=0; i<gf_list_count(pmt->program->streams); i++) {
GF_M2TS_PES *an_es = NULL;
GF_M2TS_PES *es = (GF_M2TS_PES *)gf_list_get(pmt->program->streams, i);
if ( !(es->flags & GF_M2TS_ES_IS_PES)) continue;
if (!es->depends_on_pid) continue;
//fixeme we are not always assured that hierarchy_layer_index matches the stream index...
//+1 is because our first stream is the PMT
an_es = (GF_M2TS_PES *)gf_list_get(pmt->program->streams, es->depends_on_pid);
if (an_es) {
es->depends_on_pid = an_es->pid;
} else {
GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[M2TS] Wrong dependency index in hierarchy descriptor, assuming non-scalable stream\n"));
es->depends_on_pid = 0;
}
}
evt_type = (status&GF_M2TS_TABLE_FOUND) ? GF_M2TS_EVT_PMT_FOUND : GF_M2TS_EVT_PMT_UPDATE;
if (ts->on_event) ts->on_event(ts, evt_type, pmt->program);
} else {
/* if we found no new ES it's simply a repeat of the PMT */
if (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_PMT_REPEAT, pmt->program);
}
} | 2812 | True | 1 |
CVE-2019-20628 | 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/gpac/gpac/commit/98b727637e32d1d4824101d8947e2dbd573d4fc8', 'name': 'https://github.com/gpac/gpac/commit/98b727637e32d1d4824101d8947e2dbd573d4fc8', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/issues/1269', 'name': 'https://github.com/gpac/gpac/issues/1269', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/1ab4860609f2e7a35634930571e7d0531297e090', 'name': 'https://github.com/gpac/gpac/commit/1ab4860609f2e7a35634930571e7d0531297e090', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-416'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:*:*:*:*:*:*:*:*', 'versionEndExcluding': '0.8.0', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'An issue was discovered in libgpac.a in GPAC before 0.8.0, as demonstrated by MP4Box. It contains a Use-After-Free vulnerability in gf_m2ts_process_pmt in media_tools/mpegts.c that can cause a denial of service via a crafted MP4 file.'}] | 2020-03-25T13:51Z | 2020-03-24T19: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 | jeanlf | 2019-07-07 17:42:35+02:00 | fixed potential crash on PMT IOD parse - cf #1268 #1269 | 1ab4860609f2e7a35634930571e7d0531297e090 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_m2ts_process_pmt | gf_m2ts_process_pmt( GF_M2TS_Demuxer * ts , GF_M2TS_SECTION_ES * pmt , GF_List * sections , u8 table_id , u16 ex_table_id , u8 version_number , u8 last_section_number , u32 status) | ['ts', 'pmt', 'sections', 'table_id', 'ex_table_id', 'version_number', 'last_section_number', 'status'] | static void gf_m2ts_process_pmt(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *pmt, GF_List *sections, u8 table_id, u16 ex_table_id, u8 version_number, u8 last_section_number, u32 status)
{
u32 info_length, pos, desc_len, evt_type, nb_es,i;
u32 nb_sections;
u32 data_size;
u32 nb_hevc, nb_hevc_temp, nb_shvc, nb_shvc_temp, nb_mhvc, nb_mhvc_temp;
unsigned char *data;
GF_M2TS_Section *section;
GF_Err e = GF_OK;
/*wait for the last section */
if (!(status&GF_M2TS_TABLE_END)) return;
nb_es = 0;
/*skip if already received but no update detected (eg same data) */
if ((status&GF_M2TS_TABLE_REPEAT) && !(status&GF_M2TS_TABLE_UPDATE)) {
if (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_PMT_REPEAT, pmt->program);
return;
}
if (pmt->sec->demux_restarted) {
pmt->sec->demux_restarted = 0;
return;
}
GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[MPEG-2 TS] PMT Found or updated\n"));
nb_sections = gf_list_count(sections);
if (nb_sections > 1) {
GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("PMT on multiple sections not supported\n"));
}
section = (GF_M2TS_Section *)gf_list_get(sections, 0);
data = section->data;
data_size = section->data_size;
pmt->program->pcr_pid = ((data[0] & 0x1f) << 8) | data[1];
info_length = ((data[2]&0xf)<<8) | data[3];
if (info_length != 0) {
/* ...Read Descriptors ... */
u8 tag, len;
u32 first_loop_len = 0;
tag = data[4];
len = data[5];
while (info_length > first_loop_len) {
if (tag == GF_M2TS_MPEG4_IOD_DESCRIPTOR) {
u32 size;
GF_BitStream *iod_bs;
iod_bs = gf_bs_new((char *)data+8, len-2, GF_BITSTREAM_READ);
if (pmt->program->pmt_iod) gf_odf_desc_del((GF_Descriptor *)pmt->program->pmt_iod);
e = gf_odf_parse_descriptor(iod_bs , (GF_Descriptor **) &pmt->program->pmt_iod, &size);
gf_bs_del(iod_bs );
if (e==GF_OK) {
/*remember program number for service/program selection*/
if (pmt->program->pmt_iod) pmt->program->pmt_iod->ServiceID = pmt->program->number;
/*if empty IOD (freebox case), discard it and use dynamic declaration of object*/
if (!gf_list_count(pmt->program->pmt_iod->ESDescriptors)) {
gf_odf_desc_del((GF_Descriptor *)pmt->program->pmt_iod);
pmt->program->pmt_iod = NULL;
}
}
} else if (tag == GF_M2TS_METADATA_POINTER_DESCRIPTOR) {
GF_BitStream *metadatapd_bs;
GF_M2TS_MetadataPointerDescriptor *metapd;
metadatapd_bs = gf_bs_new((char *)data+6, len, GF_BITSTREAM_READ);
metapd = gf_m2ts_read_metadata_pointer_descriptor(metadatapd_bs, len);
gf_bs_del(metadatapd_bs);
if (metapd->application_format_identifier == GF_M2TS_META_ID3 &&
metapd->format_identifier == GF_M2TS_META_ID3 &&
metapd->carriage_flag == METADATA_CARRIAGE_SAME_TS) {
/*HLS ID3 Metadata */
pmt->program->metadata_pointer_descriptor = metapd;
} else {
/* don't know what to do with it for now, delete */
gf_m2ts_metadata_pointer_descriptor_del(metapd);
}
} else {
GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[MPEG-2 TS] Skipping descriptor (0x%x) and others not supported\n", tag));
}
first_loop_len += 2 + len;
}
}
if (data_size <= 4 + info_length) return;
data += 4 + info_length;
data_size -= 4 + info_length;
pos = 0;
/* count de number of program related PMT received */
for(i=0; i<gf_list_count(ts->programs); i++) {
GF_M2TS_Program *prog = (GF_M2TS_Program *)gf_list_get(ts->programs,i);
if(prog->pmt_pid == pmt->pid) {
break;
}
}
nb_hevc = nb_hevc_temp = nb_shvc = nb_shvc_temp = nb_mhvc = nb_mhvc_temp = 0;
while (pos<data_size) {
GF_M2TS_PES *pes = NULL;
GF_M2TS_SECTION_ES *ses = NULL;
GF_M2TS_ES *es = NULL;
Bool inherit_pcr = 0;
u32 pid, stream_type, reg_desc_format;
if (pos + 5 > data_size) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("Broken PMT! size %d but position %d and need at least 5 bytes to declare es\n", data_size, pos));
break;
}
stream_type = data[0];
pid = ((data[1] & 0x1f) << 8) | data[2];
desc_len = ((data[3] & 0xf) << 8) | data[4];
GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("stream_type :%d \n",stream_type));
switch (stream_type) {
/* PES */
case GF_M2TS_VIDEO_MPEG1:
case GF_M2TS_VIDEO_MPEG2:
case GF_M2TS_VIDEO_DCII:
case GF_M2TS_VIDEO_MPEG4:
case GF_M2TS_SYSTEMS_MPEG4_PES:
case GF_M2TS_VIDEO_H264:
case GF_M2TS_VIDEO_SVC:
case GF_M2TS_VIDEO_MVCD:
case GF_M2TS_VIDEO_HEVC:
case GF_M2TS_VIDEO_HEVC_MCTS:
case GF_M2TS_VIDEO_HEVC_TEMPORAL:
case GF_M2TS_VIDEO_SHVC:
case GF_M2TS_VIDEO_SHVC_TEMPORAL:
case GF_M2TS_VIDEO_MHVC:
case GF_M2TS_VIDEO_MHVC_TEMPORAL:
inherit_pcr = 1;
case GF_M2TS_AUDIO_MPEG1:
case GF_M2TS_AUDIO_MPEG2:
case GF_M2TS_AUDIO_AAC:
case GF_M2TS_AUDIO_LATM_AAC:
case GF_M2TS_AUDIO_AC3:
case GF_M2TS_AUDIO_DTS:
case GF_M2TS_MHAS_MAIN:
case GF_M2TS_MHAS_AUX:
case GF_M2TS_SUBTITLE_DVB:
case GF_M2TS_METADATA_PES:
GF_SAFEALLOC(pes, GF_M2TS_PES);
if (!pes) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG2TS] Failed to allocate ES for pid %d\n", pid));
return;
}
pes->cc = -1;
pes->flags = GF_M2TS_ES_IS_PES;
if (inherit_pcr)
pes->flags |= GF_M2TS_INHERIT_PCR;
es = (GF_M2TS_ES *)pes;
break;
case GF_M2TS_PRIVATE_DATA:
GF_SAFEALLOC(pes, GF_M2TS_PES);
if (!pes) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG2TS] Failed to allocate ES for pid %d\n", pid));
return;
}
pes->cc = -1;
pes->flags = GF_M2TS_ES_IS_PES;
es = (GF_M2TS_ES *)pes;
break;
/* Sections */
case GF_M2TS_SYSTEMS_MPEG4_SECTIONS:
GF_SAFEALLOC(ses, GF_M2TS_SECTION_ES);
if (!ses) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG2TS] Failed to allocate ES for pid %d\n", pid));
return;
}
es = (GF_M2TS_ES *)ses;
es->flags |= GF_M2TS_ES_IS_SECTION;
/* carriage of ISO_IEC_14496 data in sections */
if (stream_type == GF_M2TS_SYSTEMS_MPEG4_SECTIONS) {
/*MPEG-4 sections need to be fully checked: if one section is lost, this means we lost
one SL packet in the AU so we must wait for the complete section again*/
ses->sec = gf_m2ts_section_filter_new(gf_m2ts_process_mpeg4section, 0);
/*create OD container*/
if (!pmt->program->additional_ods) {
pmt->program->additional_ods = gf_list_new();
ts->has_4on2 = 1;
}
}
break;
case GF_M2TS_13818_6_ANNEX_A:
case GF_M2TS_13818_6_ANNEX_B:
case GF_M2TS_13818_6_ANNEX_C:
case GF_M2TS_13818_6_ANNEX_D:
case GF_M2TS_PRIVATE_SECTION:
case GF_M2TS_QUALITY_SEC:
case GF_M2TS_MORE_SEC:
GF_SAFEALLOC(ses, GF_M2TS_SECTION_ES);
if (!ses) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG2TS] Failed to allocate ES for pid %d\n", pid));
return;
}
es = (GF_M2TS_ES *)ses;
es->flags |= GF_M2TS_ES_IS_SECTION;
es->pid = pid;
es->service_id = pmt->program->number;
if (stream_type == GF_M2TS_PRIVATE_SECTION) {
GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("AIT sections on pid %d\n", pid));
} else if (stream_type == GF_M2TS_QUALITY_SEC) {
GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("Quality metadata sections on pid %d\n", pid));
} else if (stream_type == GF_M2TS_MORE_SEC) {
GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("MORE sections on pid %d\n", pid));
} else {
GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("stream type DSM CC user private sections on pid %d \n", pid));
}
/* NULL means: trigger the call to on_event with DVB_GENERAL type and the raw section as payload */
ses->sec = gf_m2ts_section_filter_new(NULL, 1);
//ses->sec->service_id = pmt->program->number;
break;
case GF_M2TS_MPE_SECTIONS:
if (! ts->prefix_present) {
GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("stream type MPE found : pid = %d \n", pid));
#ifdef GPAC_ENABLE_MPE
es = gf_dvb_mpe_section_new();
if (es->flags & GF_M2TS_ES_IS_SECTION) {
/* NULL means: trigger the call to on_event with DVB_GENERAL type and the raw section as payload */
((GF_M2TS_SECTION_ES*)es)->sec = gf_m2ts_section_filter_new(NULL, 1);
}
#endif
break;
}
default:
GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[MPEG-2 TS] Stream type (0x%x) for PID %d not supported\n", stream_type, pid ) );
//GF_LOG(/*GF_LOG_WARNING*/GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG-2 TS] Stream type (0x%x) for PID %d not supported\n", stream_type, pid ) );
break;
}
if (es) {
es->stream_type = (stream_type==GF_M2TS_PRIVATE_DATA) ? 0 : stream_type;
es->program = pmt->program;
es->pid = pid;
es->component_tag = -1;
}
pos += 5;
data += 5;
while (desc_len) {
if (pos + 2 > data_size) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("Broken PMT descriptor! size %d but position %d and need at least 2 bytes to parse descritpor\n", data_size, pos));
break;
}
u8 tag = data[0];
u32 len = data[1];
if (pos + 2 + len > data_size) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("Broken PMT descriptor! size %d, desc size %d but position %d\n", data_size, len, pos));
break;
}
if (es) {
switch (tag) {
case GF_M2TS_ISO_639_LANGUAGE_DESCRIPTOR:
if (pes && (len>=3) )
pes->lang = GF_4CC(' ', data[2], data[3], data[4]);
break;
case GF_M2TS_MPEG4_SL_DESCRIPTOR:
if (len>=2) {
es->mpeg4_es_id = ( (u32) data[2] & 0x1f) << 8 | data[3];
es->flags |= GF_M2TS_ES_IS_SL;
}
break;
case GF_M2TS_REGISTRATION_DESCRIPTOR:
if (len>=4) {
reg_desc_format = GF_4CC(data[2], data[3], data[4], data[5]);
/*cf http://www.smpte-ra.org/mpegreg/mpegreg.html*/
switch (reg_desc_format) {
case GF_M2TS_RA_STREAM_AC3:
es->stream_type = GF_M2TS_AUDIO_AC3;
break;
case GF_M2TS_RA_STREAM_VC1:
es->stream_type = GF_M2TS_VIDEO_VC1;
break;
case GF_M2TS_RA_STREAM_GPAC:
if (len==8) {
es->stream_type = GF_4CC(data[6], data[7], data[8], data[9]);
es->flags |= GF_M2TS_GPAC_CODEC_ID;
break;
}
default:
GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("Unknown registration descriptor %s\n", gf_4cc_to_str(reg_desc_format) ));
break;
}
}
break;
case GF_M2TS_DVB_EAC3_DESCRIPTOR:
es->stream_type = GF_M2TS_AUDIO_EC3;
break;
case GF_M2TS_DVB_DATA_BROADCAST_ID_DESCRIPTOR:
if (len>=2) {
u32 id = data[2]<<8 | data[3];
if ((id == 0xB) && ses && !ses->sec) {
ses->sec = gf_m2ts_section_filter_new(NULL, 1);
}
}
break;
case GF_M2TS_DVB_SUBTITLING_DESCRIPTOR:
if (pes && (len>=8)) {
pes->sub.language[0] = data[2];
pes->sub.language[1] = data[3];
pes->sub.language[2] = data[4];
pes->sub.type = data[5];
pes->sub.composition_page_id = (data[6]<<8) | data[7];
pes->sub.ancillary_page_id = (data[8]<<8) | data[9];
}
es->stream_type = GF_M2TS_DVB_SUBTITLE;
break;
case GF_M2TS_DVB_STREAM_IDENTIFIER_DESCRIPTOR:
if (len>=1) {
es->component_tag = data[2];
GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("Component Tag: %d on Program %d\n", es->component_tag, es->program->number));
}
break;
case GF_M2TS_DVB_TELETEXT_DESCRIPTOR:
es->stream_type = GF_M2TS_DVB_TELETEXT;
break;
case GF_M2TS_DVB_VBI_DATA_DESCRIPTOR:
es->stream_type = GF_M2TS_DVB_VBI;
break;
case GF_M2TS_HIERARCHY_DESCRIPTOR:
if (pes && (len>=4)) {
u8 hierarchy_embedded_layer_index;
GF_BitStream *hbs = gf_bs_new((const char *)data, data_size, GF_BITSTREAM_READ);
/*u32 skip = */gf_bs_read_int(hbs, 16);
/*u8 res1 = */gf_bs_read_int(hbs, 1);
/*u8 temp_scal = */gf_bs_read_int(hbs, 1);
/*u8 spatial_scal = */gf_bs_read_int(hbs, 1);
/*u8 quality_scal = */gf_bs_read_int(hbs, 1);
/*u8 hierarchy_type = */gf_bs_read_int(hbs, 4);
/*u8 res2 = */gf_bs_read_int(hbs, 2);
/*u8 hierarchy_layer_index = */gf_bs_read_int(hbs, 6);
/*u8 tref_not_present = */gf_bs_read_int(hbs, 1);
/*u8 res3 = */gf_bs_read_int(hbs, 1);
hierarchy_embedded_layer_index = gf_bs_read_int(hbs, 6);
/*u8 res4 = */gf_bs_read_int(hbs, 2);
/*u8 hierarchy_channel = */gf_bs_read_int(hbs, 6);
gf_bs_del(hbs);
pes->depends_on_pid = 1+hierarchy_embedded_layer_index;
}
break;
case GF_M2TS_METADATA_DESCRIPTOR:
{
GF_BitStream *metadatad_bs;
GF_M2TS_MetadataDescriptor *metad;
metadatad_bs = gf_bs_new((char *)data+2, len, GF_BITSTREAM_READ);
metad = gf_m2ts_read_metadata_descriptor(metadatad_bs, len);
gf_bs_del(metadatad_bs);
if (metad->application_format_identifier == GF_M2TS_META_ID3 &&
metad->format_identifier == GF_M2TS_META_ID3) {
/*HLS ID3 Metadata */
if (pes) {
pes->metadata_descriptor = metad;
pes->stream_type = GF_M2TS_METADATA_ID3_HLS;
}
} else {
/* don't know what to do with it for now, delete */
gf_m2ts_metadata_descriptor_del(metad);
}
}
break;
default:
GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[MPEG-2 TS] skipping descriptor (0x%x) not supported\n", tag));
break;
}
}
data += len+2;
pos += len+2;
if (desc_len < len+2) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG-2 TS] Invalid PMT es descriptor size for PID %d\n", pid ) );
break;
}
desc_len-=len+2;
}
if (es && !es->stream_type) {
gf_free(es);
es = NULL;
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG-2 TS] Private Stream type (0x%x) for PID %d not supported\n", stream_type, pid ) );
}
if (!es) continue;
if (ts->ess[pid]) {
//this is component reuse across programs, overwrite the previously declared stream ...
if (status & GF_M2TS_TABLE_FOUND) {
GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[MPEG-2 TS] PID %d reused across programs %d and %d, not completely supported\n", pid, ts->ess[pid]->program->number, es->program->number ) );
//add stream to program but don't reassign the pid table until the stream is playing (>GF_M2TS_PES_FRAMING_SKIP)
gf_list_add(pmt->program->streams, es);
if (!(es->flags & GF_M2TS_ES_IS_SECTION) ) gf_m2ts_set_pes_framing(pes, GF_M2TS_PES_FRAMING_SKIP);
nb_es++;
//skip assignment below
es = NULL;
}
/*watchout for pmt update - FIXME this likely won't work in most cases*/
else {
GF_M2TS_ES *o_es = ts->ess[es->pid];
if ((o_es->stream_type == es->stream_type)
&& ((o_es->flags & GF_M2TS_ES_STATIC_FLAGS_MASK) == (es->flags & GF_M2TS_ES_STATIC_FLAGS_MASK))
&& (o_es->mpeg4_es_id == es->mpeg4_es_id)
&& ((o_es->flags & GF_M2TS_ES_IS_SECTION) || ((GF_M2TS_PES *)o_es)->lang == ((GF_M2TS_PES *)es)->lang)
) {
gf_free(es);
es = NULL;
} else {
gf_m2ts_es_del(o_es, ts);
ts->ess[es->pid] = NULL;
}
}
}
if (es) {
ts->ess[es->pid] = es;
gf_list_add(pmt->program->streams, es);
if (!(es->flags & GF_M2TS_ES_IS_SECTION) ) gf_m2ts_set_pes_framing(pes, GF_M2TS_PES_FRAMING_SKIP);
nb_es++;
if (es->stream_type == GF_M2TS_VIDEO_HEVC) nb_hevc++;
else if (es->stream_type == GF_M2TS_VIDEO_HEVC_TEMPORAL) nb_hevc_temp++;
else if (es->stream_type == GF_M2TS_VIDEO_SHVC) nb_shvc++;
else if (es->stream_type == GF_M2TS_VIDEO_SHVC_TEMPORAL) nb_shvc_temp++;
else if (es->stream_type == GF_M2TS_VIDEO_MHVC) nb_mhvc++;
else if (es->stream_type == GF_M2TS_VIDEO_MHVC_TEMPORAL) nb_mhvc_temp++;
}
}
//Table 2-139, implied hierarchy indexes
if (nb_hevc_temp + nb_shvc + nb_shvc_temp + nb_mhvc+ nb_mhvc_temp) {
for (i=0; i<gf_list_count(pmt->program->streams); i++) {
GF_M2TS_PES *es = (GF_M2TS_PES *)gf_list_get(pmt->program->streams, i);
if ( !(es->flags & GF_M2TS_ES_IS_PES)) continue;
if (es->depends_on_pid) continue;
switch (es->stream_type) {
case GF_M2TS_VIDEO_HEVC_TEMPORAL:
es->depends_on_pid = 1;
break;
case GF_M2TS_VIDEO_SHVC:
if (!nb_hevc_temp) es->depends_on_pid = 1;
else es->depends_on_pid = 2;
break;
case GF_M2TS_VIDEO_SHVC_TEMPORAL:
es->depends_on_pid = 3;
break;
case GF_M2TS_VIDEO_MHVC:
if (!nb_hevc_temp) es->depends_on_pid = 1;
else es->depends_on_pid = 2;
break;
case GF_M2TS_VIDEO_MHVC_TEMPORAL:
if (!nb_hevc_temp) es->depends_on_pid = 2;
else es->depends_on_pid = 3;
break;
}
}
}
if (nb_es) {
u32 i;
//translate hierarchy descriptors indexes into PIDs - check whether the PMT-index rules are the same for HEVC
for (i=0; i<gf_list_count(pmt->program->streams); i++) {
GF_M2TS_PES *an_es = NULL;
GF_M2TS_PES *es = (GF_M2TS_PES *)gf_list_get(pmt->program->streams, i);
if ( !(es->flags & GF_M2TS_ES_IS_PES)) continue;
if (!es->depends_on_pid) continue;
//fixeme we are not always assured that hierarchy_layer_index matches the stream index...
//+1 is because our first stream is the PMT
an_es = (GF_M2TS_PES *)gf_list_get(pmt->program->streams, es->depends_on_pid);
if (an_es) {
es->depends_on_pid = an_es->pid;
} else {
GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[M2TS] Wrong dependency index in hierarchy descriptor, assuming non-scalable stream\n"));
es->depends_on_pid = 0;
}
}
evt_type = (status&GF_M2TS_TABLE_FOUND) ? GF_M2TS_EVT_PMT_FOUND : GF_M2TS_EVT_PMT_UPDATE;
if (ts->on_event) ts->on_event(ts, evt_type, pmt->program);
} else {
/* if we found no new ES it's simply a repeat of the PMT */
if (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_PMT_REPEAT, pmt->program);
}
} | 2943 | True | 1 |
CVE-2019-20630 | 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/gpac/gpac/issues/1268', 'name': 'https://github.com/gpac/gpac/issues/1268', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/1ab4860609f2e7a35634930571e7d0531297e090', 'name': 'https://github.com/gpac/gpac/commit/1ab4860609f2e7a35634930571e7d0531297e090', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:*:*:*:*:*:*:*:*', 'versionEndExcluding': '0.8.0', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'An issue was discovered in libgpac.a in GPAC before 0.8.0, as demonstrated by MP4Box. It contains a heap-based buffer over-read in BS_ReadByte (called from gf_bs_read_bit) in utils/bitstream.c that can cause a denial of service via a crafted MP4 file.'}] | 2020-03-25T13:54Z | 2020-03-24T19: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 | jeanlf | 2019-07-07 17:42:35+02:00 | fixed potential crash on PMT IOD parse - cf #1268 #1269 | 1ab4860609f2e7a35634930571e7d0531297e090 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_m2ts_process_pmt | gf_m2ts_process_pmt( GF_M2TS_Demuxer * ts , GF_M2TS_SECTION_ES * pmt , GF_List * sections , u8 table_id , u16 ex_table_id , u8 version_number , u8 last_section_number , u32 status) | ['ts', 'pmt', 'sections', 'table_id', 'ex_table_id', 'version_number', 'last_section_number', 'status'] | static void gf_m2ts_process_pmt(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *pmt, GF_List *sections, u8 table_id, u16 ex_table_id, u8 version_number, u8 last_section_number, u32 status)
{
u32 info_length, pos, desc_len, evt_type, nb_es,i;
u32 nb_sections;
u32 data_size;
u32 nb_hevc, nb_hevc_temp, nb_shvc, nb_shvc_temp, nb_mhvc, nb_mhvc_temp;
unsigned char *data;
GF_M2TS_Section *section;
GF_Err e = GF_OK;
/*wait for the last section */
if (!(status&GF_M2TS_TABLE_END)) return;
nb_es = 0;
/*skip if already received but no update detected (eg same data) */
if ((status&GF_M2TS_TABLE_REPEAT) && !(status&GF_M2TS_TABLE_UPDATE)) {
if (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_PMT_REPEAT, pmt->program);
return;
}
if (pmt->sec->demux_restarted) {
pmt->sec->demux_restarted = 0;
return;
}
GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[MPEG-2 TS] PMT Found or updated\n"));
nb_sections = gf_list_count(sections);
if (nb_sections > 1) {
GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("PMT on multiple sections not supported\n"));
}
section = (GF_M2TS_Section *)gf_list_get(sections, 0);
data = section->data;
data_size = section->data_size;
pmt->program->pcr_pid = ((data[0] & 0x1f) << 8) | data[1];
info_length = ((data[2]&0xf)<<8) | data[3];
if (info_length != 0) {
/* ...Read Descriptors ... */
u8 tag, len;
u32 first_loop_len = 0;
tag = data[4];
len = data[5];
while (info_length > first_loop_len) {
if (tag == GF_M2TS_MPEG4_IOD_DESCRIPTOR) {
u32 size;
GF_BitStream *iod_bs;
iod_bs = gf_bs_new((char *)data+8, len-2, GF_BITSTREAM_READ);
if (pmt->program->pmt_iod) gf_odf_desc_del((GF_Descriptor *)pmt->program->pmt_iod);
e = gf_odf_parse_descriptor(iod_bs , (GF_Descriptor **) &pmt->program->pmt_iod, &size);
gf_bs_del(iod_bs );
if (e==GF_OK) {
/*remember program number for service/program selection*/
if (pmt->program->pmt_iod) pmt->program->pmt_iod->ServiceID = pmt->program->number;
/*if empty IOD (freebox case), discard it and use dynamic declaration of object*/
if (!gf_list_count(pmt->program->pmt_iod->ESDescriptors)) {
gf_odf_desc_del((GF_Descriptor *)pmt->program->pmt_iod);
pmt->program->pmt_iod = NULL;
}
}
} else if (tag == GF_M2TS_METADATA_POINTER_DESCRIPTOR) {
GF_BitStream *metadatapd_bs;
GF_M2TS_MetadataPointerDescriptor *metapd;
metadatapd_bs = gf_bs_new((char *)data+6, len, GF_BITSTREAM_READ);
metapd = gf_m2ts_read_metadata_pointer_descriptor(metadatapd_bs, len);
gf_bs_del(metadatapd_bs);
if (metapd->application_format_identifier == GF_M2TS_META_ID3 &&
metapd->format_identifier == GF_M2TS_META_ID3 &&
metapd->carriage_flag == METADATA_CARRIAGE_SAME_TS) {
/*HLS ID3 Metadata */
pmt->program->metadata_pointer_descriptor = metapd;
} else {
/* don't know what to do with it for now, delete */
gf_m2ts_metadata_pointer_descriptor_del(metapd);
}
} else {
GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[MPEG-2 TS] Skipping descriptor (0x%x) and others not supported\n", tag));
}
first_loop_len += 2 + len;
}
}
if (data_size <= 4 + info_length) return;
data += 4 + info_length;
data_size -= 4 + info_length;
pos = 0;
/* count de number of program related PMT received */
for(i=0; i<gf_list_count(ts->programs); i++) {
GF_M2TS_Program *prog = (GF_M2TS_Program *)gf_list_get(ts->programs,i);
if(prog->pmt_pid == pmt->pid) {
break;
}
}
nb_hevc = nb_hevc_temp = nb_shvc = nb_shvc_temp = nb_mhvc = nb_mhvc_temp = 0;
while (pos<data_size) {
GF_M2TS_PES *pes = NULL;
GF_M2TS_SECTION_ES *ses = NULL;
GF_M2TS_ES *es = NULL;
Bool inherit_pcr = 0;
u32 pid, stream_type, reg_desc_format;
if (pos + 5 > data_size) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("Broken PMT! size %d but position %d and need at least 5 bytes to declare es\n", data_size, pos));
break;
}
stream_type = data[0];
pid = ((data[1] & 0x1f) << 8) | data[2];
desc_len = ((data[3] & 0xf) << 8) | data[4];
GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("stream_type :%d \n",stream_type));
switch (stream_type) {
/* PES */
case GF_M2TS_VIDEO_MPEG1:
case GF_M2TS_VIDEO_MPEG2:
case GF_M2TS_VIDEO_DCII:
case GF_M2TS_VIDEO_MPEG4:
case GF_M2TS_SYSTEMS_MPEG4_PES:
case GF_M2TS_VIDEO_H264:
case GF_M2TS_VIDEO_SVC:
case GF_M2TS_VIDEO_MVCD:
case GF_M2TS_VIDEO_HEVC:
case GF_M2TS_VIDEO_HEVC_MCTS:
case GF_M2TS_VIDEO_HEVC_TEMPORAL:
case GF_M2TS_VIDEO_SHVC:
case GF_M2TS_VIDEO_SHVC_TEMPORAL:
case GF_M2TS_VIDEO_MHVC:
case GF_M2TS_VIDEO_MHVC_TEMPORAL:
inherit_pcr = 1;
case GF_M2TS_AUDIO_MPEG1:
case GF_M2TS_AUDIO_MPEG2:
case GF_M2TS_AUDIO_AAC:
case GF_M2TS_AUDIO_LATM_AAC:
case GF_M2TS_AUDIO_AC3:
case GF_M2TS_AUDIO_DTS:
case GF_M2TS_MHAS_MAIN:
case GF_M2TS_MHAS_AUX:
case GF_M2TS_SUBTITLE_DVB:
case GF_M2TS_METADATA_PES:
GF_SAFEALLOC(pes, GF_M2TS_PES);
if (!pes) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG2TS] Failed to allocate ES for pid %d\n", pid));
return;
}
pes->cc = -1;
pes->flags = GF_M2TS_ES_IS_PES;
if (inherit_pcr)
pes->flags |= GF_M2TS_INHERIT_PCR;
es = (GF_M2TS_ES *)pes;
break;
case GF_M2TS_PRIVATE_DATA:
GF_SAFEALLOC(pes, GF_M2TS_PES);
if (!pes) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG2TS] Failed to allocate ES for pid %d\n", pid));
return;
}
pes->cc = -1;
pes->flags = GF_M2TS_ES_IS_PES;
es = (GF_M2TS_ES *)pes;
break;
/* Sections */
case GF_M2TS_SYSTEMS_MPEG4_SECTIONS:
GF_SAFEALLOC(ses, GF_M2TS_SECTION_ES);
if (!ses) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG2TS] Failed to allocate ES for pid %d\n", pid));
return;
}
es = (GF_M2TS_ES *)ses;
es->flags |= GF_M2TS_ES_IS_SECTION;
/* carriage of ISO_IEC_14496 data in sections */
if (stream_type == GF_M2TS_SYSTEMS_MPEG4_SECTIONS) {
/*MPEG-4 sections need to be fully checked: if one section is lost, this means we lost
one SL packet in the AU so we must wait for the complete section again*/
ses->sec = gf_m2ts_section_filter_new(gf_m2ts_process_mpeg4section, 0);
/*create OD container*/
if (!pmt->program->additional_ods) {
pmt->program->additional_ods = gf_list_new();
ts->has_4on2 = 1;
}
}
break;
case GF_M2TS_13818_6_ANNEX_A:
case GF_M2TS_13818_6_ANNEX_B:
case GF_M2TS_13818_6_ANNEX_C:
case GF_M2TS_13818_6_ANNEX_D:
case GF_M2TS_PRIVATE_SECTION:
case GF_M2TS_QUALITY_SEC:
case GF_M2TS_MORE_SEC:
GF_SAFEALLOC(ses, GF_M2TS_SECTION_ES);
if (!ses) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG2TS] Failed to allocate ES for pid %d\n", pid));
return;
}
es = (GF_M2TS_ES *)ses;
es->flags |= GF_M2TS_ES_IS_SECTION;
es->pid = pid;
es->service_id = pmt->program->number;
if (stream_type == GF_M2TS_PRIVATE_SECTION) {
GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("AIT sections on pid %d\n", pid));
} else if (stream_type == GF_M2TS_QUALITY_SEC) {
GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("Quality metadata sections on pid %d\n", pid));
} else if (stream_type == GF_M2TS_MORE_SEC) {
GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("MORE sections on pid %d\n", pid));
} else {
GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("stream type DSM CC user private sections on pid %d \n", pid));
}
/* NULL means: trigger the call to on_event with DVB_GENERAL type and the raw section as payload */
ses->sec = gf_m2ts_section_filter_new(NULL, 1);
//ses->sec->service_id = pmt->program->number;
break;
case GF_M2TS_MPE_SECTIONS:
if (! ts->prefix_present) {
GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("stream type MPE found : pid = %d \n", pid));
#ifdef GPAC_ENABLE_MPE
es = gf_dvb_mpe_section_new();
if (es->flags & GF_M2TS_ES_IS_SECTION) {
/* NULL means: trigger the call to on_event with DVB_GENERAL type and the raw section as payload */
((GF_M2TS_SECTION_ES*)es)->sec = gf_m2ts_section_filter_new(NULL, 1);
}
#endif
break;
}
default:
GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[MPEG-2 TS] Stream type (0x%x) for PID %d not supported\n", stream_type, pid ) );
//GF_LOG(/*GF_LOG_WARNING*/GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG-2 TS] Stream type (0x%x) for PID %d not supported\n", stream_type, pid ) );
break;
}
if (es) {
es->stream_type = (stream_type==GF_M2TS_PRIVATE_DATA) ? 0 : stream_type;
es->program = pmt->program;
es->pid = pid;
es->component_tag = -1;
}
pos += 5;
data += 5;
while (desc_len) {
if (pos + 2 > data_size) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("Broken PMT descriptor! size %d but position %d and need at least 2 bytes to parse descritpor\n", data_size, pos));
break;
}
u8 tag = data[0];
u32 len = data[1];
if (pos + 2 + len > data_size) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("Broken PMT descriptor! size %d, desc size %d but position %d\n", data_size, len, pos));
break;
}
if (es) {
switch (tag) {
case GF_M2TS_ISO_639_LANGUAGE_DESCRIPTOR:
if (pes && (len>=3) )
pes->lang = GF_4CC(' ', data[2], data[3], data[4]);
break;
case GF_M2TS_MPEG4_SL_DESCRIPTOR:
if (len>=2) {
es->mpeg4_es_id = ( (u32) data[2] & 0x1f) << 8 | data[3];
es->flags |= GF_M2TS_ES_IS_SL;
}
break;
case GF_M2TS_REGISTRATION_DESCRIPTOR:
if (len>=4) {
reg_desc_format = GF_4CC(data[2], data[3], data[4], data[5]);
/*cf http://www.smpte-ra.org/mpegreg/mpegreg.html*/
switch (reg_desc_format) {
case GF_M2TS_RA_STREAM_AC3:
es->stream_type = GF_M2TS_AUDIO_AC3;
break;
case GF_M2TS_RA_STREAM_VC1:
es->stream_type = GF_M2TS_VIDEO_VC1;
break;
case GF_M2TS_RA_STREAM_GPAC:
if (len==8) {
es->stream_type = GF_4CC(data[6], data[7], data[8], data[9]);
es->flags |= GF_M2TS_GPAC_CODEC_ID;
break;
}
default:
GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("Unknown registration descriptor %s\n", gf_4cc_to_str(reg_desc_format) ));
break;
}
}
break;
case GF_M2TS_DVB_EAC3_DESCRIPTOR:
es->stream_type = GF_M2TS_AUDIO_EC3;
break;
case GF_M2TS_DVB_DATA_BROADCAST_ID_DESCRIPTOR:
if (len>=2) {
u32 id = data[2]<<8 | data[3];
if ((id == 0xB) && ses && !ses->sec) {
ses->sec = gf_m2ts_section_filter_new(NULL, 1);
}
}
break;
case GF_M2TS_DVB_SUBTITLING_DESCRIPTOR:
if (pes && (len>=8)) {
pes->sub.language[0] = data[2];
pes->sub.language[1] = data[3];
pes->sub.language[2] = data[4];
pes->sub.type = data[5];
pes->sub.composition_page_id = (data[6]<<8) | data[7];
pes->sub.ancillary_page_id = (data[8]<<8) | data[9];
}
es->stream_type = GF_M2TS_DVB_SUBTITLE;
break;
case GF_M2TS_DVB_STREAM_IDENTIFIER_DESCRIPTOR:
if (len>=1) {
es->component_tag = data[2];
GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("Component Tag: %d on Program %d\n", es->component_tag, es->program->number));
}
break;
case GF_M2TS_DVB_TELETEXT_DESCRIPTOR:
es->stream_type = GF_M2TS_DVB_TELETEXT;
break;
case GF_M2TS_DVB_VBI_DATA_DESCRIPTOR:
es->stream_type = GF_M2TS_DVB_VBI;
break;
case GF_M2TS_HIERARCHY_DESCRIPTOR:
if (pes && (len>=4)) {
u8 hierarchy_embedded_layer_index;
GF_BitStream *hbs = gf_bs_new((const char *)data, data_size, GF_BITSTREAM_READ);
/*u32 skip = */gf_bs_read_int(hbs, 16);
/*u8 res1 = */gf_bs_read_int(hbs, 1);
/*u8 temp_scal = */gf_bs_read_int(hbs, 1);
/*u8 spatial_scal = */gf_bs_read_int(hbs, 1);
/*u8 quality_scal = */gf_bs_read_int(hbs, 1);
/*u8 hierarchy_type = */gf_bs_read_int(hbs, 4);
/*u8 res2 = */gf_bs_read_int(hbs, 2);
/*u8 hierarchy_layer_index = */gf_bs_read_int(hbs, 6);
/*u8 tref_not_present = */gf_bs_read_int(hbs, 1);
/*u8 res3 = */gf_bs_read_int(hbs, 1);
hierarchy_embedded_layer_index = gf_bs_read_int(hbs, 6);
/*u8 res4 = */gf_bs_read_int(hbs, 2);
/*u8 hierarchy_channel = */gf_bs_read_int(hbs, 6);
gf_bs_del(hbs);
pes->depends_on_pid = 1+hierarchy_embedded_layer_index;
}
break;
case GF_M2TS_METADATA_DESCRIPTOR:
{
GF_BitStream *metadatad_bs;
GF_M2TS_MetadataDescriptor *metad;
metadatad_bs = gf_bs_new((char *)data+2, len, GF_BITSTREAM_READ);
metad = gf_m2ts_read_metadata_descriptor(metadatad_bs, len);
gf_bs_del(metadatad_bs);
if (metad->application_format_identifier == GF_M2TS_META_ID3 &&
metad->format_identifier == GF_M2TS_META_ID3) {
/*HLS ID3 Metadata */
if (pes) {
pes->metadata_descriptor = metad;
pes->stream_type = GF_M2TS_METADATA_ID3_HLS;
}
} else {
/* don't know what to do with it for now, delete */
gf_m2ts_metadata_descriptor_del(metad);
}
}
break;
default:
GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[MPEG-2 TS] skipping descriptor (0x%x) not supported\n", tag));
break;
}
}
data += len+2;
pos += len+2;
if (desc_len < len+2) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG-2 TS] Invalid PMT es descriptor size for PID %d\n", pid ) );
break;
}
desc_len-=len+2;
}
if (es && !es->stream_type) {
gf_free(es);
es = NULL;
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[MPEG-2 TS] Private Stream type (0x%x) for PID %d not supported\n", stream_type, pid ) );
}
if (!es) continue;
if (ts->ess[pid]) {
//this is component reuse across programs, overwrite the previously declared stream ...
if (status & GF_M2TS_TABLE_FOUND) {
GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[MPEG-2 TS] PID %d reused across programs %d and %d, not completely supported\n", pid, ts->ess[pid]->program->number, es->program->number ) );
//add stream to program but don't reassign the pid table until the stream is playing (>GF_M2TS_PES_FRAMING_SKIP)
gf_list_add(pmt->program->streams, es);
if (!(es->flags & GF_M2TS_ES_IS_SECTION) ) gf_m2ts_set_pes_framing(pes, GF_M2TS_PES_FRAMING_SKIP);
nb_es++;
//skip assignment below
es = NULL;
}
/*watchout for pmt update - FIXME this likely won't work in most cases*/
else {
GF_M2TS_ES *o_es = ts->ess[es->pid];
if ((o_es->stream_type == es->stream_type)
&& ((o_es->flags & GF_M2TS_ES_STATIC_FLAGS_MASK) == (es->flags & GF_M2TS_ES_STATIC_FLAGS_MASK))
&& (o_es->mpeg4_es_id == es->mpeg4_es_id)
&& ((o_es->flags & GF_M2TS_ES_IS_SECTION) || ((GF_M2TS_PES *)o_es)->lang == ((GF_M2TS_PES *)es)->lang)
) {
gf_free(es);
es = NULL;
} else {
gf_m2ts_es_del(o_es, ts);
ts->ess[es->pid] = NULL;
}
}
}
if (es) {
ts->ess[es->pid] = es;
gf_list_add(pmt->program->streams, es);
if (!(es->flags & GF_M2TS_ES_IS_SECTION) ) gf_m2ts_set_pes_framing(pes, GF_M2TS_PES_FRAMING_SKIP);
nb_es++;
if (es->stream_type == GF_M2TS_VIDEO_HEVC) nb_hevc++;
else if (es->stream_type == GF_M2TS_VIDEO_HEVC_TEMPORAL) nb_hevc_temp++;
else if (es->stream_type == GF_M2TS_VIDEO_SHVC) nb_shvc++;
else if (es->stream_type == GF_M2TS_VIDEO_SHVC_TEMPORAL) nb_shvc_temp++;
else if (es->stream_type == GF_M2TS_VIDEO_MHVC) nb_mhvc++;
else if (es->stream_type == GF_M2TS_VIDEO_MHVC_TEMPORAL) nb_mhvc_temp++;
}
}
//Table 2-139, implied hierarchy indexes
if (nb_hevc_temp + nb_shvc + nb_shvc_temp + nb_mhvc+ nb_mhvc_temp) {
for (i=0; i<gf_list_count(pmt->program->streams); i++) {
GF_M2TS_PES *es = (GF_M2TS_PES *)gf_list_get(pmt->program->streams, i);
if ( !(es->flags & GF_M2TS_ES_IS_PES)) continue;
if (es->depends_on_pid) continue;
switch (es->stream_type) {
case GF_M2TS_VIDEO_HEVC_TEMPORAL:
es->depends_on_pid = 1;
break;
case GF_M2TS_VIDEO_SHVC:
if (!nb_hevc_temp) es->depends_on_pid = 1;
else es->depends_on_pid = 2;
break;
case GF_M2TS_VIDEO_SHVC_TEMPORAL:
es->depends_on_pid = 3;
break;
case GF_M2TS_VIDEO_MHVC:
if (!nb_hevc_temp) es->depends_on_pid = 1;
else es->depends_on_pid = 2;
break;
case GF_M2TS_VIDEO_MHVC_TEMPORAL:
if (!nb_hevc_temp) es->depends_on_pid = 2;
else es->depends_on_pid = 3;
break;
}
}
}
if (nb_es) {
u32 i;
//translate hierarchy descriptors indexes into PIDs - check whether the PMT-index rules are the same for HEVC
for (i=0; i<gf_list_count(pmt->program->streams); i++) {
GF_M2TS_PES *an_es = NULL;
GF_M2TS_PES *es = (GF_M2TS_PES *)gf_list_get(pmt->program->streams, i);
if ( !(es->flags & GF_M2TS_ES_IS_PES)) continue;
if (!es->depends_on_pid) continue;
//fixeme we are not always assured that hierarchy_layer_index matches the stream index...
//+1 is because our first stream is the PMT
an_es = (GF_M2TS_PES *)gf_list_get(pmt->program->streams, es->depends_on_pid);
if (an_es) {
es->depends_on_pid = an_es->pid;
} else {
GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[M2TS] Wrong dependency index in hierarchy descriptor, assuming non-scalable stream\n"));
es->depends_on_pid = 0;
}
}
evt_type = (status&GF_M2TS_TABLE_FOUND) ? GF_M2TS_EVT_PMT_FOUND : GF_M2TS_EVT_PMT_UPDATE;
if (ts->on_event) ts->on_event(ts, evt_type, pmt->program);
} else {
/* if we found no new ES it's simply a repeat of the PMT */
if (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_PMT_REPEAT, pmt->program);
}
} | 2943 | True | 1 |
CVE-2019-20628 | 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/gpac/gpac/commit/98b727637e32d1d4824101d8947e2dbd573d4fc8', 'name': 'https://github.com/gpac/gpac/commit/98b727637e32d1d4824101d8947e2dbd573d4fc8', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/issues/1269', 'name': 'https://github.com/gpac/gpac/issues/1269', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/1ab4860609f2e7a35634930571e7d0531297e090', 'name': 'https://github.com/gpac/gpac/commit/1ab4860609f2e7a35634930571e7d0531297e090', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-416'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:*:*:*:*:*:*:*:*', 'versionEndExcluding': '0.8.0', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'An issue was discovered in libgpac.a in GPAC before 0.8.0, as demonstrated by MP4Box. It contains a Use-After-Free vulnerability in gf_m2ts_process_pmt in media_tools/mpegts.c that can cause a denial of service via a crafted MP4 file.'}] | 2020-03-25T13:51Z | 2020-03-24T19: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 | jeanlf | 2019-07-07 17:54:21+02:00 | be stricter in PAT processing - cf #1269 | 98b727637e32d1d4824101d8947e2dbd573d4fc8 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_m2ts_process_pat | gf_m2ts_process_pat( GF_M2TS_Demuxer * ts , GF_M2TS_SECTION_ES * ses , GF_List * sections , u8 table_id , u16 ex_table_id , u8 version_number , u8 last_section_number , u32 status) | ['ts', 'ses', 'sections', 'table_id', 'ex_table_id', 'version_number', 'last_section_number', 'status'] | static void gf_m2ts_process_pat(GF_M2TS_Demuxer *ts, GF_M2TS_SECTION_ES *ses, GF_List *sections, u8 table_id, u16 ex_table_id, u8 version_number, u8 last_section_number, u32 status)
{
GF_M2TS_Program *prog;
GF_M2TS_SECTION_ES *pmt;
u32 i, nb_progs, evt_type;
u32 nb_sections;
u32 data_size;
unsigned char *data;
GF_M2TS_Section *section;
/*wait for the last section */
if (!(status&GF_M2TS_TABLE_END)) return;
/*skip if already received*/
if (status&GF_M2TS_TABLE_REPEAT) {
if (ts->on_event) ts->on_event(ts, GF_M2TS_EVT_PAT_REPEAT, NULL);
return;
}
nb_sections = gf_list_count(sections);
if (nb_sections > 1) {
GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("PAT on multiple sections not supported\n"));
}
section = (GF_M2TS_Section *)gf_list_get(sections, 0);
data = section->data;
data_size = section->data_size;
if (!(status&GF_M2TS_TABLE_UPDATE) && gf_list_count(ts->programs)) {
if (ts->pat->demux_restarted) {
ts->pat->demux_restarted = 0;
} else {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("Multiple different PAT on single TS found, ignoring new PAT declaration (table id %d - extended table id %d)\n", table_id, ex_table_id));
}
return;
}
nb_progs = data_size / 4;
for (i=0; i<nb_progs; i++) {
u16 number, pid;
number = (data[0]<<8) | data[1];
pid = (data[2]&0x1f)<<8 | data[3];
data += 4;
if (number==0) {
if (!ts->nit) {
ts->nit = gf_m2ts_section_filter_new(gf_m2ts_process_nit, 0);
}
} else {
GF_SAFEALLOC(prog, GF_M2TS_Program);
if (!prog) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("Fail to allocate program for pid %d\n", pid));
return;
}
prog->streams = gf_list_new();
prog->pmt_pid = pid;
prog->number = number;
prog->ts = ts;
gf_list_add(ts->programs, prog);
GF_SAFEALLOC(pmt, GF_M2TS_SECTION_ES);
if (!pmt) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("Fail to allocate pmt filter for pid %d\n", pid));
return;
}
pmt->flags = GF_M2TS_ES_IS_SECTION;
gf_list_add(prog->streams, pmt);
pmt->pid = prog->pmt_pid;
pmt->program = prog;
ts->ess[pmt->pid] = (GF_M2TS_ES *)pmt;
pmt->sec = gf_m2ts_section_filter_new(gf_m2ts_process_pmt, 0);
}
}
evt_type = (status&GF_M2TS_TABLE_UPDATE) ? GF_M2TS_EVT_PAT_UPDATE : GF_M2TS_EVT_PAT_FOUND;
if (ts->on_event) ts->on_event(ts, evt_type, NULL);
} | 480 | True | 1 |
CVE-2020-11558 | 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/gpac/gpac/issues/1440', 'name': 'https://github.com/gpac/gpac/issues/1440', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/6063b1a011c3f80cee25daade18154e15e4c058c', 'name': 'https://github.com/gpac/gpac/commit/6063b1a011c3f80cee25daade18154e15e4c058c', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-416'}]}] | HIGH | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:0.8.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'An issue was discovered in libgpac.a in GPAC 0.8.0, as demonstrated by MP4Box. audio_sample_entry_Read in isomedia/box_code_base.c does not properly decide when to make gf_isom_box_del calls. This leads to various use-after-free outcomes involving mdia_Read, gf_isom_delete_movie, and gf_isom_parse_movie_boxes.'}] | 2020-04-06T14:51Z | 2020-04-05T20: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 | Aurelien David | 2020-03-26 19:17:07+01:00 | fix UAF in audio_sample_entry_Read (#1440) | 6063b1a011c3f80cee25daade18154e15e4c058c | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | audio_sample_entry_Read | audio_sample_entry_Read( GF_Box * s , GF_BitStream * bs) | ['s', 'bs'] | GF_Err audio_sample_entry_Read(GF_Box *s, GF_BitStream *bs)
{
GF_MPEGAudioSampleEntryBox *ptr;
char *data;
u8 a, b, c, d;
u32 i, size, v, nb_alnum;
GF_Err e;
u64 pos, start;
ptr = (GF_MPEGAudioSampleEntryBox *)s;
start = gf_bs_get_position(bs);
gf_bs_seek(bs, start + 8);
v = gf_bs_read_u16(bs);
if (v)
ptr->is_qtff = 1;
//try to disambiguate QTFF v1 and MP4 v1 audio sample entries ...
if (v==1) {
//go to end of ISOM audio sample entry, skip 4 byte (box size field), read 4 bytes (box type) and check if this looks like a box
gf_bs_seek(bs, start + 8 + 20 + 4);
a = gf_bs_read_u8(bs);
b = gf_bs_read_u8(bs);
c = gf_bs_read_u8(bs);
d = gf_bs_read_u8(bs);
nb_alnum = 0;
if (isalnum(a)) nb_alnum++;
if (isalnum(b)) nb_alnum++;
if (isalnum(c)) nb_alnum++;
if (isalnum(d)) nb_alnum++;
if (nb_alnum>2) ptr->is_qtff = 0;
}
gf_bs_seek(bs, start);
e = gf_isom_audio_sample_entry_read((GF_AudioSampleEntryBox*)s, bs);
if (e) return e;
pos = gf_bs_get_position(bs);
size = (u32) s->size;
//when cookie is set on bs, always convert qtff-style mp4a to isobmff-style
//since the conversion is done in addBox and we don't have the bitstream there (arg...), flag the box
if (gf_bs_get_cookie(bs)) {
ptr->is_qtff |= 1<<16;
}
e = gf_isom_box_array_read(s, bs, audio_sample_entry_AddBox);
if (!e) return GF_OK;
if (size<8) return GF_ISOM_INVALID_FILE;
/*hack for some weird files (possibly recorded with live.com tools, needs further investigations)*/
gf_bs_seek(bs, pos);
data = (char*)gf_malloc(sizeof(char) * size);
gf_bs_read_data(bs, data, size);
for (i=0; i<size-8; i++) {
if (GF_4CC((u32)data[i+4], (u8)data[i+5], (u8)data[i+6], (u8)data[i+7]) == GF_ISOM_BOX_TYPE_ESDS) {
GF_BitStream *mybs = gf_bs_new(data + i, size - i, GF_BITSTREAM_READ);
if (ptr->esd) {
gf_isom_box_del((GF_Box *)ptr->esd);
ptr->esd=NULL;
}
e = gf_isom_box_parse((GF_Box **)&ptr->esd, mybs);
if (e==GF_OK) {
gf_isom_box_add_for_dump_mode((GF_Box*)ptr, (GF_Box*)ptr->esd);
} else if (ptr->esd) {
gf_isom_box_del((GF_Box *)ptr->esd);
ptr->esd=NULL;
}
gf_bs_del(mybs);
break;
}
}
gf_free(data);
return e;
} | 503 | True | 1 |
CVE-2018-13006 | 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/gpac/gpac/commit/bceb03fd2be95097a7b409ea59914f332fb6bc86', 'name': 'https://github.com/gpac/gpac/commit/bceb03fd2be95097a7b409ea59914f332fb6bc86', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2018/07/msg00024.html', 'name': '[debian-lts-announce] 20180719 [SECURITY] [DLA 1432-1] gpac security update', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://usn.ubuntu.com/3926-1/', 'name': 'USN-3926-1', 'refsource': 'UBUNTU', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}]}] | HIGH | [{'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:gpac:gpac:0.7.1:*:*:*:*:*:*:*', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:canonical:ubuntu_linux:16.04:*:*:*:lts:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:canonical:ubuntu_linux:18.04:*:*:*:lts:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:canonical:ubuntu_linux:18.10:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'An issue was discovered in MP4Box in GPAC 0.7.1. There is a heap-based buffer over-read in the isomedia/box_dump.c function hdlr_dump.'}] | 2019-03-29T18:58Z | 2018-06-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 | Aurelien David | 2018-06-28 13:34:08+02:00 | fixed 2 possible heap overflows (inc. #1088) | bceb03fd2be95097a7b409ea59914f332fb6bc86 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | urn_Read | urn_Read( GF_Box * s , GF_BitStream * bs) | ['s', 'bs'] | GF_Err urn_Read(GF_Box *s, GF_BitStream *bs)
{
u32 i, to_read;
char *tmpName;
GF_DataEntryURNBox *ptr = (GF_DataEntryURNBox *)s;
if (! ptr->size ) return GF_OK;
//here we have to handle that in a clever way
to_read = (u32) ptr->size;
tmpName = (char*)gf_malloc(sizeof(char) * to_read);
if (!tmpName) return GF_OUT_OF_MEM;
//get the data
gf_bs_read_data(bs, tmpName, to_read);
//then get the break
i = 0;
while ( (tmpName[i] != 0) && (i < to_read) ) {
i++;
}
//check the data is consistent
if (i == to_read) {
gf_free(tmpName);
return GF_ISOM_INVALID_FILE;
}
//no NULL char, URL is not specified
if (i == to_read - 1) {
ptr->nameURN = tmpName;
ptr->location = NULL;
return GF_OK;
}
//OK, this has both URN and URL
ptr->nameURN = (char*)gf_malloc(sizeof(char) * (i+1));
if (!ptr->nameURN) {
gf_free(tmpName);
return GF_OUT_OF_MEM;
}
ptr->location = (char*)gf_malloc(sizeof(char) * (to_read - i - 1));
if (!ptr->location) {
gf_free(tmpName);
gf_free(ptr->nameURN);
ptr->nameURN = NULL;
return GF_OUT_OF_MEM;
}
memcpy(ptr->nameURN, tmpName, i + 1);
memcpy(ptr->location, tmpName + i + 1, (to_read - i - 1));
gf_free(tmpName);
return GF_OK;
} | 285 | True | 1 |
CVE-2018-13006 | 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/gpac/gpac/commit/bceb03fd2be95097a7b409ea59914f332fb6bc86', 'name': 'https://github.com/gpac/gpac/commit/bceb03fd2be95097a7b409ea59914f332fb6bc86', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2018/07/msg00024.html', 'name': '[debian-lts-announce] 20180719 [SECURITY] [DLA 1432-1] gpac security update', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://usn.ubuntu.com/3926-1/', 'name': 'USN-3926-1', 'refsource': 'UBUNTU', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}]}] | HIGH | [{'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:gpac:gpac:0.7.1:*:*:*:*:*:*:*', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:canonical:ubuntu_linux:16.04:*:*:*:lts:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:canonical:ubuntu_linux:18.04:*:*:*:lts:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:canonical:ubuntu_linux:18.10:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'An issue was discovered in MP4Box in GPAC 0.7.1. There is a heap-based buffer over-read in the isomedia/box_dump.c function hdlr_dump.'}] | 2019-03-29T18:58Z | 2018-06-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 | Aurelien David | 2018-06-28 13:34:08+02:00 | fixed 2 possible heap overflows (inc. #1088) | bceb03fd2be95097a7b409ea59914f332fb6bc86 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | hdlr_dump | hdlr_dump( GF_Box * a , FILE * trace) | ['a', 'trace'] | GF_Err hdlr_dump(GF_Box *a, FILE * trace)
{
GF_HandlerBox *p = (GF_HandlerBox *)a;
gf_isom_box_dump_start(a, "HandlerBox", trace);
if (p->nameUTF8 && (u32) p->nameUTF8[0] == strlen(p->nameUTF8+1)) {
fprintf(trace, "hdlrType=\"%s\" Name=\"%s\" ", gf_4cc_to_str(p->handlerType), p->nameUTF8+1);
} else {
fprintf(trace, "hdlrType=\"%s\" Name=\"%s\" ", gf_4cc_to_str(p->handlerType), p->nameUTF8);
}
fprintf(trace, "reserved1=\"%d\" reserved2=\"", p->reserved1);
dump_data(trace, (char *) p->reserved2, 12);
fprintf(trace, "\"");
fprintf(trace, ">\n");
gf_isom_box_dump_done("HandlerBox", a, trace);
return GF_OK;
} | 151 | True | 1 |
CVE-2018-13006 | 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/gpac/gpac/commit/bceb03fd2be95097a7b409ea59914f332fb6bc86', 'name': 'https://github.com/gpac/gpac/commit/bceb03fd2be95097a7b409ea59914f332fb6bc86', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2018/07/msg00024.html', 'name': '[debian-lts-announce] 20180719 [SECURITY] [DLA 1432-1] gpac security update', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://usn.ubuntu.com/3926-1/', 'name': 'USN-3926-1', 'refsource': 'UBUNTU', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}]}] | HIGH | [{'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:gpac:gpac:0.7.1:*:*:*:*:*:*:*', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:canonical:ubuntu_linux:16.04:*:*:*:lts:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:canonical:ubuntu_linux:18.04:*:*:*:lts:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:canonical:ubuntu_linux:18.10:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'An issue was discovered in MP4Box in GPAC 0.7.1. There is a heap-based buffer over-read in the isomedia/box_dump.c function hdlr_dump.'}] | 2019-03-29T18:58Z | 2018-06-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 | Aurelien David | 2018-06-28 13:34:08+02:00 | fixed 2 possible heap overflows (inc. #1088) | bceb03fd2be95097a7b409ea59914f332fb6bc86 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | nalm_dump | nalm_dump( FILE * trace , char * data , u32 data_size) | ['trace', 'data', 'data_size'] | static void nalm_dump(FILE * trace, char *data, u32 data_size)
{
GF_BitStream *bs;
Bool rle, large_size;
u32 entry_count;
if (!data) {
fprintf(trace, "<NALUMap rle=\"\" large_size=\"\">\n");
fprintf(trace, "<NALUMapEntry NALU_startNumber=\"\" groupID=\"\"/>\n");
fprintf(trace, "</NALUMap>\n");
return;
}
bs = gf_bs_new(data, data_size, GF_BITSTREAM_READ);
gf_bs_read_int(bs, 6);
large_size = gf_bs_read_int(bs, 1);
rle = gf_bs_read_int(bs, 1);
entry_count = gf_bs_read_int(bs, large_size ? 16 : 8);
fprintf(trace, "<NALUMap rle=\"%d\" large_size=\"%d\">\n", rle, large_size);
while (entry_count) {
u32 ID;
fprintf(trace, "<NALUMapEntry ");
if (rle) {
u32 start_num = gf_bs_read_int(bs, large_size ? 16 : 8);
fprintf(trace, "NALU_startNumber=\"%d\" ", start_num);
}
ID = gf_bs_read_u16(bs);
fprintf(trace, "groupID=\"%d\"/>\n", ID);
entry_count--;
}
gf_bs_del(bs);
fprintf(trace, "</NALUMap>\n");
return;
} | 195 | True | 1 |
CVE-2018-13006 | 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/gpac/gpac/commit/bceb03fd2be95097a7b409ea59914f332fb6bc86', 'name': 'https://github.com/gpac/gpac/commit/bceb03fd2be95097a7b409ea59914f332fb6bc86', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2018/07/msg00024.html', 'name': '[debian-lts-announce] 20180719 [SECURITY] [DLA 1432-1] gpac security update', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://usn.ubuntu.com/3926-1/', 'name': 'USN-3926-1', 'refsource': 'UBUNTU', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}]}] | HIGH | [{'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:gpac:gpac:0.7.1:*:*:*:*:*:*:*', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:canonical:ubuntu_linux:16.04:*:*:*:lts:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:canonical:ubuntu_linux:18.04:*:*:*:lts:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:canonical:ubuntu_linux:18.10:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'An issue was discovered in MP4Box in GPAC 0.7.1. There is a heap-based buffer over-read in the isomedia/box_dump.c function hdlr_dump.'}] | 2019-03-29T18:58Z | 2018-06-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 | Aurelien David | 2018-06-28 13:34:08+02:00 | fixed 2 possible heap overflows (inc. #1088) | bceb03fd2be95097a7b409ea59914f332fb6bc86 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | oinf_entry_dump | oinf_entry_dump( GF_OperatingPointsInformation * ptr , FILE * trace) | ['ptr', 'trace'] | static void oinf_entry_dump(GF_OperatingPointsInformation *ptr, FILE * trace)
{
u32 i, count;
if (!ptr) {
fprintf(trace, "<OperatingPointsInformation scalability_mask=\"Multiview|Spatial scalability|Auxilary|unknown\" num_profile_tier_level=\"\" num_operating_points=\"\" dependency_layers=\"\">\n");
fprintf(trace, " <ProfileTierLevel general_profile_space=\"\" general_tier_flag=\"\" general_profile_idc=\"\" general_profile_compatibility_flags=\"\" general_constraint_indicator_flags=\"\" />\n");
fprintf(trace, "<OperatingPoint output_layer_set_idx=\"\" max_temporal_id=\"\" layer_count=\"\" minPicWidth=\"\" minPicHeight=\"\" maxPicWidth=\"\" maxPicHeight=\"\" maxChromaFormat=\"\" maxBitDepth=\"\" frame_rate_info_flag=\"\" bit_rate_info_flag=\"\" avgFrameRate=\"\" constantFrameRate=\"\" maxBitRate=\"\" avgBitRate=\"\"/>\n");
fprintf(trace, "<Layer dependent_layerID=\"\" num_layers_dependent_on=\"\" dependent_on_layerID=\"\" dimension_identifier=\"\"/>\n");
fprintf(trace, "</OperatingPointsInformation>\n");
return;
}
fprintf(trace, "<OperatingPointsInformation");
fprintf(trace, " scalability_mask=\"%u (", ptr->scalability_mask);
switch (ptr->scalability_mask) {
case 2:
fprintf(trace, "Multiview");
break;
case 4:
fprintf(trace, "Spatial scalability");
break;
case 8:
fprintf(trace, "Auxilary");
break;
default:
fprintf(trace, "unknown");
}
fprintf(trace, ")\" num_profile_tier_level=\"%u\"", gf_list_count(ptr->profile_tier_levels) );
fprintf(trace, " num_operating_points=\"%u\" dependency_layers=\"%u\"", gf_list_count(ptr->operating_points), gf_list_count(ptr->dependency_layers));
fprintf(trace, ">\n");
count=gf_list_count(ptr->profile_tier_levels);
for (i = 0; i < count; i++) {
LHEVC_ProfileTierLevel *ptl = (LHEVC_ProfileTierLevel *)gf_list_get(ptr->profile_tier_levels, i);
fprintf(trace, " <ProfileTierLevel general_profile_space=\"%u\" general_tier_flag=\"%u\" general_profile_idc=\"%u\" general_profile_compatibility_flags=\"%X\" general_constraint_indicator_flags=\""LLX"\" />\n", ptl->general_profile_space, ptl->general_tier_flag, ptl->general_profile_idc, ptl->general_profile_compatibility_flags, ptl->general_constraint_indicator_flags);
}
count=gf_list_count(ptr->operating_points);
for (i = 0; i < count; i++) {
LHEVC_OperatingPoint *op = (LHEVC_OperatingPoint *)gf_list_get(ptr->operating_points, i);
fprintf(trace, "<OperatingPoint output_layer_set_idx=\"%u\"", op->output_layer_set_idx);
fprintf(trace, " max_temporal_id=\"%u\" layer_count=\"%u\"", op->max_temporal_id, op->layer_count);
fprintf(trace, " minPicWidth=\"%u\" minPicHeight=\"%u\"", op->minPicWidth, op->minPicHeight);
fprintf(trace, " maxPicWidth=\"%u\" maxPicHeight=\"%u\"", op->maxPicWidth, op->maxPicHeight);
fprintf(trace, " maxChromaFormat=\"%u\" maxBitDepth=\"%u\"", op->maxChromaFormat, op->maxBitDepth);
fprintf(trace, " frame_rate_info_flag=\"%u\" bit_rate_info_flag=\"%u\"", op->frame_rate_info_flag, op->bit_rate_info_flag);
if (op->frame_rate_info_flag)
fprintf(trace, " avgFrameRate=\"%u\" constantFrameRate=\"%u\"", op->avgFrameRate, op->constantFrameRate);
if (op->bit_rate_info_flag)
fprintf(trace, " maxBitRate=\"%u\" avgBitRate=\"%u\"", op->maxBitRate, op->avgBitRate);
fprintf(trace, "/>\n");
}
count=gf_list_count(ptr->dependency_layers);
for (i = 0; i < count; i++) {
u32 j;
LHEVC_DependentLayer *dep = (LHEVC_DependentLayer *)gf_list_get(ptr->dependency_layers, i);
fprintf(trace, "<Layer dependent_layerID=\"%u\" num_layers_dependent_on=\"%u\"", dep->dependent_layerID, dep->num_layers_dependent_on);
if (dep->num_layers_dependent_on) {
fprintf(trace, " dependent_on_layerID=\"");
for (j = 0; j < dep->num_layers_dependent_on; j++)
fprintf(trace, "%d ", dep->dependent_on_layerID[j]);
fprintf(trace, "\"");
}
fprintf(trace, " dimension_identifier=\"");
for (j = 0; j < 16; j++)
if (ptr->scalability_mask & (1 << j))
fprintf(trace, "%d ", dep->dimension_identifier[j]);
fprintf(trace, "\"/>\n");
}
fprintf(trace, "</OperatingPointsInformation>\n");
return;
} | 593 | True | 1 |
CVE-2018-13006 | 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/gpac/gpac/commit/bceb03fd2be95097a7b409ea59914f332fb6bc86', 'name': 'https://github.com/gpac/gpac/commit/bceb03fd2be95097a7b409ea59914f332fb6bc86', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2018/07/msg00024.html', 'name': '[debian-lts-announce] 20180719 [SECURITY] [DLA 1432-1] gpac security update', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://usn.ubuntu.com/3926-1/', 'name': 'USN-3926-1', 'refsource': 'UBUNTU', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}]}] | HIGH | [{'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:gpac:gpac:0.7.1:*:*:*:*:*:*:*', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:canonical:ubuntu_linux:16.04:*:*:*:lts:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:canonical:ubuntu_linux:18.04:*:*:*:lts:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:canonical:ubuntu_linux:18.10:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'An issue was discovered in MP4Box in GPAC 0.7.1. There is a heap-based buffer over-read in the isomedia/box_dump.c function hdlr_dump.'}] | 2019-03-29T18:58Z | 2018-06-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 | Aurelien David | 2018-06-28 13:34:08+02:00 | fixed 2 possible heap overflows (inc. #1088) | bceb03fd2be95097a7b409ea59914f332fb6bc86 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | sgpd_dump | sgpd_dump( GF_Box * a , FILE * trace) | ['a', 'trace'] | GF_Err sgpd_dump(GF_Box *a, FILE * trace)
{
u32 i;
GF_SampleGroupDescriptionBox *ptr = (GF_SampleGroupDescriptionBox*) a;
if (!a) return GF_BAD_PARAM;
gf_isom_box_dump_start(a, "SampleGroupDescriptionBox", trace);
if (ptr->grouping_type)
fprintf(trace, "grouping_type=\"%s\"", gf_4cc_to_str(ptr->grouping_type) );
if (ptr->version==1) fprintf(trace, " default_length=\"%d\"", ptr->default_length);
if ((ptr->version>=2) && ptr->default_description_index) fprintf(trace, " default_group_index=\"%d\"", ptr->default_description_index);
fprintf(trace, ">\n");
for (i=0; i<gf_list_count(ptr->group_descriptions); i++) {
void *entry = gf_list_get(ptr->group_descriptions, i);
switch (ptr->grouping_type) {
case GF_ISOM_SAMPLE_GROUP_ROLL:
fprintf(trace, "<RollRecoveryEntry roll_distance=\"%d\" />\n", ((GF_RollRecoveryEntry*)entry)->roll_distance );
break;
case GF_ISOM_SAMPLE_GROUP_PROL:
fprintf(trace, "<AudioPreRollEntry roll_distance=\"%d\" />\n", ((GF_RollRecoveryEntry*)entry)->roll_distance );
break;
case GF_ISOM_SAMPLE_GROUP_TELE:
fprintf(trace, "<TemporalLevelEntry level_independently_decodable=\"%d\"/>\n", ((GF_TemporalLevelEntry*)entry)->level_independently_decodable);
break;
case GF_ISOM_SAMPLE_GROUP_RAP:
fprintf(trace, "<VisualRandomAccessEntry num_leading_samples_known=\"%s\"", ((GF_VisualRandomAccessEntry*)entry)->num_leading_samples_known ? "yes" : "no");
if (((GF_VisualRandomAccessEntry*)entry)->num_leading_samples_known)
fprintf(trace, " num_leading_samples=\"%d\"", ((GF_VisualRandomAccessEntry*)entry)->num_leading_samples);
fprintf(trace, "/>\n");
break;
case GF_ISOM_SAMPLE_GROUP_SYNC:
fprintf(trace, "<SyncSampleGroupEntry NAL_unit_type=\"%d\"/>\n", ((GF_SYNCEntry*)entry)->NALU_type);
break;
case GF_ISOM_SAMPLE_GROUP_SEIG:
fprintf(trace, "<CENCSampleEncryptionGroupEntry IsEncrypted=\"%d\" IV_size=\"%d\" KID=\"", ((GF_CENCSampleEncryptionGroupEntry*)entry)->IsProtected, ((GF_CENCSampleEncryptionGroupEntry*)entry)->Per_Sample_IV_size);
dump_data_hex(trace, (char *)((GF_CENCSampleEncryptionGroupEntry*)entry)->KID, 16);
if ((((GF_CENCSampleEncryptionGroupEntry*)entry)->IsProtected == 1) && !((GF_CENCSampleEncryptionGroupEntry*)entry)->Per_Sample_IV_size) {
fprintf(trace, "\" constant_IV_size=\"%d\" constant_IV=\"", ((GF_CENCSampleEncryptionGroupEntry*)entry)->constant_IV_size);
dump_data_hex(trace, (char *)((GF_CENCSampleEncryptionGroupEntry*)entry)->constant_IV, ((GF_CENCSampleEncryptionGroupEntry*)entry)->constant_IV_size);
}
fprintf(trace, "\"/>\n");
break;
case GF_ISOM_SAMPLE_GROUP_OINF:
oinf_entry_dump(entry, trace);
break;
case GF_ISOM_SAMPLE_GROUP_LINF:
linf_dump(entry, trace);
break;
case GF_ISOM_SAMPLE_GROUP_TRIF:
trif_dump(trace, (char *) ((GF_DefaultSampleGroupDescriptionEntry*)entry)->data, ((GF_DefaultSampleGroupDescriptionEntry*)entry)->length);
break;
case GF_ISOM_SAMPLE_GROUP_NALM:
nalm_dump(trace, (char *) ((GF_DefaultSampleGroupDescriptionEntry*)entry)->data, ((GF_DefaultSampleGroupDescriptionEntry*)entry)->length);
break;
case GF_ISOM_SAMPLE_GROUP_SAP:
fprintf(trace, "<SAPEntry dependent_flag=\"%d\" SAP_type=\"%d\" />\n", ((GF_SAPEntry*)entry)->dependent_flag, ((GF_SAPEntry*)entry)->SAP_type);
break;
default:
fprintf(trace, "<DefaultSampleGroupDescriptionEntry size=\"%d\" data=\"", ((GF_DefaultSampleGroupDescriptionEntry*)entry)->length);
dump_data(trace, (char *) ((GF_DefaultSampleGroupDescriptionEntry*)entry)->data, ((GF_DefaultSampleGroupDescriptionEntry*)entry)->length);
fprintf(trace, "\"/>\n");
}
}
if (!ptr->size) {
switch (ptr->grouping_type) {
case GF_ISOM_SAMPLE_GROUP_ROLL:
fprintf(trace, "<RollRecoveryEntry roll_distance=\"\"/>\n");
break;
case GF_ISOM_SAMPLE_GROUP_PROL:
fprintf(trace, "<AudioPreRollEntry roll_distance=\"\"/>\n");
break;
case GF_ISOM_SAMPLE_GROUP_TELE:
fprintf(trace, "<TemporalLevelEntry level_independently_decodable=\"\"/>\n");
break;
case GF_ISOM_SAMPLE_GROUP_RAP:
fprintf(trace, "<VisualRandomAccessEntry num_leading_samples_known=\"yes|no\" num_leading_samples=\"\" />\n");
break;
case GF_ISOM_SAMPLE_GROUP_SYNC:
fprintf(trace, "<SyncSampleGroupEntry NAL_unit_type=\"\" />\n");
break;
case GF_ISOM_SAMPLE_GROUP_SEIG:
fprintf(trace, "<CENCSampleEncryptionGroupEntry IsEncrypted=\"\" IV_size=\"\" KID=\"\" constant_IV_size=\"\" constant_IV=\"\"/>\n");
break;
case GF_ISOM_SAMPLE_GROUP_OINF:
oinf_entry_dump(NULL, trace);
break;
case GF_ISOM_SAMPLE_GROUP_LINF:
linf_dump(NULL, trace);
break;
case GF_ISOM_SAMPLE_GROUP_TRIF:
trif_dump(trace, NULL, 0);
break;
case GF_ISOM_SAMPLE_GROUP_NALM:
nalm_dump(trace, NULL, 0);
break;
case GF_ISOM_SAMPLE_GROUP_SAP:
fprintf(trace, "<SAPEntry dependent_flag=\"\" SAP_type=\"\" />\n");
break;
default:
fprintf(trace, "<DefaultSampleGroupDescriptionEntry size=\"\" data=\"\"/>\n");
}
}
gf_isom_box_dump_done("SampleGroupDescriptionBox", a, trace);
return GF_OK;
} | 792 | True | 1 |
CVE-2018-13006 | 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/gpac/gpac/commit/bceb03fd2be95097a7b409ea59914f332fb6bc86', 'name': 'https://github.com/gpac/gpac/commit/bceb03fd2be95097a7b409ea59914f332fb6bc86', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://lists.debian.org/debian-lts-announce/2018/07/msg00024.html', 'name': '[debian-lts-announce] 20180719 [SECURITY] [DLA 1432-1] gpac security update', 'refsource': 'MLIST', 'tags': ['Mailing List', 'Third Party Advisory']}, {'url': 'https://usn.ubuntu.com/3926-1/', 'name': 'USN-3926-1', 'refsource': 'UBUNTU', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}]}] | HIGH | [{'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:gpac:gpac:0.7.1:*:*:*:*:*:*:*', 'cpe_name': []}]}, {'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:canonical:ubuntu_linux:16.04:*:*:*:lts:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:canonical:ubuntu_linux:18.04:*:*:*:lts:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:o:canonical:ubuntu_linux:18.10:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'An issue was discovered in MP4Box in GPAC 0.7.1. There is a heap-based buffer over-read in the isomedia/box_dump.c function hdlr_dump.'}] | 2019-03-29T18:58Z | 2018-06-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 | Aurelien David | 2018-06-28 13:34:08+02:00 | fixed 2 possible heap overflows (inc. #1088) | bceb03fd2be95097a7b409ea59914f332fb6bc86 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | tenc_dump | tenc_dump( GF_Box * a , FILE * trace) | ['a', 'trace'] | GF_Err tenc_dump(GF_Box *a, FILE * trace)
{
GF_TrackEncryptionBox *ptr = (GF_TrackEncryptionBox*) a;
if (!a) return GF_BAD_PARAM;
gf_isom_box_dump_start(a, "TrackEncryptionBox", trace);
fprintf(trace, "isEncrypted=\"%d\"", ptr->isProtected);
if (ptr->Per_Sample_IV_Size)
fprintf(trace, " IV_size=\"%d\" KID=\"", ptr->Per_Sample_IV_Size);
else {
fprintf(trace, " constant_IV_size=\"%d\" constant_IV=\"", ptr->constant_IV_size);
dump_data_hex(trace, (char *) ptr->constant_IV, ptr->constant_IV_size);
fprintf(trace, "\" KID=\"");
}
dump_data_hex(trace, (char *) ptr->KID, 16);
if (ptr->version)
fprintf(trace, "\" crypt_byte_block=\"%d\" skip_byte_block=\"%d", ptr->crypt_byte_block, ptr->skip_byte_block);
fprintf(trace, "\">\n");
gf_isom_box_dump_done("TrackEncryptionBox", a, trace);
return GF_OK;
} | 160 | True | 1 |
CVE-2020-25427 | 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/gpac/gpac/commit/8e585e623b1d666b4ef736ed609264639cb27701', 'name': 'https://github.com/gpac/gpac/commit/8e585e623b1d666b4ef736ed609264639cb27701', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/issues/1406', 'name': 'https://github.com/gpac/gpac/issues/1406', 'refsource': 'MISC', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-476'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:0.8.0:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'A Null pointer dereference vulnerability exits in MP4Box - GPAC version 0.8.0-rev177-g51a8ef874-master via the gf_isom_get_track_id function, which causes a denial of service.'}] | 2022-01-18T20:55Z | 2022-01-10T22: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 | jeanlf | 2020-06-11 19:28:51+02:00 | fixed potential crash - cf #1406 | 8e585e623b1d666b4ef736ed609264639cb27701 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_isom_box_parse_ex | gf_isom_box_parse_ex( GF_Box ** outBox , GF_BitStream * bs , u32 parent_type , Bool is_root_box) | ['outBox', 'bs', 'parent_type', 'is_root_box'] | GF_Err gf_isom_box_parse_ex(GF_Box **outBox, GF_BitStream *bs, u32 parent_type, Bool is_root_box)
{
u32 type, uuid_type, hdr_size;
u64 size, start, payload_start, end;
char uuid[16];
GF_Err e;
GF_Box *newBox;
Bool skip_logs = gf_bs_get_cookie(bs) ? GF_TRUE : GF_FALSE;
Bool is_special = GF_TRUE;
if ((bs == NULL) || (outBox == NULL) ) return GF_BAD_PARAM;
*outBox = NULL;
if (gf_bs_available(bs) < 8) {
return GF_ISOM_INCOMPLETE_FILE;
}
start = gf_bs_get_position(bs);
uuid_type = 0;
size = (u64) gf_bs_read_u32(bs);
hdr_size = 4;
/*fix for some boxes found in some old hinted files*/
if ((size >= 2) && (size <= 4)) {
size = 4;
type = GF_ISOM_BOX_TYPE_VOID;
} else {
type = gf_bs_read_u32(bs);
hdr_size += 4;
/*no size means till end of file - EXCEPT FOR some old QuickTime boxes...*/
if (type == GF_ISOM_BOX_TYPE_TOTL)
size = 12;
if (!size) {
if (is_root_box) {
if (!skip_logs) {
GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[iso file] Warning Read Box type %s (0x%08X) size 0 reading till the end of file\n", gf_4cc_to_str(type), type));
}
size = gf_bs_available(bs) + 8;
} else {
if (!skip_logs) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Read Box type %s (0x%08X) at position "LLU" has size 0 but is not at root/file level, skipping\n", gf_4cc_to_str(type), type, start));
}
return GF_OK;
// return GF_ISOM_INVALID_FILE;
}
}
}
/*handle uuid*/
memset(uuid, 0, 16);
if (type == GF_ISOM_BOX_TYPE_UUID ) {
if (gf_bs_available(bs) < 16) {
return GF_ISOM_INCOMPLETE_FILE;
}
gf_bs_read_data(bs, uuid, 16);
hdr_size += 16;
uuid_type = gf_isom_solve_uuid_box(uuid);
}
//handle large box
if (size == 1) {
if (gf_bs_available(bs) < 8) {
return GF_ISOM_INCOMPLETE_FILE;
}
size = gf_bs_read_u64(bs);
hdr_size += 8;
}
GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[iso file] Read Box type %s size "LLD" start "LLD"\n", gf_4cc_to_str(type), LLD_CAST size, LLD_CAST start));
if ( size < hdr_size ) {
GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[iso file] Box size "LLD" less than box header size %d\n", LLD_CAST size, hdr_size));
return GF_ISOM_INVALID_FILE;
}
//some special boxes (references and track groups) are handled by a single generic box with an associated ref/group type
if (parent_type && (parent_type == GF_ISOM_BOX_TYPE_TREF)) {
newBox = gf_isom_box_new(GF_ISOM_BOX_TYPE_REFT);
if (!newBox) return GF_OUT_OF_MEM;
((GF_TrackReferenceTypeBox*)newBox)->reference_type = type;
} else if (parent_type && (parent_type == GF_ISOM_BOX_TYPE_IREF)) {
newBox = gf_isom_box_new(GF_ISOM_BOX_TYPE_REFI);
if (!newBox) return GF_OUT_OF_MEM;
((GF_ItemReferenceTypeBox*)newBox)->reference_type = type;
} else if (parent_type && (parent_type == GF_ISOM_BOX_TYPE_TRGR)) {
newBox = gf_isom_box_new(GF_ISOM_BOX_TYPE_TRGT);
if (!newBox) return GF_OUT_OF_MEM;
((GF_TrackGroupTypeBox*)newBox)->group_type = type;
} else if (parent_type && (parent_type == GF_ISOM_BOX_TYPE_GRPL)) {
newBox = gf_isom_box_new(GF_ISOM_BOX_TYPE_GRPT);
if (!newBox) return GF_OUT_OF_MEM;
((GF_EntityToGroupTypeBox*)newBox)->grouping_type = type;
} else {
//OK, create the box based on the type
is_special = GF_FALSE;
newBox = gf_isom_box_new_ex(uuid_type ? uuid_type : type, parent_type, skip_logs, is_root_box);
if (!newBox) return GF_OUT_OF_MEM;
}
//OK, init and read this box
if (type==GF_ISOM_BOX_TYPE_UUID && !is_special) {
memcpy(((GF_UUIDBox *)newBox)->uuid, uuid, 16);
((GF_UUIDBox *)newBox)->internal_4cc = uuid_type;
}
if (!newBox->type) newBox->type = type;
payload_start = gf_bs_get_position(bs);
retry_unknown_box:
end = gf_bs_available(bs);
if (size - hdr_size > end ) {
newBox->size = size - hdr_size - end;
*outBox = newBox;
return GF_ISOM_INCOMPLETE_FILE;
}
newBox->size = size - hdr_size;
if (newBox->size) {
e = gf_isom_full_box_read(newBox, bs);
if (!e) e = gf_isom_box_read(newBox, bs);
newBox->size = size;
end = gf_bs_get_position(bs);
} else {
newBox->size = size;
//empty box
e = GF_OK;
end = gf_bs_get_position(bs);
}
if (e && (e != GF_ISOM_INCOMPLETE_FILE)) {
gf_isom_box_del(newBox);
*outBox = NULL;
if (parent_type==GF_ISOM_BOX_TYPE_STSD) {
newBox = gf_isom_box_new(GF_ISOM_BOX_TYPE_UNKNOWN);
((GF_UnknownBox *)newBox)->original_4cc = type;
newBox->size = size;
gf_bs_seek(bs, payload_start);
goto retry_unknown_box;
}
if (!skip_logs) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Read Box \"%s\" (start "LLU") failed (%s) - skipping\n", gf_4cc_to_str(type), start, gf_error_to_string(e)));
}
//we don't try to reparse known boxes that have been failing (too dangerous)
return e;
}
if (end-start > size) {
if (!skip_logs) {
GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[iso file] Box \"%s\" size "LLU" (start "LLU") invalid (read "LLU")\n", gf_4cc_to_str(type), LLU_CAST size, start, LLU_CAST (end-start) ));
}
/*let's still try to load the file since no error was notified*/
gf_bs_seek(bs, start+size);
} else if (end-start < size) {
u32 to_skip = (u32) (size-(end-start));
if (!skip_logs) {
if ((to_skip!=4) || gf_bs_peek_bits(bs, 32, 0)) {
GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[iso file] Box \"%s\" (start "LLU") has %u extra bytes\n", gf_4cc_to_str(type), start, to_skip));
}
}
gf_bs_skip_bytes(bs, to_skip);
}
*outBox = newBox;
return e;
} | 1004 | True | 1 |
CVE-2020-23931 | 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://github.com/gpac/gpac/issues/1567', 'name': 'https://github.com/gpac/gpac/issues/1567', 'refsource': 'MISC', 'tags': ['Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/issues/1564', 'name': 'https://github.com/gpac/gpac/issues/1564', 'refsource': 'MISC', 'tags': ['Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/093283e727f396130651280609e687cd4778e0d1', 'name': 'https://github.com/gpac/gpac/commit/093283e727f396130651280609e687cd4778e0d1', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://cwe.mitre.org/data/definitions/126.html', 'name': 'https://cwe.mitre.org/data/definitions/126.html', 'refsource': 'MISC', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:*:*:*:*:*:*:*:*', 'versionEndExcluding': '1.0.1', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'An issue was discovered in gpac before 1.0.1. The abst_box_read function in box_code_adobe.c has a heap-based buffer over-read.'}] | 2022-07-10T21:15Z | 2021-04-21T18: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 | jeanlf | 2020-09-01 16:42:40+02:00 | fixed #1564 | 093283e727f396130651280609e687cd4778e0d1 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | abst_box_read | abst_box_read( GF_Box * s , GF_BitStream * bs) | ['s', 'bs'] | GF_Err abst_box_read(GF_Box *s, GF_BitStream *bs)
{
GF_AdobeBootstrapInfoBox *ptr = (GF_AdobeBootstrapInfoBox *)s;
int i;
u32 tmp_strsize;
char *tmp_str;
GF_Err e;
ISOM_DECREASE_SIZE(ptr, 25)
ptr->bootstrapinfo_version = gf_bs_read_u32(bs);
ptr->profile = gf_bs_read_int(bs, 2);
ptr->live = gf_bs_read_int(bs, 1);
ptr->update = gf_bs_read_int(bs, 1);
ptr->reserved = gf_bs_read_int(bs, 4);
ptr->time_scale = gf_bs_read_u32(bs);
ptr->current_media_time = gf_bs_read_u64(bs);
ptr->smpte_time_code_offset = gf_bs_read_u64(bs);
i=0;
if (ptr->size<8) return GF_ISOM_INVALID_FILE;
tmp_strsize =(u32)ptr->size-8;
tmp_str = gf_malloc(sizeof(char)*tmp_strsize);
if (!tmp_str) return GF_OUT_OF_MEM;
memset(tmp_str, 0, sizeof(char)*tmp_strsize);
while (tmp_strsize) {
tmp_str[i] = gf_bs_read_u8(bs);
tmp_strsize--;
if (!tmp_str[i])
break;
i++;
}
if (i) {
ptr->movie_identifier = gf_strdup(tmp_str);
}
ptr->server_entry_count = gf_bs_read_u8(bs);
for (i=0; i<ptr->server_entry_count; i++) {
int j=0;
tmp_strsize=(u32)ptr->size-8;
while (tmp_strsize) {
tmp_str[j] = gf_bs_read_u8(bs);
tmp_strsize--;
if (!tmp_str[j])
break;
j++;
}
if (j) {
gf_list_insert(ptr->server_entry_table, gf_strdup(tmp_str), i);
}
}
ptr->quality_entry_count = gf_bs_read_u8(bs);
for (i=0; i<ptr->quality_entry_count; i++) {
int j=0;
tmp_strsize=(u32)ptr->size-8;
while (tmp_strsize) {
tmp_str[j] = gf_bs_read_u8(bs);
tmp_strsize--;
if (!tmp_str[j])
break;
j++;
}
if (j) {
gf_list_insert(ptr->quality_entry_table, gf_strdup(tmp_str), i);
}
}
i=0;
tmp_strsize=(u32)ptr->size-8;
while (tmp_strsize) {
tmp_str[i] = gf_bs_read_u8(bs);
tmp_strsize--;
if (!tmp_str[i])
break;
i++;
}
if (i) {
ptr->drm_data = gf_strdup(tmp_str);
}
i=0;
tmp_strsize=(u32)ptr->size-8;
while (tmp_strsize) {
tmp_str[i] = gf_bs_read_u8(bs);
tmp_strsize--;
if (!tmp_str[i])
break;
i++;
}
if (i) {
ptr->meta_data = gf_strdup(tmp_str);
}
ptr->segment_run_table_count = gf_bs_read_u8(bs);
for (i=0; i<ptr->segment_run_table_count; i++) {
GF_AdobeSegmentRunTableBox *asrt = NULL;
e = gf_isom_box_parse((GF_Box **)&asrt, bs);
if (e) {
if (asrt) gf_isom_box_del((GF_Box*)asrt);
gf_free(tmp_str);
return e;
}
gf_list_add(ptr->segment_run_table_entries, asrt);
}
ptr->fragment_run_table_count = gf_bs_read_u8(bs);
for (i=0; i<ptr->fragment_run_table_count; i++) {
GF_AdobeFragmentRunTableBox *afrt = NULL;
e = gf_isom_box_parse((GF_Box **)&afrt, bs);
if (e) {
if (afrt) gf_isom_box_del((GF_Box*)afrt);
gf_free(tmp_str);
return e;
}
gf_list_add(ptr->fragment_run_table_entries, afrt);
}
gf_free(tmp_str);
return GF_OK;
} | 712 | True | 1 |
CVE-2020-23930 | 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/gpac/gpac/issues/1565', 'name': 'https://github.com/gpac/gpac/issues/1565', 'refsource': 'MISC', 'tags': ['Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/9eeac00b38348c664dfeae2525bba0cf1bc32349', 'name': 'https://github.com/gpac/gpac/commit/9eeac00b38348c664dfeae2525bba0cf1bc32349', 'refsource': 'MISC', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-476'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:*:*:*:*:*:*:*:*', 'versionEndIncluding': '20200801', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'An issue was discovered in gpac through 20200801. A NULL pointer dereference exists in the function nhmldump_send_header located in write_nhml.c. It allows an attacker to cause Denial of Service.'}] | 2021-04-22T19:06Z | 2021-04-21T18: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 | jeanlf | 2020-09-01 16:46:07+02:00 | fixed #1565 | 9eeac00b38348c664dfeae2525bba0cf1bc32349 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | mp4boxMain | mp4boxMain( int argc , char ** argv) | ['argc', 'argv'] | int mp4boxMain(int argc, char **argv)
{
u32 i, j;
const char *gpac_profile = "0";
GF_Err e = GF_OK;
nb_tsel_acts = nb_add = nb_cat = nb_track_act = nb_sdp_ex = max_ptime = nb_meta_act = rtp_rate = major_brand = nb_alt_brand_add = nb_alt_brand_rem = car_dur = minor_version = 0;
split_duration = 0.0;
split_start = -1.0;
interleaving_time = 0;
dash_duration = dash_subduration = 0.0;
import_fps.num = import_fps.den = 0;
import_flags = 0;
split_size = 0;
movie_time = 0;
dump_nal = dump_saps = dump_saps_mode = force_new = 0;
FullInter = HintInter = encode = do_scene_log = old_interleave = do_saf = do_hash = verbose = do_mpd_rip = merge_vtt_cues = get_nb_tracks = GF_FALSE;
#ifndef GPAC_DISABLE_SCENE_DUMP
dump_mode = GF_SM_DUMP_NONE;
#endif
Frag = force_ocr = remove_sys_tracks = agg_samples = remove_hint = keep_sys_tracks = remove_root_od = single_group = clean_groups = compress_moov = GF_FALSE;
conv_type = HintIt = needSave = print_sdp = regular_iod = dump_std = open_edit = dump_rtp = dump_cr = dump_srt = dump_ttxt = dump_m2ts = dump_cart = import_subtitle = force_cat = pack_wgt = dash_live = GF_FALSE;
no_fragments_defaults = GF_FALSE;
single_traf_per_moof = hls_clock = GF_FALSE;
tfdt_per_traf = GF_FALSE;
dump_nal_type = 0;
dump_isom = 0;
print_info = 0;
/*align cat is the new default behaviour for -cat*/
align_cat = GF_TRUE;
subsegs_per_sidx = 0;
track_dump_type = 0;
crypt = 0;
time_shift_depth = 0;
file = NULL;
itunes_tags = pes_dump = NULL;
seg_name = dash_ctx_file = NULL;
compress_top_boxes = NULL;
initial_moof_sn = 0;
initial_tfdt = 0;
#ifndef GPAC_DISABLE_SCENE_ENCODER
memset(&smenc_opts, 0, sizeof(smenc_opts));
#endif
trackID = stat_level = hint_flags = 0;
program_number = 0;
info_track_id = 0;
do_flat = 0;
inName = outName = mediaSource = input_ctx = output_ctx = drm_file = avi2raw = cprt = chap_file = pack_file = raw_cat = high_dynamc_range_filename = use_init_seg = box_patch_filename = NULL;
#ifndef GPAC_DISABLE_SWF_IMPORT
swf_flags = GF_SM_SWF_SPLIT_TIMELINE;
#endif
swf_flatten_angle = 0.0f;
tmpdir = NULL;
for (i = 1; i < (u32) argc ; i++) {
if (!strcmp(argv[i], "-mem-track") || !strcmp(argv[i], "-mem-track-stack")) {
#ifdef GPAC_MEMORY_TRACKING
mem_track = !strcmp(argv[i], "-mem-track-stack") ? GF_MemTrackerBackTrace : GF_MemTrackerSimple;
#else
fprintf(stderr, "WARNING - GPAC not compiled with Memory Tracker - ignoring \"%s\"\n", argv[i]);
#endif
break;
}
else if (!strcmp(argv[i], "-p")) {
if (i+1<(u32) argc)
gpac_profile = argv[i+1];
else {
fprintf(stderr, "Bad argument for -p, expecting profile name but no more args\n");
return 1;
}
}
else if (!strncmp(argv[i], "-p=", 3))
gpac_profile = argv[i]+3;
}
#ifdef _TWO_DIGIT_EXPONENT
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
/*init libgpac*/
gf_sys_init(mem_track, gpac_profile);
if (argc < 2) {
fprintf(stderr, "Not enough arguments - check usage with -h\n"
"MP4Box - GPAC version %s\n"
"%s\n", gf_gpac_version(), gf_gpac_copyright());
gf_sys_close();
return 0;
}
helpout = stdout;
i = mp4box_parse_args(argc, argv);
if (i) {
return mp4box_cleanup(i - 1);
}
if (!inName && dump_std)
inName = "std";
if (!inName) {
if (has_next_arg) {
fprintf(stderr, "Broken argument specifier or file name missing - check usage with -h\n");
} else {
PrintUsage();
}
return mp4box_cleanup(1);
}
if (!strcmp(inName, "std")) dump_std = 2;
if (!strcmp(inName, "stdb")) {
inName = "std";
dump_std = 1;
}
if (!interleaving_time) {
/*by default use single fragment per dash segment*/
if (dash_duration)
interleaving_time = dash_duration;
else if (!do_flat) {
interleaving_time = DEFAULT_INTERLEAVING_IN_SEC;
}
}
if (dump_std)
outName = "std";
if (dump_std==2) {
#ifdef WIN32
if ( _setmode(_fileno(stdout), _O_BINARY) == -1 )
#else
if ( freopen(NULL, "wb", stdout) == NULL)
#endif
{
fprintf(stderr, "Fatal error: cannot reopen stdout in binary mode.\n");
return mp4box_cleanup(1);
}
}
#if !defined(GPAC_DISABLE_STREAMING) && !defined(GPAC_DISABLE_SENG)
if (live_scene) {
int ret = live_session(argc, argv);
return mp4box_cleanup(ret);
}
#endif
GF_LOG_Level level = verbose ? GF_LOG_DEBUG : GF_LOG_INFO;
gf_log_set_tool_level(GF_LOG_CONTAINER, level);
gf_log_set_tool_level(GF_LOG_SCENE, level);
gf_log_set_tool_level(GF_LOG_PARSER, level);
gf_log_set_tool_level(GF_LOG_AUTHOR, level);
gf_log_set_tool_level(GF_LOG_CODING, level);
gf_log_set_tool_level(GF_LOG_DASH, level);
#ifdef GPAC_MEMORY_TRACKING
if (mem_track)
gf_log_set_tool_level(GF_LOG_MEMORY, level);
#endif
e = gf_sys_set_args(argc, (const char **) argv);
if (e) {
fprintf(stderr, "Error assigning libgpac arguments: %s\n", gf_error_to_string(e) );
return mp4box_cleanup(1);
}
if (raw_cat) {
char chunk[4096];
FILE *fin, *fout;
s64 to_copy, done;
fin = gf_fopen(raw_cat, "rb");
if (!fin) return mp4box_cleanup(1);
fout = gf_fopen(inName, "a+b");
if (!fout) {
gf_fclose(fin);
return mp4box_cleanup(1);
}
gf_fseek(fin, 0, SEEK_END);
to_copy = gf_ftell(fin);
gf_fseek(fin, 0, SEEK_SET);
done = 0;
while (1) {
u32 nb_bytes = (u32) gf_fread(chunk, 4096, fin);
gf_fwrite(chunk, nb_bytes, fout);
done += nb_bytes;
fprintf(stderr, "Appending file %s - %02.2f done\r", raw_cat, 100.0*done/to_copy);
if (done >= to_copy) break;
}
gf_fclose(fin);
gf_fclose(fout);
return mp4box_cleanup(0);
}
if (compress_top_boxes) {
if (size_top_box) {
u64 top_size = do_size_top_boxes(inName, compress_top_boxes, size_top_box);
fprintf(stdout, LLU"\n", top_size);
return mp4box_cleanup(e ? 1 : 0);
} else {
e = do_compress_top_boxes(inName, outName, compress_top_boxes, comp_top_box_version, comp_lzma);
return mp4box_cleanup(e ? 1 : 0);
}
}
if (do_mpd_rip) {
e = rip_mpd(inName, outName);
return mp4box_cleanup(e ? 1 : 0);
}
#ifndef GPAC_DISABLE_CORE_TOOLS
if (do_wget != NULL) {
e = gf_dm_wget(do_wget, inName, 0, 0, NULL);
if (e != GF_OK) {
fprintf(stderr, "Cannot retrieve %s: %s\n", do_wget, gf_error_to_string(e) );
return mp4box_cleanup(1);
}
return mp4box_cleanup(0);
}
#endif
if (udp_dest) {
GF_Socket *sock = gf_sk_new(GF_SOCK_TYPE_UDP);
u16 port = 2345;
char *sep = strrchr(udp_dest, ':');
if (sep) {
sep[0] = 0;
port = atoi(sep+1);
}
e = gf_sk_bind( sock, "127.0.0.1", 0, udp_dest, port, 0);
if (sep) sep[0] = ':';
if (e) fprintf(stderr, "Failed to bind socket to %s: %s\n", udp_dest, gf_error_to_string(e) );
else {
e = gf_sk_send(sock, (u8 *) inName, (u32)strlen(inName));
if (e) fprintf(stderr, "Failed to send datagram: %s\n", gf_error_to_string(e) );
}
gf_sk_del(sock);
return 0;
}
#ifndef GPAC_DISABLE_MPD
if (do_mpd) {
Bool remote = GF_FALSE;
GF_MPD *mpd;
char *mpd_base_url = NULL;
if (!strnicmp(inName, "http://", 7) || !strnicmp(inName, "https://", 8)) {
#if !defined(GPAC_DISABLE_CORE_TOOLS)
e = gf_dm_wget(inName, "tmp_main.m3u8", 0, 0, &mpd_base_url);
if (e != GF_OK) {
fprintf(stderr, "Cannot retrieve M3U8 (%s): %s\n", inName, gf_error_to_string(e));
if (mpd_base_url) gf_free(mpd_base_url);
return mp4box_cleanup(1);
}
remote = GF_TRUE;
#else
gf_free(mpd_base_url);
fprintf(stderr, "HTTP Downloader disabled in this build\n");
return mp4box_cleanup(1);
#endif
if (outName)
strcpy(outfile, outName);
else {
const char *sep = gf_file_basename(inName);
char *ext = gf_file_ext_start(sep);
if (ext) ext[0] = 0;
sprintf(outfile, "%s.mpd", sep);
if (ext) ext[0] = '.';
}
} else {
if (outName)
strcpy(outfile, outName);
else {
char *dst = strdup(inName);
char *ext = strstr(dst, ".m3u8");
if (ext) ext[0] = 0;
sprintf(outfile, "%s.mpd", dst);
gf_free(dst);
}
}
mpd = gf_mpd_new();
if (!mpd) {
e = GF_OUT_OF_MEM;
fprintf(stderr, "[DASH] Error: MPD creation problem %s\n", gf_error_to_string(e));
mp4box_cleanup(1);
}
FILE *f = gf_fopen(remote ? "tmp_main.m3u8" : inName, "r");
u32 manif_type = 0;
if (f) {
char szDATA[1000];
s32 read;
szDATA[999]=0;
read = (s32) gf_fread(szDATA, 999, f);
if (read<0) read = 0;
szDATA[read]=0;
gf_fclose(f);
if (strstr(szDATA, "SmoothStreamingMedia"))
manif_type = 2;
else if (strstr(szDATA, "#EXTM3U"))
manif_type = 1;
}
if (manif_type==1) {
e = gf_m3u8_to_mpd(remote ? "tmp_main.m3u8" : inName, mpd_base_url ? mpd_base_url : inName, outfile, 0, "video/mp2t", GF_TRUE, use_url_template, segment_timeline, NULL, mpd, GF_TRUE, GF_TRUE);
} else if (manif_type==2) {
e = gf_mpd_smooth_to_mpd(remote ? "tmp_main.m3u8" : inName, mpd, mpd_base_url ? mpd_base_url : inName);
} else {
e = GF_NOT_SUPPORTED;
}
if (!e)
gf_mpd_write_file(mpd, outfile);
if (mpd)
gf_mpd_del(mpd);
if (mpd_base_url)
gf_free(mpd_base_url);
if (remote) {
gf_file_delete("tmp_main.m3u8");
}
if (e != GF_OK) {
fprintf(stderr, "Error converting %s (%s) to MPD (%s): %s\n", (manif_type==1) ? "HLS" : "Smooth", inName, outfile, gf_error_to_string(e));
return mp4box_cleanup(1);
} else {
fprintf(stderr, "Done converting %s (%s) to MPD (%s)\n", (manif_type==1) ? "HLS" : "Smooth", inName, outfile);
return mp4box_cleanup(0);
}
}
#endif
if (dash_duration && !nb_dash_inputs) {
dash_inputs = set_dash_input(dash_inputs, inName, &nb_dash_inputs);
}
if (do_saf && !encode) {
switch (get_file_type_by_ext(inName)) {
case GF_FILE_TYPE_BT_WRL_X3DV:
case GF_FILE_TYPE_XMT_X3D:
case GF_FILE_TYPE_SVG:
encode = GF_TRUE;
break;
case GF_FILE_TYPE_NOT_SUPPORTED:
case GF_FILE_TYPE_ISO_MEDIA:
case GF_FILE_TYPE_SWF:
case GF_FILE_TYPE_LSR_SAF:
break;
}
}
#ifndef GPAC_DISABLE_SCENE_DUMP
if (dump_mode == GF_SM_DUMP_SVG) {
if (strstr(inName, ".srt") || strstr(inName, ".ttxt")) import_subtitle = 2;
}
#endif
if (import_subtitle && !trackID) {
/* We import the subtitle file,
i.e. we parse it and store the content as samples of a 3GPP Timed Text track in an ISO file,
possibly for later export (e.g. when converting SRT to TTXT, ...) */
#ifndef GPAC_DISABLE_MEDIA_IMPORT
GF_MediaImporter import;
/* Prepare the importer */
file = gf_isom_open("ttxt_convert", GF_ISOM_OPEN_WRITE, NULL);
if (timescale && file) gf_isom_set_timescale(file, timescale);
memset(&import, 0, sizeof(GF_MediaImporter));
import.dest = file;
import.in_name = inName;
/* Start the import */
e = gf_media_import(&import);
if (e) {
fprintf(stderr, "Error importing %s: %s\n", inName, gf_error_to_string(e));
gf_isom_delete(file);
gf_file_delete("ttxt_convert");
return mp4box_cleanup(1);
}
/* Prepare the export */
strcpy(outfile, inName);
if (strchr(outfile, '.')) {
while (outfile[strlen(outfile)-1] != '.') outfile[strlen(outfile)-1] = 0;
outfile[strlen(outfile)-1] = 0;
}
#ifndef GPAC_DISABLE_ISOM_DUMP
/* Start the export of the track #1, in the appropriate dump type, indicating it's a conversion */
dump_isom_timed_text(file, gf_isom_get_track_id(file, 1),
dump_std ? NULL : (outName ? outName : outfile), outName ? GF_TRUE : GF_FALSE,
GF_TRUE,
(import_subtitle==2) ? GF_TEXTDUMPTYPE_SVG : (dump_srt ? GF_TEXTDUMPTYPE_SRT : GF_TEXTDUMPTYPE_TTXT));
#endif
/* Clean the importer */
gf_isom_delete(file);
gf_file_delete("ttxt_convert");
if (e) {
fprintf(stderr, "Error converting %s: %s\n", inName, gf_error_to_string(e));
return mp4box_cleanup(1);
}
return mp4box_cleanup(0);
#else
fprintf(stderr, "Feature not supported\n");
return mp4box_cleanup(1);
#endif
}
#if !defined(GPAC_DISABLE_MEDIA_IMPORT) && !defined(GPAC_DISABLE_ISOM_WRITE)
if (nb_add || nb_cat) {
u32 ipass, nb_pass = 1;
char *mux_args=NULL;
GF_FilterSession *fs = NULL;
if (nb_add) {
GF_ISOOpenMode open_mode = GF_ISOM_OPEN_EDIT;
if (force_new) {
open_mode = (do_flat || (force_new==2)) ? GF_ISOM_OPEN_WRITE : GF_ISOM_WRITE_EDIT;
} else {
FILE *test = gf_fopen(inName, "rb");
if (!test) {
open_mode = (do_flat) ? GF_ISOM_OPEN_WRITE : GF_ISOM_WRITE_EDIT;
if (!outName) outName = inName;
} else {
gf_fclose(test);
if (! gf_isom_probe_file(inName) ) {
open_mode = (do_flat) ? GF_ISOM_OPEN_WRITE : GF_ISOM_WRITE_EDIT;
if (!outName) outName = inName;
}
}
}
open_edit = do_flat ? GF_FALSE : GF_TRUE;
file = gf_isom_open(inName, open_mode, tmpdir);
if (!file) {
fprintf(stderr, "Cannot open destination file %s: %s\n", inName, gf_error_to_string(gf_isom_last_error(NULL)) );
return mp4box_cleanup(1);
}
if (freeze_box_order)
gf_isom_freeze_order(file);
}
if (do_flat && interleaving_time) {
char szSubArg[100];
gf_isom_set_storage_mode(file, GF_ISOM_STORE_FASTSTART);
do_flat = 2;
nb_pass = 2;
fs = gf_fs_new_defaults(0);
if (!fs) {
fprintf(stderr, "Error creating filter session\n");
gf_isom_delete(file);
return mp4box_cleanup(1);
}
//mux args
gf_dynstrcat(&mux_args, "mp4mx:importer:store=fstart", ":");
sprintf(szSubArg, "file=%p", file);
gf_dynstrcat(&mux_args, szSubArg, ":");
sprintf(szSubArg, "cdur=%g", interleaving_time);
gf_dynstrcat(&mux_args, szSubArg, ":");
}
for (ipass=0; ipass<nb_pass; ipass++) {
u32 tk_idx = 1;
for (i=0; i<(u32) argc; i++) {
char *margs=NULL;
if (!strcmp(argv[i], "-add")) {
char *src = argv[i+1];
while (src) {
char *loc_src = src;
char *sep = NULL;
while (1) {
char *opt_sep;
sep = strchr(loc_src, '+');
if (!sep) break;
sep[0] = 0;
if (strstr(src, "://"))
break;
opt_sep = gf_url_colon_suffix(src);
if (opt_sep)
opt_sep[0] = 0;
if (gf_file_exists(src)) {
if (opt_sep)
opt_sep[0] = ':';
break;
}
if (opt_sep)
opt_sep[0] = ':';
sep[0] = '+';
loc_src = sep+1;
}
e = import_file(file, src, import_flags, import_fps, agg_samples, fs, (fs && (ipass==0)) ? &margs : NULL, tk_idx);
tk_idx++;
if (margs) {
gf_dynstrcat(&mux_args, margs, ":");
gf_free(margs);
}
if (e) {
fprintf(stderr, "Error importing %s: %s\n", argv[i+1], gf_error_to_string(e));
gf_isom_delete(file);
if (fs)
gf_fs_del(fs);
return mp4box_cleanup(1);
}
if (sep) {
sep[0] = '+';
src = sep+1;
} else {
break;
}
}
i++;
} else if (!strcmp(argv[i], "-cat") || !strcmp(argv[i], "-catx") || !strcmp(argv[i], "-catpl")) {
if (nb_pass == 2) {
fprintf(stderr, "Cannot cat files when using -newfs mode\n");
return mp4box_cleanup(1);
}
if (!file) {
u8 open_mode = GF_ISOM_OPEN_EDIT;
if (force_new) {
open_mode = (do_flat) ? GF_ISOM_OPEN_WRITE : GF_ISOM_WRITE_EDIT;
} else {
FILE *test = gf_fopen(inName, "rb");
if (!test) {
open_mode = (do_flat) ? GF_ISOM_OPEN_WRITE : GF_ISOM_WRITE_EDIT;
if (!outName) outName = inName;
}
else gf_fclose(test);
}
open_edit = GF_TRUE;
file = gf_isom_open(inName, open_mode, tmpdir);
if (!file) {
fprintf(stderr, "Cannot open destination file %s: %s\n", inName, gf_error_to_string(gf_isom_last_error(NULL)) );
return mp4box_cleanup(1);
}
}
e = cat_isomedia_file(file, argv[i+1], import_flags, import_fps, agg_samples, tmpdir, force_cat, align_cat, !strcmp(argv[i], "-catx") ? GF_TRUE : GF_FALSE, !strcmp(argv[i], "-catpl") ? GF_TRUE : GF_FALSE);
if (e) {
fprintf(stderr, "Error appending %s: %s\n", argv[i+1], gf_error_to_string(e));
gf_isom_delete(file);
return mp4box_cleanup(1);
}
i++;
}
}
if ((nb_pass == 2) && !ipass) {
GF_Filter *mux_filter = gf_fs_load_filter(fs, mux_args, NULL);
gf_free(mux_args);
if (!mux_filter) {
fprintf(stderr, "Error loadin isobmff mux filter\n");
gf_isom_delete(file);
gf_fs_del(fs);
return mp4box_cleanup(1);
}
e = gf_fs_run(fs);
if (e==GF_EOS) e = GF_OK;
if (!e) e = gf_fs_get_last_connect_error(fs);
if (!e) e = gf_fs_get_last_process_error(fs);
if (e) {
fprintf(stderr, "Error importing sources: %s\n", gf_error_to_string(e));
gf_isom_delete(file);
gf_fs_del(fs);
return mp4box_cleanup(1);
}
}
}
if (fs) {
if (fs_dump_flags & 1) gf_fs_print_stats(fs);
if (fs_dump_flags & 2) gf_fs_print_connections(fs);
gf_fs_del(fs);
}
/*unless explicitly asked, remove all systems tracks*/
#ifndef GPAC_DISABLE_AV_PARSERS
if (!keep_sys_tracks) remove_systems_tracks(file);
#endif
needSave = GF_TRUE;
}
#endif /*!GPAC_DISABLE_MEDIA_IMPORT && !GPAC_DISABLE_ISOM_WRITE*/
#if !defined(GPAC_DISABLE_ISOM_WRITE) && !defined(GPAC_DISABLE_SCENE_ENCODER) && !defined(GPAC_DISABLE_MEDIA_IMPORT)
else if (chunk_mode) {
if (!inName) {
fprintf(stderr, "chunk encoding syntax: [-outctx outDump] -inctx inScene auFile\n");
return mp4box_cleanup(1);
}
e = EncodeFileChunk(inName, outName ? outName : inName, input_ctx, output_ctx, tmpdir);
if (e) {
fprintf(stderr, "Error encoding chunk file %s\n", gf_error_to_string(e));
return mp4box_cleanup(1);
}
goto exit;
}
#endif // !defined(GPAC_DISABLE_ISOM_WRITE) && !defined(GPAC_DISABLE_SCENE_ENCODER) && !defined(GPAC_DISABLE_MEDIA_IMPORT)
else if (encode) {
#if !defined(GPAC_DISABLE_ISOM_WRITE) && !defined(GPAC_DISABLE_SCENE_ENCODER) && !defined(GPAC_DISABLE_MEDIA_IMPORT)
FILE *logs = NULL;
if (do_scene_log) {
char alogfile[GF_MAX_PATH];
strcpy(alogfile, inName);
if (strchr(alogfile, '.')) {
while (alogfile[strlen(alogfile)-1] != '.') alogfile[strlen(alogfile)-1] = 0;
alogfile[strlen(alogfile)-1] = 0;
}
strcat(alogfile, "_enc.logs");
logs = gf_fopen(alogfile, "wt");
}
strcpy(outfile, outName ? outName : inName);
if (strchr(outfile, '.')) {
while (outfile[strlen(outfile)-1] != '.') outfile[strlen(outfile)-1] = 0;
outfile[strlen(outfile)-1] = 0;
}
strcat(outfile, ".mp4");
file = gf_isom_open(outfile, GF_ISOM_WRITE_EDIT, tmpdir);
smenc_opts.mediaSource = mediaSource ? mediaSource : outfile;
e = EncodeFile(inName, file, &smenc_opts, logs);
if (logs) gf_fclose(logs);
if (e) goto err_exit;
needSave = GF_TRUE;
if (do_saf) {
needSave = GF_FALSE;
open_edit = GF_FALSE;
}
#endif //!defined(GPAC_DISABLE_ISOM_WRITE) && !defined(GPAC_DISABLE_SCENE_ENCODER) && !defined(GPAC_DISABLE_MEDIA_IMPORT)
}
#ifndef GPAC_DISABLE_ISOM_WRITE
else if (pack_file) {
char *fileName = gf_url_colon_suffix(pack_file);
if (fileName && ((fileName - pack_file)==4)) {
fileName[0] = 0;
file = package_file(fileName + 1, pack_file, tmpdir, pack_wgt);
fileName[0] = ':';
} else {
file = package_file(pack_file, NULL, tmpdir, pack_wgt);
if (!file) {
fprintf(stderr, "Failed to package file\n");
return mp4box_cleanup(1);
}
}
if (!outName) outName = inName;
needSave = GF_TRUE;
open_edit = GF_TRUE;
}
#endif //GPAC_DISABLE_ISOM_WRITE
if (dash_duration) {
Bool del_file = GF_FALSE;
char szMPD[GF_MAX_PATH], *sep;
char szStateFile[GF_MAX_PATH];
Bool dyn_state_file = GF_FALSE;
u32 do_abort = 0;
GF_DASHSegmenter *dasher=NULL;
if (crypt) {
fprintf(stderr, "MP4Box cannot crypt and DASH on the same pass. Please encrypt your content first.\n");
return mp4box_cleanup(1);
}
strcpy(outfile, outName ? outName : gf_url_get_resource_name(inName) );
sep = strrchr(outfile, '.');
if (sep) sep[0] = 0;
if (!outName) strcat(outfile, "_dash");
strcpy(szMPD, outfile);
if (outName && sep) {
sep[0] = '.';
strcat(szMPD, sep);
} else {
strcat(szMPD, ".mpd");
}
if ((dash_subduration>0) && (dash_duration > dash_subduration)) {
fprintf(stderr, "Warning: -subdur parameter (%g s) should be greater than segment duration (%g s), using segment duration instead\n", dash_subduration, dash_duration);
dash_subduration = dash_duration;
}
if (dash_mode && dash_live)
fprintf(stderr, "Live DASH-ing - press 'q' to quit, 's' to save context and quit\n");
if (!dash_ctx_file && dash_live) {
u32 r1;
u64 add = (u64) (intptr_t) &dasher;
add ^= gf_net_get_utc();
r1 = (u32) add ^ (u32) (add/0xFFFFFFFF);
r1 ^= gf_rand();
sprintf(szStateFile, "%s/dasher_%X.xml", gf_get_default_cache_directory(), r1 );
dash_ctx_file = szStateFile;
dyn_state_file = GF_TRUE;
} else if (dash_ctx_file) {
if (force_new)
gf_file_delete(dash_ctx_file);
}
if (dash_profile==GF_DASH_PROFILE_AUTO)
dash_profile = dash_mode ? GF_DASH_PROFILE_LIVE : GF_DASH_PROFILE_FULL;
if (!dash_mode) {
time_shift_depth = 0;
mpd_update_time = 0;
} else if ((dash_profile>=GF_DASH_PROFILE_MAIN) && !use_url_template && !mpd_update_time) {
/*use a default MPD update of dash_duration sec*/
mpd_update_time = (Double) (dash_subduration ? dash_subduration : dash_duration);
fprintf(stderr, "Using default MPD refresh of %g seconds\n", mpd_update_time);
}
if (file && needSave) {
gf_isom_close(file);
file = NULL;
del_file = GF_TRUE;
}
/*setup dash*/
dasher = gf_dasher_new(szMPD, dash_profile, tmpdir, dash_scale, dash_ctx_file);
if (!dasher) {
return mp4box_cleanup(1);
}
e = gf_dasher_set_info(dasher, dash_title, cprt, dash_more_info, dash_source, NULL);
if (e) {
fprintf(stderr, "DASH Error: %s\n", gf_error_to_string(e));
gf_dasher_del(dasher);
return mp4box_cleanup(1);
}
gf_dasher_set_start_date(dasher, dash_start_date);
gf_dasher_set_location(dasher, dash_source);
for (i=0; i < nb_mpd_base_urls; i++) {
e = gf_dasher_add_base_url(dasher, mpd_base_urls[i]);
if (e) {
fprintf(stderr, "DASH Error: %s\n", gf_error_to_string(e));
gf_dasher_del(dasher);
return mp4box_cleanup(1);
}
}
if (segment_timeline && !use_url_template) {
fprintf(stderr, "DASH Warning: using -segment-timeline with no -url-template. Forcing URL template.\n");
use_url_template = GF_TRUE;
}
e = gf_dasher_enable_url_template(dasher, (Bool) use_url_template, seg_name, seg_ext, init_seg_ext);
if (!e) e = gf_dasher_enable_segment_timeline(dasher, segment_timeline);
if (!e) e = gf_dasher_enable_single_segment(dasher, single_segment);
if (!e) e = gf_dasher_enable_single_file(dasher, single_file);
if (!e) e = gf_dasher_set_switch_mode(dasher, bitstream_switching_mode);
if (!e) e = gf_dasher_set_durations(dasher, dash_duration, interleaving_time, dash_subduration);
if (!e) e = gf_dasher_enable_rap_splitting(dasher, seg_at_rap, frag_at_rap);
if (!e) e = gf_dasher_set_segment_marker(dasher, segment_marker);
if (!e) e = gf_dasher_enable_sidx(dasher, (subsegs_per_sidx>=0) ? 1 : 0, (u32) subsegs_per_sidx, daisy_chain_sidx, use_ssix);
if (!e) e = gf_dasher_set_dynamic_mode(dasher, dash_mode, mpd_update_time, time_shift_depth, mpd_live_duration);
if (!e) e = gf_dasher_set_min_buffer(dasher, min_buffer);
if (!e) e = gf_dasher_set_ast_offset(dasher, ast_offset_ms);
if (!e) e = gf_dasher_enable_memory_fragmenting(dasher, memory_frags);
if (!e) e = gf_dasher_set_initial_isobmf(dasher, initial_moof_sn, initial_tfdt);
if (!e) e = gf_dasher_configure_isobmf_default(dasher, no_fragments_defaults, pssh_mode, samplegroups_in_traf, single_traf_per_moof, tfdt_per_traf, mvex_after_traks, sdtp_in_traf);
if (!e) e = gf_dasher_enable_utc_ref(dasher, insert_utc);
if (!e) e = gf_dasher_enable_real_time(dasher, frag_real_time);
if (!e) e = gf_dasher_set_content_protection_location_mode(dasher, cp_location_mode);
if (!e) e = gf_dasher_set_profile_extension(dasher, dash_profile_extension);
if (!e) e = gf_dasher_enable_cached_inputs(dasher, no_cache);
if (!e) e = gf_dasher_enable_loop_inputs(dasher, ! no_loop);
if (!e) e = gf_dasher_set_split_mode(dasher, dash_split_mode);
if (!e) e = gf_dasher_set_hls_clock(dasher, hls_clock);
if (!e && dash_cues) e = gf_dasher_set_cues(dasher, dash_cues, strict_cues);
if (!e && fs_dump_flags) e = gf_dasher_print_session_info(dasher, fs_dump_flags);
for (i=0; i < nb_dash_inputs; i++) {
if (!e) e = gf_dasher_add_input(dasher, &dash_inputs[i]);
}
if (e) {
fprintf(stderr, "DASH Setup Error: %s\n", gf_error_to_string(e));
gf_dasher_del(dasher);
return mp4box_cleanup(1);
}
dash_cumulated_time=0;
while (1) {
if (run_for && (dash_cumulated_time >= run_for)) {
fprintf(stderr, "Done running, computing static MPD\n");
do_abort = 3;
}
dash_prev_time=gf_sys_clock();
if (do_abort>=2) {
e = gf_dasher_set_dynamic_mode(dasher, GF_DASH_DYNAMIC_LAST, 0, time_shift_depth, mpd_live_duration);
}
if (!e) e = gf_dasher_process(dasher);
if (!dash_live && (e==GF_EOS) ) {
fprintf(stderr, "Nothing to dash, too early ...\n");
e = GF_OK;
}
if (do_abort)
break;
//this happens when reading file while writing them (local playback of the live session ...)
if (dash_live && (e==GF_IO_ERR) ) {
fprintf(stderr, "Error dashing file (%s) but continuing ...\n", gf_error_to_string(e) );
e = GF_OK;
}
if (e) break;
if (dash_live) {
u64 ms_in_session=0;
u32 slept = gf_sys_clock();
u32 sleep_for = gf_dasher_next_update_time(dasher, &ms_in_session);
fprintf(stderr, "Next generation scheduled in %u ms (DASH time "LLU" ms)\r", sleep_for, ms_in_session);
if (run_for && (ms_in_session>=run_for)) {
dash_cumulated_time = 1+run_for;
continue;
}
while (1) {
if (gf_prompt_has_input()) {
char c = (char) gf_prompt_get_char();
if (c=='X') {
do_abort = 1;
break;
}
if (c=='q') {
do_abort = 2;
break;
}
if (c=='s') {
do_abort = 3;
break;
}
}
if (dash_mode == GF_DASH_DYNAMIC_DEBUG) {
break;
}
if (!sleep_for) break;
gf_sleep(sleep_for/10);
sleep_for = gf_dasher_next_update_time(dasher, NULL);
if (sleep_for<=1) {
dash_now_time=gf_sys_clock();
dash_cumulated_time+=(dash_now_time-dash_prev_time);
fprintf(stderr, "Slept for %d ms before generation, dash cumulated time %d\n", dash_now_time - slept, dash_cumulated_time);
break;
}
}
} else {
break;
}
}
gf_dasher_del(dasher);
if (!run_for && dash_ctx_file && (do_abort==3) && (dyn_state_file) && !gf_sys_is_test_mode() ) {
char szName[1024];
fprintf(stderr, "Enter file name to save dash context:\n");
if (scanf("%1023s", szName) == 1) {
gf_file_move(dash_ctx_file, szName);
}
}
if (e) fprintf(stderr, "Error DASHing file: %s\n", gf_error_to_string(e));
if (file) gf_isom_delete(file);
if (del_file)
gf_file_delete(inName);
if (e) return mp4box_cleanup(1);
goto exit;
}
else if (!file && !do_hash
#ifndef GPAC_DISABLE_MEDIA_EXPORT
&& !(track_dump_type & GF_EXPORT_AVI_NATIVE)
#endif
) {
FILE *st = gf_fopen(inName, "rb");
Bool file_exists = 0;
GF_ISOOpenMode omode;
if (st) {
file_exists = 1;
gf_fclose(st);
}
switch (get_file_type_by_ext(inName)) {
case 1:
omode = (u8) (force_new ? GF_ISOM_WRITE_EDIT : (open_edit ? GF_ISOM_OPEN_EDIT : ( ((dump_isom>0) || print_info) ? GF_ISOM_OPEN_READ_DUMP : GF_ISOM_OPEN_READ) ) );
if (crypt) {
//keep fragment signaling in moov
omode = GF_ISOM_OPEN_READ;
if (use_init_seg)
file = gf_isom_open(use_init_seg, GF_ISOM_OPEN_READ, tmpdir);
}
if (!crypt && use_init_seg) {
file = gf_isom_open(use_init_seg, GF_ISOM_OPEN_READ_DUMP, tmpdir);
if (file) {
e = gf_isom_open_segment(file, inName, 0, 0, 0);
if (e) {
fprintf(stderr, "Error opening segment %s: %s\n", inName, gf_error_to_string(e) );
gf_isom_delete(file);
file = NULL;
}
}
}
if (!file)
file = gf_isom_open(inName, omode, tmpdir);
if (!file && (gf_isom_last_error(NULL) == GF_ISOM_INCOMPLETE_FILE) && !open_edit) {
u64 missing_bytes;
e = gf_isom_open_progressive(inName, 0, 0, GF_FALSE, &file, &missing_bytes);
fprintf(stderr, "Truncated file - missing "LLD" bytes\n", missing_bytes);
}
if (!file) {
if (open_edit && nb_meta_act) {
file = gf_isom_open(inName, GF_ISOM_WRITE_EDIT, tmpdir);
if (!outName && file) outName = inName;
}
if (!file) {
fprintf(stderr, "Error opening file %s: %s\n", inName, gf_error_to_string(gf_isom_last_error(NULL)));
return mp4box_cleanup(1);
}
}
if (freeze_box_order)
gf_isom_freeze_order(file);
break;
/*allowed for bt<->xmt*/
case 2:
case 3:
/*allowed for svg->lsr**/
case 4:
/*allowed for swf->bt, swf->xmt, swf->svg*/
case 5:
break;
/*used for .saf / .lsr dump*/
case 6:
#ifndef GPAC_DISABLE_SCENE_DUMP
if ((dump_mode==GF_SM_DUMP_LASER) || (dump_mode==GF_SM_DUMP_SVG)) {
break;
}
#endif
default:
if (!open_edit && file_exists && !gf_isom_probe_file(inName) && track_dump_type) {
}
#ifndef GPAC_DISABLE_ISOM_WRITE
else if (!open_edit && file_exists /* && !gf_isom_probe_file(inName) */
#ifndef GPAC_DISABLE_SCENE_DUMP
&& dump_mode == GF_SM_DUMP_NONE
#endif //GPAC_DISABLE_SCENE_DUMP
) {
/*************************************************************************************************/
#ifndef GPAC_DISABLE_MEDIA_IMPORT
if(dvbhdemux)
{
GF_MediaImporter import;
file = gf_isom_open("ttxt_convert", GF_ISOM_OPEN_WRITE, NULL);
memset(&import, 0, sizeof(GF_MediaImporter));
import.dest = file;
import.in_name = inName;
import.flags = GF_IMPORT_MPE_DEMUX;
e = gf_media_import(&import);
if (e) {
fprintf(stderr, "Error importing %s: %s\n", inName, gf_error_to_string(e));
gf_isom_delete(file);
gf_file_delete("ttxt_convert");
return mp4box_cleanup(1);
}
}
#endif /*GPAC_DISABLE_MEDIA_IMPORT*/
if (dump_m2ts) {
#ifndef GPAC_DISABLE_MPEG2TS
dump_mpeg2_ts(inName, pes_dump, program_number);
#endif
} else if (dump_timestamps) {
#ifndef GPAC_DISABLE_MPEG2TS
dump_mpeg2_ts(inName, pes_dump, program_number);
#endif
#ifndef GPAC_DISABLE_CORE_TOOLS
} else if (do_bin_xml) {
xml_bs_to_bin(inName, outName, dump_std);
#endif
} else if (do_hash) {
hash_file(inName, dump_std);
} else if (print_info) {
#ifndef GPAC_DISABLE_MEDIA_IMPORT
convert_file_info(inName, info_track_id);
#endif
} else {
fprintf(stderr, "Input %s is not an MP4 file, operation not allowed\n", inName);
return mp4box_cleanup(1);
}
goto exit;
}
#endif /*GPAC_DISABLE_ISOM_WRITE*/
else if (open_edit) {
file = gf_isom_open(inName, GF_ISOM_WRITE_EDIT, tmpdir);
if (!outName && file) outName = inName;
} else if (!file_exists) {
fprintf(stderr, "Error creating file %s: %s\n", inName, gf_error_to_string(GF_URL_ERROR));
return mp4box_cleanup(1);
} else {
fprintf(stderr, "Cannot open %s - extension not supported\n", inName);
return mp4box_cleanup(1);
}
}
}
if (high_dynamc_range_filename) {
e = parse_high_dynamc_range_xml_desc(file, high_dynamc_range_filename);
if (e) goto err_exit;
}
if (file && keep_utc && open_edit) {
gf_isom_keep_utc_times(file, 1);
}
strcpy(outfile, outName ? outName : inName);
{
char *szExt = gf_file_ext_start(outfile);
if (szExt)
{
/*turn on 3GP saving*/
if (!stricmp(szExt, ".3gp") || !stricmp(szExt, ".3gpp") || !stricmp(szExt, ".3g2"))
conv_type = GF_ISOM_CONV_TYPE_3GPP;
else if (!stricmp(szExt, ".m4a") || !stricmp(szExt, ".m4v"))
conv_type = GF_ISOM_CONV_TYPE_IPOD;
else if (!stricmp(szExt, ".psp"))
conv_type = GF_ISOM_CONV_TYPE_PSP;
else if (!stricmp(szExt, ".mov") || !stricmp(szExt, ".qt"))
conv_type = GF_ISOM_CONV_TYPE_MOV;
//remove extension from outfile
*szExt = 0;
}
}
#ifndef GPAC_DISABLE_MEDIA_EXPORT
if (track_dump_type & GF_EXPORT_AVI_NATIVE) {
char szFile[GF_MAX_PATH+24];
GF_MediaExporter mdump;
memset(&mdump, 0, sizeof(mdump));
mdump.in_name = inName;
mdump.flags = GF_EXPORT_AVI_NATIVE;
mdump.trackID = trackID;
if (dump_std) {
mdump.out_name = "std";
} else if (outName) {
mdump.out_name = outName;
} else if (trackID>2) {
sprintf(szFile, "%s_audio%d", outfile, trackID-1);
mdump.out_name = szFile;
} else {
sprintf(szFile, "%s_%s", outfile, (trackID==1) ? "video" : "audio");
mdump.out_name = szFile;
}
mdump.print_stats_graph = fs_dump_flags;
e = gf_media_export(&mdump);
if (e) goto err_exit;
goto exit;
}
if (!open_edit && track_dump_type && !gf_isom_probe_file(inName)) {
GF_MediaExporter mdump;
char szFile[GF_MAX_PATH+24];
for (i=0; i<nb_track_act; i++) {
TrackAction *tka = &tracks[i];
if (tka->act_type != TRAC_ACTION_RAW_EXTRACT) continue;
memset(&mdump, 0, sizeof(mdump));
mdump.in_name = inName;
mdump.flags = tka->dump_type;
mdump.trackID = tka->trackID;
mdump.sample_num = tka->sample_num;
if (outName) {
mdump.out_name = outName;
mdump.flags |= GF_EXPORT_MERGE;
} else if (nb_track_act>1) {
sprintf(szFile, "%s_track%d", outfile, mdump.trackID);
mdump.out_name = szFile;
} else {
mdump.out_name = outfile;
}
mdump.print_stats_graph = fs_dump_flags;
e = gf_media_export(&mdump);
if (e) goto err_exit;
}
goto exit;
}
#endif /*GPAC_DISABLE_MEDIA_EXPORT*/
#ifndef GPAC_DISABLE_SCENE_DUMP
if (dump_mode != GF_SM_DUMP_NONE) {
e = dump_isom_scene(inName, dump_std ? NULL : (outName ? outName : outfile), outName ? GF_TRUE : GF_FALSE, dump_mode, do_scene_log, no_odf_conf);
if (e) goto err_exit;
}
#endif
#ifndef GPAC_DISABLE_SCENE_STATS
if (stat_level) dump_isom_scene_stats(inName, dump_std ? NULL : (outName ? outName : outfile), outName ? GF_TRUE : GF_FALSE, stat_level);
#endif
#ifndef GPAC_DISABLE_ISOM_HINTING
if (!HintIt && print_sdp) dump_isom_sdp(file, dump_std ? NULL : (outName ? outName : outfile), outName ? GF_TRUE : GF_FALSE);
#endif
if (get_nb_tracks) {
fprintf(stdout, "%d\n", gf_isom_get_track_count(file));
}
if (print_info) {
if (!file) {
fprintf(stderr, "Cannot print info on a non ISOM file (%s)\n", inName);
} else {
if (info_track_id) DumpTrackInfo(file, info_track_id, 1, (print_info==2) ? GF_TRUE : GF_FALSE);
else DumpMovieInfo(file);
}
}
#ifndef GPAC_DISABLE_ISOM_DUMP
if (dump_isom) {
e = dump_isom_xml(file, dump_std ? NULL : (outName ? outName : outfile), outName ? GF_TRUE : GF_FALSE, (dump_isom==2) ? GF_TRUE : GF_FALSE, merge_vtt_cues, use_init_seg ? GF_TRUE : GF_FALSE, (dump_isom==3) ? GF_TRUE : GF_FALSE);
if (e) goto err_exit;
}
if (dump_cr) dump_isom_ismacryp(file, dump_std ? NULL : (outName ? outName : outfile), outName ? GF_TRUE : GF_FALSE);
if ((dump_ttxt || dump_srt) && trackID) {
if (trackID == (u32)-1) {
for (j=0; j<gf_isom_get_track_count(file); j++) {
trackID = gf_isom_get_track_id(file, j+1);
dump_isom_timed_text(file, trackID, dump_std ? NULL : (outName ? outName : outfile), outName ? GF_TRUE : GF_FALSE,
GF_FALSE, dump_srt ? GF_TEXTDUMPTYPE_SRT : GF_TEXTDUMPTYPE_TTXT);
}
}
else {
dump_isom_timed_text(file, trackID, dump_std ? NULL : (outName ? outName : outfile), outName ? GF_TRUE : GF_FALSE,
GF_FALSE, dump_srt ? GF_TEXTDUMPTYPE_SRT : GF_TEXTDUMPTYPE_TTXT);
}
}
#ifndef GPAC_DISABLE_ISOM_HINTING
if (dump_rtp) dump_isom_rtp(file, dump_std ? NULL : (outName ? outName : outfile), outName ? GF_TRUE : GF_FALSE);
#endif
#endif
if (dump_timestamps) dump_isom_timestamps(file, dump_std ? NULL : (outName ? outName : outfile), outName ? GF_TRUE : GF_FALSE, dump_timestamps);
if (dump_nal) dump_isom_nal(file, dump_nal, dump_std ? NULL : (outName ? outName : outfile), outName ? GF_TRUE : GF_FALSE, dump_nal_type);
if (dump_saps) dump_isom_saps(file, dump_saps, dump_saps_mode, dump_std ? NULL : (outName ? outName : outfile), outName ? GF_TRUE : GF_FALSE);
if (do_hash) {
e = hash_file(inName, dump_std);
if (e) goto err_exit;
}
#ifndef GPAC_DISABLE_CORE_TOOLS
if (do_bin_xml) {
e = xml_bs_to_bin(inName, outName, dump_std);
if (e) goto err_exit;
}
#endif
if (dump_cart) dump_isom_cover_art(file, dump_std ? NULL : (outName ? outName : outfile), outName ? GF_TRUE : GF_FALSE);
if (dump_chap) dump_isom_chapters(file, dump_std ? NULL : (outName ? outName : outfile), outName ? GF_TRUE : GF_FALSE, dump_chap);
if (dump_udta_type) dump_isom_udta(file, dump_std ? NULL : (outName ? outName : outfile), outName ? GF_TRUE : GF_FALSE, dump_udta_type, dump_udta_track);
if (dump_iod) {
GF_InitialObjectDescriptor *iod = (GF_InitialObjectDescriptor *)gf_isom_get_root_od(file);
if (!iod) {
fprintf(stderr, "File %s has no IOD", inName);
} else {
char szName[GF_MAX_PATH+10];
FILE *iodf;
sprintf(szName, "%s.iod", outfile);
iodf = gf_fopen(szName, "wb");
if (!iodf) {
fprintf(stderr, "Cannot open destination %s\n", szName);
} else {
u8 *desc;
u32 size;
GF_BitStream *bs = gf_bs_from_file(iodf, GF_BITSTREAM_WRITE);
if (gf_odf_desc_write((GF_Descriptor *)iod, &desc, &size)==GF_OK) {
gf_fwrite(desc, size, iodf);
gf_free(desc);
} else {
fprintf(stderr, "Error writing IOD %s\n", szName);
}
gf_fclose(iodf);
gf_bs_del(bs);
}
gf_odf_desc_del((GF_Descriptor*)iod);
}
}
#if !defined(GPAC_DISABLE_ISOM_WRITE) && !defined(GPAC_DISABLE_MEDIA_IMPORT)
if (split_duration || split_size || split_range_str) {
split_isomedia_file(file, split_duration, split_size, inName, interleaving_time, split_start, adjust_split_end, outName, tmpdir, seg_at_rap, split_range_str);
/*never save file when splitting is desired*/
open_edit = GF_FALSE;
needSave = GF_FALSE;
}
#endif // !defined(GPAC_DISABLE_ISOM_WRITE) && !defined(GPAC_DISABLE_MEDIA_IMPORT)
#ifndef GPAC_DISABLE_MEDIA_EXPORT
if (track_dump_type) {
char szFile[GF_MAX_PATH+24];
GF_MediaExporter mdump;
for (i=0; i<nb_track_act; i++) {
TrackAction *tka = &tracks[i];
if (tka->act_type != TRAC_ACTION_RAW_EXTRACT) continue;
memset(&mdump, 0, sizeof(mdump));
mdump.file = file;
mdump.flags = tka->dump_type;
mdump.trackID = tka->trackID;
mdump.sample_num = tka->sample_num;
if (tka->out_name) {
mdump.out_name = tka->out_name;
} else if (outName) {
mdump.out_name = outName;
mdump.flags |= GF_EXPORT_MERGE;
/*don't infer extension on user-given filename*/
mdump.flags |= GF_EXPORT_NO_FILE_EXT;
} else if (mdump.trackID) {
sprintf(szFile, "%s_track%d", outfile, mdump.trackID);
mdump.out_name = szFile;
} else {
sprintf(szFile, "%s_export", outfile);
mdump.out_name = szFile;
}
if (tka->trackID==(u32) -1) {
for (j=0; j<gf_isom_get_track_count(file); j++) {
mdump.trackID = gf_isom_get_track_id(file, j+1);
sprintf(szFile, "%s_track%d", outfile, mdump.trackID);
mdump.out_name = szFile;
mdump.print_stats_graph = fs_dump_flags;
e = gf_media_export(&mdump);
if (e) goto err_exit;
}
} else {
mdump.print_stats_graph = fs_dump_flags;
e = gf_media_export(&mdump);
if (e) goto err_exit;
}
}
} else if (do_saf) {
GF_MediaExporter mdump;
memset(&mdump, 0, sizeof(mdump));
mdump.file = file;
mdump.flags = GF_EXPORT_SAF;
mdump.out_name = outfile;
mdump.print_stats_graph = fs_dump_flags;
e = gf_media_export(&mdump);
if (e) goto err_exit;
}
#endif
for (i=0; i<nb_meta_act; i++) {
u32 tk = 0;
#ifndef GPAC_DISABLE_ISOM_WRITE
Bool self_ref;
#endif
MetaAction *meta = &metas[i];
if (meta->trackID) tk = gf_isom_get_track_by_id(file, meta->trackID);
switch (meta->act_type) {
#ifndef GPAC_DISABLE_ISOM_WRITE
case META_ACTION_SET_TYPE:
/*note: we don't handle file brand modification, this is an author stuff and cannot be guessed from meta type*/
e = gf_isom_set_meta_type(file, meta->root_meta, tk, meta->meta_4cc);
gf_isom_modify_alternate_brand(file, GF_ISOM_BRAND_ISO2, GF_TRUE);
needSave = GF_TRUE;
break;
case META_ACTION_ADD_ITEM:
self_ref = !stricmp(meta->szPath, "NULL") || !stricmp(meta->szPath, "this") || !stricmp(meta->szPath, "self");
e = gf_isom_add_meta_item(file, meta->root_meta, tk, self_ref, self_ref ? NULL : meta->szPath,
meta->szName,
meta->item_id,
meta->item_type,
meta->mime_type,
meta->enc_type,
meta->use_dref ? meta->szPath : NULL, NULL,
meta->image_props);
if (meta->ref_type) {
e = gf_isom_meta_add_item_ref(file, meta->root_meta, tk, meta->item_id, meta->ref_item_id, meta->ref_type, NULL);
}
needSave = GF_TRUE;
break;
case META_ACTION_ADD_IMAGE_ITEM:
{
u32 old_tk_count = gf_isom_get_track_count(file);
GF_Fraction _frac = {0,0};
e = import_file(file, meta->szPath, 0, _frac, 0, NULL, NULL, 0);
if (e == GF_OK) {
u32 meta_type = gf_isom_get_meta_type(file, meta->root_meta, tk);
if (!meta_type) {
e = gf_isom_set_meta_type(file, meta->root_meta, tk, GF_META_ITEM_TYPE_PICT);
} else {
if (meta_type != GF_META_ITEM_TYPE_PICT) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("Warning: file already has a root 'meta' box of type %s\n", gf_4cc_to_str(meta_type)));
e = GF_BAD_PARAM;
}
}
if (e == GF_OK) {
if (!meta->item_id) {
e = gf_isom_meta_get_next_item_id(file, meta->root_meta, tk, &meta->item_id);
}
if (e == GF_OK) {
e = gf_isom_iff_create_image_item_from_track(file, meta->root_meta, tk, 1,
meta->szName,
meta->item_id,
meta->image_props, NULL);
if (e == GF_OK && meta->primary) {
e = gf_isom_set_meta_primary_item(file, meta->root_meta, tk, meta->item_id);
}
if (e == GF_OK && meta->ref_type) {
e = gf_isom_meta_add_item_ref(file, meta->root_meta, tk, meta->item_id, meta->ref_item_id, meta->ref_type, NULL);
}
}
}
}
gf_isom_remove_track(file, old_tk_count+1);
needSave = GF_TRUE;
}
break;
case META_ACTION_REM_ITEM:
e = gf_isom_remove_meta_item(file, meta->root_meta, tk, meta->item_id);
needSave = GF_TRUE;
break;
case META_ACTION_SET_PRIMARY_ITEM:
e = gf_isom_set_meta_primary_item(file, meta->root_meta, tk, meta->item_id);
needSave = GF_TRUE;
break;
case META_ACTION_SET_XML:
case META_ACTION_SET_BINARY_XML:
e = gf_isom_set_meta_xml(file, meta->root_meta, tk, meta->szPath, NULL, 0, (meta->act_type==META_ACTION_SET_BINARY_XML) ? 1 : 0);
needSave = GF_TRUE;
break;
case META_ACTION_REM_XML:
if (gf_isom_get_meta_item_count(file, meta->root_meta, tk)) {
e = gf_isom_remove_meta_xml(file, meta->root_meta, tk);
needSave = GF_TRUE;
} else {
fprintf(stderr, "No meta box in input file\n");
}
break;
case META_ACTION_DUMP_ITEM:
if (gf_isom_get_meta_item_count(file, meta->root_meta, tk)) {
e = gf_isom_extract_meta_item(file, meta->root_meta, tk, meta->item_id, strlen(meta->szPath) ? meta->szPath : NULL);
} else {
fprintf(stderr, "No meta box in input file\n");
}
break;
#endif // GPAC_DISABLE_ISOM_WRITE
case META_ACTION_DUMP_XML:
if (gf_isom_has_meta_xml(file, meta->root_meta, tk)) {
e = gf_isom_extract_meta_xml(file, meta->root_meta, tk, meta->szPath, NULL);
} else {
fprintf(stderr, "No meta box in input file\n");
}
break;
default:
break;
}
if (meta->image_props) {
gf_free(meta->image_props);
meta->image_props = NULL;
}
if (e) goto err_exit;
}
if (!open_edit && !needSave) {
if (file) gf_isom_delete(file);
goto exit;
}
#ifndef GPAC_DISABLE_ISOM_WRITE
if (clean_groups) {
e = gf_isom_reset_switch_parameters(file);
if (e) goto err_exit;
needSave = GF_TRUE;
}
for (i=0; i<nb_tsel_acts; i++) {
switch (tsel_acts[i].act_type) {
case TSEL_ACTION_SET_PARAM:
e = gf_isom_set_track_switch_parameter(file,
gf_isom_get_track_by_id(file, tsel_acts[i].trackID),
tsel_acts[i].refTrackID ? gf_isom_get_track_by_id(file, tsel_acts[i].refTrackID) : 0,
tsel_acts[i].is_switchGroup ? 1 : 0,
&tsel_acts[i].switchGroupID,
tsel_acts[i].criteria, tsel_acts[i].nb_criteria);
if (e == GF_BAD_PARAM) {
u32 alternateGroupID, nb_groups;
gf_isom_get_track_switch_group_count(file, gf_isom_get_track_by_id(file, tsel_acts[i].trackID), &alternateGroupID, &nb_groups);
if (alternateGroupID)
fprintf(stderr, "Hint: for adding more tracks to group, using: -group-add -refTrack=ID1:[criteria:]trackID=ID2\n");
else
fprintf(stderr, "Hint: for creates a new grouping information, using -group-add -trackID=ID1:[criteria:]trackID=ID2\n");
}
if (e) goto err_exit;
needSave = GF_TRUE;
break;
case TSEL_ACTION_REMOVE_TSEL:
e = gf_isom_reset_track_switch_parameter(file, gf_isom_get_track_by_id(file, tsel_acts[i].trackID), 0);
if (e) goto err_exit;
needSave = GF_TRUE;
break;
case TSEL_ACTION_REMOVE_ALL_TSEL_IN_GROUP:
e = gf_isom_reset_track_switch_parameter(file, gf_isom_get_track_by_id(file, tsel_acts[i].trackID), 1);
if (e) goto err_exit;
needSave = GF_TRUE;
break;
default:
break;
}
}
if (remove_sys_tracks) {
#ifndef GPAC_DISABLE_AV_PARSERS
remove_systems_tracks(file);
#endif
needSave = GF_TRUE;
if (conv_type < GF_ISOM_CONV_TYPE_ISMA_EX) conv_type = 0;
}
if (remove_root_od) {
gf_isom_remove_root_od(file);
needSave = GF_TRUE;
}
#ifndef GPAC_DISABLE_ISOM_HINTING
if (remove_hint) {
for (i=0; i<gf_isom_get_track_count(file); i++) {
if (gf_isom_get_media_type(file, i+1) == GF_ISOM_MEDIA_HINT) {
fprintf(stderr, "Removing hint track ID %d\n", gf_isom_get_track_id(file, i+1));
gf_isom_remove_track(file, i+1);
i--;
}
}
gf_isom_sdp_clean(file);
needSave = GF_TRUE;
}
#endif // GPAC_DISABLE_ISOM_HINTING
if (timescale && (timescale != gf_isom_get_timescale(file))) {
gf_isom_set_timescale(file, timescale);
needSave = GF_TRUE;
}
if (!encode) {
if (!file) {
fprintf(stderr, "Nothing to do - exiting\n");
goto exit;
}
if (outName) {
strcpy(outfile, outName);
} else {
char *rel_name = strrchr(inName, GF_PATH_SEPARATOR);
if (!rel_name) rel_name = strrchr(inName, '/');
strcpy(outfile, "");
if (tmpdir) {
strcpy(outfile, tmpdir);
if (!strchr("\\/", tmpdir[strlen(tmpdir)-1])) strcat(outfile, "/");
}
if (!pack_file) strcat(outfile, "out_");
strcat(outfile, rel_name ? rel_name + 1 : inName);
if (pack_file) {
strcpy(outfile, rel_name ? rel_name + 1 : inName);
rel_name = strrchr(outfile, '.');
if (rel_name) rel_name[0] = 0;
strcat(outfile, ".m21");
}
}
#ifndef GPAC_DISABLE_MEDIA_IMPORT
if ((conv_type == GF_ISOM_CONV_TYPE_ISMA) || (conv_type == GF_ISOM_CONV_TYPE_ISMA_EX)) {
fprintf(stderr, "Converting to ISMA Audio-Video MP4 file...\n");
/*keep ESIDs when doing ISMACryp*/
e = gf_media_make_isma(file, crypt ? 1 : 0, GF_FALSE, (conv_type==GF_ISOM_CONV_TYPE_ISMA_EX) ? 1 : 0);
if (e) goto err_exit;
needSave = GF_TRUE;
}
if (conv_type == GF_ISOM_CONV_TYPE_3GPP) {
fprintf(stderr, "Converting to 3GP file...\n");
e = gf_media_make_3gpp(file);
if (e) goto err_exit;
needSave = GF_TRUE;
}
if (conv_type == GF_ISOM_CONV_TYPE_PSP) {
fprintf(stderr, "Converting to PSP file...\n");
e = gf_media_make_psp(file);
if (e) goto err_exit;
needSave = GF_TRUE;
}
if (conv_type == GF_ISOM_CONV_TYPE_MOV) {
e = gf_media_check_qt_prores(file);
if (e) goto err_exit;
needSave = GF_TRUE;
if (interleaving_time) interleaving_time = 0.5;
}
#endif /*GPAC_DISABLE_MEDIA_IMPORT*/
if (conv_type == GF_ISOM_CONV_TYPE_IPOD) {
u32 ipod_major_brand = 0;
fprintf(stderr, "Setting up iTunes/iPod file...\n");
for (i=0; i<gf_isom_get_track_count(file); i++) {
u32 mType = gf_isom_get_media_type(file, i+1);
switch (mType) {
case GF_ISOM_MEDIA_VISUAL:
case GF_ISOM_MEDIA_AUXV:
case GF_ISOM_MEDIA_PICT:
ipod_major_brand = GF_ISOM_BRAND_M4V;
gf_isom_set_ipod_compatible(file, i+1);
break;
case GF_ISOM_MEDIA_AUDIO:
if (!ipod_major_brand) ipod_major_brand = GF_ISOM_BRAND_M4A;
else gf_isom_modify_alternate_brand(file, GF_ISOM_BRAND_M4A, GF_TRUE);
break;
case GF_ISOM_MEDIA_TEXT:
/*this is a text track track*/
if (gf_isom_get_media_subtype(file, i+1, 1) == GF_ISOM_SUBTYPE_TX3G) {
Bool is_chap = 0;
for (j=0; j<gf_isom_get_track_count(file); j++) {
s32 count = gf_isom_get_reference_count(file, j+1, GF_ISOM_REF_CHAP);
if (count>0) {
u32 tk, k;
for (k=0; k<(u32) count; k++) {
gf_isom_get_reference(file, j+1, GF_ISOM_REF_CHAP, k+1, &tk);
if (tk==i+1) {
is_chap = 1;
break;
}
}
if (is_chap) break;
}
if (is_chap) break;
}
/*this is a subtitle track*/
if (!is_chap)
gf_isom_set_media_type(file, i+1, GF_ISOM_MEDIA_SUBT);
}
break;
}
}
gf_isom_set_brand_info(file, ipod_major_brand, 1);
gf_isom_modify_alternate_brand(file, GF_ISOM_BRAND_MP42, GF_TRUE);
needSave = GF_TRUE;
}
} else if (outName) {
strcpy(outfile, outName);
}
for (j=0; j<nb_track_act; j++) {
TrackAction *tka = &tracks[j];
u32 track = tka->trackID ? gf_isom_get_track_by_id(file, tka->trackID) : 0;
timescale = gf_isom_get_timescale(file);
switch (tka->act_type) {
case TRAC_ACTION_REM_TRACK:
e = gf_isom_remove_track(file, track);
if (e) {
fprintf(stderr, "Error Removing track ID %d: %s\n", tka->trackID, gf_error_to_string(e));
} else {
fprintf(stderr, "Removing track ID %d\n", tka->trackID);
}
needSave = GF_TRUE;
break;
case TRAC_ACTION_SET_LANGUAGE:
for (i=0; i<gf_isom_get_track_count(file); i++) {
if (track && (track != i+1)) continue;
e = gf_isom_set_media_language(file, i+1, tka->lang);
if (e) goto err_exit;
needSave = GF_TRUE;
}
needSave = GF_TRUE;
break;
case TRAC_ACTION_SET_KIND:
for (i=0; i<gf_isom_get_track_count(file); i++) {
if (track && (track != i+1)) continue;
e = gf_isom_add_track_kind(file, i+1, tka->kind_scheme, tka->kind_value);
if (e) goto err_exit;
needSave = GF_TRUE;
}
needSave = GF_TRUE;
break;
case TRAC_ACTION_REM_KIND:
for (i=0; i<gf_isom_get_track_count(file); i++) {
if (track && (track != i+1)) continue;
e = gf_isom_remove_track_kind(file, i+1, tka->kind_scheme, tka->kind_value);
if (e) goto err_exit;
needSave = GF_TRUE;
}
needSave = GF_TRUE;
break;
case TRAC_ACTION_SET_DELAY:
if (tka->delay_ms) {
u64 tk_dur;
gf_isom_remove_edits(file, track);
tk_dur = gf_isom_get_track_duration(file, track);
if (gf_isom_get_edits_count(file, track))
needSave = GF_TRUE;
if (tka->delay_ms>0) {
gf_isom_append_edit(file, track, (timescale*tka->delay_ms)/1000, 0, GF_ISOM_EDIT_EMPTY);
gf_isom_append_edit(file, track, tk_dur, 0, GF_ISOM_EDIT_NORMAL);
needSave = GF_TRUE;
} else {
u64 to_skip = (timescale*(-tka->delay_ms))/1000;
if (to_skip<tk_dur) {
u64 media_time = (-tka->delay_ms)*gf_isom_get_media_timescale(file, track) / 1000;
gf_isom_append_edit(file, track, tk_dur-to_skip, media_time, GF_ISOM_EDIT_NORMAL);
needSave = GF_TRUE;
} else {
fprintf(stderr, "Warning: request negative delay longer than track duration - ignoring\n");
}
}
} else if (gf_isom_get_edits_count(file, track)) {
gf_isom_remove_edits(file, track);
needSave = GF_TRUE;
}
break;
case TRAC_ACTION_SET_KMS_URI:
for (i=0; i<gf_isom_get_track_count(file); i++) {
if (track && (track != i+1)) continue;
if (!gf_isom_is_media_encrypted(file, i+1, 1)) continue;
if (!gf_isom_is_ismacryp_media(file, i+1, 1)) continue;
e = gf_isom_change_ismacryp_protection(file, i+1, 1, NULL, (char *) tka->kms);
if (e) goto err_exit;
needSave = GF_TRUE;
}
break;
case TRAC_ACTION_SET_ID:
if (!tka->trackID && (gf_isom_get_track_count(file) == 1)) {
fprintf(stderr, "Warning: track id is not specified, but file has only one track - assume that you want to change id for this track\n");
track = 1;
}
if (track) {
u32 newTrack;
newTrack = gf_isom_get_track_by_id(file, tka->newTrackID);
if (newTrack != 0) {
fprintf(stderr, "Error: Cannot set track id with value %d because a track already exists - ignoring", tka->newTrackID);
} else {
e = gf_isom_set_track_id(file, track, tka->newTrackID);
needSave = GF_TRUE;
}
} else {
fprintf(stderr, "Error: Cannot change id for track %d because it does not exist - ignoring", tka->trackID);
}
break;
case TRAC_ACTION_SWAP_ID:
if (track) {
u32 tk1, tk2;
tk1 = gf_isom_get_track_by_id(file, tka->trackID);
tk2 = gf_isom_get_track_by_id(file, tka->newTrackID);
if (!tk1 || !tk2) {
fprintf(stderr, "Error: Cannot swap track IDs because not existing - ignoring");
} else {
e = gf_isom_set_track_id(file, tk2, 0);
if (!e) e = gf_isom_set_track_id(file, tk1, tka->newTrackID);
if (!e) e = gf_isom_set_track_id(file, tk2, tka->trackID);
needSave = GF_TRUE;
}
} else {
fprintf(stderr, "Error: Cannot change id for track %d because it does not exist - ignoring", tka->trackID);
}
break;
case TRAC_ACTION_SET_PAR:
e = gf_media_change_par(file, track, tka->par_num, tka->par_den, tka->force_par, tka->rewrite_bs);
needSave = GF_TRUE;
break;
case TRAC_ACTION_SET_CLAP:
e = gf_isom_set_clean_aperture(file, track, 1, tka->clap_wnum, tka->clap_wden, tka->clap_hnum, tka->clap_hden, tka->clap_honum, tka->clap_hoden, tka->clap_vonum, tka->clap_voden);
needSave = GF_TRUE;
break;
case TRAC_ACTION_SET_MX:
e = gf_isom_set_track_matrix(file, track, tka->mx);
needSave = GF_TRUE;
break;
case TRAC_ACTION_SET_HANDLER_NAME:
e = gf_isom_set_handler_name(file, track, tka->hdl_name);
needSave = GF_TRUE;
break;
case TRAC_ACTION_ENABLE:
if (!gf_isom_is_track_enabled(file, track)) {
e = gf_isom_set_track_enabled(file, track, GF_TRUE);
needSave = GF_TRUE;
}
break;
case TRAC_ACTION_DISABLE:
if (gf_isom_is_track_enabled(file, track)) {
e = gf_isom_set_track_enabled(file, track, GF_FALSE);
needSave = GF_TRUE;
}
break;
case TRAC_ACTION_REFERENCE:
e = gf_isom_set_track_reference(file, track, GF_4CC(tka->lang[0], tka->lang[1], tka->lang[2], tka->lang[3]), (u32) tka->delay_ms);
needSave = GF_TRUE;
break;
case TRAC_ACTION_REM_NON_RAP:
fprintf(stderr, "Removing non-rap samples from track %d\n", tka->trackID);
e = gf_media_remove_non_rap(file, track, GF_FALSE);
needSave = GF_TRUE;
break;
case TRAC_ACTION_REM_NON_REFS:
fprintf(stderr, "Removing non-reference samples from track %d\n", tka->trackID);
e = gf_media_remove_non_rap(file, track, GF_TRUE);
needSave = GF_TRUE;
break;
case TRAC_ACTION_SET_UDTA:
fprintf(stderr, "Assigning udta box\n");
e = set_file_udta(file, track, tka->udta_type, tka->src_name, tka->sample_num ? GF_TRUE : GF_FALSE);
if (e) goto err_exit;
needSave = GF_TRUE;
break;
default:
break;
}
if (e) goto err_exit;
}
if (itunes_tags) {
char *tags = itunes_tags;
while (tags) {
char *val;
char *sep = gf_url_colon_suffix(tags);
u32 tlen, itag = 0;
if (sep) {
while (sep) {
for (itag=0; itag<nb_itunes_tags; itag++) {
if (!strnicmp(sep+1, itags[itag].name, strlen(itags[itag].name))) break;
}
if (itag<nb_itunes_tags) {
break;
}
sep = gf_url_colon_suffix(sep+1);
}
if (sep) sep[0] = 0;
}
for (itag=0; itag<nb_itunes_tags; itag++) {
if (!strnicmp(tags, itags[itag].name, strlen(itags[itag].name))) {
break;
}
}
if (itag==nb_itunes_tags) {
fprintf(stderr, "Invalid iTune tag format \"%s\" - ignoring\n", tags);
tags = NULL;
continue;
}
itag = itags[itag].code;
val = strchr(tags, '=');
if (!val) {
fprintf(stderr, "Invalid iTune tag format \"%s\" (expecting '=') - ignoring\n", tags);
tags = NULL;
continue;
}
val ++;
if ((val[0]==':') || !val[0] || !stricmp(val, "NULL") ) val = NULL;
tlen = val ? (u32) strlen(val) : 0;
switch (itag) {
case GF_ISOM_ITUNE_COVER_ART:
{
u8 *d=NULL;
e = GF_OK;
if (val) {
char *ext;
e = gf_file_load_data(val, (u8 **) &d, &tlen);
ext = strrchr(val, '.');
if (!stricmp(ext, ".png")) tlen |= 0x80000000;
}
if (!e)
e = gf_isom_apple_set_tag(file, GF_ISOM_ITUNE_COVER_ART, d, tlen);
if (d) gf_free(d);
}
break;
case GF_ISOM_ITUNE_TEMPO:
gf_isom_apple_set_tag(file, itag, NULL, val ? atoi(val) : 0);
break;
case GF_ISOM_ITUNE_GENRE:
{
u8 _v = gf_id3_get_genre_tag(val);
if (_v) {
gf_isom_apple_set_tag(file, itag, NULL, _v);
} else {
if (!val) val="";
gf_isom_apple_set_tag(file, itag, (u8 *) val, (u32) strlen(val) );
}
}
break;
case GF_ISOM_ITUNE_DISK:
case GF_ISOM_ITUNE_TRACKNUMBER:
{
u32 n, t;
char _t[8];
n = t = 0;
if (val) {
memset(_t, 0, sizeof(char) * 8);
tlen = (itag == GF_ISOM_ITUNE_DISK) ? 6 : 8;
if (sscanf(val, "%u/%u", &n, &t) == 2) {
_t[3] = n;
_t[2] = n >> 8;
_t[5] = t;
_t[4] = t >> 8;
}
else if (sscanf(val, "%u", &n) == 1) {
_t[3] = n;
_t[2] = n >> 8;
}
else tlen = 0;
}
if (!val || tlen) gf_isom_apple_set_tag(file, itag, val ? (u8 *)_t : NULL, tlen);
}
break;
case GF_ISOM_ITUNE_GAPLESS:
case GF_ISOM_ITUNE_COMPILATION:
{
u8 _t[1];
if (val && !stricmp(val, "yes")) _t[0] = 1;
else _t[0] = 0;
gf_isom_apple_set_tag(file, itag, _t, 1);
}
break;
default:
gf_isom_apple_set_tag(file, itag, (u8 *)val, tlen);
break;
}
needSave = GF_TRUE;
if (sep) {
sep[0] = ':';
tags = sep+1;
} else {
tags = NULL;
}
}
}
if (movie_time) {
gf_isom_set_creation_time(file, movie_time);
for (i=0; i<gf_isom_get_track_count(file); i++) {
gf_isom_set_track_creation_time(file, i+1, movie_time);
}
needSave = GF_TRUE;
}
if (cprt) {
e = gf_isom_set_copyright(file, "und", cprt);
needSave = GF_TRUE;
if (e) goto err_exit;
}
if (chap_file) {
#ifndef GPAC_DISABLE_MEDIA_IMPORT
e = gf_media_import_chapters(file, chap_file, import_fps, chap_qt);
needSave = GF_TRUE;
#else
fprintf(stderr, "Warning: GPAC compiled without Media Import, chapters can't be imported\n");
e = GF_NOT_SUPPORTED;
#endif
if (e) goto err_exit;
}
if (major_brand) {
gf_isom_set_brand_info(file, major_brand, minor_version);
needSave = GF_TRUE;
}
for (i=0; i<nb_alt_brand_add; i++) {
gf_isom_modify_alternate_brand(file, brand_add[i], GF_TRUE);
needSave = GF_TRUE;
}
for (i=0; i<nb_alt_brand_rem; i++) {
gf_isom_modify_alternate_brand(file, brand_rem[i], GF_FALSE);
needSave = GF_TRUE;
}
if (box_patch_filename) {
e = gf_isom_apply_box_patch(file, box_patch_trackID, box_patch_filename, GF_FALSE);
if (e) {
fprintf(stderr, "Failed to apply box patch %s: %s\n", box_patch_filename, gf_error_to_string(e) );
goto err_exit;
}
needSave = GF_TRUE;
}
#ifndef GPAC_DISABLE_CRYPTO
if (crypt) {
if (!drm_file) {
fprintf(stderr, "Missing DRM file location - usage '-%s drm_file input_file\n", (crypt==1) ? "crypt" : "decrypt");
e = GF_BAD_PARAM;
goto err_exit;
}
if (get_file_type_by_ext(inName) != GF_FILE_TYPE_ISO_MEDIA) {
fprintf(stderr, "MP4Box can crypt only ISOMedia File\n");
e = GF_BAD_PARAM;
goto err_exit;
}
if (crypt == 1) {
if (use_init_seg) {
e = gf_crypt_fragment(file, drm_file, outfile, inName, fs_dump_flags);
} else {
e = gf_crypt_file(file, drm_file, outfile, interleaving_time, fs_dump_flags);
}
} else if (crypt ==2) {
if (use_init_seg) {
e = gf_decrypt_fragment(file, drm_file, outfile, inName, fs_dump_flags);
} else {
e = gf_decrypt_file(file, drm_file, outfile, interleaving_time, fs_dump_flags);
}
}
if (e) goto err_exit;
needSave = outName ? GF_FALSE : GF_TRUE;
if (!Frag && !HintIt && !FullInter && !force_co64) {
char szName[GF_MAX_PATH];
strcpy(szName, gf_isom_get_filename(file) );
gf_isom_delete(file);
file = NULL;
if (!outName) {
e = gf_file_move(outfile, szName);
if (e) goto err_exit;
}
goto exit;
}
}
#endif /*GPAC_DISABLE_CRYPTO*/
#ifndef GPAC_DISABLE_ISOM_FRAGMENTS
if (Frag) {
if (!interleaving_time) interleaving_time = DEFAULT_INTERLEAVING_IN_SEC;
if (HintIt) fprintf(stderr, "Warning: cannot hint and fragment - ignoring hint\n");
fprintf(stderr, "Fragmenting file (%.3f seconds fragments)\n", interleaving_time);
e = gf_media_fragment_file(file, outfile, interleaving_time, use_mfra);
if (e) fprintf(stderr, "Error while fragmenting file: %s\n", gf_error_to_string(e));
if (!e && !outName) {
if (gf_file_exists(inName) && gf_file_delete(inName)) fprintf(stderr, "Error removing file %s\n", inName);
else if (gf_file_move(outfile, inName)) fprintf(stderr, "Error renaming file %s to %s\n", outfile, inName);
}
if (e) goto err_exit;
gf_isom_delete(file);
goto exit;
}
#endif
#ifndef GPAC_DISABLE_ISOM_HINTING
if (HintIt) {
if (force_ocr) SetupClockReferences(file);
fprintf(stderr, "Hinting file with Path-MTU %d Bytes\n", MTUSize);
MTUSize -= 12;
e = HintFile(file, MTUSize, max_ptime, rtp_rate, hint_flags, HintCopy, HintInter, regular_iod, single_group, hint_no_offset);
if (e) goto err_exit;
needSave = GF_TRUE;
if (print_sdp) dump_isom_sdp(file, dump_std ? NULL : (outName ? outName : outfile), outName ? GF_TRUE : GF_FALSE);
}
#endif
#if !defined(GPAC_DISABLE_ISOM_HINTING) && !defined(GPAC_DISABLE_SENG)
for (i=0; i<nb_sdp_ex; i++) {
if (sdp_lines[i].trackID) {
u32 track = gf_isom_get_track_by_id(file, sdp_lines[i].trackID);
if (gf_isom_get_media_type(file, track)!=GF_ISOM_MEDIA_HINT) {
s32 ref_count;
u32 k, count = gf_isom_get_track_count(file);
for (j=0; j<count; j++) {
if (gf_isom_get_media_type(file, j+1)!=GF_ISOM_MEDIA_HINT) continue;
ref_count = gf_isom_get_reference_count(file, j+1, GF_ISOM_REF_HINT);
if (ref_count<0) continue;
for (k=0; k<(u32) ref_count; k++) {
u32 refTk;
if (gf_isom_get_reference(file, j+1, GF_ISOM_REF_HINT, k+1, &refTk)) continue;
if (refTk==track) {
track = j+1;
j=count;
break;
}
}
}
}
gf_isom_sdp_add_track_line(file, track, sdp_lines[i].line);
needSave = GF_TRUE;
} else {
gf_isom_sdp_add_line(file, sdp_lines[i].line);
needSave = GF_TRUE;
}
}
#endif /*!defined(GPAC_DISABLE_ISOM_HINTING) && !defined(GPAC_DISABLE_SENG)*/
/*full interleave (sample-based) if just hinted*/
if (FullInter) {
e = gf_isom_set_storage_mode(file, GF_ISOM_STORE_TIGHT);
} else if (do_flat) {
e = gf_isom_set_storage_mode(file, (do_flat==1) ? GF_ISOM_STORE_FLAT : GF_ISOM_STORE_STREAMABLE);
needSave = GF_TRUE;
} else {
e = gf_isom_make_interleave(file, interleaving_time);
if (!e && old_interleave) e = gf_isom_set_storage_mode(file, GF_ISOM_STORE_INTERLEAVED);
}
if (force_co64)
gf_isom_force_64bit_chunk_offset(file, GF_TRUE);
if (compress_moov)
gf_isom_enable_compression(file, GF_ISO_COMP_MOOV, GF_FALSE);
if (e) goto err_exit;
if (!encode && !force_new) gf_isom_set_final_name(file, outfile);
if (needSave) {
if (!gf_sys_is_quiet()) {
if (outName) {
gf_isom_set_final_name(file, outfile);
} else if (encode || pack_file) {
fprintf(stderr, "Saving to %s: ", gf_isom_get_filename(file) );
} else {
fprintf(stderr, "Saving %s: ", inName);
}
if (HintIt && FullInter) fprintf(stderr, "Hinted file - Full Interleaving\n");
else if (FullInter) fprintf(stderr, "Full Interleaving\n");
else if ((force_new==2) && interleaving_time) fprintf(stderr, "Fast-start interleaved storage\n");
else if (do_flat || !interleaving_time) fprintf(stderr, "Flat storage\n");
else fprintf(stderr, "%.3f secs Interleaving%s\n", interleaving_time, old_interleave ? " - no drift control" : "");
} else {
if (outName)
gf_isom_set_final_name(file, outfile);
}
e = gf_isom_close(file);
file = NULL;
if (!e && !outName && !encode && !force_new && !pack_file) {
if (gf_file_exists(inName)) {
e = gf_file_delete(inName);
if (e) {
fprintf(stderr, "Error removing file %s\n", inName);
}
}
e = gf_file_move(outfile, inName);
if (e) {
fprintf(stderr, "Error renaming file %s to %s\n", outfile, inName);
}
}
} else {
gf_isom_delete(file);
}
if (e) {
fprintf(stderr, "Error: %s\n", gf_error_to_string(e));
goto err_exit;
}
goto exit;
#else
/*close libgpac*/
gf_isom_delete(file);
fprintf(stderr, "Error: Read-only version of MP4Box.\n");
return mp4box_cleanup(1);
#endif //GPAC_DISABLE_ISOM_WRITE
err_exit:
/*close libgpac*/
if (file) gf_isom_delete(file);
fprintf(stderr, "\n\tError: %s\n", gf_error_to_string(e));
return mp4box_cleanup(1);
exit:
mp4box_cleanup(0);
#ifdef GPAC_MEMORY_TRACKING
if (mem_track && (gf_memory_size() || gf_file_handles_count() )) {
gf_log_set_tool_level(GF_LOG_MEMORY, GF_LOG_INFO);
gf_memory_print();
return 2;
}
#endif
return 0;
} | 12816 | True | 1 |
CVE-2020-23930 | 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/gpac/gpac/issues/1565', 'name': 'https://github.com/gpac/gpac/issues/1565', 'refsource': 'MISC', 'tags': ['Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/9eeac00b38348c664dfeae2525bba0cf1bc32349', 'name': 'https://github.com/gpac/gpac/commit/9eeac00b38348c664dfeae2525bba0cf1bc32349', 'refsource': 'MISC', 'tags': ['Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-476'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:*:*:*:*:*:*:*:*', 'versionEndIncluding': '20200801', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'An issue was discovered in gpac through 20200801. A NULL pointer dereference exists in the function nhmldump_send_header located in write_nhml.c. It allows an attacker to cause Denial of Service.'}] | 2021-04-22T19:06Z | 2021-04-21T18: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 | jeanlf | 2020-09-01 16:46:07+02:00 | fixed #1565 | 9eeac00b38348c664dfeae2525bba0cf1bc32349 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | nhmldump_send_header | nhmldump_send_header( GF_NHMLDumpCtx * ctx) | ['ctx'] | static void nhmldump_send_header(GF_NHMLDumpCtx *ctx)
{
GF_FilterPacket *dst_pck;
char nhml[1024];
u32 size;
u8 *output;
const GF_PropertyValue *p;
ctx->szRootName = "NHNTStream";
if (ctx->dims) {
ctx->szRootName = "DIMSStream";
}
if (!ctx->filep) {
sprintf(nhml, "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
gf_bs_write_data(ctx->bs_w, nhml, (u32) strlen(nhml));
}
/*write header*/
sprintf(nhml, "<%s version=\"1.0\" ", ctx->szRootName);
gf_bs_write_data(ctx->bs_w, nhml, (u32) strlen(nhml));
NHML_PRINT_UINT(GF_PROP_PID_ID, NULL, "trackID")
NHML_PRINT_UINT(GF_PROP_PID_TIMESCALE, NULL, "timeScale")
p = gf_filter_pid_get_property(ctx->ipid, GF_PROP_PID_IN_IOD);
if (p && p->value.boolean) {
sprintf(nhml, "inRootOD=\"yes\" ");
gf_bs_write_data(ctx->bs_w, nhml, (u32) strlen(nhml));
}
if (ctx->oti && (ctx->oti<GF_CODECID_LAST_MPEG4_MAPPING)) {
sprintf(nhml, "streamType=\"%d\" objectTypeIndication=\"%d\" ", ctx->streamtype, ctx->oti);
gf_bs_write_data(ctx->bs_w, nhml, (u32)strlen(nhml));
} else {
p = gf_filter_pid_get_property(ctx->ipid, GF_PROP_PID_SUBTYPE);
if (p) {
sprintf(nhml, "%s=\"%s\" ", "mediaType", gf_4cc_to_str(p->value.uint));
gf_bs_write_data(ctx->bs_w, nhml, (u32) strlen(nhml));
NHML_PRINT_4CC(GF_PROP_PID_ISOM_SUBTYPE, "mediaSubType", "mediaSubType")
} else {
NHML_PRINT_4CC(GF_PROP_PID_CODECID, NULL, "codecID")
}
}
if (ctx->w && ctx->h) {
//compatibility with old arch, we might want to remove this
switch (ctx->streamtype) {
case GF_STREAM_VISUAL:
case GF_STREAM_SCENE:
sprintf(nhml, "width=\"%d\" height=\"%d\" ", ctx->w, ctx->h);
gf_bs_write_data(ctx->bs_w, nhml, (u32) strlen(nhml));
break;
default:
break;
}
}
else if (ctx->sr && ctx->chan) {
sprintf(nhml, "sampleRate=\"%d\" numChannels=\"%d\" ", ctx->sr, ctx->chan);
gf_bs_write_data(ctx->bs_w, nhml, (u32) strlen(nhml));
sprintf(nhml, "sampleRate=\"%d\" numChannels=\"%d\" ", ctx->sr, ctx->chan);
gf_bs_write_data(ctx->bs_w, nhml, (u32) strlen(nhml));
p = gf_filter_pid_get_property(ctx->ipid, GF_PROP_PID_AUDIO_FORMAT);
sprintf(nhml, "bitsPerSample=\"%d\" ", gf_audio_fmt_bit_depth(p->value.uint));
gf_bs_write_data(ctx->bs_w, nhml, (u32) strlen(nhml));
}
NHML_PRINT_4CC(0, "codec_vendor", "codecVendor")
NHML_PRINT_UINT(0, "codec_version", "codecVersion")
NHML_PRINT_UINT(0, "codec_revision", "codecRevision")
NHML_PRINT_STRING(0, "compressor_name", "compressorName")
NHML_PRINT_UINT(0, "temporal_quality", "temporalQuality")
NHML_PRINT_UINT(0, "spatial_quality", "spatialQuality")
NHML_PRINT_UINT(0, "hres", "horizontalResolution")
NHML_PRINT_UINT(0, "vres", "verticalResolution")
NHML_PRINT_UINT(GF_PROP_PID_BIT_DEPTH_Y, NULL, "bitDepth")
NHML_PRINT_STRING(0, "meta:xmlns", "xml_namespace")
NHML_PRINT_STRING(0, "meta:schemaloc", "xml_schema_location")
NHML_PRINT_STRING(0, "meta:mime", "mime_type")
NHML_PRINT_STRING(0, "meta:config", "config")
NHML_PRINT_STRING(0, "meta:aux_mimes", "aux_mime_type")
if (ctx->codecid == GF_CODECID_DIMS) {
if (gf_filter_pid_get_property_str(ctx->ipid, "meta:xmlns")==NULL) {
sprintf(nhml, "xmlns=\"http://www.3gpp.org/richmedia\" ");
gf_bs_write_data(ctx->bs_w, nhml, (u32) strlen(nhml));
}
NHML_PRINT_UINT(0, "dims:profile", "profile")
NHML_PRINT_UINT(0, "dims:level", "level")
NHML_PRINT_UINT(0, "dims:pathComponents", "pathComponents")
p = gf_filter_pid_get_property_str(ctx->ipid, "dims:fullRequestHost");
if (p) {
sprintf(nhml, "useFullRequestHost=\"%s\" ", p->value.boolean ? "yes" : "no");
gf_bs_write_data(ctx->bs_w, nhml, (u32) strlen(nhml));
}
p = gf_filter_pid_get_property_str(ctx->ipid, "dims:streamType");
if (p) {
sprintf(nhml, "stream_type=\"%s\" ", p->value.boolean ? "primary" : "secondary");
gf_bs_write_data(ctx->bs_w, nhml, (u32) strlen(nhml));
}
p = gf_filter_pid_get_property_str(ctx->ipid, "dims:redundant");
if (p) {
sprintf(nhml, "contains_redundant=\"%s\" ", (p->value.uint==1) ? "main" : ((p->value.uint==1) ? "redundant" : "main+redundant") );
gf_bs_write_data(ctx->bs_w, nhml, (u32) strlen(nhml));
}
NHML_PRINT_UINT(0, "dims:scriptTypes", "scriptTypes")
}
//send DCD
if (ctx->opid_info) {
sprintf(nhml, "specificInfoFile=\"%s\" ", gf_file_basename(ctx->info_file) );
gf_bs_write_data(ctx->bs_w, nhml, (u32) strlen(nhml));
dst_pck = gf_filter_pck_new_shared(ctx->opid_info, ctx->dcfg, ctx->dcfg_size, NULL);
gf_filter_pck_set_framing(dst_pck, GF_TRUE, GF_TRUE);
gf_filter_pck_set_readonly(dst_pck);
gf_filter_pck_send(dst_pck);
}
NHML_PRINT_STRING(0, "meta:encoding", "encoding")
NHML_PRINT_STRING(0, "meta:contentEncoding", "content_encoding")
ctx->uncompress = GF_FALSE;
if (p) {
if (!strcmp(p->value.string, "deflate")) ctx->uncompress = GF_TRUE;
else {
GF_LOG(GF_LOG_ERROR, GF_LOG_AUTHOR, ("[NHMLMx] content_encoding %s not supported\n", p->value.string ));
}
}
if (ctx->opid_mdia) {
sprintf(nhml, "baseMediaFile=\"%s\" ", gf_file_basename(ctx->media_file) );
gf_bs_write_data(ctx->bs_w, nhml, (u32) strlen(nhml));
}
sprintf(nhml, ">\n");
gf_bs_write_data(ctx->bs_w, nhml, (u32) strlen(nhml));
gf_bs_get_content_no_truncate(ctx->bs_w, &ctx->nhml_buffer, &size, &ctx->nhml_buffer_size);
if (ctx->filep) {
gf_fwrite(ctx->nhml_buffer, size, ctx->filep);
return;
}
dst_pck = gf_filter_pck_new_alloc(ctx->opid_nhml, size, &output);
memcpy(output, ctx->nhml_buffer, size);
gf_filter_pck_set_framing(dst_pck, GF_TRUE, GF_FALSE);
gf_filter_pck_send(dst_pck);
} | 1135 | True | 1 |
CVE-2020-23932 | 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/gpac/gpac/issues/1566', 'name': 'https://github.com/gpac/gpac/issues/1566', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/ce01bd15f711d4575b7424b54b3a395ec64c1784', 'name': 'https://github.com/gpac/gpac/commit/ce01bd15f711d4575b7424b54b3a395ec64c1784', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-476'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:*:*:*:*:*:*:*:*', 'versionEndExcluding': '1.0.1', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'An issue was discovered in gpac before 1.0.1. A NULL pointer dereference exists in the function dump_isom_sdp located in filedump.c. It allows an attacker to cause Denial of Service.'}] | 2021-04-22T18:48Z | 2021-04-21T18: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 | jeanlf | 2020-09-01 17:05:02+02:00 | fixed #1566 | ce01bd15f711d4575b7424b54b3a395ec64c1784 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | dump_isom_sdp | dump_isom_sdp( GF_ISOFile * file , char * inName , Bool is_final_name) | ['file', 'inName', 'is_final_name'] | #ifndef GPAC_DISABLE_ISOM_HINTING
void dump_isom_sdp(GF_ISOFile *file, char *inName, Bool is_final_name)
{
const char *sdp;
u32 size, i;
FILE *dump;
if (inName) {
char szBuf[1024];
strcpy(szBuf, inName);
if (!is_final_name) {
char *ext = strchr(szBuf, '.');
if (ext) ext[0] = 0;
strcat(szBuf, "_sdp.txt");
}
dump = gf_fopen(szBuf, "wt");
if (!dump) {
fprintf(stderr, "Failed to open %s for dumping\n", szBuf);
return;
}
} else {
dump = stdout;
fprintf(dump, "* File SDP content *\n\n");
}
//get the movie SDP
gf_isom_sdp_get(file, &sdp, &size);
fprintf(dump, "%s", sdp);
fprintf(dump, "\r\n");
//then tracks
for (i=0; i<gf_isom_get_track_count(file); i++) {
if (gf_isom_get_media_type(file, i+1) != GF_ISOM_MEDIA_HINT) continue;
gf_isom_sdp_track_get(file, i+1, &sdp, &size);
fprintf(dump, "%s", sdp);
}
fprintf(dump, "\n\n"); | 225 | True | 1 |
CVE-2020-23928 | 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://github.com/gpac/gpac/issues/1568', 'name': 'https://github.com/gpac/gpac/issues/1568', 'refsource': 'MISC', 'tags': ['Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/8e05648d6b4459facbc783025c5c42d301fef5c3', 'name': 'https://github.com/gpac/gpac/commit/8e05648d6b4459facbc783025c5c42d301fef5c3', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/issues/1569', 'name': 'https://github.com/gpac/gpac/issues/1569', 'refsource': 'MISC', 'tags': ['Third Party Advisory']}, {'url': 'https://cwe.mitre.org/data/definitions/126.html', 'name': 'https://cwe.mitre.org/data/definitions/126.html', 'refsource': 'MISC', 'tags': []}] | [{'description': [{'lang': 'en', 'value': 'CWE-125'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:*:*:*:*:*:*:*:*', 'versionEndExcluding': '1.0.1', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'An issue was discovered in gpac before 1.0.1. The abst_box_read function in box_code_adobe.c has a heap-based buffer over-read.'}] | 2022-07-10T21:15Z | 2021-04-21T18: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 | jeanlf | 2020-09-01 17:10:13+02:00 | fixed #1568 | 8e05648d6b4459facbc783025c5c42d301fef5c3 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | abst_box_read | abst_box_read( GF_Box * s , GF_BitStream * bs) | ['s', 'bs'] | GF_Err abst_box_read(GF_Box *s, GF_BitStream *bs)
{
GF_AdobeBootstrapInfoBox *ptr = (GF_AdobeBootstrapInfoBox *)s;
int i;
u32 tmp_strsize;
char *tmp_str;
GF_Err e;
ISOM_DECREASE_SIZE(ptr, 25)
ptr->bootstrapinfo_version = gf_bs_read_u32(bs);
ptr->profile = gf_bs_read_int(bs, 2);
ptr->live = gf_bs_read_int(bs, 1);
ptr->update = gf_bs_read_int(bs, 1);
ptr->reserved = gf_bs_read_int(bs, 4);
ptr->time_scale = gf_bs_read_u32(bs);
ptr->current_media_time = gf_bs_read_u64(bs);
ptr->smpte_time_code_offset = gf_bs_read_u64(bs);
i=0;
if (ptr->size<8) return GF_ISOM_INVALID_FILE;
tmp_strsize =(u32)ptr->size-8;
tmp_str = gf_malloc(sizeof(char)*tmp_strsize);
if (!tmp_str) return GF_OUT_OF_MEM;
memset(tmp_str, 0, sizeof(char)*tmp_strsize);
while (tmp_strsize) {
ISOM_DECREASE_SIZE(ptr, 1)
tmp_str[i] = gf_bs_read_u8(bs);
tmp_strsize--;
if (!tmp_str[i])
break;
i++;
}
if (i) {
ptr->movie_identifier = gf_strdup(tmp_str);
}
ISOM_DECREASE_SIZE(ptr, 1)
ptr->server_entry_count = gf_bs_read_u8(bs);
for (i=0; i<ptr->server_entry_count; i++) {
int j=0;
tmp_strsize=(u32)ptr->size;
while (tmp_strsize) {
ISOM_DECREASE_SIZE(ptr, 1)
tmp_str[j] = gf_bs_read_u8(bs);
tmp_strsize--;
if (!tmp_str[j])
break;
j++;
}
if (j) {
gf_list_insert(ptr->server_entry_table, gf_strdup(tmp_str), i);
}
}
ISOM_DECREASE_SIZE(ptr, 1)
ptr->quality_entry_count = gf_bs_read_u8(bs);
for (i=0; i<ptr->quality_entry_count; i++) {
int j=0;
tmp_strsize=(u32)ptr->size;
while (tmp_strsize) {
ISOM_DECREASE_SIZE(ptr, 1)
tmp_str[j] = gf_bs_read_u8(bs);
tmp_strsize--;
if (!tmp_str[j])
break;
j++;
}
if (j) {
gf_list_insert(ptr->quality_entry_table, gf_strdup(tmp_str), i);
}
}
i=0;
tmp_strsize=(u32)ptr->size;
while (tmp_strsize) {
ISOM_DECREASE_SIZE(ptr, 1)
tmp_str[i] = gf_bs_read_u8(bs);
tmp_strsize--;
if (!tmp_str[i])
break;
i++;
}
if (i) {
ptr->drm_data = gf_strdup(tmp_str);
}
i=0;
tmp_strsize=(u32)ptr->size;
while (tmp_strsize) {
ISOM_DECREASE_SIZE(ptr, 1)
tmp_str[i] = gf_bs_read_u8(bs);
tmp_strsize--;
if (!tmp_str[i])
break;
i++;
}
if (i) {
ptr->meta_data = gf_strdup(tmp_str);
}
ISOM_DECREASE_SIZE(ptr, 1)
ptr->segment_run_table_count = gf_bs_read_u8(bs);
for (i=0; i<ptr->segment_run_table_count; i++) {
GF_AdobeSegmentRunTableBox *asrt = NULL;
e = gf_isom_box_parse((GF_Box **)&asrt, bs);
if (e) {
if (asrt) gf_isom_box_del((GF_Box*)asrt);
gf_free(tmp_str);
return e;
}
gf_list_add(ptr->segment_run_table_entries, asrt);
}
ISOM_DECREASE_SIZE(ptr, 1)
ptr->fragment_run_table_count = gf_bs_read_u8(bs);
for (i=0; i<ptr->fragment_run_table_count; i++) {
GF_AdobeFragmentRunTableBox *afrt = NULL;
e = gf_isom_box_parse((GF_Box **)&afrt, bs);
if (e) {
if (afrt) gf_isom_box_del((GF_Box*)afrt);
gf_free(tmp_str);
return e;
}
gf_list_add(ptr->fragment_run_table_entries, afrt);
}
gf_free(tmp_str);
return GF_OK;
} | 758 | True | 1 |
CVE-2020-35979 | 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/gpac/gpac/issues/1662', 'name': 'https://github.com/gpac/gpac/issues/1662', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/b15020f54aff24aaeb64b80771472be8e64a7adc', 'name': 'https://github.com/gpac/gpac/commit/b15020f54aff24aaeb64b80771472be8e64a7adc', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-787'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:0.8.0:*:*:*:*:*:*:*', 'cpe_name': []}, {'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'An issue was discovered in GPAC version 0.8.0 and 1.0.1. There is heap-based buffer overflow in the function gp_rtp_builder_do_avc() in ietf/rtp_pck_mpeg4.c.'}] | 2021-04-23T19:53Z | 2021-04-21T16: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 | jeanlf | 2021-01-04 11:24:26+01:00 | fixed #1662 | b15020f54aff24aaeb64b80771472be8e64a7adc | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_hinter_track_process | gf_hinter_track_process( GF_RTPHinter * tkHint) | ['tkHint'] | GF_Err gf_hinter_track_process(GF_RTPHinter *tkHint)
{
GF_Err e;
u32 i, descIndex, duration;
u64 ts;
u8 PadBits;
GF_Fraction ft;
GF_ISOSample *samp;
tkHint->HintSample = tkHint->RTPTime = 0;
tkHint->TotalSample = gf_isom_get_sample_count(tkHint->file, tkHint->TrackNum);
ft.num = tkHint->rtp_p->sl_config.timestampResolution;
ft.den = tkHint->OrigTimeScale;
e = GF_OK;
for (i=0; i<tkHint->TotalSample; i++) {
samp = gf_isom_get_sample(tkHint->file, tkHint->TrackNum, i+1, &descIndex);
if (!samp) return gf_isom_last_error(tkHint->file);
//setup SL
tkHint->CurrentSample = i + 1;
/*keep same AU indicator if sync shadow - TODO FIXME: this assumes shadows are placed interleaved with
the track content which is the case for GPAC scene carousel generation, but may not always be true*/
if (samp->IsRAP==RAP_REDUNDANT) {
tkHint->rtp_p->sl_header.AU_sequenceNumber -= 1;
samp->IsRAP = RAP;
}
ts = ft.num * (samp->DTS+samp->CTS_Offset) / ft.den;
tkHint->rtp_p->sl_header.compositionTimeStamp = ts;
ts = ft.num * samp->DTS / ft.den;
tkHint->rtp_p->sl_header.decodingTimeStamp = ts;
tkHint->rtp_p->sl_header.randomAccessPointFlag = samp->IsRAP;
tkHint->base_offset_in_sample = 0;
/*crypted*/
if (tkHint->rtp_p->slMap.IV_length) {
GF_ISMASample *s = gf_isom_get_ismacryp_sample(tkHint->file, tkHint->TrackNum, samp, descIndex);
/*one byte take for selective_enc flag*/
if (s->flags & GF_ISOM_ISMA_USE_SEL_ENC) tkHint->base_offset_in_sample += 1;
if (s->flags & GF_ISOM_ISMA_IS_ENCRYPTED) tkHint->base_offset_in_sample += s->IV_length + s->KI_length;
gf_free(samp->data);
samp->data = s->data;
samp->dataLength = s->dataLength;
gf_rtp_builder_set_cryp_info(tkHint->rtp_p, s->IV, (char*)s->key_indicator, (s->flags & GF_ISOM_ISMA_IS_ENCRYPTED) ? 1 : 0);
s->data = NULL;
s->dataLength = 0;
gf_isom_ismacryp_delete_sample(s);
}
if (tkHint->rtp_p->sl_config.usePaddingFlag) {
gf_isom_get_sample_padding_bits(tkHint->file, tkHint->TrackNum, i+1, &PadBits);
tkHint->rtp_p->sl_header.paddingBits = PadBits;
} else {
tkHint->rtp_p->sl_header.paddingBits = 0;
}
duration = gf_isom_get_sample_duration(tkHint->file, tkHint->TrackNum, i+1);
// ts = (u32) (ft * (s64) (duration));
/*unpack nal units*/
if (tkHint->avc_nalu_size) {
u32 v, size;
u32 remain = samp->dataLength;
char *ptr = samp->data;
tkHint->rtp_p->sl_header.accessUnitStartFlag = 1;
tkHint->rtp_p->sl_header.accessUnitEndFlag = 0;
while (remain) {
size = 0;
v = tkHint->avc_nalu_size;
if (v>remain) {
GF_LOG(GF_LOG_ERROR, GF_LOG_RTP, ("[rtp hinter] Broken AVC nalu encapsulation: NALU size length is %d but only %d bytes left in sample %d\n", v, remain, tkHint->CurrentSample));
break;
}
while (v) {
size |= (u8) *ptr;
ptr++;
remain--;
v-=1;
if (v) size<<=8;
}
tkHint->base_offset_in_sample = samp->dataLength-remain;
if (remain < size) {
GF_LOG(GF_LOG_ERROR, GF_LOG_RTP, ("[rtp hinter] Broken AVC nalu encapsulation: NALU size is %d but only %d bytes left in sample %d\n", size, remain, tkHint->CurrentSample));
break;
}
remain -= size;
tkHint->rtp_p->sl_header.accessUnitEndFlag = remain ? 0 : 1;
e = gf_rtp_builder_process(tkHint->rtp_p, ptr, size, (u8) !remain, samp->dataLength, duration, (u8) (descIndex + GF_RTP_TX3G_SIDX_OFFSET) );
ptr += size;
tkHint->rtp_p->sl_header.accessUnitStartFlag = 0;
}
} else {
e = gf_rtp_builder_process(tkHint->rtp_p, samp->data, samp->dataLength, 1, samp->dataLength, duration, (u8) (descIndex + GF_RTP_TX3G_SIDX_OFFSET) );
}
tkHint->rtp_p->sl_header.packetSequenceNumber += 1;
//signal some progress
gf_set_progress("Hinting", tkHint->CurrentSample, tkHint->TotalSample);
tkHint->rtp_p->sl_header.AU_sequenceNumber += 1;
gf_isom_sample_del(&samp);
if (e) return e;
}
//flush
gf_rtp_builder_process(tkHint->rtp_p, NULL, 0, 1, 0, 0, 0);
gf_isom_end_hint_sample(tkHint->file, tkHint->HintTrack, (u8) tkHint->SampleIsRAP);
return GF_OK;
} | 795 | True | 1 |
CVE-2021-31258 | 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/gpac/gpac/issues/1706', 'name': 'https://github.com/gpac/gpac/issues/1706', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/ebfa346eff05049718f7b80041093b4c5581c24e', 'name': 'https://github.com/gpac/gpac/commit/ebfa346eff05049718f7b80041093b4c5581c24e', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-476'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'The gf_isom_set_extraction_slc function in GPAC 1.0.1 allows attackers to cause a denial of service (NULL pointer dereference) via a crafted file in the MP4Box command.'}] | 2021-04-21T19:23Z | 2021-04-19T19: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 | jeanlf | 2021-03-12 11:56:53+01:00 | fixed #1706 | ebfa346eff05049718f7b80041093b4c5581c24e | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_isom_set_extraction_slc | gf_isom_set_extraction_slc( GF_ISOFile * the_file , u32 trackNumber , u32 StreamDescriptionIndex , const GF_SLConfig * slConfig) | ['the_file', 'trackNumber', 'StreamDescriptionIndex', 'slConfig'] | GF_Err gf_isom_set_extraction_slc(GF_ISOFile *the_file, u32 trackNumber, u32 StreamDescriptionIndex, const GF_SLConfig *slConfig)
{
GF_TrackBox *trak;
GF_SampleEntryBox *entry;
GF_Err e;
GF_SLConfig **slc;
trak = gf_isom_get_track_from_file(the_file, trackNumber);
if (!trak) return GF_BAD_PARAM;
e = Media_GetSampleDesc(trak->Media, StreamDescriptionIndex, &entry, NULL);
if (e) return e;
//we must be sure we are not using a remote ESD
switch (entry->type) {
case GF_ISOM_BOX_TYPE_MP4S:
if (((GF_MPEGSampleEntryBox *)entry)->esd->desc->slConfig->predefined != SLPredef_MP4) return GF_BAD_PARAM;
slc = & ((GF_MPEGSampleEntryBox *)entry)->slc;
break;
case GF_ISOM_BOX_TYPE_MP4A:
if (((GF_MPEGAudioSampleEntryBox *)entry)->esd->desc->slConfig->predefined != SLPredef_MP4) return GF_BAD_PARAM;
slc = & ((GF_MPEGAudioSampleEntryBox *)entry)->slc;
break;
case GF_ISOM_BOX_TYPE_MP4V:
if (((GF_MPEGVisualSampleEntryBox *)entry)->esd->desc->slConfig->predefined != SLPredef_MP4) return GF_BAD_PARAM;
slc = & ((GF_MPEGVisualSampleEntryBox *)entry)->slc;
break;
default:
return GF_BAD_PARAM;
}
if (*slc) {
gf_odf_desc_del((GF_Descriptor *)*slc);
*slc = NULL;
}
if (!slConfig) return GF_OK;
//finally duplicate the SL
return gf_odf_desc_copy((GF_Descriptor *) slConfig, (GF_Descriptor **) slc);
} | 256 | True | 1 |
CVE-2021-31258 | 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/gpac/gpac/issues/1706', 'name': 'https://github.com/gpac/gpac/issues/1706', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/ebfa346eff05049718f7b80041093b4c5581c24e', 'name': 'https://github.com/gpac/gpac/commit/ebfa346eff05049718f7b80041093b4c5581c24e', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-476'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'The gf_isom_set_extraction_slc function in GPAC 1.0.1 allows attackers to cause a denial of service (NULL pointer dereference) via a crafted file in the MP4Box command.'}] | 2021-04-21T19:23Z | 2021-04-19T19: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 | jeanlf | 2021-03-12 11:56:53+01:00 | fixed #1706 | ebfa346eff05049718f7b80041093b4c5581c24e | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_hinter_track_new | gf_hinter_track_new( GF_ISOFile * file , u32 TrackNum , u32 Path_MTU , u32 max_ptime , u32 default_rtp_rate , u32 flags , u8 PayloadID , Bool copy_media , u32 InterleaveGroupID , u8 InterleaveGroupPriority , GF_Err * e) | ['file', 'TrackNum', 'Path_MTU', 'max_ptime', 'default_rtp_rate', 'flags', 'PayloadID', 'copy_media', 'InterleaveGroupID', 'InterleaveGroupPriority', 'e'] | GF_RTPHinter *gf_hinter_track_new(GF_ISOFile *file, u32 TrackNum,
u32 Path_MTU, u32 max_ptime, u32 default_rtp_rate, u32 flags, u8 PayloadID,
Bool copy_media, u32 InterleaveGroupID, u8 InterleaveGroupPriority, GF_Err *e)
{
GF_SLConfig my_sl;
u32 descIndex, MinSize, MaxSize, avgTS, streamType, codecid, const_dur, nb_ch, maxDTSDelta;
u8 OfficialPayloadID;
u32 TrackMediaSubType, TrackMediaType, hintType, nbEdts, required_rate, force_dts_delta, avc_nalu_size, PL_ID, bandwidth, IV_length, KI_length;
const char *url, *urn;
char *mpeg4mode;
Bool is_crypted, has_mpeg4_mapping;
GF_RTPHinter *tmp;
GF_ESD *esd;
*e = GF_BAD_PARAM;
if (!file || !TrackNum || !gf_isom_get_track_id(file, TrackNum)) return NULL;
if (!gf_isom_get_sample_count(file, TrackNum)) {
*e = GF_OK;
return NULL;
}
*e = GF_NOT_SUPPORTED;
nbEdts = gf_isom_get_edits_count(file, TrackNum);
if (nbEdts>1) {
u64 et, sd, mt;
GF_ISOEditType em;
gf_isom_get_edit(file, TrackNum, 1, &et, &sd, &mt, &em);
if ((nbEdts>2) || (em!=GF_ISOM_EDIT_EMPTY)) {
GF_LOG(GF_LOG_ERROR, GF_LOG_RTP, ("[rtp hinter] Cannot hint track whith EditList\n"));
return NULL;
}
}
if (nbEdts) gf_isom_remove_edits(file, TrackNum);
if (!gf_isom_is_track_enabled(file, TrackNum)) return NULL;
/*by default NO PL signaled*/
PL_ID = 0;
OfficialPayloadID = 0;
force_dts_delta = 0;
streamType = 0;
mpeg4mode = NULL;
required_rate = 0;
is_crypted = 0;
IV_length = KI_length = 0;
codecid = 0;
nb_ch = 0;
avc_nalu_size = 0;
has_mpeg4_mapping = 1;
const_dur = 0;
bandwidth=0;
TrackMediaType = gf_isom_get_media_type(file, TrackNum);
/*for max compatibility with QT*/
if (!default_rtp_rate) default_rtp_rate = 90000;
/*timed-text is a bit special, we support multiple stream descriptions & co*/
if ( (TrackMediaType==GF_ISOM_MEDIA_TEXT) || (TrackMediaType==GF_ISOM_MEDIA_SUBT)) {
hintType = GF_RTP_PAYT_3GPP_TEXT;
codecid = GF_CODECID_TEXT_MPEG4;
streamType = GF_STREAM_TEXT;
/*fixme - this works cos there's only one PL for text in mpeg4 at the current time*/
PL_ID = 0x10;
} else {
if (gf_isom_get_sample_description_count(file, TrackNum) > 1) return NULL;
TrackMediaSubType = gf_isom_get_media_subtype(file, TrackNum, 1);
switch (TrackMediaSubType) {
case GF_ISOM_SUBTYPE_MPEG4_CRYP:
is_crypted = 1;
case GF_ISOM_SUBTYPE_MPEG4:
esd = gf_isom_get_esd(file, TrackNum, 1);
hintType = GF_RTP_PAYT_MPEG4;
if (esd && esd->decoderConfig) {
streamType = esd->decoderConfig->streamType;
codecid = esd->decoderConfig->objectTypeIndication;
if (esd->URLString) hintType = 0;
/*AAC*/
if ((streamType==GF_STREAM_AUDIO)
&& esd->decoderConfig->decoderSpecificInfo && esd->decoderConfig->decoderSpecificInfo->data
/*(nb: we use mpeg4 for MPEG-2 AAC)*/
&& ((codecid==GF_CODECID_AAC_MPEG4) || (codecid==GF_CODECID_AAC_MPEG2_MP) || (codecid==GF_CODECID_AAC_MPEG2_LCP) || (codecid==GF_CODECID_AAC_MPEG2_SSRP)) ) {
u32 sample_rate;
GF_M4ADecSpecInfo a_cfg;
gf_m4a_get_config(esd->decoderConfig->decoderSpecificInfo->data, esd->decoderConfig->decoderSpecificInfo->dataLength, &a_cfg);
nb_ch = a_cfg.nb_chan;
sample_rate = a_cfg.base_sr;
PL_ID = a_cfg.audioPL;
switch (a_cfg.base_object_type) {
case GF_M4A_AAC_MAIN:
case GF_M4A_AAC_LC:
if (flags & GP_RTP_PCK_USE_LATM_AAC) {
hintType = GF_RTP_PAYT_LATM;
break;
}
case GF_M4A_AAC_SBR:
case GF_M4A_AAC_PS:
case GF_M4A_AAC_LTP:
case GF_M4A_AAC_SCALABLE:
case GF_M4A_ER_AAC_LC:
case GF_M4A_ER_AAC_LTP:
case GF_M4A_ER_AAC_SCALABLE:
mpeg4mode = "AAC";
break;
case GF_M4A_CELP:
case GF_M4A_ER_CELP:
mpeg4mode = "CELP";
break;
}
required_rate = sample_rate;
}
/*MPEG1/2 audio*/
else if ((streamType==GF_STREAM_AUDIO) && ((codecid==GF_CODECID_MPEG2_PART3) || (codecid==GF_CODECID_MPEG_AUDIO))) {
GF_ISOSample *samp = NULL;
if (!is_crypted)
samp = gf_isom_get_sample(file, TrackNum, 1, NULL);
if (samp && (samp->dataLength>3)) {
u32 hdr = GF_4CC((u32)samp->data[0], (u8)samp->data[1], (u8)samp->data[2], (u8)samp->data[3]);
nb_ch = gf_mp3_num_channels(hdr);
hintType = GF_RTP_PAYT_MPEG12_AUDIO;
/*use official RTP/AVP payload type*/
OfficialPayloadID = 14;
required_rate = 90000;
}
/*encrypted MP3 must be sent through MPEG-4 generic to signal all ISMACryp stuff*/
else {
u32 sample_rate;
gf_isom_get_audio_info(file, TrackNum, 1, &sample_rate, &nb_ch, NULL);
required_rate = sample_rate;
}
if (samp)
gf_isom_sample_del(&samp);
}
/*QCELP audio*/
else if ((streamType==GF_STREAM_AUDIO) && (codecid==GF_CODECID_QCELP)) {
hintType = GF_RTP_PAYT_QCELP;
OfficialPayloadID = 12;
required_rate = 8000;
streamType = GF_STREAM_AUDIO;
nb_ch = 1;
}
/*EVRC/SVM audio*/
else if ((streamType==GF_STREAM_AUDIO) && ((codecid==GF_CODECID_EVRC) || (codecid==GF_CODECID_SMV)) ) {
hintType = GF_RTP_PAYT_EVRC_SMV;
required_rate = 8000;
streamType = GF_STREAM_AUDIO;
nb_ch = 1;
}
/*visual streams*/
else if (streamType==GF_STREAM_VISUAL) {
if ((codecid==GF_CODECID_MPEG4_PART2) && esd->decoderConfig->decoderSpecificInfo) {
GF_M4VDecSpecInfo dsi;
gf_m4v_get_config(esd->decoderConfig->decoderSpecificInfo->data, esd->decoderConfig->decoderSpecificInfo->dataLength, &dsi);
PL_ID = dsi.VideoPL;
}
/*MPEG1/2 video*/
if ( ((codecid>=GF_CODECID_MPEG2_SIMPLE) && (codecid<=GF_CODECID_MPEG2_422)) || (codecid==GF_CODECID_MPEG1)) {
if (!is_crypted) {
hintType = GF_RTP_PAYT_MPEG12_VIDEO;
OfficialPayloadID = 32;
}
}
/*for ISMA*/
if (is_crypted) {
/*that's another pain with ISMACryp, even if no B-frames the DTS is signaled...*/
if (codecid==GF_CODECID_MPEG4_PART2) force_dts_delta = 22;
else if ((codecid==GF_CODECID_AVC) || (codecid==GF_CODECID_SVC)) {
flags &= ~GP_RTP_PCK_USE_MULTI;
force_dts_delta = 22;
}
flags |= GP_RTP_PCK_SIGNAL_RAP | GP_RTP_PCK_SIGNAL_TS;
}
required_rate = default_rtp_rate;
}
/*systems streams*/
else if (gf_isom_has_sync_shadows(file, TrackNum) || gf_isom_has_sample_dependency(file, TrackNum)) {
flags |= GP_RTP_PCK_SYSTEMS_CAROUSEL;
}
gf_odf_desc_del((GF_Descriptor*)esd);
}
break;
case GF_ISOM_SUBTYPE_3GP_H263:
hintType = GF_RTP_PAYT_H263;
required_rate = 90000;
streamType = GF_STREAM_VISUAL;
OfficialPayloadID = 34;
/*not 100% compliant (short header is missing) but should still work*/
codecid = GF_CODECID_MPEG4_PART2;
PL_ID = 0x01;
break;
case GF_ISOM_SUBTYPE_3GP_AMR:
required_rate = 8000;
hintType = GF_RTP_PAYT_AMR;
streamType = GF_STREAM_AUDIO;
has_mpeg4_mapping = 0;
nb_ch = 1;
break;
case GF_ISOM_SUBTYPE_3GP_AMR_WB:
required_rate = 16000;
hintType = GF_RTP_PAYT_AMR_WB;
streamType = GF_STREAM_AUDIO;
has_mpeg4_mapping = 0;
nb_ch = 1;
break;
case GF_ISOM_SUBTYPE_AVC_H264:
case GF_ISOM_SUBTYPE_AVC2_H264:
case GF_ISOM_SUBTYPE_AVC3_H264:
case GF_ISOM_SUBTYPE_AVC4_H264:
case GF_ISOM_SUBTYPE_SVC_H264:
case GF_ISOM_SUBTYPE_MVC_H264:
{
GF_AVCConfig *avcc = gf_isom_avc_config_get(file, TrackNum, 1);
GF_AVCConfig *svcc = gf_isom_svc_config_get(file, TrackNum, 1);
GF_AVCConfig *mvcc = gf_isom_mvc_config_get(file, TrackNum, 1);
if (!avcc && !svcc && !mvcc) {
*e = GF_NON_COMPLIANT_BITSTREAM;
return NULL;
}
required_rate = 90000; /* "90 kHz clock rate MUST be used"*/
hintType = GF_RTP_PAYT_H264_AVC;
if (TrackMediaSubType==GF_ISOM_SUBTYPE_SVC_H264)
hintType = GF_RTP_PAYT_H264_SVC;
else if (TrackMediaSubType==GF_ISOM_SUBTYPE_MVC_H264)
hintType = GF_RTP_PAYT_H264_SVC;
streamType = GF_STREAM_VISUAL;
avc_nalu_size = avcc ? avcc->nal_unit_size : svcc ? svcc->nal_unit_size : mvcc->nal_unit_size;
codecid = GF_CODECID_AVC;
PL_ID = 0x0F;
gf_odf_avc_cfg_del(avcc);
gf_odf_avc_cfg_del(svcc);
}
break;
case GF_ISOM_SUBTYPE_HVC1:
case GF_ISOM_SUBTYPE_HEV1:
case GF_ISOM_SUBTYPE_HVC2:
case GF_ISOM_SUBTYPE_HEV2:
{
GF_HEVCConfig *hevcc = gf_isom_hevc_config_get(file, TrackNum, 1);
if (!hevcc) {
*e = GF_NON_COMPLIANT_BITSTREAM;
return NULL;
}
required_rate = 90000; /* "90 kHz clock rate MUST be used"*/
hintType = GF_RTP_PAYT_HEVC;
streamType = GF_STREAM_VISUAL;
avc_nalu_size = hevcc->nal_unit_size;
codecid = GF_CODECID_HEVC;
PL_ID = 0x0F;
flags |= GP_RTP_PCK_USE_MULTI;
gf_odf_hevc_cfg_del(hevcc);
break;
}
break;
case GF_ISOM_SUBTYPE_3GP_QCELP:
required_rate = 8000;
hintType = GF_RTP_PAYT_QCELP;
streamType = GF_STREAM_AUDIO;
codecid = GF_CODECID_QCELP;
OfficialPayloadID = 12;
nb_ch = 1;
break;
case GF_ISOM_SUBTYPE_3GP_EVRC:
case GF_ISOM_SUBTYPE_3GP_SMV:
required_rate = 8000;
hintType = GF_RTP_PAYT_EVRC_SMV;
streamType = GF_STREAM_AUDIO;
codecid = (TrackMediaSubType==GF_ISOM_SUBTYPE_3GP_EVRC) ? GF_CODECID_EVRC : GF_CODECID_SMV;
nb_ch = 1;
break;
case GF_ISOM_SUBTYPE_3GP_DIMS:
#if GPAC_ENABLE_3GPP_DIMS_RTP
hintType = GF_RTP_PAYT_3GPP_DIMS;
streamType = GF_STREAM_SCENE;
#else
hintType = 0;
GF_LOG(GF_LOG_ERROR, GF_LOG_RTP, ("[RTP Packetizer] 3GPP DIMS over RTP disabled in build\n", streamType));
#endif
break;
case GF_ISOM_SUBTYPE_AC3:
hintType = GF_RTP_PAYT_AC3;
streamType = GF_STREAM_AUDIO;
gf_isom_get_audio_info(file, TrackNum, 1, NULL, &nb_ch, NULL);
break;
case GF_ISOM_SUBTYPE_MP3:
{
GF_ISOSample *samp = gf_isom_get_sample(file, TrackNum, 1, NULL);
if (samp && (samp->dataLength>3)) {
u32 hdr = GF_4CC((u32)samp->data[0], (u8)samp->data[1], (u8)samp->data[2], (u8)samp->data[3]);
nb_ch = gf_mp3_num_channels(hdr);
} else {
u32 bps;
gf_isom_get_audio_info(file, TrackNum, 1, &required_rate, &nb_ch, &bps);
}
hintType = GF_RTP_PAYT_MPEG12_AUDIO;
/*use official RTP/AVP payload type*/
OfficialPayloadID = 14;
required_rate = 90000;
if (samp)
gf_isom_sample_del(&samp);
}
break;
default:
/*ERROR*/
hintType = 0;
break;
}
}
/*not hintable*/
if (!hintType) return NULL;
/*we only support self-contained files for hinting*/
gf_isom_get_data_reference(file, TrackNum, 1, &url, &urn);
if (url || urn) return NULL;
*e = GF_OUT_OF_MEM;
GF_SAFEALLOC(tmp, GF_RTPHinter);
if (!tmp) return NULL;
/*override hinter type if requested and possible*/
if (has_mpeg4_mapping && (flags & GP_RTP_PCK_FORCE_MPEG4)) {
hintType = GF_RTP_PAYT_MPEG4;
avc_nalu_size = 0;
}
/*use static payload ID if enabled*/
else if (OfficialPayloadID && (flags & GP_RTP_PCK_USE_STATIC_ID) ) {
PayloadID = OfficialPayloadID;
}
tmp->file = file;
tmp->TrackNum = TrackNum;
tmp->avc_nalu_size = avc_nalu_size;
tmp->nb_chan = nb_ch;
/*spatial scalability check*/
tmp->has_ctts = gf_isom_has_time_offset(file, TrackNum);
/*get sample info*/
gf_media_get_sample_average_infos(file, TrackNum, &MinSize, &MaxSize, &avgTS, &maxDTSDelta, &const_dur, &bandwidth);
/*systems carousel: we need at least IDX and RAP signaling*/
if (flags & GP_RTP_PCK_SYSTEMS_CAROUSEL) {
flags |= GP_RTP_PCK_SIGNAL_RAP;
}
/*update flags in MultiSL*/
if (flags & GP_RTP_PCK_USE_MULTI) {
if (MinSize != MaxSize) flags |= GP_RTP_PCK_SIGNAL_SIZE;
if (!const_dur) flags |= GP_RTP_PCK_SIGNAL_TS;
}
if (tmp->has_ctts) flags |= GP_RTP_PCK_SIGNAL_TS;
/*default SL for RTP */
InitSL_RTP(&my_sl);
my_sl.timestampResolution = gf_isom_get_media_timescale(file, TrackNum);
/*override clockrate if set*/
if (required_rate) {
Double sc = required_rate;
sc /= my_sl.timestampResolution;
maxDTSDelta = (u32) (maxDTSDelta*sc);
my_sl.timestampResolution = required_rate;
}
/*switch to RTP TS*/
max_ptime = (u32) (max_ptime * my_sl.timestampResolution / 1000);
my_sl.AUSeqNumLength = gf_get_bit_size(gf_isom_get_sample_count(file, TrackNum));
if (my_sl.AUSeqNumLength>16) my_sl.AUSeqNumLength=16;
my_sl.CUDuration = const_dur;
if (gf_isom_has_sync_points(file, TrackNum)) {
my_sl.useRandomAccessPointFlag = 1;
} else {
my_sl.useRandomAccessPointFlag = 0;
my_sl.hasRandomAccessUnitsOnlyFlag = 1;
}
if (is_crypted) {
Bool use_sel_enc;
gf_isom_get_ismacryp_info(file, TrackNum, 1, NULL, NULL, NULL, NULL, NULL, &use_sel_enc, &IV_length, &KI_length);
if (use_sel_enc) flags |= GP_RTP_PCK_SELECTIVE_ENCRYPTION;
}
// in case a different timescale was provided
tmp->OrigTimeScale = gf_isom_get_media_timescale(file, TrackNum);
tmp->rtp_p = gf_rtp_builder_new(hintType, &my_sl, flags, tmp,
MP4T_OnNewPacket, MP4T_OnPacketDone,
/*if copy, no data ref*/
copy_media ? NULL : MP4T_OnDataRef,
MP4T_OnData);
//init the builder
gf_rtp_builder_init(tmp->rtp_p, PayloadID, Path_MTU, max_ptime,
streamType, codecid, PL_ID, MinSize, MaxSize, avgTS, maxDTSDelta, IV_length, KI_length, mpeg4mode);
/*ISMA compliance is a pain...*/
if (force_dts_delta) tmp->rtp_p->slMap.DTSDeltaLength = force_dts_delta;
/* Hint Track Setup */
tmp->TrackID = gf_isom_get_track_id(file, TrackNum);
tmp->HintID = tmp->TrackID + 65535;
while (gf_isom_get_track_by_id(file, tmp->HintID)) tmp->HintID++;
tmp->HintTrack = gf_isom_new_track(file, tmp->HintID, GF_ISOM_MEDIA_HINT, my_sl.timestampResolution);
gf_isom_setup_hint_track(file, tmp->HintTrack, GF_ISOM_HINT_RTP);
/*create a hint description*/
gf_isom_new_hint_description(file, tmp->HintTrack, -1, -1, 0, &descIndex);
gf_isom_rtp_set_timescale(file, tmp->HintTrack, descIndex, my_sl.timestampResolution);
if (hintType==GF_RTP_PAYT_MPEG4) {
tmp->rtp_p->slMap.CodecID = codecid;
/*set this SL for extraction.*/
gf_isom_set_extraction_slc(file, TrackNum, 1, &my_sl);
}
tmp->bandwidth = bandwidth;
/*set interleaving*/
gf_isom_set_track_interleaving_group(file, TrackNum, InterleaveGroupID);
if (!copy_media) {
/*if we don't copy data set hint track and media track in the same group*/
gf_isom_set_track_interleaving_group(file, tmp->HintTrack, InterleaveGroupID);
} else {
gf_isom_set_track_interleaving_group(file, tmp->HintTrack, InterleaveGroupID + OFFSET_HINT_GROUP_ID);
}
/*use user-secified priority*/
InterleaveGroupPriority*=2;
gf_isom_set_track_priority_in_group(file, TrackNum, InterleaveGroupPriority+1);
gf_isom_set_track_priority_in_group(file, tmp->HintTrack, InterleaveGroupPriority);
#if 0
#endif
*e = GF_OK;
return tmp;
} | 2312 | True | 1 |
CVE-2021-29279 | 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/gpac/gpac/issues/1718', 'name': 'https://github.com/gpac/gpac/issues/1718', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/da69ad1f970a7e17c865eaec9af98cc84df10d5b', 'name': 'https://github.com/gpac/gpac/commit/da69ad1f970a7e17c865eaec9af98cc84df10d5b', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-787'}, {'lang': 'en', 'value': 'CWE-190'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'There is a integer overflow in function filter_core/filter_props.c:gf_props_assign_value in GPAC 1.0.1. In which, the arg const GF_PropertyValue *value,maybe value->value.data.size is a negative number. In result, memcpy in gf_props_assign_value failed.'}] | 2021-04-21T19:21Z | 2021-04-19T20:15Z | Integer Overflow or Wraparound | The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | An integer overflow or wraparound occurs when an integer value is incremented to a value that is too large to store in the associated representation. When this occurs, the value may wrap to become a very small or negative number. While this may be intended behavior in circumstances that rely on wrapping, it can have security consequences if the wrap is unexpected. This is especially the case if the integer overflow can be triggered using user-supplied inputs. This becomes security-critical when the result is used to control looping, make a security decision, or determine the offset or size in behaviors such as memory allocation, copying, concatenation, etc.
| https://cwe.mitre.org/data/definitions/190.html | 0 | jeanlf | 2021-03-29 09:17:40+02:00 | fixed 1718 | da69ad1f970a7e17c865eaec9af98cc84df10d5b | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | flac_dmx_process | flac_dmx_process( GF_Filter * filter) | ['filter'] | GF_Err flac_dmx_process(GF_Filter *filter)
{
GF_FLACDmxCtx *ctx = gf_filter_get_udta(filter);
GF_FilterPacket *pck, *dst_pck;
u8 *output;
u8 *start;
Bool final_flush=GF_FALSE;
u32 pck_size, remain, prev_pck_size;
u64 cts = GF_FILTER_NO_TS;
FLACHeader hdr;
//always reparse duration
if (!ctx->duration.num)
flac_dmx_check_dur(filter, ctx);
if (ctx->opid && !ctx->is_playing)
return GF_OK;
pck = gf_filter_pid_get_packet(ctx->ipid);
if (!pck) {
if (gf_filter_pid_is_eos(ctx->ipid)) {
if (!ctx->flac_buffer_size) {
if (ctx->opid)
gf_filter_pid_set_eos(ctx->opid);
if (ctx->src_pck) gf_filter_pck_unref(ctx->src_pck);
ctx->src_pck = NULL;
return GF_EOS;
}
final_flush = GF_TRUE;
} else {
return GF_OK;
}
}
prev_pck_size = ctx->flac_buffer_size;
if (pck && !ctx->resume_from) {
u8 *data = (u8 *) gf_filter_pck_get_data(pck, &pck_size);
if (ctx->byte_offset != GF_FILTER_NO_BO) {
u64 byte_offset = gf_filter_pck_get_byte_offset(pck);
if (!ctx->flac_buffer_size) {
ctx->byte_offset = byte_offset;
} else if (ctx->byte_offset + ctx->flac_buffer_size != byte_offset) {
ctx->byte_offset = GF_FILTER_NO_BO;
if ((byte_offset != GF_FILTER_NO_BO) && (byte_offset>ctx->flac_buffer_size) ) {
ctx->byte_offset = byte_offset - ctx->flac_buffer_size;
}
}
}
if (ctx->flac_buffer_size + pck_size > ctx->flac_buffer_alloc) {
ctx->flac_buffer_alloc = ctx->flac_buffer_size + pck_size;
ctx->flac_buffer = gf_realloc(ctx->flac_buffer, ctx->flac_buffer_alloc);
}
memcpy(ctx->flac_buffer + ctx->flac_buffer_size, data, pck_size);
ctx->flac_buffer_size += pck_size;
}
//input pid sets some timescale - we flushed pending data , update cts
if (ctx->timescale && pck) {
cts = gf_filter_pck_get_cts(pck);
}
if (cts == GF_FILTER_NO_TS) {
//avoids updating cts
prev_pck_size = 0;
}
remain = ctx->flac_buffer_size;
start = ctx->flac_buffer;
if (ctx->resume_from) {
start += ctx->resume_from - 1;
remain -= ctx->resume_from - 1;
ctx->resume_from = 0;
}
while (remain>2) {
u32 next_frame=0, nb_samp;
u32 cur_size = remain-2;
u8 *cur_buf = start+2;
u8 *hdr_start = NULL;
if (final_flush) {
next_frame = remain;
} else {
while (cur_size) {
//wait till we have a frame header
hdr_start = memchr(cur_buf, 0xFF, cur_size);
if (!hdr_start) break;
next_frame = (u32) (hdr_start-start);
if (next_frame == remain)
break;
if ((hdr_start[1]&0xFC) == 0xF8) {
if (flac_parse_header(ctx, hdr_start, (u32) remain - next_frame, &hdr))
break;
}
cur_buf = hdr_start+1;
cur_size = (u32) (cur_buf - start);
assert(cur_size<=remain);
cur_size = remain - cur_size;
hdr_start = NULL;
}
if (!hdr_start) break;
if (next_frame == remain)
break;
}
if (!ctx->initialized) {
u32 size = next_frame;
u32 dsi_end = 0;
//we have a header
gf_bs_reassign_buffer(ctx->bs, ctx->flac_buffer, size);
u32 magic = gf_bs_read_u32(ctx->bs);
if (magic != GF_4CC('f','L','a','C')) {
}
while (gf_bs_available(ctx->bs)) {
Bool last = gf_bs_read_int(ctx->bs, 1);
u32 type = gf_bs_read_int(ctx->bs, 7);
u32 len = gf_bs_read_int(ctx->bs, 24);
if (type==0) {
u16 min_block_size = gf_bs_read_u16(ctx->bs);
u16 max_block_size = gf_bs_read_u16(ctx->bs);
/*u32 min_frame_size = */gf_bs_read_u24(ctx->bs);
/*u32 max_frame_size = */gf_bs_read_u24(ctx->bs);
ctx->sample_rate = gf_bs_read_int(ctx->bs, 20);
ctx->nb_channels = 1 + gf_bs_read_int(ctx->bs, 3);
ctx->bits_per_sample = 1 + gf_bs_read_int(ctx->bs, 5);
if (min_block_size==max_block_size) ctx->block_size = min_block_size;
else ctx->block_size = 0;
ctx->duration.num = gf_bs_read_long_int(ctx->bs, 36);
ctx->duration.den = ctx->sample_rate;
//ignore the rest
gf_bs_skip_bytes(ctx->bs, 16);
dsi_end = (u32) gf_bs_get_position(ctx->bs);
} else {
//ignore the rest for now
//TODO: expose metadata, pictures and co
gf_bs_skip_bytes(ctx->bs, len);
}
if (last) break;
}
flac_dmx_check_pid(filter, ctx, ctx->flac_buffer+4, dsi_end-4);
remain -= size;
start += size;
ctx->initialized = GF_TRUE;
if (!ctx->is_playing) break;
continue;
}
//we have a next frame, check we are synchronize
if ((start[0] != 0xFF) && ((start[1]&0xFC) != 0xF8)) {
GF_LOG(GF_LOG_WARNING, GF_LOG_PARSER, ("[FLACDmx] invalid frame, droping %d bytes and resyncing\n", next_frame));
start += next_frame;
remain -= next_frame;
continue;
}
flac_parse_header(ctx,start, next_frame, &hdr);
if (hdr.sample_rate != ctx->sample_rate) {
ctx->sample_rate = hdr.sample_rate;
gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_SAMPLE_RATE, & PROP_UINT(ctx->sample_rate));
}
nb_samp = hdr.block_size;
if (ctx->in_seek) {
u64 nb_samples_at_seek = (u64) (ctx->start_range * ctx->sample_rate);
if (ctx->cts + nb_samp >= nb_samples_at_seek) {
//u32 samples_to_discard = (ctx->cts + nb_samp ) - nb_samples_at_seek;
ctx->in_seek = GF_FALSE;
}
}
if (ctx->timescale && !prev_pck_size && (cts != GF_FILTER_NO_TS) ) {
ctx->cts = cts;
cts = GF_FILTER_NO_TS;
}
if (!ctx->in_seek) {
dst_pck = gf_filter_pck_new_alloc(ctx->opid, next_frame, &output);
memcpy(output, start, next_frame);
gf_filter_pck_set_cts(dst_pck, ctx->cts);
if (!ctx->timescale || (ctx->timescale==ctx->sample_rate) )
gf_filter_pck_set_duration(dst_pck, nb_samp);
else {
gf_filter_pck_set_duration(dst_pck, (nb_samp * ctx->timescale) / ctx->sample_rate);
}
gf_filter_pck_set_sap(dst_pck, GF_FILTER_SAP_1);
gf_filter_pck_set_framing(dst_pck, GF_TRUE, GF_TRUE);
if (ctx->byte_offset != GF_FILTER_NO_BO) {
gf_filter_pck_set_byte_offset(dst_pck, ctx->byte_offset);
}
gf_filter_pck_send(dst_pck);
}
flac_dmx_update_cts(ctx, nb_samp);
assert (start[0] == 0xFF);
assert((start[1]&0xFC) == 0xF8);
start += next_frame;
assert(remain >= next_frame);
remain -= next_frame;
}
if (!pck) {
ctx->flac_buffer_size = 0;
return flac_dmx_process(filter);
} else {
if (remain < ctx->flac_buffer_size) {
memmove(ctx->flac_buffer, start, remain);
}
ctx->flac_buffer_size = remain;
gf_filter_pid_drop_packet(ctx->ipid);
}
return GF_OK;
} | 1305 | True | 1 |
CVE-2021-29279 | 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/gpac/gpac/issues/1718', 'name': 'https://github.com/gpac/gpac/issues/1718', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/da69ad1f970a7e17c865eaec9af98cc84df10d5b', 'name': 'https://github.com/gpac/gpac/commit/da69ad1f970a7e17c865eaec9af98cc84df10d5b', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-787'}, {'lang': 'en', 'value': 'CWE-190'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'There is a integer overflow in function filter_core/filter_props.c:gf_props_assign_value in GPAC 1.0.1. In which, the arg const GF_PropertyValue *value,maybe value->value.data.size is a negative number. In result, memcpy in gf_props_assign_value failed.'}] | 2021-04-21T19:21Z | 2021-04-19T20: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 | jeanlf | 2021-03-29 09:17:40+02:00 | fixed 1718 | da69ad1f970a7e17c865eaec9af98cc84df10d5b | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | flac_dmx_process | flac_dmx_process( GF_Filter * filter) | ['filter'] | GF_Err flac_dmx_process(GF_Filter *filter)
{
GF_FLACDmxCtx *ctx = gf_filter_get_udta(filter);
GF_FilterPacket *pck, *dst_pck;
u8 *output;
u8 *start;
Bool final_flush=GF_FALSE;
u32 pck_size, remain, prev_pck_size;
u64 cts = GF_FILTER_NO_TS;
FLACHeader hdr;
//always reparse duration
if (!ctx->duration.num)
flac_dmx_check_dur(filter, ctx);
if (ctx->opid && !ctx->is_playing)
return GF_OK;
pck = gf_filter_pid_get_packet(ctx->ipid);
if (!pck) {
if (gf_filter_pid_is_eos(ctx->ipid)) {
if (!ctx->flac_buffer_size) {
if (ctx->opid)
gf_filter_pid_set_eos(ctx->opid);
if (ctx->src_pck) gf_filter_pck_unref(ctx->src_pck);
ctx->src_pck = NULL;
return GF_EOS;
}
final_flush = GF_TRUE;
} else {
return GF_OK;
}
}
prev_pck_size = ctx->flac_buffer_size;
if (pck && !ctx->resume_from) {
u8 *data = (u8 *) gf_filter_pck_get_data(pck, &pck_size);
if (ctx->byte_offset != GF_FILTER_NO_BO) {
u64 byte_offset = gf_filter_pck_get_byte_offset(pck);
if (!ctx->flac_buffer_size) {
ctx->byte_offset = byte_offset;
} else if (ctx->byte_offset + ctx->flac_buffer_size != byte_offset) {
ctx->byte_offset = GF_FILTER_NO_BO;
if ((byte_offset != GF_FILTER_NO_BO) && (byte_offset>ctx->flac_buffer_size) ) {
ctx->byte_offset = byte_offset - ctx->flac_buffer_size;
}
}
}
if (ctx->flac_buffer_size + pck_size > ctx->flac_buffer_alloc) {
ctx->flac_buffer_alloc = ctx->flac_buffer_size + pck_size;
ctx->flac_buffer = gf_realloc(ctx->flac_buffer, ctx->flac_buffer_alloc);
}
memcpy(ctx->flac_buffer + ctx->flac_buffer_size, data, pck_size);
ctx->flac_buffer_size += pck_size;
}
//input pid sets some timescale - we flushed pending data , update cts
if (ctx->timescale && pck) {
cts = gf_filter_pck_get_cts(pck);
}
if (cts == GF_FILTER_NO_TS) {
//avoids updating cts
prev_pck_size = 0;
}
remain = ctx->flac_buffer_size;
start = ctx->flac_buffer;
if (ctx->resume_from) {
start += ctx->resume_from - 1;
remain -= ctx->resume_from - 1;
ctx->resume_from = 0;
}
while (remain>2) {
u32 next_frame=0, nb_samp;
u32 cur_size = remain-2;
u8 *cur_buf = start+2;
u8 *hdr_start = NULL;
if (final_flush) {
next_frame = remain;
} else {
while (cur_size) {
//wait till we have a frame header
hdr_start = memchr(cur_buf, 0xFF, cur_size);
if (!hdr_start) break;
next_frame = (u32) (hdr_start-start);
if (next_frame == remain)
break;
if ((hdr_start[1]&0xFC) == 0xF8) {
if (flac_parse_header(ctx, hdr_start, (u32) remain - next_frame, &hdr))
break;
}
cur_buf = hdr_start+1;
cur_size = (u32) (cur_buf - start);
assert(cur_size<=remain);
cur_size = remain - cur_size;
hdr_start = NULL;
}
if (!hdr_start) break;
if (next_frame == remain)
break;
}
if (!ctx->initialized) {
u32 size = next_frame;
u32 dsi_end = 0;
//we have a header
gf_bs_reassign_buffer(ctx->bs, ctx->flac_buffer, size);
u32 magic = gf_bs_read_u32(ctx->bs);
if (magic != GF_4CC('f','L','a','C')) {
}
while (gf_bs_available(ctx->bs)) {
Bool last = gf_bs_read_int(ctx->bs, 1);
u32 type = gf_bs_read_int(ctx->bs, 7);
u32 len = gf_bs_read_int(ctx->bs, 24);
if (type==0) {
u16 min_block_size = gf_bs_read_u16(ctx->bs);
u16 max_block_size = gf_bs_read_u16(ctx->bs);
/*u32 min_frame_size = */gf_bs_read_u24(ctx->bs);
/*u32 max_frame_size = */gf_bs_read_u24(ctx->bs);
ctx->sample_rate = gf_bs_read_int(ctx->bs, 20);
ctx->nb_channels = 1 + gf_bs_read_int(ctx->bs, 3);
ctx->bits_per_sample = 1 + gf_bs_read_int(ctx->bs, 5);
if (min_block_size==max_block_size) ctx->block_size = min_block_size;
else ctx->block_size = 0;
ctx->duration.num = gf_bs_read_long_int(ctx->bs, 36);
ctx->duration.den = ctx->sample_rate;
//ignore the rest
gf_bs_skip_bytes(ctx->bs, 16);
dsi_end = (u32) gf_bs_get_position(ctx->bs);
} else {
//ignore the rest for now
//TODO: expose metadata, pictures and co
gf_bs_skip_bytes(ctx->bs, len);
}
if (last) break;
}
flac_dmx_check_pid(filter, ctx, ctx->flac_buffer+4, dsi_end-4);
remain -= size;
start += size;
ctx->initialized = GF_TRUE;
if (!ctx->is_playing) break;
continue;
}
//we have a next frame, check we are synchronize
if ((start[0] != 0xFF) && ((start[1]&0xFC) != 0xF8)) {
GF_LOG(GF_LOG_WARNING, GF_LOG_PARSER, ("[FLACDmx] invalid frame, droping %d bytes and resyncing\n", next_frame));
start += next_frame;
remain -= next_frame;
continue;
}
flac_parse_header(ctx,start, next_frame, &hdr);
if (hdr.sample_rate != ctx->sample_rate) {
ctx->sample_rate = hdr.sample_rate;
gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_SAMPLE_RATE, & PROP_UINT(ctx->sample_rate));
}
nb_samp = hdr.block_size;
if (ctx->in_seek) {
u64 nb_samples_at_seek = (u64) (ctx->start_range * ctx->sample_rate);
if (ctx->cts + nb_samp >= nb_samples_at_seek) {
//u32 samples_to_discard = (ctx->cts + nb_samp ) - nb_samples_at_seek;
ctx->in_seek = GF_FALSE;
}
}
if (ctx->timescale && !prev_pck_size && (cts != GF_FILTER_NO_TS) ) {
ctx->cts = cts;
cts = GF_FILTER_NO_TS;
}
if (!ctx->in_seek) {
dst_pck = gf_filter_pck_new_alloc(ctx->opid, next_frame, &output);
memcpy(output, start, next_frame);
gf_filter_pck_set_cts(dst_pck, ctx->cts);
if (!ctx->timescale || (ctx->timescale==ctx->sample_rate) )
gf_filter_pck_set_duration(dst_pck, nb_samp);
else {
gf_filter_pck_set_duration(dst_pck, (nb_samp * ctx->timescale) / ctx->sample_rate);
}
gf_filter_pck_set_sap(dst_pck, GF_FILTER_SAP_1);
gf_filter_pck_set_framing(dst_pck, GF_TRUE, GF_TRUE);
if (ctx->byte_offset != GF_FILTER_NO_BO) {
gf_filter_pck_set_byte_offset(dst_pck, ctx->byte_offset);
}
gf_filter_pck_send(dst_pck);
}
flac_dmx_update_cts(ctx, nb_samp);
assert (start[0] == 0xFF);
assert((start[1]&0xFC) == 0xF8);
start += next_frame;
assert(remain >= next_frame);
remain -= next_frame;
}
if (!pck) {
ctx->flac_buffer_size = 0;
return flac_dmx_process(filter);
} else {
if (remain < ctx->flac_buffer_size) {
memmove(ctx->flac_buffer, start, remain);
}
ctx->flac_buffer_size = remain;
gf_filter_pid_drop_packet(ctx->ipid);
}
return GF_OK;
} | 1305 | True | 1 |
CVE-2021-30014 | 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/gpac/gpac/issues/1721', 'name': 'https://github.com/gpac/gpac/issues/1721', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'name': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-190'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'There is a integer overflow in media_tools/av_parsers.c in the hevc_parse_slice_segment function in GPAC 1.0.1 which results in a crash.'}] | 2021-04-21T19:21Z | 2021-04-19T20:15Z | Integer Overflow or Wraparound | The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | An integer overflow or wraparound occurs when an integer value is incremented to a value that is too large to store in the associated representation. When this occurs, the value may wrap to become a very small or negative number. While this may be intended behavior in circumstances that rely on wrapping, it can have security consequences if the wrap is unexpected. This is especially the case if the integer overflow can be triggered using user-supplied inputs. This becomes security-critical when the result is used to control looping, make a security decision, or determine the offset or size in behaviors such as memory allocation, copying, concatenation, etc.
| https://cwe.mitre.org/data/definitions/190.html | 0 | jeanlf | 2021-03-29 09:34:02+02:00 | add safety in avc/hevc/vvc sps/pps/vps ID check - cf #1720 #1721 #1722 | 51cdb67ff7c5f1242ac58c5aa603ceaf1793b788 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_avc_read_pps_bs_internal | gf_avc_read_pps_bs_internal( GF_BitStream * bs , AVCState * avc , u32 nal_hdr) | ['bs', 'avc', 'nal_hdr'] | static s32 gf_avc_read_pps_bs_internal(GF_BitStream *bs, AVCState *avc, u32 nal_hdr)
{
s32 pps_id;
AVC_PPS *pps;
gf_bs_enable_emulation_byte_removal(bs, GF_TRUE);
if (!nal_hdr) {
gf_bs_read_int_log(bs, 1, "forbidden_zero_bit");
gf_bs_read_int_log(bs, 2, "nal_ref_idc");
gf_bs_read_int_log(bs, 5, "nal_unit_type");
}
pps_id = gf_bs_read_ue_log(bs, "pps_id");
if (pps_id >= 255) {
return -1;
}
pps = &avc->pps[pps_id];
pps->id = pps_id;
if (!pps->status) pps->status = 1;
pps->sps_id = gf_bs_read_ue_log(bs, "sps_id");
if (pps->sps_id >= 32) {
pps->sps_id = 0;
return -1;
}
/*sps_id may be refer to regular SPS or subseq sps, depending on the coded slice referring to the pps*/
if (!avc->sps[pps->sps_id].state && !avc->sps[pps->sps_id + GF_SVC_SSPS_ID_SHIFT].state) {
return -1;
}
avc->pps_active_idx = pps->id; /*set active sps*/
avc->sps_active_idx = pps->sps_id; /*set active sps*/
pps->entropy_coding_mode_flag = gf_bs_read_int_log(bs, 1, "entropy_coding_mode_flag");
pps->pic_order_present = gf_bs_read_int_log(bs, 1, "pic_order_present");
pps->slice_group_count = gf_bs_read_ue_log(bs, "slice_group_count_minus1") + 1;
if (pps->slice_group_count > 1) {
u32 iGroup;
pps->mb_slice_group_map_type = gf_bs_read_ue_log(bs, "mb_slice_group_map_type");
if (pps->mb_slice_group_map_type == 0) {
for (iGroup = 0; iGroup <= pps->slice_group_count - 1; iGroup++)
gf_bs_read_ue_log_idx(bs, "run_length_minus1", iGroup);
}
else if (pps->mb_slice_group_map_type == 2) {
for (iGroup = 0; iGroup < pps->slice_group_count - 1; iGroup++) {
gf_bs_read_ue_log_idx(bs, "top_left", iGroup);
gf_bs_read_ue_log_idx(bs, "bottom_right", iGroup);
}
}
else if (pps->mb_slice_group_map_type == 3 || pps->mb_slice_group_map_type == 4 || pps->mb_slice_group_map_type == 5) {
gf_bs_read_int_log(bs, 1, "slice_group_change_direction_flag");
gf_bs_read_ue_log(bs, "slice_group_change_rate_minus1");
}
else if (pps->mb_slice_group_map_type == 6) {
u32 i;
pps->pic_size_in_map_units_minus1 = gf_bs_read_ue_log(bs, "pic_size_in_map_units_minus1");
for (i = 0; i <= pps->pic_size_in_map_units_minus1; i++) {
gf_bs_read_int_log_idx(bs, (u32)ceil(log(pps->slice_group_count) / log(2)), "slice_group_id", i);
}
}
}
pps->num_ref_idx_l0_default_active_minus1 = gf_bs_read_ue_log(bs, "num_ref_idx_l0_default_active_minus1");
pps->num_ref_idx_l1_default_active_minus1 = gf_bs_read_ue_log(bs, "num_ref_idx_l1_default_active_minus1");
/*
if ((pps->ref_count[0] > 32) || (pps->ref_count[1] > 32)) goto exit;
*/
pps->weighted_pred_flag = gf_bs_read_int_log(bs, 1, "weighted_pred_flag");
gf_bs_read_int_log(bs, 2, "weighted_bipred_idc");
gf_bs_read_se_log(bs, "init_qp_minus26");
gf_bs_read_se_log(bs, "init_qs_minus26");
gf_bs_read_se_log(bs, "chroma_qp_index_offset");
pps->deblocking_filter_control_present_flag = gf_bs_read_int_log(bs, 1, "deblocking_filter_control_present_flag");
gf_bs_read_int_log(bs, 1, "constrained_intra_pred");
pps->redundant_pic_cnt_present = gf_bs_read_int_log(bs, 1, "redundant_pic_cnt_present");
return pps_id;
} | 552 | True | 1 |
CVE-2021-30020 | 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/gpac/gpac/issues/1722', 'name': 'https://github.com/gpac/gpac/issues/1722', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'name': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-787'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'In the function gf_hevc_read_pps_bs_internal function in media_tools/av_parsers.c in GPAC 1.0.1 there is a loop, which with crafted file, pps->num_tile_columns may be larger than sizeof(pps->column_width), which results in a heap overflow in the loop.'}] | 2021-04-21T19:02Z | 2021-04-19T20: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 | jeanlf | 2021-03-29 09:34:02+02:00 | add safety in avc/hevc/vvc sps/pps/vps ID check - cf #1720 #1721 #1722 | 51cdb67ff7c5f1242ac58c5aa603ceaf1793b788 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_avc_read_pps_bs_internal | gf_avc_read_pps_bs_internal( GF_BitStream * bs , AVCState * avc , u32 nal_hdr) | ['bs', 'avc', 'nal_hdr'] | static s32 gf_avc_read_pps_bs_internal(GF_BitStream *bs, AVCState *avc, u32 nal_hdr)
{
s32 pps_id;
AVC_PPS *pps;
gf_bs_enable_emulation_byte_removal(bs, GF_TRUE);
if (!nal_hdr) {
gf_bs_read_int_log(bs, 1, "forbidden_zero_bit");
gf_bs_read_int_log(bs, 2, "nal_ref_idc");
gf_bs_read_int_log(bs, 5, "nal_unit_type");
}
pps_id = gf_bs_read_ue_log(bs, "pps_id");
if (pps_id >= 255) {
return -1;
}
pps = &avc->pps[pps_id];
pps->id = pps_id;
if (!pps->status) pps->status = 1;
pps->sps_id = gf_bs_read_ue_log(bs, "sps_id");
if (pps->sps_id >= 32) {
pps->sps_id = 0;
return -1;
}
/*sps_id may be refer to regular SPS or subseq sps, depending on the coded slice referring to the pps*/
if (!avc->sps[pps->sps_id].state && !avc->sps[pps->sps_id + GF_SVC_SSPS_ID_SHIFT].state) {
return -1;
}
avc->pps_active_idx = pps->id; /*set active sps*/
avc->sps_active_idx = pps->sps_id; /*set active sps*/
pps->entropy_coding_mode_flag = gf_bs_read_int_log(bs, 1, "entropy_coding_mode_flag");
pps->pic_order_present = gf_bs_read_int_log(bs, 1, "pic_order_present");
pps->slice_group_count = gf_bs_read_ue_log(bs, "slice_group_count_minus1") + 1;
if (pps->slice_group_count > 1) {
u32 iGroup;
pps->mb_slice_group_map_type = gf_bs_read_ue_log(bs, "mb_slice_group_map_type");
if (pps->mb_slice_group_map_type == 0) {
for (iGroup = 0; iGroup <= pps->slice_group_count - 1; iGroup++)
gf_bs_read_ue_log_idx(bs, "run_length_minus1", iGroup);
}
else if (pps->mb_slice_group_map_type == 2) {
for (iGroup = 0; iGroup < pps->slice_group_count - 1; iGroup++) {
gf_bs_read_ue_log_idx(bs, "top_left", iGroup);
gf_bs_read_ue_log_idx(bs, "bottom_right", iGroup);
}
}
else if (pps->mb_slice_group_map_type == 3 || pps->mb_slice_group_map_type == 4 || pps->mb_slice_group_map_type == 5) {
gf_bs_read_int_log(bs, 1, "slice_group_change_direction_flag");
gf_bs_read_ue_log(bs, "slice_group_change_rate_minus1");
}
else if (pps->mb_slice_group_map_type == 6) {
u32 i;
pps->pic_size_in_map_units_minus1 = gf_bs_read_ue_log(bs, "pic_size_in_map_units_minus1");
for (i = 0; i <= pps->pic_size_in_map_units_minus1; i++) {
gf_bs_read_int_log_idx(bs, (u32)ceil(log(pps->slice_group_count) / log(2)), "slice_group_id", i);
}
}
}
pps->num_ref_idx_l0_default_active_minus1 = gf_bs_read_ue_log(bs, "num_ref_idx_l0_default_active_minus1");
pps->num_ref_idx_l1_default_active_minus1 = gf_bs_read_ue_log(bs, "num_ref_idx_l1_default_active_minus1");
/*
if ((pps->ref_count[0] > 32) || (pps->ref_count[1] > 32)) goto exit;
*/
pps->weighted_pred_flag = gf_bs_read_int_log(bs, 1, "weighted_pred_flag");
gf_bs_read_int_log(bs, 2, "weighted_bipred_idc");
gf_bs_read_se_log(bs, "init_qp_minus26");
gf_bs_read_se_log(bs, "init_qs_minus26");
gf_bs_read_se_log(bs, "chroma_qp_index_offset");
pps->deblocking_filter_control_present_flag = gf_bs_read_int_log(bs, 1, "deblocking_filter_control_present_flag");
gf_bs_read_int_log(bs, 1, "constrained_intra_pred");
pps->redundant_pic_cnt_present = gf_bs_read_int_log(bs, 1, "redundant_pic_cnt_present");
return pps_id;
} | 552 | True | 1 |
CVE-2021-30022 | 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/gpac/gpac/issues/1720', 'name': 'https://github.com/gpac/gpac/issues/1720', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'name': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-190'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'There is a integer overflow in media_tools/av_parsers.c in the gf_avc_read_pps_bs_internal in GPAC 1.0.1. pps_id may be a negative number, so it will not return. However, avc->pps only has 255 unit, so there is an overflow, which results a crash.'}] | 2021-04-21T19:03Z | 2021-04-19T20:15Z | Integer Overflow or Wraparound | The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | An integer overflow or wraparound occurs when an integer value is incremented to a value that is too large to store in the associated representation. When this occurs, the value may wrap to become a very small or negative number. While this may be intended behavior in circumstances that rely on wrapping, it can have security consequences if the wrap is unexpected. This is especially the case if the integer overflow can be triggered using user-supplied inputs. This becomes security-critical when the result is used to control looping, make a security decision, or determine the offset or size in behaviors such as memory allocation, copying, concatenation, etc.
| https://cwe.mitre.org/data/definitions/190.html | 0 | jeanlf | 2021-03-29 09:34:02+02:00 | add safety in avc/hevc/vvc sps/pps/vps ID check - cf #1720 #1721 #1722 | 51cdb67ff7c5f1242ac58c5aa603ceaf1793b788 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_avc_read_pps_bs_internal | gf_avc_read_pps_bs_internal( GF_BitStream * bs , AVCState * avc , u32 nal_hdr) | ['bs', 'avc', 'nal_hdr'] | static s32 gf_avc_read_pps_bs_internal(GF_BitStream *bs, AVCState *avc, u32 nal_hdr)
{
s32 pps_id;
AVC_PPS *pps;
gf_bs_enable_emulation_byte_removal(bs, GF_TRUE);
if (!nal_hdr) {
gf_bs_read_int_log(bs, 1, "forbidden_zero_bit");
gf_bs_read_int_log(bs, 2, "nal_ref_idc");
gf_bs_read_int_log(bs, 5, "nal_unit_type");
}
pps_id = gf_bs_read_ue_log(bs, "pps_id");
if (pps_id >= 255) {
return -1;
}
pps = &avc->pps[pps_id];
pps->id = pps_id;
if (!pps->status) pps->status = 1;
pps->sps_id = gf_bs_read_ue_log(bs, "sps_id");
if (pps->sps_id >= 32) {
pps->sps_id = 0;
return -1;
}
/*sps_id may be refer to regular SPS or subseq sps, depending on the coded slice referring to the pps*/
if (!avc->sps[pps->sps_id].state && !avc->sps[pps->sps_id + GF_SVC_SSPS_ID_SHIFT].state) {
return -1;
}
avc->pps_active_idx = pps->id; /*set active sps*/
avc->sps_active_idx = pps->sps_id; /*set active sps*/
pps->entropy_coding_mode_flag = gf_bs_read_int_log(bs, 1, "entropy_coding_mode_flag");
pps->pic_order_present = gf_bs_read_int_log(bs, 1, "pic_order_present");
pps->slice_group_count = gf_bs_read_ue_log(bs, "slice_group_count_minus1") + 1;
if (pps->slice_group_count > 1) {
u32 iGroup;
pps->mb_slice_group_map_type = gf_bs_read_ue_log(bs, "mb_slice_group_map_type");
if (pps->mb_slice_group_map_type == 0) {
for (iGroup = 0; iGroup <= pps->slice_group_count - 1; iGroup++)
gf_bs_read_ue_log_idx(bs, "run_length_minus1", iGroup);
}
else if (pps->mb_slice_group_map_type == 2) {
for (iGroup = 0; iGroup < pps->slice_group_count - 1; iGroup++) {
gf_bs_read_ue_log_idx(bs, "top_left", iGroup);
gf_bs_read_ue_log_idx(bs, "bottom_right", iGroup);
}
}
else if (pps->mb_slice_group_map_type == 3 || pps->mb_slice_group_map_type == 4 || pps->mb_slice_group_map_type == 5) {
gf_bs_read_int_log(bs, 1, "slice_group_change_direction_flag");
gf_bs_read_ue_log(bs, "slice_group_change_rate_minus1");
}
else if (pps->mb_slice_group_map_type == 6) {
u32 i;
pps->pic_size_in_map_units_minus1 = gf_bs_read_ue_log(bs, "pic_size_in_map_units_minus1");
for (i = 0; i <= pps->pic_size_in_map_units_minus1; i++) {
gf_bs_read_int_log_idx(bs, (u32)ceil(log(pps->slice_group_count) / log(2)), "slice_group_id", i);
}
}
}
pps->num_ref_idx_l0_default_active_minus1 = gf_bs_read_ue_log(bs, "num_ref_idx_l0_default_active_minus1");
pps->num_ref_idx_l1_default_active_minus1 = gf_bs_read_ue_log(bs, "num_ref_idx_l1_default_active_minus1");
/*
if ((pps->ref_count[0] > 32) || (pps->ref_count[1] > 32)) goto exit;
*/
pps->weighted_pred_flag = gf_bs_read_int_log(bs, 1, "weighted_pred_flag");
gf_bs_read_int_log(bs, 2, "weighted_bipred_idc");
gf_bs_read_se_log(bs, "init_qp_minus26");
gf_bs_read_se_log(bs, "init_qs_minus26");
gf_bs_read_se_log(bs, "chroma_qp_index_offset");
pps->deblocking_filter_control_present_flag = gf_bs_read_int_log(bs, 1, "deblocking_filter_control_present_flag");
gf_bs_read_int_log(bs, 1, "constrained_intra_pred");
pps->redundant_pic_cnt_present = gf_bs_read_int_log(bs, 1, "redundant_pic_cnt_present");
return pps_id;
} | 552 | True | 1 |
CVE-2021-30014 | 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/gpac/gpac/issues/1721', 'name': 'https://github.com/gpac/gpac/issues/1721', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'name': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-190'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'There is a integer overflow in media_tools/av_parsers.c in the hevc_parse_slice_segment function in GPAC 1.0.1 which results in a crash.'}] | 2021-04-21T19:21Z | 2021-04-19T20:15Z | Integer Overflow or Wraparound | The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | An integer overflow or wraparound occurs when an integer value is incremented to a value that is too large to store in the associated representation. When this occurs, the value may wrap to become a very small or negative number. While this may be intended behavior in circumstances that rely on wrapping, it can have security consequences if the wrap is unexpected. This is especially the case if the integer overflow can be triggered using user-supplied inputs. This becomes security-critical when the result is used to control looping, make a security decision, or determine the offset or size in behaviors such as memory allocation, copying, concatenation, etc.
| https://cwe.mitre.org/data/definitions/190.html | 0 | jeanlf | 2021-03-29 09:34:02+02:00 | add safety in avc/hevc/vvc sps/pps/vps ID check - cf #1720 #1721 #1722 | 51cdb67ff7c5f1242ac58c5aa603ceaf1793b788 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_avc_read_sps_bs_internal | gf_avc_read_sps_bs_internal( GF_BitStream * bs , AVCState * avc , u32 subseq_sps , u32 * vui_flag_pos , u32 nal_hdr) | ['bs', 'avc', 'subseq_sps', 'vui_flag_pos', 'nal_hdr'] | static s32 gf_avc_read_sps_bs_internal(GF_BitStream *bs, AVCState *avc, u32 subseq_sps, u32 *vui_flag_pos, u32 nal_hdr)
{
AVC_SPS *sps;
s32 mb_width, mb_height, sps_id = -1;
u32 profile_idc, level_idc, pcomp, i, chroma_format_idc, cl = 0, cr = 0, ct = 0, cb = 0, luma_bd, chroma_bd;
u8 separate_colour_plane_flag = 0;
if (!vui_flag_pos) {
gf_bs_enable_emulation_byte_removal(bs, GF_TRUE);
}
if (!bs) {
return -1;
}
if (!nal_hdr) {
gf_bs_read_int_log(bs, 1, "forbidden_zero_bit");
gf_bs_read_int_log(bs, 2, "nal_ref_idc");
gf_bs_read_int_log(bs, 5, "nal_unit_type");
}
profile_idc = gf_bs_read_int_log(bs, 8, "profile_idc");
pcomp = gf_bs_read_int_log(bs, 8, "profile_compatibility");
/*sanity checks*/
if (pcomp & 0x3)
return -1;
level_idc = gf_bs_read_int_log(bs, 8, "level_idc");
/*SubsetSps is used to be sure that AVC SPS are not going to be scratched
by subset SPS. According to the SVC standard, subset SPS can have the same sps_id
than its base layer, but it does not refer to the same SPS. */
sps_id = gf_bs_read_ue_log(bs, "sps_id") + GF_SVC_SSPS_ID_SHIFT * subseq_sps;
if (sps_id >= 32) {
return -1;
}
if (sps_id < 0) {
return -1;
}
luma_bd = chroma_bd = 0;
sps = &avc->sps[sps_id];
chroma_format_idc = sps->ChromaArrayType = 1;
sps->state |= subseq_sps ? AVC_SUBSPS_PARSED : AVC_SPS_PARSED;
/*High Profile and SVC*/
switch (profile_idc) {
case 100:
case 110:
case 122:
case 244:
case 44:
/*sanity checks: note1 from 7.4.2.1.1 of iso/iec 14496-10-N11084*/
if (pcomp & 0xE0)
return -1;
case 83:
case 86:
case 118:
case 128:
chroma_format_idc = gf_bs_read_ue_log(bs, "chroma_format_idc");
sps->ChromaArrayType = chroma_format_idc;
if (chroma_format_idc == 3) {
separate_colour_plane_flag = gf_bs_read_int_log(bs, 1, "separate_colour_plane_flag");
/*
Depending on the value of separate_colour_plane_flag, the value of the variable ChromaArrayType is assigned as follows.
\96 If separate_colour_plane_flag is equal to 0, ChromaArrayType is set equal to chroma_format_idc.
\96 Otherwise (separate_colour_plane_flag is equal to 1), ChromaArrayType is set equal to 0.
*/
if (separate_colour_plane_flag) sps->ChromaArrayType = 0;
}
luma_bd = gf_bs_read_ue_log(bs, "luma_bit_depth");
chroma_bd = gf_bs_read_ue_log(bs, "chroma_bit_depth");
/*qpprime_y_zero_transform_bypass_flag = */ gf_bs_read_int_log(bs, 1, "qpprime_y_zero_transform_bypass_flag");
/*seq_scaling_matrix_present_flag*/
if (gf_bs_read_int_log(bs, 1, "seq_scaling_matrix_present_flag")) {
u32 k;
for (k = 0; k < 8; k++) {
if (gf_bs_read_int_log_idx(bs, 1, "seq_scaling_list_present_flag", k)) {
u32 z, last = 8, next = 8;
u32 sl = k < 6 ? 16 : 64;
for (z = 0; z < sl; z++) {
if (next) {
s32 delta = gf_bs_read_se(bs);
next = (last + delta + 256) % 256;
}
last = next ? next : last;
}
}
}
}
break;
}
sps->profile_idc = profile_idc;
sps->level_idc = level_idc;
sps->prof_compat = pcomp;
sps->log2_max_frame_num = gf_bs_read_ue_log(bs, "log2_max_frame_num") + 4;
sps->poc_type = gf_bs_read_ue_log(bs, "poc_type");
sps->chroma_format = chroma_format_idc;
sps->luma_bit_depth_m8 = luma_bd;
sps->chroma_bit_depth_m8 = chroma_bd;
if (sps->poc_type == 0) {
sps->log2_max_poc_lsb = gf_bs_read_ue_log(bs, "log2_max_poc_lsb") + 4;
}
else if (sps->poc_type == 1) {
sps->delta_pic_order_always_zero_flag = gf_bs_read_int_log(bs, 1, "delta_pic_order_always_zero_flag");
sps->offset_for_non_ref_pic = gf_bs_read_se_log(bs, "offset_for_non_ref_pic");
sps->offset_for_top_to_bottom_field = gf_bs_read_se_log(bs, "offset_for_top_to_bottom_field");
sps->poc_cycle_length = gf_bs_read_ue_log(bs, "poc_cycle_length");
if (sps->poc_cycle_length > GF_ARRAY_LENGTH(sps->offset_for_ref_frame)) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[avc-h264] offset_for_ref_frame overflow from poc_cycle_length\n"));
return -1;
}
for (i = 0; i < sps->poc_cycle_length; i++)
sps->offset_for_ref_frame[i] = gf_bs_read_se_log_idx(bs, "offset_for_ref_frame", i);
}
if (sps->poc_type > 2) {
return -1;
}
sps->max_num_ref_frames = gf_bs_read_ue_log(bs, "max_num_ref_frames");
sps->gaps_in_frame_num_value_allowed_flag = gf_bs_read_int_log(bs, 1, "gaps_in_frame_num_value_allowed_flag");
mb_width = gf_bs_read_ue_log(bs, "pic_width_in_mbs_minus1") + 1;
mb_height = gf_bs_read_ue_log(bs, "pic_height_in_map_units_minus1") + 1;
sps->frame_mbs_only_flag = gf_bs_read_int_log(bs, 1, "frame_mbs_only_flag");
sps->width = mb_width * 16;
sps->height = (2 - sps->frame_mbs_only_flag) * mb_height * 16;
if (!sps->frame_mbs_only_flag) sps->mb_adaptive_frame_field_flag = gf_bs_read_int_log(bs, 1, "mb_adaptive_frame_field_flag");
gf_bs_read_int_log(bs, 1, "direct_8x8_inference_flag");
if (gf_bs_read_int_log(bs, 1, "frame_cropping_flag")) {
int CropUnitX, CropUnitY, SubWidthC = -1, SubHeightC = -1;
if (chroma_format_idc == 1) {
SubWidthC = 2; SubHeightC = 2;
}
else if (chroma_format_idc == 2) {
SubWidthC = 2; SubHeightC = 1;
}
else if ((chroma_format_idc == 3) && (separate_colour_plane_flag == 0)) {
SubWidthC = 1; SubHeightC = 1;
}
if (sps->ChromaArrayType == 0) {
assert(SubWidthC == -1);
CropUnitX = 1;
CropUnitY = 2 - sps->frame_mbs_only_flag;
}
else {
CropUnitX = SubWidthC;
CropUnitY = SubHeightC * (2 - sps->frame_mbs_only_flag);
}
cl = gf_bs_read_ue_log(bs, "frame_crop_left_offset");
cr = gf_bs_read_ue_log(bs, "frame_crop_right_offset");
ct = gf_bs_read_ue_log(bs, "frame_crop_top_offset");
cb = gf_bs_read_ue_log(bs, "frame_crop_bottom_offset");
sps->width -= CropUnitX * (cl + cr);
sps->height -= CropUnitY * (ct + cb);
cl *= CropUnitX;
cr *= CropUnitX;
ct *= CropUnitY;
cb *= CropUnitY;
}
sps->crop.left = cl;
sps->crop.right = cr;
sps->crop.top = ct;
sps->crop.bottom = cb;
if (vui_flag_pos) {
*vui_flag_pos = (u32)gf_bs_get_bit_offset(bs);
}
/*vui_parameters_present_flag*/
sps->vui_parameters_present_flag = gf_bs_read_int_log(bs, 1, "vui_parameters_present_flag");
if (sps->vui_parameters_present_flag) {
sps->vui.aspect_ratio_info_present_flag = gf_bs_read_int_log(bs, 1, "aspect_ratio_info_present_flag");
if (sps->vui.aspect_ratio_info_present_flag) {
s32 aspect_ratio_idc = gf_bs_read_int_log(bs, 8, "aspect_ratio_idc");
if (aspect_ratio_idc == 255) {
sps->vui.par_num = gf_bs_read_int_log(bs, 16, "aspect_ratio_num");
sps->vui.par_den = gf_bs_read_int_log(bs, 16, "aspect_ratio_den");
}
else if (aspect_ratio_idc < GF_ARRAY_LENGTH(avc_hevc_sar) ) {
sps->vui.par_num = avc_hevc_sar[aspect_ratio_idc].w;
sps->vui.par_den = avc_hevc_sar[aspect_ratio_idc].h;
}
else {
GF_LOG(GF_LOG_WARNING, GF_LOG_CODING, ("[avc-h264] Unknown aspect_ratio_idc: your video may have a wrong aspect ratio. Contact the GPAC team!\n"));
}
}
sps->vui.overscan_info_present_flag = gf_bs_read_int_log(bs, 1, "overscan_info_present_flag");
if (sps->vui.overscan_info_present_flag)
gf_bs_read_int_log(bs, 1, "overscan_appropriate_flag");
/* default values */
sps->vui.video_format = 5;
sps->vui.colour_primaries = 2;
sps->vui.transfer_characteristics = 2;
sps->vui.matrix_coefficients = 2;
/* now read values if possible */
sps->vui.video_signal_type_present_flag = gf_bs_read_int_log(bs, 1, "video_signal_type_present_flag");
if (sps->vui.video_signal_type_present_flag) {
sps->vui.video_format = gf_bs_read_int_log(bs, 3, "video_format");
sps->vui.video_full_range_flag = gf_bs_read_int_log(bs, 1, "video_full_range_flag");
sps->vui.colour_description_present_flag = gf_bs_read_int_log(bs, 1, "colour_description_present_flag");
if (sps->vui.colour_description_present_flag) {
sps->vui.colour_primaries = gf_bs_read_int_log(bs, 8, "colour_primaries");
sps->vui.transfer_characteristics = gf_bs_read_int_log(bs, 8, "transfer_characteristics");
sps->vui.matrix_coefficients = gf_bs_read_int_log(bs, 8, "matrix_coefficients");
}
}
if (gf_bs_read_int_log(bs, 1, "chroma_location_info_present_flag")) {
gf_bs_read_ue_log(bs, "chroma_sample_location_type_top_field");
gf_bs_read_ue_log(bs, "chroma_sample_location_type_bottom_field");
}
sps->vui.timing_info_present_flag = gf_bs_read_int_log(bs, 1, "timing_info_present_flag");
if (sps->vui.timing_info_present_flag) {
sps->vui.num_units_in_tick = gf_bs_read_int_log(bs, 32, "num_units_in_tick");
sps->vui.time_scale = gf_bs_read_int_log(bs, 32, "time_scale");
sps->vui.fixed_frame_rate_flag = gf_bs_read_int_log(bs, 1, "fixed_frame_rate_flag");
}
sps->vui.nal_hrd_parameters_present_flag = gf_bs_read_int_log(bs, 1, "nal_hrd_parameters_present_flag");
if (sps->vui.nal_hrd_parameters_present_flag)
avc_parse_hrd_parameters(bs, &sps->vui.hrd);
sps->vui.vcl_hrd_parameters_present_flag = gf_bs_read_int_log(bs, 1, "vcl_hrd_parameters_present_flag");
if (sps->vui.vcl_hrd_parameters_present_flag)
avc_parse_hrd_parameters(bs, &sps->vui.hrd);
if (sps->vui.nal_hrd_parameters_present_flag || sps->vui.vcl_hrd_parameters_present_flag)
sps->vui.low_delay_hrd_flag = gf_bs_read_int_log(bs, 1, "low_delay_hrd_flag");
sps->vui.pic_struct_present_flag = gf_bs_read_int_log(bs, 1, "pic_struct_present_flag");
}
/*end of seq_parameter_set_data*/
if (subseq_sps) {
if ((profile_idc == 83) || (profile_idc == 86)) {
u8 extended_spatial_scalability_idc;
/*parsing seq_parameter_set_svc_extension*/
gf_bs_read_int_log(bs, 1, "inter_layer_deblocking_filter_control_present_flag");
extended_spatial_scalability_idc = gf_bs_read_int_log(bs, 2, "extended_spatial_scalability_idc");
if (sps->ChromaArrayType == 1 || sps->ChromaArrayType == 2) {
gf_bs_read_int_log(bs, 1, "chroma_phase_x_plus1_flag");
}
if (sps->ChromaArrayType == 1) {
gf_bs_read_int_log(bs, 2, "chroma_phase_y_plus1");
}
if (extended_spatial_scalability_idc == 1) {
if (sps->ChromaArrayType > 0) {
gf_bs_read_int_log(bs, 1, "seq_ref_layer_chroma_phase_x_plus1_flag");
gf_bs_read_int_log(bs, 2, "seq_ref_layer_chroma_phase_y_plus1");
}
gf_bs_read_se_log(bs, "seq_scaled_ref_layer_left_offset");
gf_bs_read_se_log(bs, "seq_scaled_ref_layer_top_offset");
gf_bs_read_se_log(bs, "seq_scaled_ref_layer_right_offset");
gf_bs_read_se_log(bs, "seq_scaled_ref_layer_bottom_offset");
}
if (gf_bs_read_int_log(bs, 1, "seq_tcoeff_level_prediction_flag")) {
gf_bs_read_int_log(bs, 1, "adaptive_tcoeff_level_prediction_flag");
}
gf_bs_read_int_log(bs, 1, "slice_header_restriction_flag");
if (gf_bs_read_int_log(bs, 1, "svc_vui_parameters_present")) {
u32 vui_ext_num_entries_minus1 = gf_bs_read_ue_log(bs, "vui_ext_num_entries_minus1");
for (i = 0; i <= vui_ext_num_entries_minus1; i++) {
u8 vui_ext_nal_hrd_parameters_present_flag, vui_ext_vcl_hrd_parameters_present_flag, vui_ext_timing_info_present_flag;
gf_bs_read_int_log(bs, 3, "vui_ext_dependency_id");
gf_bs_read_int_log(bs, 4, "vui_ext_quality_id");
gf_bs_read_int_log(bs, 3, "vui_ext_temporal_id");
vui_ext_timing_info_present_flag = gf_bs_read_int_log(bs, 1, "vui_ext_timing_info_present_flag");
if (vui_ext_timing_info_present_flag) {
gf_bs_read_int_log(bs, 32, "vui_ext_num_units_in_tick");
gf_bs_read_int_log(bs, 32, "vui_ext_time_scale");
gf_bs_read_int_log(bs, 1, "vui_ext_fixed_frame_rate_flag");
}
vui_ext_nal_hrd_parameters_present_flag = gf_bs_read_int_log(bs, 1, "vui_ext_nal_hrd_parameters_present_flag");
if (vui_ext_nal_hrd_parameters_present_flag) {
//hrd_parameters( )
}
vui_ext_vcl_hrd_parameters_present_flag = gf_bs_read_int_log(bs, 1, "vui_ext_vcl_hrd_parameters_present_flag");
if (vui_ext_vcl_hrd_parameters_present_flag) {
//hrd_parameters( )
}
if (vui_ext_nal_hrd_parameters_present_flag || vui_ext_vcl_hrd_parameters_present_flag) {
gf_bs_read_int_log(bs, 1, "vui_ext_low_delay_hrd_flag");
}
gf_bs_read_int_log(bs, 1, "vui_ext_pic_struct_present_flag");
}
}
}
else if ((profile_idc == 118) || (profile_idc == 128)) {
GF_LOG(GF_LOG_INFO, GF_LOG_CODING, ("[avc-h264] MVC parsing not implemented - skipping parsing end of Subset SPS\n"));
return sps_id;
}
if (gf_bs_read_int_log(bs, 1, "additional_extension2")) {
GF_LOG(GF_LOG_WARNING, GF_LOG_CODING, ("[avc-h264] skipping parsing end of Subset SPS (additional_extension2)\n"));
return sps_id;
}
}
return sps_id;
} | 2038 | True | 1 |
CVE-2021-30020 | 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/gpac/gpac/issues/1722', 'name': 'https://github.com/gpac/gpac/issues/1722', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'name': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-787'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'In the function gf_hevc_read_pps_bs_internal function in media_tools/av_parsers.c in GPAC 1.0.1 there is a loop, which with crafted file, pps->num_tile_columns may be larger than sizeof(pps->column_width), which results in a heap overflow in the loop.'}] | 2021-04-21T19:02Z | 2021-04-19T20: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 | jeanlf | 2021-03-29 09:34:02+02:00 | add safety in avc/hevc/vvc sps/pps/vps ID check - cf #1720 #1721 #1722 | 51cdb67ff7c5f1242ac58c5aa603ceaf1793b788 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_avc_read_sps_bs_internal | gf_avc_read_sps_bs_internal( GF_BitStream * bs , AVCState * avc , u32 subseq_sps , u32 * vui_flag_pos , u32 nal_hdr) | ['bs', 'avc', 'subseq_sps', 'vui_flag_pos', 'nal_hdr'] | static s32 gf_avc_read_sps_bs_internal(GF_BitStream *bs, AVCState *avc, u32 subseq_sps, u32 *vui_flag_pos, u32 nal_hdr)
{
AVC_SPS *sps;
s32 mb_width, mb_height, sps_id = -1;
u32 profile_idc, level_idc, pcomp, i, chroma_format_idc, cl = 0, cr = 0, ct = 0, cb = 0, luma_bd, chroma_bd;
u8 separate_colour_plane_flag = 0;
if (!vui_flag_pos) {
gf_bs_enable_emulation_byte_removal(bs, GF_TRUE);
}
if (!bs) {
return -1;
}
if (!nal_hdr) {
gf_bs_read_int_log(bs, 1, "forbidden_zero_bit");
gf_bs_read_int_log(bs, 2, "nal_ref_idc");
gf_bs_read_int_log(bs, 5, "nal_unit_type");
}
profile_idc = gf_bs_read_int_log(bs, 8, "profile_idc");
pcomp = gf_bs_read_int_log(bs, 8, "profile_compatibility");
/*sanity checks*/
if (pcomp & 0x3)
return -1;
level_idc = gf_bs_read_int_log(bs, 8, "level_idc");
/*SubsetSps is used to be sure that AVC SPS are not going to be scratched
by subset SPS. According to the SVC standard, subset SPS can have the same sps_id
than its base layer, but it does not refer to the same SPS. */
sps_id = gf_bs_read_ue_log(bs, "sps_id") + GF_SVC_SSPS_ID_SHIFT * subseq_sps;
if (sps_id >= 32) {
return -1;
}
if (sps_id < 0) {
return -1;
}
luma_bd = chroma_bd = 0;
sps = &avc->sps[sps_id];
chroma_format_idc = sps->ChromaArrayType = 1;
sps->state |= subseq_sps ? AVC_SUBSPS_PARSED : AVC_SPS_PARSED;
/*High Profile and SVC*/
switch (profile_idc) {
case 100:
case 110:
case 122:
case 244:
case 44:
/*sanity checks: note1 from 7.4.2.1.1 of iso/iec 14496-10-N11084*/
if (pcomp & 0xE0)
return -1;
case 83:
case 86:
case 118:
case 128:
chroma_format_idc = gf_bs_read_ue_log(bs, "chroma_format_idc");
sps->ChromaArrayType = chroma_format_idc;
if (chroma_format_idc == 3) {
separate_colour_plane_flag = gf_bs_read_int_log(bs, 1, "separate_colour_plane_flag");
/*
Depending on the value of separate_colour_plane_flag, the value of the variable ChromaArrayType is assigned as follows.
\96 If separate_colour_plane_flag is equal to 0, ChromaArrayType is set equal to chroma_format_idc.
\96 Otherwise (separate_colour_plane_flag is equal to 1), ChromaArrayType is set equal to 0.
*/
if (separate_colour_plane_flag) sps->ChromaArrayType = 0;
}
luma_bd = gf_bs_read_ue_log(bs, "luma_bit_depth");
chroma_bd = gf_bs_read_ue_log(bs, "chroma_bit_depth");
/*qpprime_y_zero_transform_bypass_flag = */ gf_bs_read_int_log(bs, 1, "qpprime_y_zero_transform_bypass_flag");
/*seq_scaling_matrix_present_flag*/
if (gf_bs_read_int_log(bs, 1, "seq_scaling_matrix_present_flag")) {
u32 k;
for (k = 0; k < 8; k++) {
if (gf_bs_read_int_log_idx(bs, 1, "seq_scaling_list_present_flag", k)) {
u32 z, last = 8, next = 8;
u32 sl = k < 6 ? 16 : 64;
for (z = 0; z < sl; z++) {
if (next) {
s32 delta = gf_bs_read_se(bs);
next = (last + delta + 256) % 256;
}
last = next ? next : last;
}
}
}
}
break;
}
sps->profile_idc = profile_idc;
sps->level_idc = level_idc;
sps->prof_compat = pcomp;
sps->log2_max_frame_num = gf_bs_read_ue_log(bs, "log2_max_frame_num") + 4;
sps->poc_type = gf_bs_read_ue_log(bs, "poc_type");
sps->chroma_format = chroma_format_idc;
sps->luma_bit_depth_m8 = luma_bd;
sps->chroma_bit_depth_m8 = chroma_bd;
if (sps->poc_type == 0) {
sps->log2_max_poc_lsb = gf_bs_read_ue_log(bs, "log2_max_poc_lsb") + 4;
}
else if (sps->poc_type == 1) {
sps->delta_pic_order_always_zero_flag = gf_bs_read_int_log(bs, 1, "delta_pic_order_always_zero_flag");
sps->offset_for_non_ref_pic = gf_bs_read_se_log(bs, "offset_for_non_ref_pic");
sps->offset_for_top_to_bottom_field = gf_bs_read_se_log(bs, "offset_for_top_to_bottom_field");
sps->poc_cycle_length = gf_bs_read_ue_log(bs, "poc_cycle_length");
if (sps->poc_cycle_length > GF_ARRAY_LENGTH(sps->offset_for_ref_frame)) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[avc-h264] offset_for_ref_frame overflow from poc_cycle_length\n"));
return -1;
}
for (i = 0; i < sps->poc_cycle_length; i++)
sps->offset_for_ref_frame[i] = gf_bs_read_se_log_idx(bs, "offset_for_ref_frame", i);
}
if (sps->poc_type > 2) {
return -1;
}
sps->max_num_ref_frames = gf_bs_read_ue_log(bs, "max_num_ref_frames");
sps->gaps_in_frame_num_value_allowed_flag = gf_bs_read_int_log(bs, 1, "gaps_in_frame_num_value_allowed_flag");
mb_width = gf_bs_read_ue_log(bs, "pic_width_in_mbs_minus1") + 1;
mb_height = gf_bs_read_ue_log(bs, "pic_height_in_map_units_minus1") + 1;
sps->frame_mbs_only_flag = gf_bs_read_int_log(bs, 1, "frame_mbs_only_flag");
sps->width = mb_width * 16;
sps->height = (2 - sps->frame_mbs_only_flag) * mb_height * 16;
if (!sps->frame_mbs_only_flag) sps->mb_adaptive_frame_field_flag = gf_bs_read_int_log(bs, 1, "mb_adaptive_frame_field_flag");
gf_bs_read_int_log(bs, 1, "direct_8x8_inference_flag");
if (gf_bs_read_int_log(bs, 1, "frame_cropping_flag")) {
int CropUnitX, CropUnitY, SubWidthC = -1, SubHeightC = -1;
if (chroma_format_idc == 1) {
SubWidthC = 2; SubHeightC = 2;
}
else if (chroma_format_idc == 2) {
SubWidthC = 2; SubHeightC = 1;
}
else if ((chroma_format_idc == 3) && (separate_colour_plane_flag == 0)) {
SubWidthC = 1; SubHeightC = 1;
}
if (sps->ChromaArrayType == 0) {
assert(SubWidthC == -1);
CropUnitX = 1;
CropUnitY = 2 - sps->frame_mbs_only_flag;
}
else {
CropUnitX = SubWidthC;
CropUnitY = SubHeightC * (2 - sps->frame_mbs_only_flag);
}
cl = gf_bs_read_ue_log(bs, "frame_crop_left_offset");
cr = gf_bs_read_ue_log(bs, "frame_crop_right_offset");
ct = gf_bs_read_ue_log(bs, "frame_crop_top_offset");
cb = gf_bs_read_ue_log(bs, "frame_crop_bottom_offset");
sps->width -= CropUnitX * (cl + cr);
sps->height -= CropUnitY * (ct + cb);
cl *= CropUnitX;
cr *= CropUnitX;
ct *= CropUnitY;
cb *= CropUnitY;
}
sps->crop.left = cl;
sps->crop.right = cr;
sps->crop.top = ct;
sps->crop.bottom = cb;
if (vui_flag_pos) {
*vui_flag_pos = (u32)gf_bs_get_bit_offset(bs);
}
/*vui_parameters_present_flag*/
sps->vui_parameters_present_flag = gf_bs_read_int_log(bs, 1, "vui_parameters_present_flag");
if (sps->vui_parameters_present_flag) {
sps->vui.aspect_ratio_info_present_flag = gf_bs_read_int_log(bs, 1, "aspect_ratio_info_present_flag");
if (sps->vui.aspect_ratio_info_present_flag) {
s32 aspect_ratio_idc = gf_bs_read_int_log(bs, 8, "aspect_ratio_idc");
if (aspect_ratio_idc == 255) {
sps->vui.par_num = gf_bs_read_int_log(bs, 16, "aspect_ratio_num");
sps->vui.par_den = gf_bs_read_int_log(bs, 16, "aspect_ratio_den");
}
else if (aspect_ratio_idc < GF_ARRAY_LENGTH(avc_hevc_sar) ) {
sps->vui.par_num = avc_hevc_sar[aspect_ratio_idc].w;
sps->vui.par_den = avc_hevc_sar[aspect_ratio_idc].h;
}
else {
GF_LOG(GF_LOG_WARNING, GF_LOG_CODING, ("[avc-h264] Unknown aspect_ratio_idc: your video may have a wrong aspect ratio. Contact the GPAC team!\n"));
}
}
sps->vui.overscan_info_present_flag = gf_bs_read_int_log(bs, 1, "overscan_info_present_flag");
if (sps->vui.overscan_info_present_flag)
gf_bs_read_int_log(bs, 1, "overscan_appropriate_flag");
/* default values */
sps->vui.video_format = 5;
sps->vui.colour_primaries = 2;
sps->vui.transfer_characteristics = 2;
sps->vui.matrix_coefficients = 2;
/* now read values if possible */
sps->vui.video_signal_type_present_flag = gf_bs_read_int_log(bs, 1, "video_signal_type_present_flag");
if (sps->vui.video_signal_type_present_flag) {
sps->vui.video_format = gf_bs_read_int_log(bs, 3, "video_format");
sps->vui.video_full_range_flag = gf_bs_read_int_log(bs, 1, "video_full_range_flag");
sps->vui.colour_description_present_flag = gf_bs_read_int_log(bs, 1, "colour_description_present_flag");
if (sps->vui.colour_description_present_flag) {
sps->vui.colour_primaries = gf_bs_read_int_log(bs, 8, "colour_primaries");
sps->vui.transfer_characteristics = gf_bs_read_int_log(bs, 8, "transfer_characteristics");
sps->vui.matrix_coefficients = gf_bs_read_int_log(bs, 8, "matrix_coefficients");
}
}
if (gf_bs_read_int_log(bs, 1, "chroma_location_info_present_flag")) {
gf_bs_read_ue_log(bs, "chroma_sample_location_type_top_field");
gf_bs_read_ue_log(bs, "chroma_sample_location_type_bottom_field");
}
sps->vui.timing_info_present_flag = gf_bs_read_int_log(bs, 1, "timing_info_present_flag");
if (sps->vui.timing_info_present_flag) {
sps->vui.num_units_in_tick = gf_bs_read_int_log(bs, 32, "num_units_in_tick");
sps->vui.time_scale = gf_bs_read_int_log(bs, 32, "time_scale");
sps->vui.fixed_frame_rate_flag = gf_bs_read_int_log(bs, 1, "fixed_frame_rate_flag");
}
sps->vui.nal_hrd_parameters_present_flag = gf_bs_read_int_log(bs, 1, "nal_hrd_parameters_present_flag");
if (sps->vui.nal_hrd_parameters_present_flag)
avc_parse_hrd_parameters(bs, &sps->vui.hrd);
sps->vui.vcl_hrd_parameters_present_flag = gf_bs_read_int_log(bs, 1, "vcl_hrd_parameters_present_flag");
if (sps->vui.vcl_hrd_parameters_present_flag)
avc_parse_hrd_parameters(bs, &sps->vui.hrd);
if (sps->vui.nal_hrd_parameters_present_flag || sps->vui.vcl_hrd_parameters_present_flag)
sps->vui.low_delay_hrd_flag = gf_bs_read_int_log(bs, 1, "low_delay_hrd_flag");
sps->vui.pic_struct_present_flag = gf_bs_read_int_log(bs, 1, "pic_struct_present_flag");
}
/*end of seq_parameter_set_data*/
if (subseq_sps) {
if ((profile_idc == 83) || (profile_idc == 86)) {
u8 extended_spatial_scalability_idc;
/*parsing seq_parameter_set_svc_extension*/
gf_bs_read_int_log(bs, 1, "inter_layer_deblocking_filter_control_present_flag");
extended_spatial_scalability_idc = gf_bs_read_int_log(bs, 2, "extended_spatial_scalability_idc");
if (sps->ChromaArrayType == 1 || sps->ChromaArrayType == 2) {
gf_bs_read_int_log(bs, 1, "chroma_phase_x_plus1_flag");
}
if (sps->ChromaArrayType == 1) {
gf_bs_read_int_log(bs, 2, "chroma_phase_y_plus1");
}
if (extended_spatial_scalability_idc == 1) {
if (sps->ChromaArrayType > 0) {
gf_bs_read_int_log(bs, 1, "seq_ref_layer_chroma_phase_x_plus1_flag");
gf_bs_read_int_log(bs, 2, "seq_ref_layer_chroma_phase_y_plus1");
}
gf_bs_read_se_log(bs, "seq_scaled_ref_layer_left_offset");
gf_bs_read_se_log(bs, "seq_scaled_ref_layer_top_offset");
gf_bs_read_se_log(bs, "seq_scaled_ref_layer_right_offset");
gf_bs_read_se_log(bs, "seq_scaled_ref_layer_bottom_offset");
}
if (gf_bs_read_int_log(bs, 1, "seq_tcoeff_level_prediction_flag")) {
gf_bs_read_int_log(bs, 1, "adaptive_tcoeff_level_prediction_flag");
}
gf_bs_read_int_log(bs, 1, "slice_header_restriction_flag");
if (gf_bs_read_int_log(bs, 1, "svc_vui_parameters_present")) {
u32 vui_ext_num_entries_minus1 = gf_bs_read_ue_log(bs, "vui_ext_num_entries_minus1");
for (i = 0; i <= vui_ext_num_entries_minus1; i++) {
u8 vui_ext_nal_hrd_parameters_present_flag, vui_ext_vcl_hrd_parameters_present_flag, vui_ext_timing_info_present_flag;
gf_bs_read_int_log(bs, 3, "vui_ext_dependency_id");
gf_bs_read_int_log(bs, 4, "vui_ext_quality_id");
gf_bs_read_int_log(bs, 3, "vui_ext_temporal_id");
vui_ext_timing_info_present_flag = gf_bs_read_int_log(bs, 1, "vui_ext_timing_info_present_flag");
if (vui_ext_timing_info_present_flag) {
gf_bs_read_int_log(bs, 32, "vui_ext_num_units_in_tick");
gf_bs_read_int_log(bs, 32, "vui_ext_time_scale");
gf_bs_read_int_log(bs, 1, "vui_ext_fixed_frame_rate_flag");
}
vui_ext_nal_hrd_parameters_present_flag = gf_bs_read_int_log(bs, 1, "vui_ext_nal_hrd_parameters_present_flag");
if (vui_ext_nal_hrd_parameters_present_flag) {
//hrd_parameters( )
}
vui_ext_vcl_hrd_parameters_present_flag = gf_bs_read_int_log(bs, 1, "vui_ext_vcl_hrd_parameters_present_flag");
if (vui_ext_vcl_hrd_parameters_present_flag) {
//hrd_parameters( )
}
if (vui_ext_nal_hrd_parameters_present_flag || vui_ext_vcl_hrd_parameters_present_flag) {
gf_bs_read_int_log(bs, 1, "vui_ext_low_delay_hrd_flag");
}
gf_bs_read_int_log(bs, 1, "vui_ext_pic_struct_present_flag");
}
}
}
else if ((profile_idc == 118) || (profile_idc == 128)) {
GF_LOG(GF_LOG_INFO, GF_LOG_CODING, ("[avc-h264] MVC parsing not implemented - skipping parsing end of Subset SPS\n"));
return sps_id;
}
if (gf_bs_read_int_log(bs, 1, "additional_extension2")) {
GF_LOG(GF_LOG_WARNING, GF_LOG_CODING, ("[avc-h264] skipping parsing end of Subset SPS (additional_extension2)\n"));
return sps_id;
}
}
return sps_id;
} | 2038 | True | 1 |
CVE-2021-30022 | 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/gpac/gpac/issues/1720', 'name': 'https://github.com/gpac/gpac/issues/1720', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'name': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-190'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'There is a integer overflow in media_tools/av_parsers.c in the gf_avc_read_pps_bs_internal in GPAC 1.0.1. pps_id may be a negative number, so it will not return. However, avc->pps only has 255 unit, so there is an overflow, which results a crash.'}] | 2021-04-21T19:03Z | 2021-04-19T20:15Z | Integer Overflow or Wraparound | The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | An integer overflow or wraparound occurs when an integer value is incremented to a value that is too large to store in the associated representation. When this occurs, the value may wrap to become a very small or negative number. While this may be intended behavior in circumstances that rely on wrapping, it can have security consequences if the wrap is unexpected. This is especially the case if the integer overflow can be triggered using user-supplied inputs. This becomes security-critical when the result is used to control looping, make a security decision, or determine the offset or size in behaviors such as memory allocation, copying, concatenation, etc.
| https://cwe.mitre.org/data/definitions/190.html | 0 | jeanlf | 2021-03-29 09:34:02+02:00 | add safety in avc/hevc/vvc sps/pps/vps ID check - cf #1720 #1721 #1722 | 51cdb67ff7c5f1242ac58c5aa603ceaf1793b788 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_avc_read_sps_bs_internal | gf_avc_read_sps_bs_internal( GF_BitStream * bs , AVCState * avc , u32 subseq_sps , u32 * vui_flag_pos , u32 nal_hdr) | ['bs', 'avc', 'subseq_sps', 'vui_flag_pos', 'nal_hdr'] | static s32 gf_avc_read_sps_bs_internal(GF_BitStream *bs, AVCState *avc, u32 subseq_sps, u32 *vui_flag_pos, u32 nal_hdr)
{
AVC_SPS *sps;
s32 mb_width, mb_height, sps_id = -1;
u32 profile_idc, level_idc, pcomp, i, chroma_format_idc, cl = 0, cr = 0, ct = 0, cb = 0, luma_bd, chroma_bd;
u8 separate_colour_plane_flag = 0;
if (!vui_flag_pos) {
gf_bs_enable_emulation_byte_removal(bs, GF_TRUE);
}
if (!bs) {
return -1;
}
if (!nal_hdr) {
gf_bs_read_int_log(bs, 1, "forbidden_zero_bit");
gf_bs_read_int_log(bs, 2, "nal_ref_idc");
gf_bs_read_int_log(bs, 5, "nal_unit_type");
}
profile_idc = gf_bs_read_int_log(bs, 8, "profile_idc");
pcomp = gf_bs_read_int_log(bs, 8, "profile_compatibility");
/*sanity checks*/
if (pcomp & 0x3)
return -1;
level_idc = gf_bs_read_int_log(bs, 8, "level_idc");
/*SubsetSps is used to be sure that AVC SPS are not going to be scratched
by subset SPS. According to the SVC standard, subset SPS can have the same sps_id
than its base layer, but it does not refer to the same SPS. */
sps_id = gf_bs_read_ue_log(bs, "sps_id") + GF_SVC_SSPS_ID_SHIFT * subseq_sps;
if (sps_id >= 32) {
return -1;
}
if (sps_id < 0) {
return -1;
}
luma_bd = chroma_bd = 0;
sps = &avc->sps[sps_id];
chroma_format_idc = sps->ChromaArrayType = 1;
sps->state |= subseq_sps ? AVC_SUBSPS_PARSED : AVC_SPS_PARSED;
/*High Profile and SVC*/
switch (profile_idc) {
case 100:
case 110:
case 122:
case 244:
case 44:
/*sanity checks: note1 from 7.4.2.1.1 of iso/iec 14496-10-N11084*/
if (pcomp & 0xE0)
return -1;
case 83:
case 86:
case 118:
case 128:
chroma_format_idc = gf_bs_read_ue_log(bs, "chroma_format_idc");
sps->ChromaArrayType = chroma_format_idc;
if (chroma_format_idc == 3) {
separate_colour_plane_flag = gf_bs_read_int_log(bs, 1, "separate_colour_plane_flag");
/*
Depending on the value of separate_colour_plane_flag, the value of the variable ChromaArrayType is assigned as follows.
\96 If separate_colour_plane_flag is equal to 0, ChromaArrayType is set equal to chroma_format_idc.
\96 Otherwise (separate_colour_plane_flag is equal to 1), ChromaArrayType is set equal to 0.
*/
if (separate_colour_plane_flag) sps->ChromaArrayType = 0;
}
luma_bd = gf_bs_read_ue_log(bs, "luma_bit_depth");
chroma_bd = gf_bs_read_ue_log(bs, "chroma_bit_depth");
/*qpprime_y_zero_transform_bypass_flag = */ gf_bs_read_int_log(bs, 1, "qpprime_y_zero_transform_bypass_flag");
/*seq_scaling_matrix_present_flag*/
if (gf_bs_read_int_log(bs, 1, "seq_scaling_matrix_present_flag")) {
u32 k;
for (k = 0; k < 8; k++) {
if (gf_bs_read_int_log_idx(bs, 1, "seq_scaling_list_present_flag", k)) {
u32 z, last = 8, next = 8;
u32 sl = k < 6 ? 16 : 64;
for (z = 0; z < sl; z++) {
if (next) {
s32 delta = gf_bs_read_se(bs);
next = (last + delta + 256) % 256;
}
last = next ? next : last;
}
}
}
}
break;
}
sps->profile_idc = profile_idc;
sps->level_idc = level_idc;
sps->prof_compat = pcomp;
sps->log2_max_frame_num = gf_bs_read_ue_log(bs, "log2_max_frame_num") + 4;
sps->poc_type = gf_bs_read_ue_log(bs, "poc_type");
sps->chroma_format = chroma_format_idc;
sps->luma_bit_depth_m8 = luma_bd;
sps->chroma_bit_depth_m8 = chroma_bd;
if (sps->poc_type == 0) {
sps->log2_max_poc_lsb = gf_bs_read_ue_log(bs, "log2_max_poc_lsb") + 4;
}
else if (sps->poc_type == 1) {
sps->delta_pic_order_always_zero_flag = gf_bs_read_int_log(bs, 1, "delta_pic_order_always_zero_flag");
sps->offset_for_non_ref_pic = gf_bs_read_se_log(bs, "offset_for_non_ref_pic");
sps->offset_for_top_to_bottom_field = gf_bs_read_se_log(bs, "offset_for_top_to_bottom_field");
sps->poc_cycle_length = gf_bs_read_ue_log(bs, "poc_cycle_length");
if (sps->poc_cycle_length > GF_ARRAY_LENGTH(sps->offset_for_ref_frame)) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[avc-h264] offset_for_ref_frame overflow from poc_cycle_length\n"));
return -1;
}
for (i = 0; i < sps->poc_cycle_length; i++)
sps->offset_for_ref_frame[i] = gf_bs_read_se_log_idx(bs, "offset_for_ref_frame", i);
}
if (sps->poc_type > 2) {
return -1;
}
sps->max_num_ref_frames = gf_bs_read_ue_log(bs, "max_num_ref_frames");
sps->gaps_in_frame_num_value_allowed_flag = gf_bs_read_int_log(bs, 1, "gaps_in_frame_num_value_allowed_flag");
mb_width = gf_bs_read_ue_log(bs, "pic_width_in_mbs_minus1") + 1;
mb_height = gf_bs_read_ue_log(bs, "pic_height_in_map_units_minus1") + 1;
sps->frame_mbs_only_flag = gf_bs_read_int_log(bs, 1, "frame_mbs_only_flag");
sps->width = mb_width * 16;
sps->height = (2 - sps->frame_mbs_only_flag) * mb_height * 16;
if (!sps->frame_mbs_only_flag) sps->mb_adaptive_frame_field_flag = gf_bs_read_int_log(bs, 1, "mb_adaptive_frame_field_flag");
gf_bs_read_int_log(bs, 1, "direct_8x8_inference_flag");
if (gf_bs_read_int_log(bs, 1, "frame_cropping_flag")) {
int CropUnitX, CropUnitY, SubWidthC = -1, SubHeightC = -1;
if (chroma_format_idc == 1) {
SubWidthC = 2; SubHeightC = 2;
}
else if (chroma_format_idc == 2) {
SubWidthC = 2; SubHeightC = 1;
}
else if ((chroma_format_idc == 3) && (separate_colour_plane_flag == 0)) {
SubWidthC = 1; SubHeightC = 1;
}
if (sps->ChromaArrayType == 0) {
assert(SubWidthC == -1);
CropUnitX = 1;
CropUnitY = 2 - sps->frame_mbs_only_flag;
}
else {
CropUnitX = SubWidthC;
CropUnitY = SubHeightC * (2 - sps->frame_mbs_only_flag);
}
cl = gf_bs_read_ue_log(bs, "frame_crop_left_offset");
cr = gf_bs_read_ue_log(bs, "frame_crop_right_offset");
ct = gf_bs_read_ue_log(bs, "frame_crop_top_offset");
cb = gf_bs_read_ue_log(bs, "frame_crop_bottom_offset");
sps->width -= CropUnitX * (cl + cr);
sps->height -= CropUnitY * (ct + cb);
cl *= CropUnitX;
cr *= CropUnitX;
ct *= CropUnitY;
cb *= CropUnitY;
}
sps->crop.left = cl;
sps->crop.right = cr;
sps->crop.top = ct;
sps->crop.bottom = cb;
if (vui_flag_pos) {
*vui_flag_pos = (u32)gf_bs_get_bit_offset(bs);
}
/*vui_parameters_present_flag*/
sps->vui_parameters_present_flag = gf_bs_read_int_log(bs, 1, "vui_parameters_present_flag");
if (sps->vui_parameters_present_flag) {
sps->vui.aspect_ratio_info_present_flag = gf_bs_read_int_log(bs, 1, "aspect_ratio_info_present_flag");
if (sps->vui.aspect_ratio_info_present_flag) {
s32 aspect_ratio_idc = gf_bs_read_int_log(bs, 8, "aspect_ratio_idc");
if (aspect_ratio_idc == 255) {
sps->vui.par_num = gf_bs_read_int_log(bs, 16, "aspect_ratio_num");
sps->vui.par_den = gf_bs_read_int_log(bs, 16, "aspect_ratio_den");
}
else if (aspect_ratio_idc < GF_ARRAY_LENGTH(avc_hevc_sar) ) {
sps->vui.par_num = avc_hevc_sar[aspect_ratio_idc].w;
sps->vui.par_den = avc_hevc_sar[aspect_ratio_idc].h;
}
else {
GF_LOG(GF_LOG_WARNING, GF_LOG_CODING, ("[avc-h264] Unknown aspect_ratio_idc: your video may have a wrong aspect ratio. Contact the GPAC team!\n"));
}
}
sps->vui.overscan_info_present_flag = gf_bs_read_int_log(bs, 1, "overscan_info_present_flag");
if (sps->vui.overscan_info_present_flag)
gf_bs_read_int_log(bs, 1, "overscan_appropriate_flag");
/* default values */
sps->vui.video_format = 5;
sps->vui.colour_primaries = 2;
sps->vui.transfer_characteristics = 2;
sps->vui.matrix_coefficients = 2;
/* now read values if possible */
sps->vui.video_signal_type_present_flag = gf_bs_read_int_log(bs, 1, "video_signal_type_present_flag");
if (sps->vui.video_signal_type_present_flag) {
sps->vui.video_format = gf_bs_read_int_log(bs, 3, "video_format");
sps->vui.video_full_range_flag = gf_bs_read_int_log(bs, 1, "video_full_range_flag");
sps->vui.colour_description_present_flag = gf_bs_read_int_log(bs, 1, "colour_description_present_flag");
if (sps->vui.colour_description_present_flag) {
sps->vui.colour_primaries = gf_bs_read_int_log(bs, 8, "colour_primaries");
sps->vui.transfer_characteristics = gf_bs_read_int_log(bs, 8, "transfer_characteristics");
sps->vui.matrix_coefficients = gf_bs_read_int_log(bs, 8, "matrix_coefficients");
}
}
if (gf_bs_read_int_log(bs, 1, "chroma_location_info_present_flag")) {
gf_bs_read_ue_log(bs, "chroma_sample_location_type_top_field");
gf_bs_read_ue_log(bs, "chroma_sample_location_type_bottom_field");
}
sps->vui.timing_info_present_flag = gf_bs_read_int_log(bs, 1, "timing_info_present_flag");
if (sps->vui.timing_info_present_flag) {
sps->vui.num_units_in_tick = gf_bs_read_int_log(bs, 32, "num_units_in_tick");
sps->vui.time_scale = gf_bs_read_int_log(bs, 32, "time_scale");
sps->vui.fixed_frame_rate_flag = gf_bs_read_int_log(bs, 1, "fixed_frame_rate_flag");
}
sps->vui.nal_hrd_parameters_present_flag = gf_bs_read_int_log(bs, 1, "nal_hrd_parameters_present_flag");
if (sps->vui.nal_hrd_parameters_present_flag)
avc_parse_hrd_parameters(bs, &sps->vui.hrd);
sps->vui.vcl_hrd_parameters_present_flag = gf_bs_read_int_log(bs, 1, "vcl_hrd_parameters_present_flag");
if (sps->vui.vcl_hrd_parameters_present_flag)
avc_parse_hrd_parameters(bs, &sps->vui.hrd);
if (sps->vui.nal_hrd_parameters_present_flag || sps->vui.vcl_hrd_parameters_present_flag)
sps->vui.low_delay_hrd_flag = gf_bs_read_int_log(bs, 1, "low_delay_hrd_flag");
sps->vui.pic_struct_present_flag = gf_bs_read_int_log(bs, 1, "pic_struct_present_flag");
}
/*end of seq_parameter_set_data*/
if (subseq_sps) {
if ((profile_idc == 83) || (profile_idc == 86)) {
u8 extended_spatial_scalability_idc;
/*parsing seq_parameter_set_svc_extension*/
gf_bs_read_int_log(bs, 1, "inter_layer_deblocking_filter_control_present_flag");
extended_spatial_scalability_idc = gf_bs_read_int_log(bs, 2, "extended_spatial_scalability_idc");
if (sps->ChromaArrayType == 1 || sps->ChromaArrayType == 2) {
gf_bs_read_int_log(bs, 1, "chroma_phase_x_plus1_flag");
}
if (sps->ChromaArrayType == 1) {
gf_bs_read_int_log(bs, 2, "chroma_phase_y_plus1");
}
if (extended_spatial_scalability_idc == 1) {
if (sps->ChromaArrayType > 0) {
gf_bs_read_int_log(bs, 1, "seq_ref_layer_chroma_phase_x_plus1_flag");
gf_bs_read_int_log(bs, 2, "seq_ref_layer_chroma_phase_y_plus1");
}
gf_bs_read_se_log(bs, "seq_scaled_ref_layer_left_offset");
gf_bs_read_se_log(bs, "seq_scaled_ref_layer_top_offset");
gf_bs_read_se_log(bs, "seq_scaled_ref_layer_right_offset");
gf_bs_read_se_log(bs, "seq_scaled_ref_layer_bottom_offset");
}
if (gf_bs_read_int_log(bs, 1, "seq_tcoeff_level_prediction_flag")) {
gf_bs_read_int_log(bs, 1, "adaptive_tcoeff_level_prediction_flag");
}
gf_bs_read_int_log(bs, 1, "slice_header_restriction_flag");
if (gf_bs_read_int_log(bs, 1, "svc_vui_parameters_present")) {
u32 vui_ext_num_entries_minus1 = gf_bs_read_ue_log(bs, "vui_ext_num_entries_minus1");
for (i = 0; i <= vui_ext_num_entries_minus1; i++) {
u8 vui_ext_nal_hrd_parameters_present_flag, vui_ext_vcl_hrd_parameters_present_flag, vui_ext_timing_info_present_flag;
gf_bs_read_int_log(bs, 3, "vui_ext_dependency_id");
gf_bs_read_int_log(bs, 4, "vui_ext_quality_id");
gf_bs_read_int_log(bs, 3, "vui_ext_temporal_id");
vui_ext_timing_info_present_flag = gf_bs_read_int_log(bs, 1, "vui_ext_timing_info_present_flag");
if (vui_ext_timing_info_present_flag) {
gf_bs_read_int_log(bs, 32, "vui_ext_num_units_in_tick");
gf_bs_read_int_log(bs, 32, "vui_ext_time_scale");
gf_bs_read_int_log(bs, 1, "vui_ext_fixed_frame_rate_flag");
}
vui_ext_nal_hrd_parameters_present_flag = gf_bs_read_int_log(bs, 1, "vui_ext_nal_hrd_parameters_present_flag");
if (vui_ext_nal_hrd_parameters_present_flag) {
//hrd_parameters( )
}
vui_ext_vcl_hrd_parameters_present_flag = gf_bs_read_int_log(bs, 1, "vui_ext_vcl_hrd_parameters_present_flag");
if (vui_ext_vcl_hrd_parameters_present_flag) {
//hrd_parameters( )
}
if (vui_ext_nal_hrd_parameters_present_flag || vui_ext_vcl_hrd_parameters_present_flag) {
gf_bs_read_int_log(bs, 1, "vui_ext_low_delay_hrd_flag");
}
gf_bs_read_int_log(bs, 1, "vui_ext_pic_struct_present_flag");
}
}
}
else if ((profile_idc == 118) || (profile_idc == 128)) {
GF_LOG(GF_LOG_INFO, GF_LOG_CODING, ("[avc-h264] MVC parsing not implemented - skipping parsing end of Subset SPS\n"));
return sps_id;
}
if (gf_bs_read_int_log(bs, 1, "additional_extension2")) {
GF_LOG(GF_LOG_WARNING, GF_LOG_CODING, ("[avc-h264] skipping parsing end of Subset SPS (additional_extension2)\n"));
return sps_id;
}
}
return sps_id;
} | 2038 | True | 1 |
CVE-2021-30014 | 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/gpac/gpac/issues/1721', 'name': 'https://github.com/gpac/gpac/issues/1721', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'name': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-190'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'There is a integer overflow in media_tools/av_parsers.c in the hevc_parse_slice_segment function in GPAC 1.0.1 which results in a crash.'}] | 2021-04-21T19:21Z | 2021-04-19T20:15Z | Integer Overflow or Wraparound | The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | An integer overflow or wraparound occurs when an integer value is incremented to a value that is too large to store in the associated representation. When this occurs, the value may wrap to become a very small or negative number. While this may be intended behavior in circumstances that rely on wrapping, it can have security consequences if the wrap is unexpected. This is especially the case if the integer overflow can be triggered using user-supplied inputs. This becomes security-critical when the result is used to control looping, make a security decision, or determine the offset or size in behaviors such as memory allocation, copying, concatenation, etc.
| https://cwe.mitre.org/data/definitions/190.html | 0 | jeanlf | 2021-03-29 09:34:02+02:00 | add safety in avc/hevc/vvc sps/pps/vps ID check - cf #1720 #1721 #1722 | 51cdb67ff7c5f1242ac58c5aa603ceaf1793b788 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_hevc_read_pps_bs_internal | gf_hevc_read_pps_bs_internal( GF_BitStream * bs , HEVCState * hevc) | ['bs', 'hevc'] | static s32 gf_hevc_read_pps_bs_internal(GF_BitStream *bs, HEVCState *hevc)
{
u32 i;
s32 pps_id;
HEVC_PPS *pps;
//NAL header already read
pps_id = gf_bs_read_ue_log(bs, "pps_id");
if ((pps_id < 0) || (pps_id >= 64)) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[HEVC] wrong PPS ID %d in PPS\n", pps_id));
return -1;
}
pps = &hevc->pps[pps_id];
if (!pps->state) {
pps->id = pps_id;
pps->state = 1;
}
pps->sps_id = gf_bs_read_ue_log(bs, "sps_id");
if (pps->sps_id >= 16) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[HEVC] wrong SPS ID %d in PPS\n", pps->sps_id));
pps->sps_id=0;
return -1;
}
hevc->sps_active_idx = pps->sps_id; /*set active sps*/
pps->dependent_slice_segments_enabled_flag = gf_bs_read_int_log(bs, 1, "dependent_slice_segments_enabled_flag");
pps->output_flag_present_flag = gf_bs_read_int_log(bs, 1, "output_flag_present_flag");
pps->num_extra_slice_header_bits = gf_bs_read_int_log(bs, 3, "num_extra_slice_header_bits");
pps->sign_data_hiding_flag = gf_bs_read_int_log(bs, 1, "sign_data_hiding_flag");
pps->cabac_init_present_flag = gf_bs_read_int_log(bs, 1, "cabac_init_present_flag");
pps->num_ref_idx_l0_default_active = 1 + gf_bs_read_ue_log(bs, "num_ref_idx_l0_default_active");
pps->num_ref_idx_l1_default_active = 1 + gf_bs_read_ue_log(bs, "num_ref_idx_l1_default_active");
pps->pic_init_qp_minus26 = gf_bs_read_se_log(bs, "pic_init_qp_minus26");
pps->constrained_intra_pred_flag = gf_bs_read_int_log(bs, 1, "constrained_intra_pred_flag");
pps->transform_skip_enabled_flag = gf_bs_read_int_log(bs, 1, "transform_skip_enabled_flag");
if ((pps->cu_qp_delta_enabled_flag = gf_bs_read_int_log(bs, 1, "cu_qp_delta_enabled_flag")))
pps->diff_cu_qp_delta_depth = gf_bs_read_ue_log(bs, "diff_cu_qp_delta_depth");
pps->pic_cb_qp_offset = gf_bs_read_se_log(bs, "pic_cb_qp_offset");
pps->pic_cr_qp_offset = gf_bs_read_se_log(bs, "pic_cr_qp_offset");
pps->slice_chroma_qp_offsets_present_flag = gf_bs_read_int_log(bs, 1, "slice_chroma_qp_offsets_present_flag");
pps->weighted_pred_flag = gf_bs_read_int_log(bs, 1, "weighted_pred_flag");
pps->weighted_bipred_flag = gf_bs_read_int_log(bs, 1, "weighted_bipred_flag");
pps->transquant_bypass_enable_flag = gf_bs_read_int_log(bs, 1, "transquant_bypass_enable_flag");
pps->tiles_enabled_flag = gf_bs_read_int_log(bs, 1, "tiles_enabled_flag");
pps->entropy_coding_sync_enabled_flag = gf_bs_read_int_log(bs, 1, "entropy_coding_sync_enabled_flag");
if (pps->tiles_enabled_flag) {
pps->num_tile_columns = 1 + gf_bs_read_ue_log(bs, "num_tile_columns_minus1");
pps->num_tile_rows = 1 + gf_bs_read_ue_log(bs, "num_tile_rows_minus1");
pps->uniform_spacing_flag = gf_bs_read_int_log(bs, 1, "uniform_spacing_flag");
if (!pps->uniform_spacing_flag) {
for (i = 0; i < pps->num_tile_columns - 1; i++) {
pps->column_width[i] = 1 + gf_bs_read_ue_log_idx(bs, "column_width_minus1", i);
}
for (i = 0; i < pps->num_tile_rows - 1; i++) {
pps->row_height[i] = 1 + gf_bs_read_ue_log_idx(bs, "row_height_minus1", i);
}
}
pps->loop_filter_across_tiles_enabled_flag = gf_bs_read_int_log(bs, 1, "loop_filter_across_tiles_enabled_flag");
}
pps->loop_filter_across_slices_enabled_flag = gf_bs_read_int_log(bs, 1, "loop_filter_across_slices_enabled_flag");
if ((pps->deblocking_filter_control_present_flag = gf_bs_read_int_log(bs, 1, "deblocking_filter_control_present_flag"))) {
pps->deblocking_filter_override_enabled_flag = gf_bs_read_int_log(bs, 1, "deblocking_filter_override_enabled_flag");
if (! (pps->pic_disable_deblocking_filter_flag = gf_bs_read_int_log(bs, 1, "pic_disable_deblocking_filter_flag"))) {
pps->beta_offset_div2 = gf_bs_read_se_log(bs, "beta_offset_div2");
pps->tc_offset_div2 = gf_bs_read_se_log(bs, "tc_offset_div2");
}
}
if ((pps->pic_scaling_list_data_present_flag = gf_bs_read_int_log(bs, 1, "pic_scaling_list_data_present_flag"))) {
hevc_scaling_list_data(bs);
}
pps->lists_modification_present_flag = gf_bs_read_int_log(bs, 1, "lists_modification_present_flag");
pps->log2_parallel_merge_level_minus2 = gf_bs_read_ue_log(bs, "log2_parallel_merge_level_minus2");
pps->slice_segment_header_extension_present_flag = gf_bs_read_int_log(bs, 1, "slice_segment_header_extension_present_flag");
if (gf_bs_read_int_log(bs, 1, "pps_extension_flag")) {
#if 0
while (gf_bs_available(bs)) {
/*pps_extension_data_flag */ gf_bs_read_int(bs, 1);
}
#endif
}
return pps_id;
} | 728 | True | 1 |
CVE-2021-30020 | 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/gpac/gpac/issues/1722', 'name': 'https://github.com/gpac/gpac/issues/1722', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'name': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-787'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'In the function gf_hevc_read_pps_bs_internal function in media_tools/av_parsers.c in GPAC 1.0.1 there is a loop, which with crafted file, pps->num_tile_columns may be larger than sizeof(pps->column_width), which results in a heap overflow in the loop.'}] | 2021-04-21T19:02Z | 2021-04-19T20: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 | jeanlf | 2021-03-29 09:34:02+02:00 | add safety in avc/hevc/vvc sps/pps/vps ID check - cf #1720 #1721 #1722 | 51cdb67ff7c5f1242ac58c5aa603ceaf1793b788 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_hevc_read_pps_bs_internal | gf_hevc_read_pps_bs_internal( GF_BitStream * bs , HEVCState * hevc) | ['bs', 'hevc'] | static s32 gf_hevc_read_pps_bs_internal(GF_BitStream *bs, HEVCState *hevc)
{
u32 i;
s32 pps_id;
HEVC_PPS *pps;
//NAL header already read
pps_id = gf_bs_read_ue_log(bs, "pps_id");
if ((pps_id < 0) || (pps_id >= 64)) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[HEVC] wrong PPS ID %d in PPS\n", pps_id));
return -1;
}
pps = &hevc->pps[pps_id];
if (!pps->state) {
pps->id = pps_id;
pps->state = 1;
}
pps->sps_id = gf_bs_read_ue_log(bs, "sps_id");
if (pps->sps_id >= 16) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[HEVC] wrong SPS ID %d in PPS\n", pps->sps_id));
pps->sps_id=0;
return -1;
}
hevc->sps_active_idx = pps->sps_id; /*set active sps*/
pps->dependent_slice_segments_enabled_flag = gf_bs_read_int_log(bs, 1, "dependent_slice_segments_enabled_flag");
pps->output_flag_present_flag = gf_bs_read_int_log(bs, 1, "output_flag_present_flag");
pps->num_extra_slice_header_bits = gf_bs_read_int_log(bs, 3, "num_extra_slice_header_bits");
pps->sign_data_hiding_flag = gf_bs_read_int_log(bs, 1, "sign_data_hiding_flag");
pps->cabac_init_present_flag = gf_bs_read_int_log(bs, 1, "cabac_init_present_flag");
pps->num_ref_idx_l0_default_active = 1 + gf_bs_read_ue_log(bs, "num_ref_idx_l0_default_active");
pps->num_ref_idx_l1_default_active = 1 + gf_bs_read_ue_log(bs, "num_ref_idx_l1_default_active");
pps->pic_init_qp_minus26 = gf_bs_read_se_log(bs, "pic_init_qp_minus26");
pps->constrained_intra_pred_flag = gf_bs_read_int_log(bs, 1, "constrained_intra_pred_flag");
pps->transform_skip_enabled_flag = gf_bs_read_int_log(bs, 1, "transform_skip_enabled_flag");
if ((pps->cu_qp_delta_enabled_flag = gf_bs_read_int_log(bs, 1, "cu_qp_delta_enabled_flag")))
pps->diff_cu_qp_delta_depth = gf_bs_read_ue_log(bs, "diff_cu_qp_delta_depth");
pps->pic_cb_qp_offset = gf_bs_read_se_log(bs, "pic_cb_qp_offset");
pps->pic_cr_qp_offset = gf_bs_read_se_log(bs, "pic_cr_qp_offset");
pps->slice_chroma_qp_offsets_present_flag = gf_bs_read_int_log(bs, 1, "slice_chroma_qp_offsets_present_flag");
pps->weighted_pred_flag = gf_bs_read_int_log(bs, 1, "weighted_pred_flag");
pps->weighted_bipred_flag = gf_bs_read_int_log(bs, 1, "weighted_bipred_flag");
pps->transquant_bypass_enable_flag = gf_bs_read_int_log(bs, 1, "transquant_bypass_enable_flag");
pps->tiles_enabled_flag = gf_bs_read_int_log(bs, 1, "tiles_enabled_flag");
pps->entropy_coding_sync_enabled_flag = gf_bs_read_int_log(bs, 1, "entropy_coding_sync_enabled_flag");
if (pps->tiles_enabled_flag) {
pps->num_tile_columns = 1 + gf_bs_read_ue_log(bs, "num_tile_columns_minus1");
pps->num_tile_rows = 1 + gf_bs_read_ue_log(bs, "num_tile_rows_minus1");
pps->uniform_spacing_flag = gf_bs_read_int_log(bs, 1, "uniform_spacing_flag");
if (!pps->uniform_spacing_flag) {
for (i = 0; i < pps->num_tile_columns - 1; i++) {
pps->column_width[i] = 1 + gf_bs_read_ue_log_idx(bs, "column_width_minus1", i);
}
for (i = 0; i < pps->num_tile_rows - 1; i++) {
pps->row_height[i] = 1 + gf_bs_read_ue_log_idx(bs, "row_height_minus1", i);
}
}
pps->loop_filter_across_tiles_enabled_flag = gf_bs_read_int_log(bs, 1, "loop_filter_across_tiles_enabled_flag");
}
pps->loop_filter_across_slices_enabled_flag = gf_bs_read_int_log(bs, 1, "loop_filter_across_slices_enabled_flag");
if ((pps->deblocking_filter_control_present_flag = gf_bs_read_int_log(bs, 1, "deblocking_filter_control_present_flag"))) {
pps->deblocking_filter_override_enabled_flag = gf_bs_read_int_log(bs, 1, "deblocking_filter_override_enabled_flag");
if (! (pps->pic_disable_deblocking_filter_flag = gf_bs_read_int_log(bs, 1, "pic_disable_deblocking_filter_flag"))) {
pps->beta_offset_div2 = gf_bs_read_se_log(bs, "beta_offset_div2");
pps->tc_offset_div2 = gf_bs_read_se_log(bs, "tc_offset_div2");
}
}
if ((pps->pic_scaling_list_data_present_flag = gf_bs_read_int_log(bs, 1, "pic_scaling_list_data_present_flag"))) {
hevc_scaling_list_data(bs);
}
pps->lists_modification_present_flag = gf_bs_read_int_log(bs, 1, "lists_modification_present_flag");
pps->log2_parallel_merge_level_minus2 = gf_bs_read_ue_log(bs, "log2_parallel_merge_level_minus2");
pps->slice_segment_header_extension_present_flag = gf_bs_read_int_log(bs, 1, "slice_segment_header_extension_present_flag");
if (gf_bs_read_int_log(bs, 1, "pps_extension_flag")) {
#if 0
while (gf_bs_available(bs)) {
/*pps_extension_data_flag */ gf_bs_read_int(bs, 1);
}
#endif
}
return pps_id;
} | 728 | True | 1 |
CVE-2021-30022 | 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/gpac/gpac/issues/1720', 'name': 'https://github.com/gpac/gpac/issues/1720', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'name': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-190'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'There is a integer overflow in media_tools/av_parsers.c in the gf_avc_read_pps_bs_internal in GPAC 1.0.1. pps_id may be a negative number, so it will not return. However, avc->pps only has 255 unit, so there is an overflow, which results a crash.'}] | 2021-04-21T19:03Z | 2021-04-19T20:15Z | Integer Overflow or Wraparound | The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | An integer overflow or wraparound occurs when an integer value is incremented to a value that is too large to store in the associated representation. When this occurs, the value may wrap to become a very small or negative number. While this may be intended behavior in circumstances that rely on wrapping, it can have security consequences if the wrap is unexpected. This is especially the case if the integer overflow can be triggered using user-supplied inputs. This becomes security-critical when the result is used to control looping, make a security decision, or determine the offset or size in behaviors such as memory allocation, copying, concatenation, etc.
| https://cwe.mitre.org/data/definitions/190.html | 0 | jeanlf | 2021-03-29 09:34:02+02:00 | add safety in avc/hevc/vvc sps/pps/vps ID check - cf #1720 #1721 #1722 | 51cdb67ff7c5f1242ac58c5aa603ceaf1793b788 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_hevc_read_pps_bs_internal | gf_hevc_read_pps_bs_internal( GF_BitStream * bs , HEVCState * hevc) | ['bs', 'hevc'] | static s32 gf_hevc_read_pps_bs_internal(GF_BitStream *bs, HEVCState *hevc)
{
u32 i;
s32 pps_id;
HEVC_PPS *pps;
//NAL header already read
pps_id = gf_bs_read_ue_log(bs, "pps_id");
if ((pps_id < 0) || (pps_id >= 64)) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[HEVC] wrong PPS ID %d in PPS\n", pps_id));
return -1;
}
pps = &hevc->pps[pps_id];
if (!pps->state) {
pps->id = pps_id;
pps->state = 1;
}
pps->sps_id = gf_bs_read_ue_log(bs, "sps_id");
if (pps->sps_id >= 16) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[HEVC] wrong SPS ID %d in PPS\n", pps->sps_id));
pps->sps_id=0;
return -1;
}
hevc->sps_active_idx = pps->sps_id; /*set active sps*/
pps->dependent_slice_segments_enabled_flag = gf_bs_read_int_log(bs, 1, "dependent_slice_segments_enabled_flag");
pps->output_flag_present_flag = gf_bs_read_int_log(bs, 1, "output_flag_present_flag");
pps->num_extra_slice_header_bits = gf_bs_read_int_log(bs, 3, "num_extra_slice_header_bits");
pps->sign_data_hiding_flag = gf_bs_read_int_log(bs, 1, "sign_data_hiding_flag");
pps->cabac_init_present_flag = gf_bs_read_int_log(bs, 1, "cabac_init_present_flag");
pps->num_ref_idx_l0_default_active = 1 + gf_bs_read_ue_log(bs, "num_ref_idx_l0_default_active");
pps->num_ref_idx_l1_default_active = 1 + gf_bs_read_ue_log(bs, "num_ref_idx_l1_default_active");
pps->pic_init_qp_minus26 = gf_bs_read_se_log(bs, "pic_init_qp_minus26");
pps->constrained_intra_pred_flag = gf_bs_read_int_log(bs, 1, "constrained_intra_pred_flag");
pps->transform_skip_enabled_flag = gf_bs_read_int_log(bs, 1, "transform_skip_enabled_flag");
if ((pps->cu_qp_delta_enabled_flag = gf_bs_read_int_log(bs, 1, "cu_qp_delta_enabled_flag")))
pps->diff_cu_qp_delta_depth = gf_bs_read_ue_log(bs, "diff_cu_qp_delta_depth");
pps->pic_cb_qp_offset = gf_bs_read_se_log(bs, "pic_cb_qp_offset");
pps->pic_cr_qp_offset = gf_bs_read_se_log(bs, "pic_cr_qp_offset");
pps->slice_chroma_qp_offsets_present_flag = gf_bs_read_int_log(bs, 1, "slice_chroma_qp_offsets_present_flag");
pps->weighted_pred_flag = gf_bs_read_int_log(bs, 1, "weighted_pred_flag");
pps->weighted_bipred_flag = gf_bs_read_int_log(bs, 1, "weighted_bipred_flag");
pps->transquant_bypass_enable_flag = gf_bs_read_int_log(bs, 1, "transquant_bypass_enable_flag");
pps->tiles_enabled_flag = gf_bs_read_int_log(bs, 1, "tiles_enabled_flag");
pps->entropy_coding_sync_enabled_flag = gf_bs_read_int_log(bs, 1, "entropy_coding_sync_enabled_flag");
if (pps->tiles_enabled_flag) {
pps->num_tile_columns = 1 + gf_bs_read_ue_log(bs, "num_tile_columns_minus1");
pps->num_tile_rows = 1 + gf_bs_read_ue_log(bs, "num_tile_rows_minus1");
pps->uniform_spacing_flag = gf_bs_read_int_log(bs, 1, "uniform_spacing_flag");
if (!pps->uniform_spacing_flag) {
for (i = 0; i < pps->num_tile_columns - 1; i++) {
pps->column_width[i] = 1 + gf_bs_read_ue_log_idx(bs, "column_width_minus1", i);
}
for (i = 0; i < pps->num_tile_rows - 1; i++) {
pps->row_height[i] = 1 + gf_bs_read_ue_log_idx(bs, "row_height_minus1", i);
}
}
pps->loop_filter_across_tiles_enabled_flag = gf_bs_read_int_log(bs, 1, "loop_filter_across_tiles_enabled_flag");
}
pps->loop_filter_across_slices_enabled_flag = gf_bs_read_int_log(bs, 1, "loop_filter_across_slices_enabled_flag");
if ((pps->deblocking_filter_control_present_flag = gf_bs_read_int_log(bs, 1, "deblocking_filter_control_present_flag"))) {
pps->deblocking_filter_override_enabled_flag = gf_bs_read_int_log(bs, 1, "deblocking_filter_override_enabled_flag");
if (! (pps->pic_disable_deblocking_filter_flag = gf_bs_read_int_log(bs, 1, "pic_disable_deblocking_filter_flag"))) {
pps->beta_offset_div2 = gf_bs_read_se_log(bs, "beta_offset_div2");
pps->tc_offset_div2 = gf_bs_read_se_log(bs, "tc_offset_div2");
}
}
if ((pps->pic_scaling_list_data_present_flag = gf_bs_read_int_log(bs, 1, "pic_scaling_list_data_present_flag"))) {
hevc_scaling_list_data(bs);
}
pps->lists_modification_present_flag = gf_bs_read_int_log(bs, 1, "lists_modification_present_flag");
pps->log2_parallel_merge_level_minus2 = gf_bs_read_ue_log(bs, "log2_parallel_merge_level_minus2");
pps->slice_segment_header_extension_present_flag = gf_bs_read_int_log(bs, 1, "slice_segment_header_extension_present_flag");
if (gf_bs_read_int_log(bs, 1, "pps_extension_flag")) {
#if 0
while (gf_bs_available(bs)) {
/*pps_extension_data_flag */ gf_bs_read_int(bs, 1);
}
#endif
}
return pps_id;
} | 728 | True | 1 |
CVE-2021-30014 | 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/gpac/gpac/issues/1721', 'name': 'https://github.com/gpac/gpac/issues/1721', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'name': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-190'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'There is a integer overflow in media_tools/av_parsers.c in the hevc_parse_slice_segment function in GPAC 1.0.1 which results in a crash.'}] | 2021-04-21T19:21Z | 2021-04-19T20:15Z | Integer Overflow or Wraparound | The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | An integer overflow or wraparound occurs when an integer value is incremented to a value that is too large to store in the associated representation. When this occurs, the value may wrap to become a very small or negative number. While this may be intended behavior in circumstances that rely on wrapping, it can have security consequences if the wrap is unexpected. This is especially the case if the integer overflow can be triggered using user-supplied inputs. This becomes security-critical when the result is used to control looping, make a security decision, or determine the offset or size in behaviors such as memory allocation, copying, concatenation, etc.
| https://cwe.mitre.org/data/definitions/190.html | 0 | jeanlf | 2021-03-29 09:34:02+02:00 | add safety in avc/hevc/vvc sps/pps/vps ID check - cf #1720 #1721 #1722 | 51cdb67ff7c5f1242ac58c5aa603ceaf1793b788 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_hevc_read_sps_bs_internal | gf_hevc_read_sps_bs_internal( GF_BitStream * bs , HEVCState * hevc , u8 layer_id , u32 * vui_flag_pos) | ['bs', 'hevc', 'layer_id', 'vui_flag_pos'] | static s32 gf_hevc_read_sps_bs_internal(GF_BitStream *bs, HEVCState *hevc, u8 layer_id, u32 *vui_flag_pos)
{
s32 vps_id, sps_id = -1;
u32 i, nb_CTUs, depth;
HEVC_SPS *sps;
HEVC_VPS *vps;
HEVC_ProfileTierLevel ptl;
Bool multiLayerExtSpsFlag;
u8 sps_ext_or_max_sub_layers_minus1, max_sub_layers_minus1;
if (vui_flag_pos) *vui_flag_pos = 0;
//nalu header already parsed
vps_id = gf_bs_read_int_log(bs, 4, "vps_id");
if (vps_id >= 16) {
return -1;
}
memset(&ptl, 0, sizeof(ptl));
max_sub_layers_minus1 = 0;
sps_ext_or_max_sub_layers_minus1 = 0;
if (layer_id == 0)
max_sub_layers_minus1 = gf_bs_read_int_log(bs, 3, "max_sub_layers_minus1");
else
sps_ext_or_max_sub_layers_minus1 = gf_bs_read_int_log(bs, 3, "sps_ext_or_max_sub_layers_minus1");
multiLayerExtSpsFlag = (layer_id != 0) && (sps_ext_or_max_sub_layers_minus1 == 7);
if (!multiLayerExtSpsFlag) {
gf_bs_read_int_log(bs, 1, "temporal_id_nesting_flag");
hevc_profile_tier_level(bs, 1, max_sub_layers_minus1, &ptl, 0);
}
sps_id = gf_bs_read_ue_log(bs, "sps_id");
if ((sps_id < 0) || (sps_id >= 16)) {
return -1;
}
sps = &hevc->sps[sps_id];
if (!sps->state) {
sps->state = 1;
sps->id = sps_id;
sps->vps_id = vps_id;
}
sps->ptl = ptl;
vps = &hevc->vps[vps_id];
sps->max_sub_layers_minus1 = 0;
sps->sps_ext_or_max_sub_layers_minus1 = 0;
/* default values */
sps->colour_primaries = 2;
sps->transfer_characteristic = 2;
sps->matrix_coeffs = 2;
//sps_rep_format_idx = 0;
if (multiLayerExtSpsFlag) {
sps->update_rep_format_flag = gf_bs_read_int_log(bs, 1, "update_rep_format_flag");
if (sps->update_rep_format_flag) {
sps->rep_format_idx = gf_bs_read_int_log(bs, 8, "rep_format_idx");
}
else {
sps->rep_format_idx = vps->rep_format_idx[layer_id];
}
sps->width = vps->rep_formats[sps->rep_format_idx].pic_width_luma_samples;
sps->height = vps->rep_formats[sps->rep_format_idx].pic_height_luma_samples;
sps->chroma_format_idc = vps->rep_formats[sps->rep_format_idx].chroma_format_idc;
sps->bit_depth_luma = vps->rep_formats[sps->rep_format_idx].bit_depth_luma;
sps->bit_depth_chroma = vps->rep_formats[sps->rep_format_idx].bit_depth_chroma;
sps->separate_colour_plane_flag = vps->rep_formats[sps->rep_format_idx].separate_colour_plane_flag;
//TODO this is crude ...
sps->ptl = vps->ext_ptl[0];
}
else {
sps->chroma_format_idc = gf_bs_read_ue_log(bs, "chroma_format_idc");
if (sps->chroma_format_idc == 3)
sps->separate_colour_plane_flag = gf_bs_read_int_log(bs, 1, "separate_colour_plane_flag");
sps->width = gf_bs_read_ue_log(bs, "width");
sps->height = gf_bs_read_ue_log(bs, "height");
if ((sps->cw_flag = gf_bs_read_int_log(bs, 1, "conformance_window_flag"))) {
u32 SubWidthC, SubHeightC;
if (sps->chroma_format_idc == 1) {
SubWidthC = SubHeightC = 2;
}
else if (sps->chroma_format_idc == 2) {
SubWidthC = 2;
SubHeightC = 1;
}
else {
SubWidthC = SubHeightC = 1;
}
sps->cw_left = gf_bs_read_ue_log(bs, "conformance_window_left");
sps->cw_right = gf_bs_read_ue_log(bs, "conformance_window_right");
sps->cw_top = gf_bs_read_ue_log(bs, "conformance_window_top");
sps->cw_bottom = gf_bs_read_ue_log(bs, "conformance_window_bottom");
sps->width -= SubWidthC * (sps->cw_left + sps->cw_right);
sps->height -= SubHeightC * (sps->cw_top + sps->cw_bottom);
}
sps->bit_depth_luma = 8 + gf_bs_read_ue_log(bs, "bit_depth_luma_minus8");
sps->bit_depth_chroma = 8 + gf_bs_read_ue_log(bs, "bit_depth_chroma_minus8");
}
sps->log2_max_pic_order_cnt_lsb = 4 + gf_bs_read_ue_log(bs, "log2_max_pic_order_cnt_lsb_minus4");
if (!multiLayerExtSpsFlag) {
sps->sub_layer_ordering_info_present_flag = gf_bs_read_int_log(bs, 1, "sub_layer_ordering_info_present_flag");
for (i = sps->sub_layer_ordering_info_present_flag ? 0 : sps->max_sub_layers_minus1; i <= sps->max_sub_layers_minus1; i++) {
gf_bs_read_ue_log_idx(bs, "max_dec_pic_buffering", i);
gf_bs_read_ue_log_idx(bs, "num_reorder_pics", i);
gf_bs_read_ue_log_idx(bs, "max_latency_increase", i);
}
}
sps->log2_min_luma_coding_block_size = 3 + gf_bs_read_ue_log(bs, "log2_min_luma_coding_block_size_minus3");
sps->log2_diff_max_min_luma_coding_block_size = gf_bs_read_ue_log(bs, "log2_diff_max_min_luma_coding_block_size");
sps->max_CU_width = (1 << (sps->log2_min_luma_coding_block_size + sps->log2_diff_max_min_luma_coding_block_size));
sps->max_CU_height = (1 << (sps->log2_min_luma_coding_block_size + sps->log2_diff_max_min_luma_coding_block_size));
sps->log2_min_transform_block_size = 2 + gf_bs_read_ue_log(bs, "log2_min_transform_block_size_minus2");
sps->log2_max_transform_block_size = sps->log2_min_transform_block_size + gf_bs_read_ue_log(bs, "log2_max_transform_block_size");
depth = 0;
sps->max_transform_hierarchy_depth_inter = gf_bs_read_ue_log(bs, "max_transform_hierarchy_depth_inter");
sps->max_transform_hierarchy_depth_intra = gf_bs_read_ue_log(bs, "max_transform_hierarchy_depth_intra");
while ((u32)(sps->max_CU_width >> sps->log2_diff_max_min_luma_coding_block_size) > (u32)(1 << (sps->log2_min_transform_block_size + depth)))
{
depth++;
}
sps->max_CU_depth = sps->log2_diff_max_min_luma_coding_block_size + depth;
nb_CTUs = ((sps->width + sps->max_CU_width - 1) / sps->max_CU_width) * ((sps->height + sps->max_CU_height - 1) / sps->max_CU_height);
sps->bitsSliceSegmentAddress = 0;
while (nb_CTUs > (u32)(1 << sps->bitsSliceSegmentAddress)) {
sps->bitsSliceSegmentAddress++;
}
sps->scaling_list_enable_flag = gf_bs_read_int_log(bs, 1, "scaling_list_enable_flag");
if (sps->scaling_list_enable_flag) {
sps->infer_scaling_list_flag = 0;
sps->scaling_list_ref_layer_id = 0;
if (multiLayerExtSpsFlag) {
sps->infer_scaling_list_flag = gf_bs_read_int_log(bs, 1, "infer_scaling_list_flag");
}
if (sps->infer_scaling_list_flag) {
sps->scaling_list_ref_layer_id = gf_bs_read_int_log(bs, 6, "scaling_list_ref_layer_id");
}
else {
sps->scaling_list_data_present_flag = gf_bs_read_int_log(bs, 1, "scaling_list_data_present_flag");
if (sps->scaling_list_data_present_flag) {
hevc_scaling_list_data(bs);
}
}
}
sps->asymmetric_motion_partitions_enabled_flag = gf_bs_read_int_log(bs, 1, "asymmetric_motion_partitions_enabled_flag");
sps->sample_adaptive_offset_enabled_flag = gf_bs_read_int_log(bs, 1, "sample_adaptive_offset_enabled_flag");
if ( (sps->pcm_enabled_flag = gf_bs_read_int_log(bs, 1, "pcm_enabled_flag")) ) {
sps->pcm_sample_bit_depth_luma_minus1 = gf_bs_read_int_log(bs, 4, "pcm_sample_bit_depth_luma_minus1");
sps->pcm_sample_bit_depth_chroma_minus1 = gf_bs_read_int_log(bs, 4, "pcm_sample_bit_depth_chroma_minus1");
sps->log2_min_pcm_luma_coding_block_size_minus3 = gf_bs_read_ue_log(bs, "log2_min_pcm_luma_coding_block_size_minus3");
sps->log2_diff_max_min_pcm_luma_coding_block_size = gf_bs_read_ue_log(bs, "log2_diff_max_min_pcm_luma_coding_block_size");
sps->pcm_loop_filter_disable_flag = gf_bs_read_int_log(bs, 1, "pcm_loop_filter_disable_flag");
}
sps->num_short_term_ref_pic_sets = gf_bs_read_ue_log(bs, "num_short_term_ref_pic_sets");
if (sps->num_short_term_ref_pic_sets > 64) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[HEVC] Invalid number of short term reference picture sets %d\n", sps->num_short_term_ref_pic_sets));
return -1;
}
for (i = 0; i < sps->num_short_term_ref_pic_sets; i++) {
Bool ret = hevc_parse_short_term_ref_pic_set(bs, sps, i);
/*cannot parse short_term_ref_pic_set, skip VUI parsing*/
if (!ret) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[HEVC] Invalid short_term_ref_pic_set\n"));
return -1;
}
}
sps->long_term_ref_pics_present_flag = gf_bs_read_int_log(bs, 1, "long_term_ref_pics_present_flag");
if (sps->long_term_ref_pics_present_flag) {
sps->num_long_term_ref_pic_sps = gf_bs_read_ue_log(bs, "num_long_term_ref_pic_sps");
for (i = 0; i < sps->num_long_term_ref_pic_sps; i++) {
gf_bs_read_int_log_idx(bs, sps->log2_max_pic_order_cnt_lsb, "lt_ref_pic_poc_lsb_sps", i);
gf_bs_read_int_log_idx(bs, 1, "used_by_curr_pic_lt_sps_flag", i);
}
}
sps->temporal_mvp_enable_flag = gf_bs_read_int_log(bs, 1, "temporal_mvp_enable_flag");
sps->strong_intra_smoothing_enable_flag = gf_bs_read_int_log(bs, 1, "strong_intra_smoothing_enable_flag");
if (vui_flag_pos)
*vui_flag_pos = (u32)gf_bs_get_bit_offset(bs);
if ((sps->vui_parameters_present_flag = gf_bs_read_int_log(bs, 1, "vui_parameters_present_flag")) ) {
sps->aspect_ratio_info_present_flag = gf_bs_read_int_log(bs, 1, "aspect_ratio_info_present_flag");
if (sps->aspect_ratio_info_present_flag) {
sps->sar_idc = gf_bs_read_int_log(bs, 8, "aspect_ratio_idc");
if (sps->sar_idc == 255) {
sps->sar_width = gf_bs_read_int_log(bs, 16, "aspect_ratio_width");
sps->sar_height = gf_bs_read_int_log(bs, 16, "aspect_ratio_height");
}
else if (sps->sar_idc < 17) {
sps->sar_width = hevc_sar[sps->sar_idc].w;
sps->sar_height = hevc_sar[sps->sar_idc].h;
}
}
if ((sps->overscan_info_present = gf_bs_read_int_log(bs, 1, "overscan_info_present")))
sps->overscan_appropriate = gf_bs_read_int_log(bs, 1, "overscan_appropriate");
sps->video_signal_type_present_flag = gf_bs_read_int_log(bs, 1, "video_signal_type_present_flag");
if (sps->video_signal_type_present_flag) {
sps->video_format = gf_bs_read_int_log(bs, 3, "video_format");
sps->video_full_range_flag = gf_bs_read_int_log(bs, 1, "video_full_range_flag");
if ((sps->colour_description_present_flag = gf_bs_read_int_log(bs, 1, "colour_description_present_flag"))) {
sps->colour_primaries = gf_bs_read_int_log(bs, 8, "colour_primaries");
sps->transfer_characteristic = gf_bs_read_int_log(bs, 8, "transfer_characteristic");
sps->matrix_coeffs = gf_bs_read_int_log(bs, 8, "matrix_coefficients");
}
}
if ((sps->chroma_loc_info_present_flag = gf_bs_read_int_log(bs, 1, "chroma_loc_info_present_flag"))) {
sps->chroma_sample_loc_type_top_field = gf_bs_read_ue_log(bs, "chroma_sample_loc_type_top_field");
sps->chroma_sample_loc_type_bottom_field = gf_bs_read_ue_log(bs, "chroma_sample_loc_type_bottom_field");
}
sps->neutra_chroma_indication_flag = gf_bs_read_int_log(bs, 1, "neutra_chroma_indication_flag");
sps->field_seq_flag = gf_bs_read_int_log(bs, 1, "field_seq_flag");
sps->frame_field_info_present_flag = gf_bs_read_int_log(bs, 1, "frame_field_info_present_flag");
if ((sps->default_display_window_flag = gf_bs_read_int_log(bs, 1, "default_display_window_flag"))) {
sps->left_offset = gf_bs_read_ue_log(bs, "display_window_left_offset");
sps->right_offset = gf_bs_read_ue_log(bs, "display_window_right_offset");
sps->top_offset = gf_bs_read_ue_log(bs, "display_window_top_offset");
sps->bottom_offset = gf_bs_read_ue_log(bs, "display_window_bottom_offset");
}
sps->has_timing_info = gf_bs_read_int_log(bs, 1, "has_timing_info");
if (sps->has_timing_info) {
sps->num_units_in_tick = gf_bs_read_int_log(bs, 32, "num_units_in_tick");
sps->time_scale = gf_bs_read_int_log(bs, 32, "time_scale");
sps->poc_proportional_to_timing_flag = gf_bs_read_int_log(bs, 1, "poc_proportional_to_timing_flag");
if (sps->poc_proportional_to_timing_flag)
sps->num_ticks_poc_diff_one_minus1 = gf_bs_read_ue_log(bs, "num_ticks_poc_diff_one_minus1");
if ((sps->hrd_parameters_present_flag = gf_bs_read_int_log(bs, 1, "hrd_parameters_present_flag"))) {
// GF_LOG(GF_LOG_INFO, GF_LOG_CODING, ("[HEVC] HRD param parsing not implemented\n"));
return sps_id;
}
}
if (gf_bs_read_int_log(bs, 1, "bitstream_restriction_flag")) {
gf_bs_read_int_log(bs, 1, "tiles_fixed_structure_flag");
gf_bs_read_int_log(bs, 1, "motion_vectors_over_pic_boundaries_flag");
gf_bs_read_int_log(bs, 1, "restricted_ref_pic_lists_flag");
gf_bs_read_ue_log(bs, "min_spatial_segmentation_idc");
gf_bs_read_ue_log(bs, "max_bytes_per_pic_denom");
gf_bs_read_ue_log(bs, "max_bits_per_min_cu_denom");
gf_bs_read_ue_log(bs, "log2_max_mv_length_horizontal");
gf_bs_read_ue_log(bs, "log2_max_mv_length_vertical");
}
}
if (gf_bs_read_int_log(bs, 1, "sps_extension_flag")) {
#if 0
while (gf_bs_available(bs)) {
/*sps_extension_data_flag */ gf_bs_read_int(bs, 1);
}
#endif
}
return sps_id;
} | 2011 | True | 1 |
CVE-2021-30020 | 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/gpac/gpac/issues/1722', 'name': 'https://github.com/gpac/gpac/issues/1722', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'name': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-787'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'In the function gf_hevc_read_pps_bs_internal function in media_tools/av_parsers.c in GPAC 1.0.1 there is a loop, which with crafted file, pps->num_tile_columns may be larger than sizeof(pps->column_width), which results in a heap overflow in the loop.'}] | 2021-04-21T19:02Z | 2021-04-19T20: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 | jeanlf | 2021-03-29 09:34:02+02:00 | add safety in avc/hevc/vvc sps/pps/vps ID check - cf #1720 #1721 #1722 | 51cdb67ff7c5f1242ac58c5aa603ceaf1793b788 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_hevc_read_sps_bs_internal | gf_hevc_read_sps_bs_internal( GF_BitStream * bs , HEVCState * hevc , u8 layer_id , u32 * vui_flag_pos) | ['bs', 'hevc', 'layer_id', 'vui_flag_pos'] | static s32 gf_hevc_read_sps_bs_internal(GF_BitStream *bs, HEVCState *hevc, u8 layer_id, u32 *vui_flag_pos)
{
s32 vps_id, sps_id = -1;
u32 i, nb_CTUs, depth;
HEVC_SPS *sps;
HEVC_VPS *vps;
HEVC_ProfileTierLevel ptl;
Bool multiLayerExtSpsFlag;
u8 sps_ext_or_max_sub_layers_minus1, max_sub_layers_minus1;
if (vui_flag_pos) *vui_flag_pos = 0;
//nalu header already parsed
vps_id = gf_bs_read_int_log(bs, 4, "vps_id");
if (vps_id >= 16) {
return -1;
}
memset(&ptl, 0, sizeof(ptl));
max_sub_layers_minus1 = 0;
sps_ext_or_max_sub_layers_minus1 = 0;
if (layer_id == 0)
max_sub_layers_minus1 = gf_bs_read_int_log(bs, 3, "max_sub_layers_minus1");
else
sps_ext_or_max_sub_layers_minus1 = gf_bs_read_int_log(bs, 3, "sps_ext_or_max_sub_layers_minus1");
multiLayerExtSpsFlag = (layer_id != 0) && (sps_ext_or_max_sub_layers_minus1 == 7);
if (!multiLayerExtSpsFlag) {
gf_bs_read_int_log(bs, 1, "temporal_id_nesting_flag");
hevc_profile_tier_level(bs, 1, max_sub_layers_minus1, &ptl, 0);
}
sps_id = gf_bs_read_ue_log(bs, "sps_id");
if ((sps_id < 0) || (sps_id >= 16)) {
return -1;
}
sps = &hevc->sps[sps_id];
if (!sps->state) {
sps->state = 1;
sps->id = sps_id;
sps->vps_id = vps_id;
}
sps->ptl = ptl;
vps = &hevc->vps[vps_id];
sps->max_sub_layers_minus1 = 0;
sps->sps_ext_or_max_sub_layers_minus1 = 0;
/* default values */
sps->colour_primaries = 2;
sps->transfer_characteristic = 2;
sps->matrix_coeffs = 2;
//sps_rep_format_idx = 0;
if (multiLayerExtSpsFlag) {
sps->update_rep_format_flag = gf_bs_read_int_log(bs, 1, "update_rep_format_flag");
if (sps->update_rep_format_flag) {
sps->rep_format_idx = gf_bs_read_int_log(bs, 8, "rep_format_idx");
}
else {
sps->rep_format_idx = vps->rep_format_idx[layer_id];
}
sps->width = vps->rep_formats[sps->rep_format_idx].pic_width_luma_samples;
sps->height = vps->rep_formats[sps->rep_format_idx].pic_height_luma_samples;
sps->chroma_format_idc = vps->rep_formats[sps->rep_format_idx].chroma_format_idc;
sps->bit_depth_luma = vps->rep_formats[sps->rep_format_idx].bit_depth_luma;
sps->bit_depth_chroma = vps->rep_formats[sps->rep_format_idx].bit_depth_chroma;
sps->separate_colour_plane_flag = vps->rep_formats[sps->rep_format_idx].separate_colour_plane_flag;
//TODO this is crude ...
sps->ptl = vps->ext_ptl[0];
}
else {
sps->chroma_format_idc = gf_bs_read_ue_log(bs, "chroma_format_idc");
if (sps->chroma_format_idc == 3)
sps->separate_colour_plane_flag = gf_bs_read_int_log(bs, 1, "separate_colour_plane_flag");
sps->width = gf_bs_read_ue_log(bs, "width");
sps->height = gf_bs_read_ue_log(bs, "height");
if ((sps->cw_flag = gf_bs_read_int_log(bs, 1, "conformance_window_flag"))) {
u32 SubWidthC, SubHeightC;
if (sps->chroma_format_idc == 1) {
SubWidthC = SubHeightC = 2;
}
else if (sps->chroma_format_idc == 2) {
SubWidthC = 2;
SubHeightC = 1;
}
else {
SubWidthC = SubHeightC = 1;
}
sps->cw_left = gf_bs_read_ue_log(bs, "conformance_window_left");
sps->cw_right = gf_bs_read_ue_log(bs, "conformance_window_right");
sps->cw_top = gf_bs_read_ue_log(bs, "conformance_window_top");
sps->cw_bottom = gf_bs_read_ue_log(bs, "conformance_window_bottom");
sps->width -= SubWidthC * (sps->cw_left + sps->cw_right);
sps->height -= SubHeightC * (sps->cw_top + sps->cw_bottom);
}
sps->bit_depth_luma = 8 + gf_bs_read_ue_log(bs, "bit_depth_luma_minus8");
sps->bit_depth_chroma = 8 + gf_bs_read_ue_log(bs, "bit_depth_chroma_minus8");
}
sps->log2_max_pic_order_cnt_lsb = 4 + gf_bs_read_ue_log(bs, "log2_max_pic_order_cnt_lsb_minus4");
if (!multiLayerExtSpsFlag) {
sps->sub_layer_ordering_info_present_flag = gf_bs_read_int_log(bs, 1, "sub_layer_ordering_info_present_flag");
for (i = sps->sub_layer_ordering_info_present_flag ? 0 : sps->max_sub_layers_minus1; i <= sps->max_sub_layers_minus1; i++) {
gf_bs_read_ue_log_idx(bs, "max_dec_pic_buffering", i);
gf_bs_read_ue_log_idx(bs, "num_reorder_pics", i);
gf_bs_read_ue_log_idx(bs, "max_latency_increase", i);
}
}
sps->log2_min_luma_coding_block_size = 3 + gf_bs_read_ue_log(bs, "log2_min_luma_coding_block_size_minus3");
sps->log2_diff_max_min_luma_coding_block_size = gf_bs_read_ue_log(bs, "log2_diff_max_min_luma_coding_block_size");
sps->max_CU_width = (1 << (sps->log2_min_luma_coding_block_size + sps->log2_diff_max_min_luma_coding_block_size));
sps->max_CU_height = (1 << (sps->log2_min_luma_coding_block_size + sps->log2_diff_max_min_luma_coding_block_size));
sps->log2_min_transform_block_size = 2 + gf_bs_read_ue_log(bs, "log2_min_transform_block_size_minus2");
sps->log2_max_transform_block_size = sps->log2_min_transform_block_size + gf_bs_read_ue_log(bs, "log2_max_transform_block_size");
depth = 0;
sps->max_transform_hierarchy_depth_inter = gf_bs_read_ue_log(bs, "max_transform_hierarchy_depth_inter");
sps->max_transform_hierarchy_depth_intra = gf_bs_read_ue_log(bs, "max_transform_hierarchy_depth_intra");
while ((u32)(sps->max_CU_width >> sps->log2_diff_max_min_luma_coding_block_size) > (u32)(1 << (sps->log2_min_transform_block_size + depth)))
{
depth++;
}
sps->max_CU_depth = sps->log2_diff_max_min_luma_coding_block_size + depth;
nb_CTUs = ((sps->width + sps->max_CU_width - 1) / sps->max_CU_width) * ((sps->height + sps->max_CU_height - 1) / sps->max_CU_height);
sps->bitsSliceSegmentAddress = 0;
while (nb_CTUs > (u32)(1 << sps->bitsSliceSegmentAddress)) {
sps->bitsSliceSegmentAddress++;
}
sps->scaling_list_enable_flag = gf_bs_read_int_log(bs, 1, "scaling_list_enable_flag");
if (sps->scaling_list_enable_flag) {
sps->infer_scaling_list_flag = 0;
sps->scaling_list_ref_layer_id = 0;
if (multiLayerExtSpsFlag) {
sps->infer_scaling_list_flag = gf_bs_read_int_log(bs, 1, "infer_scaling_list_flag");
}
if (sps->infer_scaling_list_flag) {
sps->scaling_list_ref_layer_id = gf_bs_read_int_log(bs, 6, "scaling_list_ref_layer_id");
}
else {
sps->scaling_list_data_present_flag = gf_bs_read_int_log(bs, 1, "scaling_list_data_present_flag");
if (sps->scaling_list_data_present_flag) {
hevc_scaling_list_data(bs);
}
}
}
sps->asymmetric_motion_partitions_enabled_flag = gf_bs_read_int_log(bs, 1, "asymmetric_motion_partitions_enabled_flag");
sps->sample_adaptive_offset_enabled_flag = gf_bs_read_int_log(bs, 1, "sample_adaptive_offset_enabled_flag");
if ( (sps->pcm_enabled_flag = gf_bs_read_int_log(bs, 1, "pcm_enabled_flag")) ) {
sps->pcm_sample_bit_depth_luma_minus1 = gf_bs_read_int_log(bs, 4, "pcm_sample_bit_depth_luma_minus1");
sps->pcm_sample_bit_depth_chroma_minus1 = gf_bs_read_int_log(bs, 4, "pcm_sample_bit_depth_chroma_minus1");
sps->log2_min_pcm_luma_coding_block_size_minus3 = gf_bs_read_ue_log(bs, "log2_min_pcm_luma_coding_block_size_minus3");
sps->log2_diff_max_min_pcm_luma_coding_block_size = gf_bs_read_ue_log(bs, "log2_diff_max_min_pcm_luma_coding_block_size");
sps->pcm_loop_filter_disable_flag = gf_bs_read_int_log(bs, 1, "pcm_loop_filter_disable_flag");
}
sps->num_short_term_ref_pic_sets = gf_bs_read_ue_log(bs, "num_short_term_ref_pic_sets");
if (sps->num_short_term_ref_pic_sets > 64) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[HEVC] Invalid number of short term reference picture sets %d\n", sps->num_short_term_ref_pic_sets));
return -1;
}
for (i = 0; i < sps->num_short_term_ref_pic_sets; i++) {
Bool ret = hevc_parse_short_term_ref_pic_set(bs, sps, i);
/*cannot parse short_term_ref_pic_set, skip VUI parsing*/
if (!ret) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[HEVC] Invalid short_term_ref_pic_set\n"));
return -1;
}
}
sps->long_term_ref_pics_present_flag = gf_bs_read_int_log(bs, 1, "long_term_ref_pics_present_flag");
if (sps->long_term_ref_pics_present_flag) {
sps->num_long_term_ref_pic_sps = gf_bs_read_ue_log(bs, "num_long_term_ref_pic_sps");
for (i = 0; i < sps->num_long_term_ref_pic_sps; i++) {
gf_bs_read_int_log_idx(bs, sps->log2_max_pic_order_cnt_lsb, "lt_ref_pic_poc_lsb_sps", i);
gf_bs_read_int_log_idx(bs, 1, "used_by_curr_pic_lt_sps_flag", i);
}
}
sps->temporal_mvp_enable_flag = gf_bs_read_int_log(bs, 1, "temporal_mvp_enable_flag");
sps->strong_intra_smoothing_enable_flag = gf_bs_read_int_log(bs, 1, "strong_intra_smoothing_enable_flag");
if (vui_flag_pos)
*vui_flag_pos = (u32)gf_bs_get_bit_offset(bs);
if ((sps->vui_parameters_present_flag = gf_bs_read_int_log(bs, 1, "vui_parameters_present_flag")) ) {
sps->aspect_ratio_info_present_flag = gf_bs_read_int_log(bs, 1, "aspect_ratio_info_present_flag");
if (sps->aspect_ratio_info_present_flag) {
sps->sar_idc = gf_bs_read_int_log(bs, 8, "aspect_ratio_idc");
if (sps->sar_idc == 255) {
sps->sar_width = gf_bs_read_int_log(bs, 16, "aspect_ratio_width");
sps->sar_height = gf_bs_read_int_log(bs, 16, "aspect_ratio_height");
}
else if (sps->sar_idc < 17) {
sps->sar_width = hevc_sar[sps->sar_idc].w;
sps->sar_height = hevc_sar[sps->sar_idc].h;
}
}
if ((sps->overscan_info_present = gf_bs_read_int_log(bs, 1, "overscan_info_present")))
sps->overscan_appropriate = gf_bs_read_int_log(bs, 1, "overscan_appropriate");
sps->video_signal_type_present_flag = gf_bs_read_int_log(bs, 1, "video_signal_type_present_flag");
if (sps->video_signal_type_present_flag) {
sps->video_format = gf_bs_read_int_log(bs, 3, "video_format");
sps->video_full_range_flag = gf_bs_read_int_log(bs, 1, "video_full_range_flag");
if ((sps->colour_description_present_flag = gf_bs_read_int_log(bs, 1, "colour_description_present_flag"))) {
sps->colour_primaries = gf_bs_read_int_log(bs, 8, "colour_primaries");
sps->transfer_characteristic = gf_bs_read_int_log(bs, 8, "transfer_characteristic");
sps->matrix_coeffs = gf_bs_read_int_log(bs, 8, "matrix_coefficients");
}
}
if ((sps->chroma_loc_info_present_flag = gf_bs_read_int_log(bs, 1, "chroma_loc_info_present_flag"))) {
sps->chroma_sample_loc_type_top_field = gf_bs_read_ue_log(bs, "chroma_sample_loc_type_top_field");
sps->chroma_sample_loc_type_bottom_field = gf_bs_read_ue_log(bs, "chroma_sample_loc_type_bottom_field");
}
sps->neutra_chroma_indication_flag = gf_bs_read_int_log(bs, 1, "neutra_chroma_indication_flag");
sps->field_seq_flag = gf_bs_read_int_log(bs, 1, "field_seq_flag");
sps->frame_field_info_present_flag = gf_bs_read_int_log(bs, 1, "frame_field_info_present_flag");
if ((sps->default_display_window_flag = gf_bs_read_int_log(bs, 1, "default_display_window_flag"))) {
sps->left_offset = gf_bs_read_ue_log(bs, "display_window_left_offset");
sps->right_offset = gf_bs_read_ue_log(bs, "display_window_right_offset");
sps->top_offset = gf_bs_read_ue_log(bs, "display_window_top_offset");
sps->bottom_offset = gf_bs_read_ue_log(bs, "display_window_bottom_offset");
}
sps->has_timing_info = gf_bs_read_int_log(bs, 1, "has_timing_info");
if (sps->has_timing_info) {
sps->num_units_in_tick = gf_bs_read_int_log(bs, 32, "num_units_in_tick");
sps->time_scale = gf_bs_read_int_log(bs, 32, "time_scale");
sps->poc_proportional_to_timing_flag = gf_bs_read_int_log(bs, 1, "poc_proportional_to_timing_flag");
if (sps->poc_proportional_to_timing_flag)
sps->num_ticks_poc_diff_one_minus1 = gf_bs_read_ue_log(bs, "num_ticks_poc_diff_one_minus1");
if ((sps->hrd_parameters_present_flag = gf_bs_read_int_log(bs, 1, "hrd_parameters_present_flag"))) {
// GF_LOG(GF_LOG_INFO, GF_LOG_CODING, ("[HEVC] HRD param parsing not implemented\n"));
return sps_id;
}
}
if (gf_bs_read_int_log(bs, 1, "bitstream_restriction_flag")) {
gf_bs_read_int_log(bs, 1, "tiles_fixed_structure_flag");
gf_bs_read_int_log(bs, 1, "motion_vectors_over_pic_boundaries_flag");
gf_bs_read_int_log(bs, 1, "restricted_ref_pic_lists_flag");
gf_bs_read_ue_log(bs, "min_spatial_segmentation_idc");
gf_bs_read_ue_log(bs, "max_bytes_per_pic_denom");
gf_bs_read_ue_log(bs, "max_bits_per_min_cu_denom");
gf_bs_read_ue_log(bs, "log2_max_mv_length_horizontal");
gf_bs_read_ue_log(bs, "log2_max_mv_length_vertical");
}
}
if (gf_bs_read_int_log(bs, 1, "sps_extension_flag")) {
#if 0
while (gf_bs_available(bs)) {
/*sps_extension_data_flag */ gf_bs_read_int(bs, 1);
}
#endif
}
return sps_id;
} | 2011 | True | 1 |
CVE-2021-30022 | 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/gpac/gpac/issues/1720', 'name': 'https://github.com/gpac/gpac/issues/1720', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'name': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-190'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'There is a integer overflow in media_tools/av_parsers.c in the gf_avc_read_pps_bs_internal in GPAC 1.0.1. pps_id may be a negative number, so it will not return. However, avc->pps only has 255 unit, so there is an overflow, which results a crash.'}] | 2021-04-21T19:03Z | 2021-04-19T20:15Z | Integer Overflow or Wraparound | The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | An integer overflow or wraparound occurs when an integer value is incremented to a value that is too large to store in the associated representation. When this occurs, the value may wrap to become a very small or negative number. While this may be intended behavior in circumstances that rely on wrapping, it can have security consequences if the wrap is unexpected. This is especially the case if the integer overflow can be triggered using user-supplied inputs. This becomes security-critical when the result is used to control looping, make a security decision, or determine the offset or size in behaviors such as memory allocation, copying, concatenation, etc.
| https://cwe.mitre.org/data/definitions/190.html | 0 | jeanlf | 2021-03-29 09:34:02+02:00 | add safety in avc/hevc/vvc sps/pps/vps ID check - cf #1720 #1721 #1722 | 51cdb67ff7c5f1242ac58c5aa603ceaf1793b788 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_hevc_read_sps_bs_internal | gf_hevc_read_sps_bs_internal( GF_BitStream * bs , HEVCState * hevc , u8 layer_id , u32 * vui_flag_pos) | ['bs', 'hevc', 'layer_id', 'vui_flag_pos'] | static s32 gf_hevc_read_sps_bs_internal(GF_BitStream *bs, HEVCState *hevc, u8 layer_id, u32 *vui_flag_pos)
{
s32 vps_id, sps_id = -1;
u32 i, nb_CTUs, depth;
HEVC_SPS *sps;
HEVC_VPS *vps;
HEVC_ProfileTierLevel ptl;
Bool multiLayerExtSpsFlag;
u8 sps_ext_or_max_sub_layers_minus1, max_sub_layers_minus1;
if (vui_flag_pos) *vui_flag_pos = 0;
//nalu header already parsed
vps_id = gf_bs_read_int_log(bs, 4, "vps_id");
if (vps_id >= 16) {
return -1;
}
memset(&ptl, 0, sizeof(ptl));
max_sub_layers_minus1 = 0;
sps_ext_or_max_sub_layers_minus1 = 0;
if (layer_id == 0)
max_sub_layers_minus1 = gf_bs_read_int_log(bs, 3, "max_sub_layers_minus1");
else
sps_ext_or_max_sub_layers_minus1 = gf_bs_read_int_log(bs, 3, "sps_ext_or_max_sub_layers_minus1");
multiLayerExtSpsFlag = (layer_id != 0) && (sps_ext_or_max_sub_layers_minus1 == 7);
if (!multiLayerExtSpsFlag) {
gf_bs_read_int_log(bs, 1, "temporal_id_nesting_flag");
hevc_profile_tier_level(bs, 1, max_sub_layers_minus1, &ptl, 0);
}
sps_id = gf_bs_read_ue_log(bs, "sps_id");
if ((sps_id < 0) || (sps_id >= 16)) {
return -1;
}
sps = &hevc->sps[sps_id];
if (!sps->state) {
sps->state = 1;
sps->id = sps_id;
sps->vps_id = vps_id;
}
sps->ptl = ptl;
vps = &hevc->vps[vps_id];
sps->max_sub_layers_minus1 = 0;
sps->sps_ext_or_max_sub_layers_minus1 = 0;
/* default values */
sps->colour_primaries = 2;
sps->transfer_characteristic = 2;
sps->matrix_coeffs = 2;
//sps_rep_format_idx = 0;
if (multiLayerExtSpsFlag) {
sps->update_rep_format_flag = gf_bs_read_int_log(bs, 1, "update_rep_format_flag");
if (sps->update_rep_format_flag) {
sps->rep_format_idx = gf_bs_read_int_log(bs, 8, "rep_format_idx");
}
else {
sps->rep_format_idx = vps->rep_format_idx[layer_id];
}
sps->width = vps->rep_formats[sps->rep_format_idx].pic_width_luma_samples;
sps->height = vps->rep_formats[sps->rep_format_idx].pic_height_luma_samples;
sps->chroma_format_idc = vps->rep_formats[sps->rep_format_idx].chroma_format_idc;
sps->bit_depth_luma = vps->rep_formats[sps->rep_format_idx].bit_depth_luma;
sps->bit_depth_chroma = vps->rep_formats[sps->rep_format_idx].bit_depth_chroma;
sps->separate_colour_plane_flag = vps->rep_formats[sps->rep_format_idx].separate_colour_plane_flag;
//TODO this is crude ...
sps->ptl = vps->ext_ptl[0];
}
else {
sps->chroma_format_idc = gf_bs_read_ue_log(bs, "chroma_format_idc");
if (sps->chroma_format_idc == 3)
sps->separate_colour_plane_flag = gf_bs_read_int_log(bs, 1, "separate_colour_plane_flag");
sps->width = gf_bs_read_ue_log(bs, "width");
sps->height = gf_bs_read_ue_log(bs, "height");
if ((sps->cw_flag = gf_bs_read_int_log(bs, 1, "conformance_window_flag"))) {
u32 SubWidthC, SubHeightC;
if (sps->chroma_format_idc == 1) {
SubWidthC = SubHeightC = 2;
}
else if (sps->chroma_format_idc == 2) {
SubWidthC = 2;
SubHeightC = 1;
}
else {
SubWidthC = SubHeightC = 1;
}
sps->cw_left = gf_bs_read_ue_log(bs, "conformance_window_left");
sps->cw_right = gf_bs_read_ue_log(bs, "conformance_window_right");
sps->cw_top = gf_bs_read_ue_log(bs, "conformance_window_top");
sps->cw_bottom = gf_bs_read_ue_log(bs, "conformance_window_bottom");
sps->width -= SubWidthC * (sps->cw_left + sps->cw_right);
sps->height -= SubHeightC * (sps->cw_top + sps->cw_bottom);
}
sps->bit_depth_luma = 8 + gf_bs_read_ue_log(bs, "bit_depth_luma_minus8");
sps->bit_depth_chroma = 8 + gf_bs_read_ue_log(bs, "bit_depth_chroma_minus8");
}
sps->log2_max_pic_order_cnt_lsb = 4 + gf_bs_read_ue_log(bs, "log2_max_pic_order_cnt_lsb_minus4");
if (!multiLayerExtSpsFlag) {
sps->sub_layer_ordering_info_present_flag = gf_bs_read_int_log(bs, 1, "sub_layer_ordering_info_present_flag");
for (i = sps->sub_layer_ordering_info_present_flag ? 0 : sps->max_sub_layers_minus1; i <= sps->max_sub_layers_minus1; i++) {
gf_bs_read_ue_log_idx(bs, "max_dec_pic_buffering", i);
gf_bs_read_ue_log_idx(bs, "num_reorder_pics", i);
gf_bs_read_ue_log_idx(bs, "max_latency_increase", i);
}
}
sps->log2_min_luma_coding_block_size = 3 + gf_bs_read_ue_log(bs, "log2_min_luma_coding_block_size_minus3");
sps->log2_diff_max_min_luma_coding_block_size = gf_bs_read_ue_log(bs, "log2_diff_max_min_luma_coding_block_size");
sps->max_CU_width = (1 << (sps->log2_min_luma_coding_block_size + sps->log2_diff_max_min_luma_coding_block_size));
sps->max_CU_height = (1 << (sps->log2_min_luma_coding_block_size + sps->log2_diff_max_min_luma_coding_block_size));
sps->log2_min_transform_block_size = 2 + gf_bs_read_ue_log(bs, "log2_min_transform_block_size_minus2");
sps->log2_max_transform_block_size = sps->log2_min_transform_block_size + gf_bs_read_ue_log(bs, "log2_max_transform_block_size");
depth = 0;
sps->max_transform_hierarchy_depth_inter = gf_bs_read_ue_log(bs, "max_transform_hierarchy_depth_inter");
sps->max_transform_hierarchy_depth_intra = gf_bs_read_ue_log(bs, "max_transform_hierarchy_depth_intra");
while ((u32)(sps->max_CU_width >> sps->log2_diff_max_min_luma_coding_block_size) > (u32)(1 << (sps->log2_min_transform_block_size + depth)))
{
depth++;
}
sps->max_CU_depth = sps->log2_diff_max_min_luma_coding_block_size + depth;
nb_CTUs = ((sps->width + sps->max_CU_width - 1) / sps->max_CU_width) * ((sps->height + sps->max_CU_height - 1) / sps->max_CU_height);
sps->bitsSliceSegmentAddress = 0;
while (nb_CTUs > (u32)(1 << sps->bitsSliceSegmentAddress)) {
sps->bitsSliceSegmentAddress++;
}
sps->scaling_list_enable_flag = gf_bs_read_int_log(bs, 1, "scaling_list_enable_flag");
if (sps->scaling_list_enable_flag) {
sps->infer_scaling_list_flag = 0;
sps->scaling_list_ref_layer_id = 0;
if (multiLayerExtSpsFlag) {
sps->infer_scaling_list_flag = gf_bs_read_int_log(bs, 1, "infer_scaling_list_flag");
}
if (sps->infer_scaling_list_flag) {
sps->scaling_list_ref_layer_id = gf_bs_read_int_log(bs, 6, "scaling_list_ref_layer_id");
}
else {
sps->scaling_list_data_present_flag = gf_bs_read_int_log(bs, 1, "scaling_list_data_present_flag");
if (sps->scaling_list_data_present_flag) {
hevc_scaling_list_data(bs);
}
}
}
sps->asymmetric_motion_partitions_enabled_flag = gf_bs_read_int_log(bs, 1, "asymmetric_motion_partitions_enabled_flag");
sps->sample_adaptive_offset_enabled_flag = gf_bs_read_int_log(bs, 1, "sample_adaptive_offset_enabled_flag");
if ( (sps->pcm_enabled_flag = gf_bs_read_int_log(bs, 1, "pcm_enabled_flag")) ) {
sps->pcm_sample_bit_depth_luma_minus1 = gf_bs_read_int_log(bs, 4, "pcm_sample_bit_depth_luma_minus1");
sps->pcm_sample_bit_depth_chroma_minus1 = gf_bs_read_int_log(bs, 4, "pcm_sample_bit_depth_chroma_minus1");
sps->log2_min_pcm_luma_coding_block_size_minus3 = gf_bs_read_ue_log(bs, "log2_min_pcm_luma_coding_block_size_minus3");
sps->log2_diff_max_min_pcm_luma_coding_block_size = gf_bs_read_ue_log(bs, "log2_diff_max_min_pcm_luma_coding_block_size");
sps->pcm_loop_filter_disable_flag = gf_bs_read_int_log(bs, 1, "pcm_loop_filter_disable_flag");
}
sps->num_short_term_ref_pic_sets = gf_bs_read_ue_log(bs, "num_short_term_ref_pic_sets");
if (sps->num_short_term_ref_pic_sets > 64) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[HEVC] Invalid number of short term reference picture sets %d\n", sps->num_short_term_ref_pic_sets));
return -1;
}
for (i = 0; i < sps->num_short_term_ref_pic_sets; i++) {
Bool ret = hevc_parse_short_term_ref_pic_set(bs, sps, i);
/*cannot parse short_term_ref_pic_set, skip VUI parsing*/
if (!ret) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[HEVC] Invalid short_term_ref_pic_set\n"));
return -1;
}
}
sps->long_term_ref_pics_present_flag = gf_bs_read_int_log(bs, 1, "long_term_ref_pics_present_flag");
if (sps->long_term_ref_pics_present_flag) {
sps->num_long_term_ref_pic_sps = gf_bs_read_ue_log(bs, "num_long_term_ref_pic_sps");
for (i = 0; i < sps->num_long_term_ref_pic_sps; i++) {
gf_bs_read_int_log_idx(bs, sps->log2_max_pic_order_cnt_lsb, "lt_ref_pic_poc_lsb_sps", i);
gf_bs_read_int_log_idx(bs, 1, "used_by_curr_pic_lt_sps_flag", i);
}
}
sps->temporal_mvp_enable_flag = gf_bs_read_int_log(bs, 1, "temporal_mvp_enable_flag");
sps->strong_intra_smoothing_enable_flag = gf_bs_read_int_log(bs, 1, "strong_intra_smoothing_enable_flag");
if (vui_flag_pos)
*vui_flag_pos = (u32)gf_bs_get_bit_offset(bs);
if ((sps->vui_parameters_present_flag = gf_bs_read_int_log(bs, 1, "vui_parameters_present_flag")) ) {
sps->aspect_ratio_info_present_flag = gf_bs_read_int_log(bs, 1, "aspect_ratio_info_present_flag");
if (sps->aspect_ratio_info_present_flag) {
sps->sar_idc = gf_bs_read_int_log(bs, 8, "aspect_ratio_idc");
if (sps->sar_idc == 255) {
sps->sar_width = gf_bs_read_int_log(bs, 16, "aspect_ratio_width");
sps->sar_height = gf_bs_read_int_log(bs, 16, "aspect_ratio_height");
}
else if (sps->sar_idc < 17) {
sps->sar_width = hevc_sar[sps->sar_idc].w;
sps->sar_height = hevc_sar[sps->sar_idc].h;
}
}
if ((sps->overscan_info_present = gf_bs_read_int_log(bs, 1, "overscan_info_present")))
sps->overscan_appropriate = gf_bs_read_int_log(bs, 1, "overscan_appropriate");
sps->video_signal_type_present_flag = gf_bs_read_int_log(bs, 1, "video_signal_type_present_flag");
if (sps->video_signal_type_present_flag) {
sps->video_format = gf_bs_read_int_log(bs, 3, "video_format");
sps->video_full_range_flag = gf_bs_read_int_log(bs, 1, "video_full_range_flag");
if ((sps->colour_description_present_flag = gf_bs_read_int_log(bs, 1, "colour_description_present_flag"))) {
sps->colour_primaries = gf_bs_read_int_log(bs, 8, "colour_primaries");
sps->transfer_characteristic = gf_bs_read_int_log(bs, 8, "transfer_characteristic");
sps->matrix_coeffs = gf_bs_read_int_log(bs, 8, "matrix_coefficients");
}
}
if ((sps->chroma_loc_info_present_flag = gf_bs_read_int_log(bs, 1, "chroma_loc_info_present_flag"))) {
sps->chroma_sample_loc_type_top_field = gf_bs_read_ue_log(bs, "chroma_sample_loc_type_top_field");
sps->chroma_sample_loc_type_bottom_field = gf_bs_read_ue_log(bs, "chroma_sample_loc_type_bottom_field");
}
sps->neutra_chroma_indication_flag = gf_bs_read_int_log(bs, 1, "neutra_chroma_indication_flag");
sps->field_seq_flag = gf_bs_read_int_log(bs, 1, "field_seq_flag");
sps->frame_field_info_present_flag = gf_bs_read_int_log(bs, 1, "frame_field_info_present_flag");
if ((sps->default_display_window_flag = gf_bs_read_int_log(bs, 1, "default_display_window_flag"))) {
sps->left_offset = gf_bs_read_ue_log(bs, "display_window_left_offset");
sps->right_offset = gf_bs_read_ue_log(bs, "display_window_right_offset");
sps->top_offset = gf_bs_read_ue_log(bs, "display_window_top_offset");
sps->bottom_offset = gf_bs_read_ue_log(bs, "display_window_bottom_offset");
}
sps->has_timing_info = gf_bs_read_int_log(bs, 1, "has_timing_info");
if (sps->has_timing_info) {
sps->num_units_in_tick = gf_bs_read_int_log(bs, 32, "num_units_in_tick");
sps->time_scale = gf_bs_read_int_log(bs, 32, "time_scale");
sps->poc_proportional_to_timing_flag = gf_bs_read_int_log(bs, 1, "poc_proportional_to_timing_flag");
if (sps->poc_proportional_to_timing_flag)
sps->num_ticks_poc_diff_one_minus1 = gf_bs_read_ue_log(bs, "num_ticks_poc_diff_one_minus1");
if ((sps->hrd_parameters_present_flag = gf_bs_read_int_log(bs, 1, "hrd_parameters_present_flag"))) {
// GF_LOG(GF_LOG_INFO, GF_LOG_CODING, ("[HEVC] HRD param parsing not implemented\n"));
return sps_id;
}
}
if (gf_bs_read_int_log(bs, 1, "bitstream_restriction_flag")) {
gf_bs_read_int_log(bs, 1, "tiles_fixed_structure_flag");
gf_bs_read_int_log(bs, 1, "motion_vectors_over_pic_boundaries_flag");
gf_bs_read_int_log(bs, 1, "restricted_ref_pic_lists_flag");
gf_bs_read_ue_log(bs, "min_spatial_segmentation_idc");
gf_bs_read_ue_log(bs, "max_bytes_per_pic_denom");
gf_bs_read_ue_log(bs, "max_bits_per_min_cu_denom");
gf_bs_read_ue_log(bs, "log2_max_mv_length_horizontal");
gf_bs_read_ue_log(bs, "log2_max_mv_length_vertical");
}
}
if (gf_bs_read_int_log(bs, 1, "sps_extension_flag")) {
#if 0
while (gf_bs_available(bs)) {
/*sps_extension_data_flag */ gf_bs_read_int(bs, 1);
}
#endif
}
return sps_id;
} | 2011 | True | 1 |
CVE-2021-30014 | 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/gpac/gpac/issues/1721', 'name': 'https://github.com/gpac/gpac/issues/1721', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'name': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-190'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'There is a integer overflow in media_tools/av_parsers.c in the hevc_parse_slice_segment function in GPAC 1.0.1 which results in a crash.'}] | 2021-04-21T19:21Z | 2021-04-19T20:15Z | Integer Overflow or Wraparound | The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | An integer overflow or wraparound occurs when an integer value is incremented to a value that is too large to store in the associated representation. When this occurs, the value may wrap to become a very small or negative number. While this may be intended behavior in circumstances that rely on wrapping, it can have security consequences if the wrap is unexpected. This is especially the case if the integer overflow can be triggered using user-supplied inputs. This becomes security-critical when the result is used to control looping, make a security decision, or determine the offset or size in behaviors such as memory allocation, copying, concatenation, etc.
| https://cwe.mitre.org/data/definitions/190.html | 0 | jeanlf | 2021-03-29 09:34:02+02:00 | add safety in avc/hevc/vvc sps/pps/vps ID check - cf #1720 #1721 #1722 | 51cdb67ff7c5f1242ac58c5aa603ceaf1793b788 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_hevc_read_vps_bs_internal | gf_hevc_read_vps_bs_internal( GF_BitStream * bs , HEVCState * hevc , Bool stop_at_vps_ext) | ['bs', 'hevc', 'stop_at_vps_ext'] | static s32 gf_hevc_read_vps_bs_internal(GF_BitStream *bs, HEVCState *hevc, Bool stop_at_vps_ext)
{
u8 vps_sub_layer_ordering_info_present_flag, vps_extension_flag;
u32 i, j;
s32 vps_id;
HEVC_VPS *vps;
u8 layer_id_included_flag[MAX_LHVC_LAYERS][64];
//nalu header already parsed
vps_id = gf_bs_read_int_log(bs, 4, "vps_id");
if (vps_id >= 16) return -1;
vps = &hevc->vps[vps_id];
vps->bit_pos_vps_extensions = -1;
if (!vps->state) {
vps->id = vps_id;
vps->state = 1;
}
vps->base_layer_internal_flag = gf_bs_read_int_log(bs, 1, "base_layer_internal_flag");
vps->base_layer_available_flag = gf_bs_read_int_log(bs, 1, "base_layer_available_flag");
vps->max_layers = 1 + gf_bs_read_int_log(bs, 6, "max_layers_minus1");
if (vps->max_layers > MAX_LHVC_LAYERS) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[HEVC] sorry, %d layers in VPS but only %d supported\n", vps->max_layers, MAX_LHVC_LAYERS));
return -1;
}
vps->max_sub_layers = gf_bs_read_int_log(bs, 3, "max_sub_layers_minus1") + 1;
vps->temporal_id_nesting = gf_bs_read_int_log(bs, 1, "temporal_id_nesting");
gf_bs_read_int_log(bs, 16, "vps_reserved_ffff_16bits");
hevc_profile_tier_level(bs, 1, vps->max_sub_layers - 1, &vps->ptl, 0);
vps_sub_layer_ordering_info_present_flag = gf_bs_read_int_log(bs, 1, "vps_sub_layer_ordering_info_present_flag");
for (i = (vps_sub_layer_ordering_info_present_flag ? 0 : vps->max_sub_layers - 1); i < vps->max_sub_layers; i++) {
gf_bs_read_ue_log_idx(bs, "vps_max_dec_pic_buffering_minus1", i);
gf_bs_read_ue_log_idx(bs, "vps_max_num_reorder_pics", i);
gf_bs_read_ue_log_idx(bs, "vps_max_latency_increase_plus1", i);
}
vps->max_layer_id = gf_bs_read_int_log(bs, 6, "max_layer_id");
if (vps->max_layer_id > MAX_LHVC_LAYERS) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[HEVC] VPS max layer ID %u but GPAC only supports %u\n", vps->max_layer_id, MAX_LHVC_LAYERS));
return -1;
}
vps->num_layer_sets = gf_bs_read_ue_log(bs, "num_layer_sets_minus1") + 1;
if (vps->num_layer_sets > MAX_LHVC_LAYERS) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[HEVC] Wrong number of layer sets in VPS %d\n", vps->num_layer_sets));
return -1;
}
for (i = 1; i < vps->num_layer_sets; i++) {
for (j = 0; j <= vps->max_layer_id; j++) {
layer_id_included_flag[i][j] = gf_bs_read_int_log_idx2(bs, 1, "layer_id_included_flag", i, j);
}
}
vps->num_layers_in_id_list[0] = 1;
for (i = 1; i < vps->num_layer_sets; i++) {
u32 n, m;
n = 0;
for (m = 0; m <= vps->max_layer_id; m++) {
if (layer_id_included_flag[i][m]) {
vps->LayerSetLayerIdList[i][n++] = m;
if (vps->LayerSetLayerIdListMax[i] < m)
vps->LayerSetLayerIdListMax[i] = m;
}
}
vps->num_layers_in_id_list[i] = n;
}
if (gf_bs_read_int_log(bs, 1, "vps_timing_info_present_flag")) {
u32 vps_num_hrd_parameters;
gf_bs_read_int_log(bs, 32, "vps_num_units_in_tick");
gf_bs_read_int_log(bs, 32, "vps_time_scale");
if (gf_bs_read_int_log(bs, 1, "vps_poc_proportional_to_timing_flag")) {
gf_bs_read_ue_log(bs, "vps_num_ticks_poc_diff_one_minus1");
}
vps_num_hrd_parameters = gf_bs_read_ue_log(bs, "vps_num_hrd_parameters");
for (i = 0; i < vps_num_hrd_parameters; i++) {
Bool cprms_present_flag = GF_TRUE;
gf_bs_read_ue_log_idx(bs, "hrd_layer_set_idx", i);
if (i > 0)
cprms_present_flag = gf_bs_read_int_log(bs, 1, "cprms_present_flag");
hevc_parse_hrd_parameters(bs, cprms_present_flag, vps->max_sub_layers - 1, i);
}
}
if (stop_at_vps_ext) {
return vps_id;
}
vps_extension_flag = gf_bs_read_int_log(bs, 1, "vps_extension_flag");
if (vps_extension_flag) {
Bool res;
gf_bs_align(bs);
res = hevc_parse_vps_extension(vps, bs);
if (res != GF_TRUE) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[HEVC] Failed to parse VPS extensions\n"));
return -1;
}
if (gf_bs_read_int_log(bs, 1, "vps_extension2_flag")) {
#if 0
while (gf_bs_available(bs)) {
/*vps_extension_data_flag */ gf_bs_read_int(bs, 1);
}
#endif
}
}
return vps_id;
} | 763 | True | 1 |
CVE-2021-30020 | 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/gpac/gpac/issues/1722', 'name': 'https://github.com/gpac/gpac/issues/1722', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'name': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-787'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'In the function gf_hevc_read_pps_bs_internal function in media_tools/av_parsers.c in GPAC 1.0.1 there is a loop, which with crafted file, pps->num_tile_columns may be larger than sizeof(pps->column_width), which results in a heap overflow in the loop.'}] | 2021-04-21T19:02Z | 2021-04-19T20: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 | jeanlf | 2021-03-29 09:34:02+02:00 | add safety in avc/hevc/vvc sps/pps/vps ID check - cf #1720 #1721 #1722 | 51cdb67ff7c5f1242ac58c5aa603ceaf1793b788 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_hevc_read_vps_bs_internal | gf_hevc_read_vps_bs_internal( GF_BitStream * bs , HEVCState * hevc , Bool stop_at_vps_ext) | ['bs', 'hevc', 'stop_at_vps_ext'] | static s32 gf_hevc_read_vps_bs_internal(GF_BitStream *bs, HEVCState *hevc, Bool stop_at_vps_ext)
{
u8 vps_sub_layer_ordering_info_present_flag, vps_extension_flag;
u32 i, j;
s32 vps_id;
HEVC_VPS *vps;
u8 layer_id_included_flag[MAX_LHVC_LAYERS][64];
//nalu header already parsed
vps_id = gf_bs_read_int_log(bs, 4, "vps_id");
if (vps_id >= 16) return -1;
vps = &hevc->vps[vps_id];
vps->bit_pos_vps_extensions = -1;
if (!vps->state) {
vps->id = vps_id;
vps->state = 1;
}
vps->base_layer_internal_flag = gf_bs_read_int_log(bs, 1, "base_layer_internal_flag");
vps->base_layer_available_flag = gf_bs_read_int_log(bs, 1, "base_layer_available_flag");
vps->max_layers = 1 + gf_bs_read_int_log(bs, 6, "max_layers_minus1");
if (vps->max_layers > MAX_LHVC_LAYERS) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[HEVC] sorry, %d layers in VPS but only %d supported\n", vps->max_layers, MAX_LHVC_LAYERS));
return -1;
}
vps->max_sub_layers = gf_bs_read_int_log(bs, 3, "max_sub_layers_minus1") + 1;
vps->temporal_id_nesting = gf_bs_read_int_log(bs, 1, "temporal_id_nesting");
gf_bs_read_int_log(bs, 16, "vps_reserved_ffff_16bits");
hevc_profile_tier_level(bs, 1, vps->max_sub_layers - 1, &vps->ptl, 0);
vps_sub_layer_ordering_info_present_flag = gf_bs_read_int_log(bs, 1, "vps_sub_layer_ordering_info_present_flag");
for (i = (vps_sub_layer_ordering_info_present_flag ? 0 : vps->max_sub_layers - 1); i < vps->max_sub_layers; i++) {
gf_bs_read_ue_log_idx(bs, "vps_max_dec_pic_buffering_minus1", i);
gf_bs_read_ue_log_idx(bs, "vps_max_num_reorder_pics", i);
gf_bs_read_ue_log_idx(bs, "vps_max_latency_increase_plus1", i);
}
vps->max_layer_id = gf_bs_read_int_log(bs, 6, "max_layer_id");
if (vps->max_layer_id > MAX_LHVC_LAYERS) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[HEVC] VPS max layer ID %u but GPAC only supports %u\n", vps->max_layer_id, MAX_LHVC_LAYERS));
return -1;
}
vps->num_layer_sets = gf_bs_read_ue_log(bs, "num_layer_sets_minus1") + 1;
if (vps->num_layer_sets > MAX_LHVC_LAYERS) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[HEVC] Wrong number of layer sets in VPS %d\n", vps->num_layer_sets));
return -1;
}
for (i = 1; i < vps->num_layer_sets; i++) {
for (j = 0; j <= vps->max_layer_id; j++) {
layer_id_included_flag[i][j] = gf_bs_read_int_log_idx2(bs, 1, "layer_id_included_flag", i, j);
}
}
vps->num_layers_in_id_list[0] = 1;
for (i = 1; i < vps->num_layer_sets; i++) {
u32 n, m;
n = 0;
for (m = 0; m <= vps->max_layer_id; m++) {
if (layer_id_included_flag[i][m]) {
vps->LayerSetLayerIdList[i][n++] = m;
if (vps->LayerSetLayerIdListMax[i] < m)
vps->LayerSetLayerIdListMax[i] = m;
}
}
vps->num_layers_in_id_list[i] = n;
}
if (gf_bs_read_int_log(bs, 1, "vps_timing_info_present_flag")) {
u32 vps_num_hrd_parameters;
gf_bs_read_int_log(bs, 32, "vps_num_units_in_tick");
gf_bs_read_int_log(bs, 32, "vps_time_scale");
if (gf_bs_read_int_log(bs, 1, "vps_poc_proportional_to_timing_flag")) {
gf_bs_read_ue_log(bs, "vps_num_ticks_poc_diff_one_minus1");
}
vps_num_hrd_parameters = gf_bs_read_ue_log(bs, "vps_num_hrd_parameters");
for (i = 0; i < vps_num_hrd_parameters; i++) {
Bool cprms_present_flag = GF_TRUE;
gf_bs_read_ue_log_idx(bs, "hrd_layer_set_idx", i);
if (i > 0)
cprms_present_flag = gf_bs_read_int_log(bs, 1, "cprms_present_flag");
hevc_parse_hrd_parameters(bs, cprms_present_flag, vps->max_sub_layers - 1, i);
}
}
if (stop_at_vps_ext) {
return vps_id;
}
vps_extension_flag = gf_bs_read_int_log(bs, 1, "vps_extension_flag");
if (vps_extension_flag) {
Bool res;
gf_bs_align(bs);
res = hevc_parse_vps_extension(vps, bs);
if (res != GF_TRUE) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[HEVC] Failed to parse VPS extensions\n"));
return -1;
}
if (gf_bs_read_int_log(bs, 1, "vps_extension2_flag")) {
#if 0
while (gf_bs_available(bs)) {
/*vps_extension_data_flag */ gf_bs_read_int(bs, 1);
}
#endif
}
}
return vps_id;
} | 763 | True | 1 |
CVE-2021-30022 | 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/gpac/gpac/issues/1720', 'name': 'https://github.com/gpac/gpac/issues/1720', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'name': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-190'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'There is a integer overflow in media_tools/av_parsers.c in the gf_avc_read_pps_bs_internal in GPAC 1.0.1. pps_id may be a negative number, so it will not return. However, avc->pps only has 255 unit, so there is an overflow, which results a crash.'}] | 2021-04-21T19:03Z | 2021-04-19T20:15Z | Integer Overflow or Wraparound | The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | An integer overflow or wraparound occurs when an integer value is incremented to a value that is too large to store in the associated representation. When this occurs, the value may wrap to become a very small or negative number. While this may be intended behavior in circumstances that rely on wrapping, it can have security consequences if the wrap is unexpected. This is especially the case if the integer overflow can be triggered using user-supplied inputs. This becomes security-critical when the result is used to control looping, make a security decision, or determine the offset or size in behaviors such as memory allocation, copying, concatenation, etc.
| https://cwe.mitre.org/data/definitions/190.html | 0 | jeanlf | 2021-03-29 09:34:02+02:00 | add safety in avc/hevc/vvc sps/pps/vps ID check - cf #1720 #1721 #1722 | 51cdb67ff7c5f1242ac58c5aa603ceaf1793b788 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_hevc_read_vps_bs_internal | gf_hevc_read_vps_bs_internal( GF_BitStream * bs , HEVCState * hevc , Bool stop_at_vps_ext) | ['bs', 'hevc', 'stop_at_vps_ext'] | static s32 gf_hevc_read_vps_bs_internal(GF_BitStream *bs, HEVCState *hevc, Bool stop_at_vps_ext)
{
u8 vps_sub_layer_ordering_info_present_flag, vps_extension_flag;
u32 i, j;
s32 vps_id;
HEVC_VPS *vps;
u8 layer_id_included_flag[MAX_LHVC_LAYERS][64];
//nalu header already parsed
vps_id = gf_bs_read_int_log(bs, 4, "vps_id");
if (vps_id >= 16) return -1;
vps = &hevc->vps[vps_id];
vps->bit_pos_vps_extensions = -1;
if (!vps->state) {
vps->id = vps_id;
vps->state = 1;
}
vps->base_layer_internal_flag = gf_bs_read_int_log(bs, 1, "base_layer_internal_flag");
vps->base_layer_available_flag = gf_bs_read_int_log(bs, 1, "base_layer_available_flag");
vps->max_layers = 1 + gf_bs_read_int_log(bs, 6, "max_layers_minus1");
if (vps->max_layers > MAX_LHVC_LAYERS) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[HEVC] sorry, %d layers in VPS but only %d supported\n", vps->max_layers, MAX_LHVC_LAYERS));
return -1;
}
vps->max_sub_layers = gf_bs_read_int_log(bs, 3, "max_sub_layers_minus1") + 1;
vps->temporal_id_nesting = gf_bs_read_int_log(bs, 1, "temporal_id_nesting");
gf_bs_read_int_log(bs, 16, "vps_reserved_ffff_16bits");
hevc_profile_tier_level(bs, 1, vps->max_sub_layers - 1, &vps->ptl, 0);
vps_sub_layer_ordering_info_present_flag = gf_bs_read_int_log(bs, 1, "vps_sub_layer_ordering_info_present_flag");
for (i = (vps_sub_layer_ordering_info_present_flag ? 0 : vps->max_sub_layers - 1); i < vps->max_sub_layers; i++) {
gf_bs_read_ue_log_idx(bs, "vps_max_dec_pic_buffering_minus1", i);
gf_bs_read_ue_log_idx(bs, "vps_max_num_reorder_pics", i);
gf_bs_read_ue_log_idx(bs, "vps_max_latency_increase_plus1", i);
}
vps->max_layer_id = gf_bs_read_int_log(bs, 6, "max_layer_id");
if (vps->max_layer_id > MAX_LHVC_LAYERS) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[HEVC] VPS max layer ID %u but GPAC only supports %u\n", vps->max_layer_id, MAX_LHVC_LAYERS));
return -1;
}
vps->num_layer_sets = gf_bs_read_ue_log(bs, "num_layer_sets_minus1") + 1;
if (vps->num_layer_sets > MAX_LHVC_LAYERS) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[HEVC] Wrong number of layer sets in VPS %d\n", vps->num_layer_sets));
return -1;
}
for (i = 1; i < vps->num_layer_sets; i++) {
for (j = 0; j <= vps->max_layer_id; j++) {
layer_id_included_flag[i][j] = gf_bs_read_int_log_idx2(bs, 1, "layer_id_included_flag", i, j);
}
}
vps->num_layers_in_id_list[0] = 1;
for (i = 1; i < vps->num_layer_sets; i++) {
u32 n, m;
n = 0;
for (m = 0; m <= vps->max_layer_id; m++) {
if (layer_id_included_flag[i][m]) {
vps->LayerSetLayerIdList[i][n++] = m;
if (vps->LayerSetLayerIdListMax[i] < m)
vps->LayerSetLayerIdListMax[i] = m;
}
}
vps->num_layers_in_id_list[i] = n;
}
if (gf_bs_read_int_log(bs, 1, "vps_timing_info_present_flag")) {
u32 vps_num_hrd_parameters;
gf_bs_read_int_log(bs, 32, "vps_num_units_in_tick");
gf_bs_read_int_log(bs, 32, "vps_time_scale");
if (gf_bs_read_int_log(bs, 1, "vps_poc_proportional_to_timing_flag")) {
gf_bs_read_ue_log(bs, "vps_num_ticks_poc_diff_one_minus1");
}
vps_num_hrd_parameters = gf_bs_read_ue_log(bs, "vps_num_hrd_parameters");
for (i = 0; i < vps_num_hrd_parameters; i++) {
Bool cprms_present_flag = GF_TRUE;
gf_bs_read_ue_log_idx(bs, "hrd_layer_set_idx", i);
if (i > 0)
cprms_present_flag = gf_bs_read_int_log(bs, 1, "cprms_present_flag");
hevc_parse_hrd_parameters(bs, cprms_present_flag, vps->max_sub_layers - 1, i);
}
}
if (stop_at_vps_ext) {
return vps_id;
}
vps_extension_flag = gf_bs_read_int_log(bs, 1, "vps_extension_flag");
if (vps_extension_flag) {
Bool res;
gf_bs_align(bs);
res = hevc_parse_vps_extension(vps, bs);
if (res != GF_TRUE) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[HEVC] Failed to parse VPS extensions\n"));
return -1;
}
if (gf_bs_read_int_log(bs, 1, "vps_extension2_flag")) {
#if 0
while (gf_bs_available(bs)) {
/*vps_extension_data_flag */ gf_bs_read_int(bs, 1);
}
#endif
}
}
return vps_id;
} | 763 | True | 1 |
CVE-2021-30014 | 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/gpac/gpac/issues/1721', 'name': 'https://github.com/gpac/gpac/issues/1721', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'name': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-190'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'There is a integer overflow in media_tools/av_parsers.c in the hevc_parse_slice_segment function in GPAC 1.0.1 which results in a crash.'}] | 2021-04-21T19:21Z | 2021-04-19T20:15Z | Integer Overflow or Wraparound | The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | An integer overflow or wraparound occurs when an integer value is incremented to a value that is too large to store in the associated representation. When this occurs, the value may wrap to become a very small or negative number. While this may be intended behavior in circumstances that rely on wrapping, it can have security consequences if the wrap is unexpected. This is especially the case if the integer overflow can be triggered using user-supplied inputs. This becomes security-critical when the result is used to control looping, make a security decision, or determine the offset or size in behaviors such as memory allocation, copying, concatenation, etc.
| https://cwe.mitre.org/data/definitions/190.html | 0 | jeanlf | 2021-03-29 09:34:02+02:00 | add safety in avc/hevc/vvc sps/pps/vps ID check - cf #1720 #1721 #1722 | 51cdb67ff7c5f1242ac58c5aa603ceaf1793b788 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_media_vvc_read_pps_bs_internal | gf_media_vvc_read_pps_bs_internal( GF_BitStream * bs , VVCState * vvc) | ['bs', 'vvc'] | static s32 gf_media_vvc_read_pps_bs_internal(GF_BitStream *bs, VVCState *vvc)
{
u32 i;
s32 pps_id;
VVC_PPS *pps;
//NAL header already read
pps_id = gf_bs_read_int_log(bs, 6, "pps_id");
if ((pps_id < 0) || (pps_id >= 64)) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[VVC] wrong PPS ID %d in PPS\n", pps_id));
return -1;
}
pps = &vvc->pps[pps_id];
if (!pps->state) {
pps->id = pps_id;
pps->state = 1;
}
pps->sps_id = gf_bs_read_int_log(bs, 4, "sps_id");
if (pps->sps_id >= 16) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[VVC] wrong SPS ID %d in PPS\n", pps->sps_id));
pps->sps_id=0;
return -1;
}
vvc->sps_active_idx = pps->sps_id; /*set active sps*/
pps->mixed_nal_types = gf_bs_read_int_log(bs, 1, "mixed_nal_types");
pps->width = gf_bs_read_ue_log(bs, "width");
pps->height = gf_bs_read_ue_log(bs, "height");
pps->conf_window = gf_bs_read_int_log(bs, 1, "conformance_window_flag");
if (pps->conf_window) {
pps->cw_left = gf_bs_read_ue_log(bs, "conf_win_left_offset");
pps->cw_right = gf_bs_read_ue_log(bs, "conf_win_right_offset");
pps->cw_top = gf_bs_read_ue_log(bs, "conf_win_top_offset");
pps->cw_bottom = gf_bs_read_ue_log(bs, "conf_win_bottom_offset");
}
//scaling window
if (gf_bs_read_int_log(bs, 1, "scaling_window_explicit_signalling_flag")) {
gf_bs_read_se_log(bs, "scaling_win_left_offset");
gf_bs_read_se_log(bs, "scaling_win_right_offset");
gf_bs_read_se_log(bs, "scaling_win_top_offset");
gf_bs_read_se_log(bs, "scaling_win_bottom_offset");
}
pps->output_flag_present_flag = gf_bs_read_int_log(bs, 1, "output_flag_present_flag");
pps->no_pic_partition_flag = gf_bs_read_int_log(bs, 1, "no_pic_partition_flag");
pps->subpic_id_mapping_present_flag = gf_bs_read_int_log(bs, 1, "subpic_id_mapping_present_flag");
if (pps->subpic_id_mapping_present_flag) {
u32 pps_subpic_id_len, pps_num_subpics=0;
if (!pps->no_pic_partition_flag) {
pps_num_subpics = 1+gf_bs_read_ue_log(bs, "pps_num_subpics_minus1");
}
pps_subpic_id_len = 1 + gf_bs_read_ue(bs);
for (i=0; i<pps_num_subpics; i++) {
gf_bs_read_int_log_idx(bs, pps_subpic_id_len, "subpic_id", i);
}
}
if (!pps->no_pic_partition_flag) {
gf_bs_read_int_log(bs, 2, "pps_log2_ctu_size_minus5");
u32 num_exp_tile_columns = 1 + gf_bs_read_ue_log(bs, "num_exp_tile_columns_minus1");
u32 num_exp_tile_rows = 1 + gf_bs_read_ue_log(bs, "num_exp_tile_rows_minus1");
for (i=0; i<num_exp_tile_columns; i++)
gf_bs_read_ue_log_idx(bs, "tile_column_width_minus1", i);
for (i=0; i<num_exp_tile_rows; i++)
gf_bs_read_ue_log_idx(bs, "tile_row_height_minus1", i);
//todo parse the rest
return pps_id;
}
//todo parse the rest
return pps_id;
} | 495 | True | 1 |
CVE-2021-30020 | 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/gpac/gpac/issues/1722', 'name': 'https://github.com/gpac/gpac/issues/1722', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'name': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-787'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'In the function gf_hevc_read_pps_bs_internal function in media_tools/av_parsers.c in GPAC 1.0.1 there is a loop, which with crafted file, pps->num_tile_columns may be larger than sizeof(pps->column_width), which results in a heap overflow in the loop.'}] | 2021-04-21T19:02Z | 2021-04-19T20: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 | jeanlf | 2021-03-29 09:34:02+02:00 | add safety in avc/hevc/vvc sps/pps/vps ID check - cf #1720 #1721 #1722 | 51cdb67ff7c5f1242ac58c5aa603ceaf1793b788 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_media_vvc_read_pps_bs_internal | gf_media_vvc_read_pps_bs_internal( GF_BitStream * bs , VVCState * vvc) | ['bs', 'vvc'] | static s32 gf_media_vvc_read_pps_bs_internal(GF_BitStream *bs, VVCState *vvc)
{
u32 i;
s32 pps_id;
VVC_PPS *pps;
//NAL header already read
pps_id = gf_bs_read_int_log(bs, 6, "pps_id");
if ((pps_id < 0) || (pps_id >= 64)) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[VVC] wrong PPS ID %d in PPS\n", pps_id));
return -1;
}
pps = &vvc->pps[pps_id];
if (!pps->state) {
pps->id = pps_id;
pps->state = 1;
}
pps->sps_id = gf_bs_read_int_log(bs, 4, "sps_id");
if (pps->sps_id >= 16) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[VVC] wrong SPS ID %d in PPS\n", pps->sps_id));
pps->sps_id=0;
return -1;
}
vvc->sps_active_idx = pps->sps_id; /*set active sps*/
pps->mixed_nal_types = gf_bs_read_int_log(bs, 1, "mixed_nal_types");
pps->width = gf_bs_read_ue_log(bs, "width");
pps->height = gf_bs_read_ue_log(bs, "height");
pps->conf_window = gf_bs_read_int_log(bs, 1, "conformance_window_flag");
if (pps->conf_window) {
pps->cw_left = gf_bs_read_ue_log(bs, "conf_win_left_offset");
pps->cw_right = gf_bs_read_ue_log(bs, "conf_win_right_offset");
pps->cw_top = gf_bs_read_ue_log(bs, "conf_win_top_offset");
pps->cw_bottom = gf_bs_read_ue_log(bs, "conf_win_bottom_offset");
}
//scaling window
if (gf_bs_read_int_log(bs, 1, "scaling_window_explicit_signalling_flag")) {
gf_bs_read_se_log(bs, "scaling_win_left_offset");
gf_bs_read_se_log(bs, "scaling_win_right_offset");
gf_bs_read_se_log(bs, "scaling_win_top_offset");
gf_bs_read_se_log(bs, "scaling_win_bottom_offset");
}
pps->output_flag_present_flag = gf_bs_read_int_log(bs, 1, "output_flag_present_flag");
pps->no_pic_partition_flag = gf_bs_read_int_log(bs, 1, "no_pic_partition_flag");
pps->subpic_id_mapping_present_flag = gf_bs_read_int_log(bs, 1, "subpic_id_mapping_present_flag");
if (pps->subpic_id_mapping_present_flag) {
u32 pps_subpic_id_len, pps_num_subpics=0;
if (!pps->no_pic_partition_flag) {
pps_num_subpics = 1+gf_bs_read_ue_log(bs, "pps_num_subpics_minus1");
}
pps_subpic_id_len = 1 + gf_bs_read_ue(bs);
for (i=0; i<pps_num_subpics; i++) {
gf_bs_read_int_log_idx(bs, pps_subpic_id_len, "subpic_id", i);
}
}
if (!pps->no_pic_partition_flag) {
gf_bs_read_int_log(bs, 2, "pps_log2_ctu_size_minus5");
u32 num_exp_tile_columns = 1 + gf_bs_read_ue_log(bs, "num_exp_tile_columns_minus1");
u32 num_exp_tile_rows = 1 + gf_bs_read_ue_log(bs, "num_exp_tile_rows_minus1");
for (i=0; i<num_exp_tile_columns; i++)
gf_bs_read_ue_log_idx(bs, "tile_column_width_minus1", i);
for (i=0; i<num_exp_tile_rows; i++)
gf_bs_read_ue_log_idx(bs, "tile_row_height_minus1", i);
//todo parse the rest
return pps_id;
}
//todo parse the rest
return pps_id;
} | 495 | True | 1 |
CVE-2021-30022 | 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/gpac/gpac/issues/1720', 'name': 'https://github.com/gpac/gpac/issues/1720', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'name': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-190'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'There is a integer overflow in media_tools/av_parsers.c in the gf_avc_read_pps_bs_internal in GPAC 1.0.1. pps_id may be a negative number, so it will not return. However, avc->pps only has 255 unit, so there is an overflow, which results a crash.'}] | 2021-04-21T19:03Z | 2021-04-19T20:15Z | Integer Overflow or Wraparound | The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | An integer overflow or wraparound occurs when an integer value is incremented to a value that is too large to store in the associated representation. When this occurs, the value may wrap to become a very small or negative number. While this may be intended behavior in circumstances that rely on wrapping, it can have security consequences if the wrap is unexpected. This is especially the case if the integer overflow can be triggered using user-supplied inputs. This becomes security-critical when the result is used to control looping, make a security decision, or determine the offset or size in behaviors such as memory allocation, copying, concatenation, etc.
| https://cwe.mitre.org/data/definitions/190.html | 0 | jeanlf | 2021-03-29 09:34:02+02:00 | add safety in avc/hevc/vvc sps/pps/vps ID check - cf #1720 #1721 #1722 | 51cdb67ff7c5f1242ac58c5aa603ceaf1793b788 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_media_vvc_read_pps_bs_internal | gf_media_vvc_read_pps_bs_internal( GF_BitStream * bs , VVCState * vvc) | ['bs', 'vvc'] | static s32 gf_media_vvc_read_pps_bs_internal(GF_BitStream *bs, VVCState *vvc)
{
u32 i;
s32 pps_id;
VVC_PPS *pps;
//NAL header already read
pps_id = gf_bs_read_int_log(bs, 6, "pps_id");
if ((pps_id < 0) || (pps_id >= 64)) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[VVC] wrong PPS ID %d in PPS\n", pps_id));
return -1;
}
pps = &vvc->pps[pps_id];
if (!pps->state) {
pps->id = pps_id;
pps->state = 1;
}
pps->sps_id = gf_bs_read_int_log(bs, 4, "sps_id");
if (pps->sps_id >= 16) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[VVC] wrong SPS ID %d in PPS\n", pps->sps_id));
pps->sps_id=0;
return -1;
}
vvc->sps_active_idx = pps->sps_id; /*set active sps*/
pps->mixed_nal_types = gf_bs_read_int_log(bs, 1, "mixed_nal_types");
pps->width = gf_bs_read_ue_log(bs, "width");
pps->height = gf_bs_read_ue_log(bs, "height");
pps->conf_window = gf_bs_read_int_log(bs, 1, "conformance_window_flag");
if (pps->conf_window) {
pps->cw_left = gf_bs_read_ue_log(bs, "conf_win_left_offset");
pps->cw_right = gf_bs_read_ue_log(bs, "conf_win_right_offset");
pps->cw_top = gf_bs_read_ue_log(bs, "conf_win_top_offset");
pps->cw_bottom = gf_bs_read_ue_log(bs, "conf_win_bottom_offset");
}
//scaling window
if (gf_bs_read_int_log(bs, 1, "scaling_window_explicit_signalling_flag")) {
gf_bs_read_se_log(bs, "scaling_win_left_offset");
gf_bs_read_se_log(bs, "scaling_win_right_offset");
gf_bs_read_se_log(bs, "scaling_win_top_offset");
gf_bs_read_se_log(bs, "scaling_win_bottom_offset");
}
pps->output_flag_present_flag = gf_bs_read_int_log(bs, 1, "output_flag_present_flag");
pps->no_pic_partition_flag = gf_bs_read_int_log(bs, 1, "no_pic_partition_flag");
pps->subpic_id_mapping_present_flag = gf_bs_read_int_log(bs, 1, "subpic_id_mapping_present_flag");
if (pps->subpic_id_mapping_present_flag) {
u32 pps_subpic_id_len, pps_num_subpics=0;
if (!pps->no_pic_partition_flag) {
pps_num_subpics = 1+gf_bs_read_ue_log(bs, "pps_num_subpics_minus1");
}
pps_subpic_id_len = 1 + gf_bs_read_ue(bs);
for (i=0; i<pps_num_subpics; i++) {
gf_bs_read_int_log_idx(bs, pps_subpic_id_len, "subpic_id", i);
}
}
if (!pps->no_pic_partition_flag) {
gf_bs_read_int_log(bs, 2, "pps_log2_ctu_size_minus5");
u32 num_exp_tile_columns = 1 + gf_bs_read_ue_log(bs, "num_exp_tile_columns_minus1");
u32 num_exp_tile_rows = 1 + gf_bs_read_ue_log(bs, "num_exp_tile_rows_minus1");
for (i=0; i<num_exp_tile_columns; i++)
gf_bs_read_ue_log_idx(bs, "tile_column_width_minus1", i);
for (i=0; i<num_exp_tile_rows; i++)
gf_bs_read_ue_log_idx(bs, "tile_row_height_minus1", i);
//todo parse the rest
return pps_id;
}
//todo parse the rest
return pps_id;
} | 495 | True | 1 |
CVE-2021-30014 | 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/gpac/gpac/issues/1721', 'name': 'https://github.com/gpac/gpac/issues/1721', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'name': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-190'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'There is a integer overflow in media_tools/av_parsers.c in the hevc_parse_slice_segment function in GPAC 1.0.1 which results in a crash.'}] | 2021-04-21T19:21Z | 2021-04-19T20:15Z | Integer Overflow or Wraparound | The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | An integer overflow or wraparound occurs when an integer value is incremented to a value that is too large to store in the associated representation. When this occurs, the value may wrap to become a very small or negative number. While this may be intended behavior in circumstances that rely on wrapping, it can have security consequences if the wrap is unexpected. This is especially the case if the integer overflow can be triggered using user-supplied inputs. This becomes security-critical when the result is used to control looping, make a security decision, or determine the offset or size in behaviors such as memory allocation, copying, concatenation, etc.
| https://cwe.mitre.org/data/definitions/190.html | 0 | jeanlf | 2021-03-29 09:34:02+02:00 | add safety in avc/hevc/vvc sps/pps/vps ID check - cf #1720 #1721 #1722 | 51cdb67ff7c5f1242ac58c5aa603ceaf1793b788 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_media_vvc_read_sps_bs_internal | gf_media_vvc_read_sps_bs_internal( GF_BitStream * bs , VVCState * vvc , u8 layer_id , u32 * vui_flag_pos) | ['bs', 'vvc', 'layer_id', 'vui_flag_pos'] | static s32 gf_media_vvc_read_sps_bs_internal(GF_BitStream *bs, VVCState *vvc, u8 layer_id, u32 *vui_flag_pos)
{
s32 vps_id, sps_id;
u32 i, CtbSizeY;
VVC_SPS *sps;
u8 sps_ptl_dpb_hrd_params_present_flag;
if (vui_flag_pos) *vui_flag_pos = 0;
sps_id = gf_bs_read_int_log(bs, 4, "sps_id");
if (sps_id >= 16) {
return -1;
}
vps_id = gf_bs_read_int_log(bs, 4, "vps_id");
if (vps_id >= 16) {
return -1;
}
if (!vps_id && !vvc->vps[0].state) {
vvc->vps[0].state = 1;
vvc->vps[0].num_ptl = 1;
vvc->vps[0].max_layers = 1;
vvc->vps[0].all_layers_independent = 1;
}
sps = &vvc->sps[sps_id];
if (!sps->state) {
sps->state = 1;
sps->id = sps_id;
sps->vps_id = vps_id;
}
sps->max_sublayers = 1 + gf_bs_read_int_log(bs, 3, "max_sublayers_minus1");
sps->chroma_format_idc = gf_bs_read_int_log(bs, 2, "chroma_format_idc");
sps->log2_ctu_size = 5 + gf_bs_read_int_log(bs, 2, "log2_ctu_size_minus5");
CtbSizeY = 1<<sps->log2_ctu_size;
sps_ptl_dpb_hrd_params_present_flag = gf_bs_read_int_log(bs, 1, "sps_ptl_dpb_hrd_params_present_flag");
if (sps_ptl_dpb_hrd_params_present_flag) {
VVC_ProfileTierLevel ptl, *p_ptl;
if (sps->vps_id) {
p_ptl = &ptl;
} else {
p_ptl = &vvc->vps[0].ptl[0];
}
memset(p_ptl, 0, sizeof(VVC_ProfileTierLevel));
p_ptl->pt_present = 1;
p_ptl->ptl_max_tid = sps->max_sublayers;
vvc_profile_tier_level(bs, p_ptl, 0);
}
sps->gdr_enabled = gf_bs_read_int_log(bs, 1, "gdr_enabled");
sps->ref_pic_resampling = gf_bs_read_int_log(bs, 1, "ref_pic_resampling");
if (sps->ref_pic_resampling)
sps->res_change_in_clvs = gf_bs_read_int_log(bs, 1, "res_change_in_clvs");
sps->width = gf_bs_read_ue_log(bs, "width");
sps->height = gf_bs_read_ue_log(bs, "height");
sps->conf_window = gf_bs_read_int_log(bs, 1, "conformance_window_present_flag");
if (sps->conf_window) {
sps->cw_left = gf_bs_read_ue_log(bs, "conformance_window_left");
sps->cw_right = gf_bs_read_ue_log(bs, "conformance_window_right");
sps->cw_top = gf_bs_read_ue_log(bs, "conformance_window_top");
sps->cw_bottom = gf_bs_read_ue_log(bs, "conformance_window_bottom");
}
sps->subpic_info_present = gf_bs_read_int_log(bs, 1, "subpic_info_present");
if (sps->subpic_info_present) {
sps->nb_subpics = 1 + gf_bs_read_ue_log(bs, "nb_subpics_minus1");
if (sps->nb_subpics>1) {
u32 tmpWidthVal, tmpHeightVal;
sps->independent_subpic_flags = gf_bs_read_int_log(bs, 1, "independent_subpic_flags");
sps->subpic_same_size = gf_bs_read_int_log(bs, 1, "subpic_same_size");
tmpWidthVal = (sps->width + CtbSizeY-1) / CtbSizeY;
tmpWidthVal = gf_get_bit_size(tmpWidthVal);
tmpHeightVal = (sps->height + CtbSizeY-1) / CtbSizeY;
tmpHeightVal = gf_get_bit_size(tmpHeightVal);
for (i=0; i<sps->nb_subpics; i++) {
if( !sps->subpic_same_size || !i) {
if (i && (sps->width > CtbSizeY))
gf_bs_read_int_log(bs, tmpWidthVal, "subpic_ctu_top_left_x");
if (i && (sps->height > CtbSizeY))
gf_bs_read_int_log(bs, tmpHeightVal, "subpic_ctu_top_left_y");
if ((i+1 < sps->nb_subpics) && (sps->width > CtbSizeY))
gf_bs_read_int_log(bs, tmpWidthVal, "subpic_width_minus1");
if ((i+1 < sps->nb_subpics) && (sps->height > CtbSizeY))
gf_bs_read_int_log(bs, tmpHeightVal, "subpic_height_minus1");
}
if (!sps->independent_subpic_flags) {
gf_bs_read_int_log(bs, 1, "subpic_treated_as_pic_flag");
gf_bs_read_int_log(bs, 1, "loop_filter_across_subpic_enabled_flag");
}
}
sps->subpicid_len = gf_bs_read_ue_log(bs, "subpic_id_len_minus1") + 1;
sps->subpicid_mapping_explicit = gf_bs_read_int_log(bs, 1, "subpic_id_mapping_explicitly_signalled_flag");
if (sps->subpicid_mapping_explicit) {
sps->subpicid_mapping_present = gf_bs_read_int_log(bs, 1, "subpic_id_mapping_present_flag");
if (sps->subpicid_mapping_present) {
for (i=0; i<sps->nb_subpics; i++) {
gf_bs_read_ue_log(bs, "subpic_id");
}
}
}
}
}
sps->bitdepth = gf_bs_read_ue_log(bs, "bitdepth_minus8") + 8;
gf_bs_read_int_log(bs, 1, "entropy_coding_sync_enabled_flag");
gf_bs_read_int_log(bs, 1, "entry_point_offsets_present_flag");
sps->log2_max_poc_lsb = 4 + gf_bs_read_int_log(bs, 4, "log2_max_poc_lsb_minus4");
if ((sps->poc_msb_cycle_flag = gf_bs_read_int_log(bs, 1, "poc_msb_cycle_flag")))
sps->poc_msb_cycle_len = 1 + gf_bs_read_ue_log(bs, "poc_msb_cycle_len_minus1");
u8 sps_num_extra_ph_bits = 8 * gf_bs_read_int_log(bs, 2, "sps_num_extra_ph_bytes");
for (i=0; i<sps_num_extra_ph_bits; i++) {
if (gf_bs_read_int_log_idx(bs, 1, "extra_ph_bit_present_flag", 1))
sps->ph_num_extra_bits++;
}
u8 sps_num_extra_sh_bits = 8 * gf_bs_read_int_log(bs, 2, "num_extra_sh_bytes");
for (i=0; i<sps_num_extra_sh_bits; i++) {
if (gf_bs_read_int_log_idx(bs, 1, "extra_sh_bit_present_flag", i))
sps->sh_num_extra_bits++;
}
if (sps_ptl_dpb_hrd_params_present_flag) {
u8 sps_sublayer_dpb_params_flag = 0;
if (sps->max_sublayers>1) {
sps_sublayer_dpb_params_flag = gf_bs_read_int_log(bs, 1, "sps_sublayer_dpb_params_flag");
}
for (i=(sps_sublayer_dpb_params_flag ? 0 : sps->max_sublayers-1); i < sps->max_sublayers; i++ ) {
gf_bs_read_ue_log_idx(bs, "dpb_max_dec_pic_buffering_minus1", i);
gf_bs_read_ue_log_idx(bs, "dpb_max_num_reorder_pics", i);
gf_bs_read_ue_log_idx(bs, "dpb_max_latency_increase_plus1", i);
}
}
gf_bs_read_ue_log(bs, "sps_log2_min_luma_coding_block_size_minus2");
gf_bs_read_int_log(bs, 1, "sps_partition_constraints_override_enabled_flag");
gf_bs_read_ue_log(bs, "sps_log2_min_luma_coding_block_size_minus2");
u8 sps_max_mtt_hierarchy_depth_intra_slice_luma = gf_bs_read_ue_log(bs, "sps_max_mtt_hierarchy_depth_intra_slice_luma");
if (sps_max_mtt_hierarchy_depth_intra_slice_luma != 0) {
gf_bs_read_ue_log(bs, "sps_log2_diff_max_bt_min_qt_intra_slice_luma");
gf_bs_read_ue_log(bs, "sps_log2_diff_max_tt_min_qt_intra_slice_luma");
}
u8 sps_qtbtt_dual_tree_intra_flag = 0;
if (sps->chroma_format_idc) {
sps_qtbtt_dual_tree_intra_flag = gf_bs_read_int_log(bs, 1, "sps_qtbtt_dual_tree_intra_flag");
}
if (sps_qtbtt_dual_tree_intra_flag) {
gf_bs_read_ue_log(bs, "sps_log2_diff_min_qt_min_cb_intra_slice_chroma");
u8 sps_max_mtt_hierarchy_depth_intra_slice_chroma = gf_bs_read_ue_log(bs, "sps_max_mtt_hierarchy_depth_intra_slice_chroma");
if( sps_max_mtt_hierarchy_depth_intra_slice_chroma != 0) {
gf_bs_read_ue_log(bs, "sps_log2_diff_max_bt_min_qt_intra_slice_chroma");
gf_bs_read_ue_log(bs, "sps_log2_diff_max_tt_min_qt_intra_slice_chroma");
}
}
gf_bs_read_ue_log(bs, "sps_log2_diff_min_qt_min_cb_inter_slice");
u8 sps_max_mtt_hierarchy_depth_inter_slice = gf_bs_read_ue_log(bs, "sps_max_mtt_hierarchy_depth_inter_slice");
if (sps_max_mtt_hierarchy_depth_inter_slice != 0) {
gf_bs_read_ue_log(bs, "sps_log2_diff_max_bt_min_qt_inter_slice");
gf_bs_read_ue_log(bs, "sps_log2_diff_max_tt_min_qt_inter_slice");
}
//u8 sps_max_luma_transform_size_64_flag = 0;
if (CtbSizeY > 32) {
/*sps_max_luma_transform_size_64_flag = */gf_bs_read_int_log(bs, 1, "sps_max_luma_transform_size_64_flag");
}
u8 sps_transform_skip_enabled_flag = gf_bs_read_int_log(bs, 1, "sps_transform_skip_enabled_flag");
if (sps_transform_skip_enabled_flag) {
gf_bs_read_ue_log(bs, "sps_log2_transform_skip_max_size_minus2");
gf_bs_read_int_log(bs, 1, "sps_bdpcm_enabled_flag");
}
if (gf_bs_read_int_log(bs, 1, "sps_mts_enabled_flag")) {
gf_bs_read_int_log(bs, 1, "sps_explicit_mts_intra_enabled_flag");
gf_bs_read_int_log(bs, 1, "sps_explicit_mts_inter_enabled_flag");
}
gf_bs_read_int_log(bs, 1, "sps_lfnst_enabled_flag");
if (sps->chroma_format_idc) {
u8 sps_joint_cbcr_enabled_flag = gf_bs_read_int_log(bs, 1, "sps_joint_cbcr_enabled_flag");
u8 sps_same_qp_table_for_chroma_flag = gf_bs_read_int_log(bs, 1, "sps_same_qp_table_for_chroma_flag");
u32 numQpTables = sps_same_qp_table_for_chroma_flag ? 1 : (sps_joint_cbcr_enabled_flag ? 3 : 2);
for (i=0; i<numQpTables; i++) {
gf_bs_read_se_log_idx(bs, "sps_qp_table_start_minus26", i);
u32 j, sps_num_points_in_qp_table = 1 + gf_bs_read_ue_log_idx(bs, "sps_num_points_in_qp_table_minus1", i);
for (j=0; j<sps_num_points_in_qp_table; j++) {
gf_bs_read_ue_log_idx2(bs, "sps_delta_qp_in_val_minus1", i, j);
gf_bs_read_ue_log_idx2(bs, "sps_delta_qp_diff_val", i, j);
}
}
}
gf_bs_read_int_log(bs, 1, "sps_sao_enabled_flag");
sps->alf_enabled_flag = gf_bs_read_int_log(bs, 1, "sps_alf_enabled_flag");
if (sps->alf_enabled_flag && sps->chroma_format_idc) {
gf_bs_read_int_log(bs, 1, "sps_ccalf_enabled_flag");
}
/*! TODO parse the rest !*/
return sps_id;
} | 1494 | True | 1 |
CVE-2021-30020 | 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/gpac/gpac/issues/1722', 'name': 'https://github.com/gpac/gpac/issues/1722', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'name': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-787'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'In the function gf_hevc_read_pps_bs_internal function in media_tools/av_parsers.c in GPAC 1.0.1 there is a loop, which with crafted file, pps->num_tile_columns may be larger than sizeof(pps->column_width), which results in a heap overflow in the loop.'}] | 2021-04-21T19:02Z | 2021-04-19T20: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 | jeanlf | 2021-03-29 09:34:02+02:00 | add safety in avc/hevc/vvc sps/pps/vps ID check - cf #1720 #1721 #1722 | 51cdb67ff7c5f1242ac58c5aa603ceaf1793b788 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_media_vvc_read_sps_bs_internal | gf_media_vvc_read_sps_bs_internal( GF_BitStream * bs , VVCState * vvc , u8 layer_id , u32 * vui_flag_pos) | ['bs', 'vvc', 'layer_id', 'vui_flag_pos'] | static s32 gf_media_vvc_read_sps_bs_internal(GF_BitStream *bs, VVCState *vvc, u8 layer_id, u32 *vui_flag_pos)
{
s32 vps_id, sps_id;
u32 i, CtbSizeY;
VVC_SPS *sps;
u8 sps_ptl_dpb_hrd_params_present_flag;
if (vui_flag_pos) *vui_flag_pos = 0;
sps_id = gf_bs_read_int_log(bs, 4, "sps_id");
if (sps_id >= 16) {
return -1;
}
vps_id = gf_bs_read_int_log(bs, 4, "vps_id");
if (vps_id >= 16) {
return -1;
}
if (!vps_id && !vvc->vps[0].state) {
vvc->vps[0].state = 1;
vvc->vps[0].num_ptl = 1;
vvc->vps[0].max_layers = 1;
vvc->vps[0].all_layers_independent = 1;
}
sps = &vvc->sps[sps_id];
if (!sps->state) {
sps->state = 1;
sps->id = sps_id;
sps->vps_id = vps_id;
}
sps->max_sublayers = 1 + gf_bs_read_int_log(bs, 3, "max_sublayers_minus1");
sps->chroma_format_idc = gf_bs_read_int_log(bs, 2, "chroma_format_idc");
sps->log2_ctu_size = 5 + gf_bs_read_int_log(bs, 2, "log2_ctu_size_minus5");
CtbSizeY = 1<<sps->log2_ctu_size;
sps_ptl_dpb_hrd_params_present_flag = gf_bs_read_int_log(bs, 1, "sps_ptl_dpb_hrd_params_present_flag");
if (sps_ptl_dpb_hrd_params_present_flag) {
VVC_ProfileTierLevel ptl, *p_ptl;
if (sps->vps_id) {
p_ptl = &ptl;
} else {
p_ptl = &vvc->vps[0].ptl[0];
}
memset(p_ptl, 0, sizeof(VVC_ProfileTierLevel));
p_ptl->pt_present = 1;
p_ptl->ptl_max_tid = sps->max_sublayers;
vvc_profile_tier_level(bs, p_ptl, 0);
}
sps->gdr_enabled = gf_bs_read_int_log(bs, 1, "gdr_enabled");
sps->ref_pic_resampling = gf_bs_read_int_log(bs, 1, "ref_pic_resampling");
if (sps->ref_pic_resampling)
sps->res_change_in_clvs = gf_bs_read_int_log(bs, 1, "res_change_in_clvs");
sps->width = gf_bs_read_ue_log(bs, "width");
sps->height = gf_bs_read_ue_log(bs, "height");
sps->conf_window = gf_bs_read_int_log(bs, 1, "conformance_window_present_flag");
if (sps->conf_window) {
sps->cw_left = gf_bs_read_ue_log(bs, "conformance_window_left");
sps->cw_right = gf_bs_read_ue_log(bs, "conformance_window_right");
sps->cw_top = gf_bs_read_ue_log(bs, "conformance_window_top");
sps->cw_bottom = gf_bs_read_ue_log(bs, "conformance_window_bottom");
}
sps->subpic_info_present = gf_bs_read_int_log(bs, 1, "subpic_info_present");
if (sps->subpic_info_present) {
sps->nb_subpics = 1 + gf_bs_read_ue_log(bs, "nb_subpics_minus1");
if (sps->nb_subpics>1) {
u32 tmpWidthVal, tmpHeightVal;
sps->independent_subpic_flags = gf_bs_read_int_log(bs, 1, "independent_subpic_flags");
sps->subpic_same_size = gf_bs_read_int_log(bs, 1, "subpic_same_size");
tmpWidthVal = (sps->width + CtbSizeY-1) / CtbSizeY;
tmpWidthVal = gf_get_bit_size(tmpWidthVal);
tmpHeightVal = (sps->height + CtbSizeY-1) / CtbSizeY;
tmpHeightVal = gf_get_bit_size(tmpHeightVal);
for (i=0; i<sps->nb_subpics; i++) {
if( !sps->subpic_same_size || !i) {
if (i && (sps->width > CtbSizeY))
gf_bs_read_int_log(bs, tmpWidthVal, "subpic_ctu_top_left_x");
if (i && (sps->height > CtbSizeY))
gf_bs_read_int_log(bs, tmpHeightVal, "subpic_ctu_top_left_y");
if ((i+1 < sps->nb_subpics) && (sps->width > CtbSizeY))
gf_bs_read_int_log(bs, tmpWidthVal, "subpic_width_minus1");
if ((i+1 < sps->nb_subpics) && (sps->height > CtbSizeY))
gf_bs_read_int_log(bs, tmpHeightVal, "subpic_height_minus1");
}
if (!sps->independent_subpic_flags) {
gf_bs_read_int_log(bs, 1, "subpic_treated_as_pic_flag");
gf_bs_read_int_log(bs, 1, "loop_filter_across_subpic_enabled_flag");
}
}
sps->subpicid_len = gf_bs_read_ue_log(bs, "subpic_id_len_minus1") + 1;
sps->subpicid_mapping_explicit = gf_bs_read_int_log(bs, 1, "subpic_id_mapping_explicitly_signalled_flag");
if (sps->subpicid_mapping_explicit) {
sps->subpicid_mapping_present = gf_bs_read_int_log(bs, 1, "subpic_id_mapping_present_flag");
if (sps->subpicid_mapping_present) {
for (i=0; i<sps->nb_subpics; i++) {
gf_bs_read_ue_log(bs, "subpic_id");
}
}
}
}
}
sps->bitdepth = gf_bs_read_ue_log(bs, "bitdepth_minus8") + 8;
gf_bs_read_int_log(bs, 1, "entropy_coding_sync_enabled_flag");
gf_bs_read_int_log(bs, 1, "entry_point_offsets_present_flag");
sps->log2_max_poc_lsb = 4 + gf_bs_read_int_log(bs, 4, "log2_max_poc_lsb_minus4");
if ((sps->poc_msb_cycle_flag = gf_bs_read_int_log(bs, 1, "poc_msb_cycle_flag")))
sps->poc_msb_cycle_len = 1 + gf_bs_read_ue_log(bs, "poc_msb_cycle_len_minus1");
u8 sps_num_extra_ph_bits = 8 * gf_bs_read_int_log(bs, 2, "sps_num_extra_ph_bytes");
for (i=0; i<sps_num_extra_ph_bits; i++) {
if (gf_bs_read_int_log_idx(bs, 1, "extra_ph_bit_present_flag", 1))
sps->ph_num_extra_bits++;
}
u8 sps_num_extra_sh_bits = 8 * gf_bs_read_int_log(bs, 2, "num_extra_sh_bytes");
for (i=0; i<sps_num_extra_sh_bits; i++) {
if (gf_bs_read_int_log_idx(bs, 1, "extra_sh_bit_present_flag", i))
sps->sh_num_extra_bits++;
}
if (sps_ptl_dpb_hrd_params_present_flag) {
u8 sps_sublayer_dpb_params_flag = 0;
if (sps->max_sublayers>1) {
sps_sublayer_dpb_params_flag = gf_bs_read_int_log(bs, 1, "sps_sublayer_dpb_params_flag");
}
for (i=(sps_sublayer_dpb_params_flag ? 0 : sps->max_sublayers-1); i < sps->max_sublayers; i++ ) {
gf_bs_read_ue_log_idx(bs, "dpb_max_dec_pic_buffering_minus1", i);
gf_bs_read_ue_log_idx(bs, "dpb_max_num_reorder_pics", i);
gf_bs_read_ue_log_idx(bs, "dpb_max_latency_increase_plus1", i);
}
}
gf_bs_read_ue_log(bs, "sps_log2_min_luma_coding_block_size_minus2");
gf_bs_read_int_log(bs, 1, "sps_partition_constraints_override_enabled_flag");
gf_bs_read_ue_log(bs, "sps_log2_min_luma_coding_block_size_minus2");
u8 sps_max_mtt_hierarchy_depth_intra_slice_luma = gf_bs_read_ue_log(bs, "sps_max_mtt_hierarchy_depth_intra_slice_luma");
if (sps_max_mtt_hierarchy_depth_intra_slice_luma != 0) {
gf_bs_read_ue_log(bs, "sps_log2_diff_max_bt_min_qt_intra_slice_luma");
gf_bs_read_ue_log(bs, "sps_log2_diff_max_tt_min_qt_intra_slice_luma");
}
u8 sps_qtbtt_dual_tree_intra_flag = 0;
if (sps->chroma_format_idc) {
sps_qtbtt_dual_tree_intra_flag = gf_bs_read_int_log(bs, 1, "sps_qtbtt_dual_tree_intra_flag");
}
if (sps_qtbtt_dual_tree_intra_flag) {
gf_bs_read_ue_log(bs, "sps_log2_diff_min_qt_min_cb_intra_slice_chroma");
u8 sps_max_mtt_hierarchy_depth_intra_slice_chroma = gf_bs_read_ue_log(bs, "sps_max_mtt_hierarchy_depth_intra_slice_chroma");
if( sps_max_mtt_hierarchy_depth_intra_slice_chroma != 0) {
gf_bs_read_ue_log(bs, "sps_log2_diff_max_bt_min_qt_intra_slice_chroma");
gf_bs_read_ue_log(bs, "sps_log2_diff_max_tt_min_qt_intra_slice_chroma");
}
}
gf_bs_read_ue_log(bs, "sps_log2_diff_min_qt_min_cb_inter_slice");
u8 sps_max_mtt_hierarchy_depth_inter_slice = gf_bs_read_ue_log(bs, "sps_max_mtt_hierarchy_depth_inter_slice");
if (sps_max_mtt_hierarchy_depth_inter_slice != 0) {
gf_bs_read_ue_log(bs, "sps_log2_diff_max_bt_min_qt_inter_slice");
gf_bs_read_ue_log(bs, "sps_log2_diff_max_tt_min_qt_inter_slice");
}
//u8 sps_max_luma_transform_size_64_flag = 0;
if (CtbSizeY > 32) {
/*sps_max_luma_transform_size_64_flag = */gf_bs_read_int_log(bs, 1, "sps_max_luma_transform_size_64_flag");
}
u8 sps_transform_skip_enabled_flag = gf_bs_read_int_log(bs, 1, "sps_transform_skip_enabled_flag");
if (sps_transform_skip_enabled_flag) {
gf_bs_read_ue_log(bs, "sps_log2_transform_skip_max_size_minus2");
gf_bs_read_int_log(bs, 1, "sps_bdpcm_enabled_flag");
}
if (gf_bs_read_int_log(bs, 1, "sps_mts_enabled_flag")) {
gf_bs_read_int_log(bs, 1, "sps_explicit_mts_intra_enabled_flag");
gf_bs_read_int_log(bs, 1, "sps_explicit_mts_inter_enabled_flag");
}
gf_bs_read_int_log(bs, 1, "sps_lfnst_enabled_flag");
if (sps->chroma_format_idc) {
u8 sps_joint_cbcr_enabled_flag = gf_bs_read_int_log(bs, 1, "sps_joint_cbcr_enabled_flag");
u8 sps_same_qp_table_for_chroma_flag = gf_bs_read_int_log(bs, 1, "sps_same_qp_table_for_chroma_flag");
u32 numQpTables = sps_same_qp_table_for_chroma_flag ? 1 : (sps_joint_cbcr_enabled_flag ? 3 : 2);
for (i=0; i<numQpTables; i++) {
gf_bs_read_se_log_idx(bs, "sps_qp_table_start_minus26", i);
u32 j, sps_num_points_in_qp_table = 1 + gf_bs_read_ue_log_idx(bs, "sps_num_points_in_qp_table_minus1", i);
for (j=0; j<sps_num_points_in_qp_table; j++) {
gf_bs_read_ue_log_idx2(bs, "sps_delta_qp_in_val_minus1", i, j);
gf_bs_read_ue_log_idx2(bs, "sps_delta_qp_diff_val", i, j);
}
}
}
gf_bs_read_int_log(bs, 1, "sps_sao_enabled_flag");
sps->alf_enabled_flag = gf_bs_read_int_log(bs, 1, "sps_alf_enabled_flag");
if (sps->alf_enabled_flag && sps->chroma_format_idc) {
gf_bs_read_int_log(bs, 1, "sps_ccalf_enabled_flag");
}
/*! TODO parse the rest !*/
return sps_id;
} | 1494 | True | 1 |
CVE-2021-30022 | 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/gpac/gpac/issues/1720', 'name': 'https://github.com/gpac/gpac/issues/1720', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'name': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-190'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'There is a integer overflow in media_tools/av_parsers.c in the gf_avc_read_pps_bs_internal in GPAC 1.0.1. pps_id may be a negative number, so it will not return. However, avc->pps only has 255 unit, so there is an overflow, which results a crash.'}] | 2021-04-21T19:03Z | 2021-04-19T20:15Z | Integer Overflow or Wraparound | The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | An integer overflow or wraparound occurs when an integer value is incremented to a value that is too large to store in the associated representation. When this occurs, the value may wrap to become a very small or negative number. While this may be intended behavior in circumstances that rely on wrapping, it can have security consequences if the wrap is unexpected. This is especially the case if the integer overflow can be triggered using user-supplied inputs. This becomes security-critical when the result is used to control looping, make a security decision, or determine the offset or size in behaviors such as memory allocation, copying, concatenation, etc.
| https://cwe.mitre.org/data/definitions/190.html | 0 | jeanlf | 2021-03-29 09:34:02+02:00 | add safety in avc/hevc/vvc sps/pps/vps ID check - cf #1720 #1721 #1722 | 51cdb67ff7c5f1242ac58c5aa603ceaf1793b788 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_media_vvc_read_sps_bs_internal | gf_media_vvc_read_sps_bs_internal( GF_BitStream * bs , VVCState * vvc , u8 layer_id , u32 * vui_flag_pos) | ['bs', 'vvc', 'layer_id', 'vui_flag_pos'] | static s32 gf_media_vvc_read_sps_bs_internal(GF_BitStream *bs, VVCState *vvc, u8 layer_id, u32 *vui_flag_pos)
{
s32 vps_id, sps_id;
u32 i, CtbSizeY;
VVC_SPS *sps;
u8 sps_ptl_dpb_hrd_params_present_flag;
if (vui_flag_pos) *vui_flag_pos = 0;
sps_id = gf_bs_read_int_log(bs, 4, "sps_id");
if (sps_id >= 16) {
return -1;
}
vps_id = gf_bs_read_int_log(bs, 4, "vps_id");
if (vps_id >= 16) {
return -1;
}
if (!vps_id && !vvc->vps[0].state) {
vvc->vps[0].state = 1;
vvc->vps[0].num_ptl = 1;
vvc->vps[0].max_layers = 1;
vvc->vps[0].all_layers_independent = 1;
}
sps = &vvc->sps[sps_id];
if (!sps->state) {
sps->state = 1;
sps->id = sps_id;
sps->vps_id = vps_id;
}
sps->max_sublayers = 1 + gf_bs_read_int_log(bs, 3, "max_sublayers_minus1");
sps->chroma_format_idc = gf_bs_read_int_log(bs, 2, "chroma_format_idc");
sps->log2_ctu_size = 5 + gf_bs_read_int_log(bs, 2, "log2_ctu_size_minus5");
CtbSizeY = 1<<sps->log2_ctu_size;
sps_ptl_dpb_hrd_params_present_flag = gf_bs_read_int_log(bs, 1, "sps_ptl_dpb_hrd_params_present_flag");
if (sps_ptl_dpb_hrd_params_present_flag) {
VVC_ProfileTierLevel ptl, *p_ptl;
if (sps->vps_id) {
p_ptl = &ptl;
} else {
p_ptl = &vvc->vps[0].ptl[0];
}
memset(p_ptl, 0, sizeof(VVC_ProfileTierLevel));
p_ptl->pt_present = 1;
p_ptl->ptl_max_tid = sps->max_sublayers;
vvc_profile_tier_level(bs, p_ptl, 0);
}
sps->gdr_enabled = gf_bs_read_int_log(bs, 1, "gdr_enabled");
sps->ref_pic_resampling = gf_bs_read_int_log(bs, 1, "ref_pic_resampling");
if (sps->ref_pic_resampling)
sps->res_change_in_clvs = gf_bs_read_int_log(bs, 1, "res_change_in_clvs");
sps->width = gf_bs_read_ue_log(bs, "width");
sps->height = gf_bs_read_ue_log(bs, "height");
sps->conf_window = gf_bs_read_int_log(bs, 1, "conformance_window_present_flag");
if (sps->conf_window) {
sps->cw_left = gf_bs_read_ue_log(bs, "conformance_window_left");
sps->cw_right = gf_bs_read_ue_log(bs, "conformance_window_right");
sps->cw_top = gf_bs_read_ue_log(bs, "conformance_window_top");
sps->cw_bottom = gf_bs_read_ue_log(bs, "conformance_window_bottom");
}
sps->subpic_info_present = gf_bs_read_int_log(bs, 1, "subpic_info_present");
if (sps->subpic_info_present) {
sps->nb_subpics = 1 + gf_bs_read_ue_log(bs, "nb_subpics_minus1");
if (sps->nb_subpics>1) {
u32 tmpWidthVal, tmpHeightVal;
sps->independent_subpic_flags = gf_bs_read_int_log(bs, 1, "independent_subpic_flags");
sps->subpic_same_size = gf_bs_read_int_log(bs, 1, "subpic_same_size");
tmpWidthVal = (sps->width + CtbSizeY-1) / CtbSizeY;
tmpWidthVal = gf_get_bit_size(tmpWidthVal);
tmpHeightVal = (sps->height + CtbSizeY-1) / CtbSizeY;
tmpHeightVal = gf_get_bit_size(tmpHeightVal);
for (i=0; i<sps->nb_subpics; i++) {
if( !sps->subpic_same_size || !i) {
if (i && (sps->width > CtbSizeY))
gf_bs_read_int_log(bs, tmpWidthVal, "subpic_ctu_top_left_x");
if (i && (sps->height > CtbSizeY))
gf_bs_read_int_log(bs, tmpHeightVal, "subpic_ctu_top_left_y");
if ((i+1 < sps->nb_subpics) && (sps->width > CtbSizeY))
gf_bs_read_int_log(bs, tmpWidthVal, "subpic_width_minus1");
if ((i+1 < sps->nb_subpics) && (sps->height > CtbSizeY))
gf_bs_read_int_log(bs, tmpHeightVal, "subpic_height_minus1");
}
if (!sps->independent_subpic_flags) {
gf_bs_read_int_log(bs, 1, "subpic_treated_as_pic_flag");
gf_bs_read_int_log(bs, 1, "loop_filter_across_subpic_enabled_flag");
}
}
sps->subpicid_len = gf_bs_read_ue_log(bs, "subpic_id_len_minus1") + 1;
sps->subpicid_mapping_explicit = gf_bs_read_int_log(bs, 1, "subpic_id_mapping_explicitly_signalled_flag");
if (sps->subpicid_mapping_explicit) {
sps->subpicid_mapping_present = gf_bs_read_int_log(bs, 1, "subpic_id_mapping_present_flag");
if (sps->subpicid_mapping_present) {
for (i=0; i<sps->nb_subpics; i++) {
gf_bs_read_ue_log(bs, "subpic_id");
}
}
}
}
}
sps->bitdepth = gf_bs_read_ue_log(bs, "bitdepth_minus8") + 8;
gf_bs_read_int_log(bs, 1, "entropy_coding_sync_enabled_flag");
gf_bs_read_int_log(bs, 1, "entry_point_offsets_present_flag");
sps->log2_max_poc_lsb = 4 + gf_bs_read_int_log(bs, 4, "log2_max_poc_lsb_minus4");
if ((sps->poc_msb_cycle_flag = gf_bs_read_int_log(bs, 1, "poc_msb_cycle_flag")))
sps->poc_msb_cycle_len = 1 + gf_bs_read_ue_log(bs, "poc_msb_cycle_len_minus1");
u8 sps_num_extra_ph_bits = 8 * gf_bs_read_int_log(bs, 2, "sps_num_extra_ph_bytes");
for (i=0; i<sps_num_extra_ph_bits; i++) {
if (gf_bs_read_int_log_idx(bs, 1, "extra_ph_bit_present_flag", 1))
sps->ph_num_extra_bits++;
}
u8 sps_num_extra_sh_bits = 8 * gf_bs_read_int_log(bs, 2, "num_extra_sh_bytes");
for (i=0; i<sps_num_extra_sh_bits; i++) {
if (gf_bs_read_int_log_idx(bs, 1, "extra_sh_bit_present_flag", i))
sps->sh_num_extra_bits++;
}
if (sps_ptl_dpb_hrd_params_present_flag) {
u8 sps_sublayer_dpb_params_flag = 0;
if (sps->max_sublayers>1) {
sps_sublayer_dpb_params_flag = gf_bs_read_int_log(bs, 1, "sps_sublayer_dpb_params_flag");
}
for (i=(sps_sublayer_dpb_params_flag ? 0 : sps->max_sublayers-1); i < sps->max_sublayers; i++ ) {
gf_bs_read_ue_log_idx(bs, "dpb_max_dec_pic_buffering_minus1", i);
gf_bs_read_ue_log_idx(bs, "dpb_max_num_reorder_pics", i);
gf_bs_read_ue_log_idx(bs, "dpb_max_latency_increase_plus1", i);
}
}
gf_bs_read_ue_log(bs, "sps_log2_min_luma_coding_block_size_minus2");
gf_bs_read_int_log(bs, 1, "sps_partition_constraints_override_enabled_flag");
gf_bs_read_ue_log(bs, "sps_log2_min_luma_coding_block_size_minus2");
u8 sps_max_mtt_hierarchy_depth_intra_slice_luma = gf_bs_read_ue_log(bs, "sps_max_mtt_hierarchy_depth_intra_slice_luma");
if (sps_max_mtt_hierarchy_depth_intra_slice_luma != 0) {
gf_bs_read_ue_log(bs, "sps_log2_diff_max_bt_min_qt_intra_slice_luma");
gf_bs_read_ue_log(bs, "sps_log2_diff_max_tt_min_qt_intra_slice_luma");
}
u8 sps_qtbtt_dual_tree_intra_flag = 0;
if (sps->chroma_format_idc) {
sps_qtbtt_dual_tree_intra_flag = gf_bs_read_int_log(bs, 1, "sps_qtbtt_dual_tree_intra_flag");
}
if (sps_qtbtt_dual_tree_intra_flag) {
gf_bs_read_ue_log(bs, "sps_log2_diff_min_qt_min_cb_intra_slice_chroma");
u8 sps_max_mtt_hierarchy_depth_intra_slice_chroma = gf_bs_read_ue_log(bs, "sps_max_mtt_hierarchy_depth_intra_slice_chroma");
if( sps_max_mtt_hierarchy_depth_intra_slice_chroma != 0) {
gf_bs_read_ue_log(bs, "sps_log2_diff_max_bt_min_qt_intra_slice_chroma");
gf_bs_read_ue_log(bs, "sps_log2_diff_max_tt_min_qt_intra_slice_chroma");
}
}
gf_bs_read_ue_log(bs, "sps_log2_diff_min_qt_min_cb_inter_slice");
u8 sps_max_mtt_hierarchy_depth_inter_slice = gf_bs_read_ue_log(bs, "sps_max_mtt_hierarchy_depth_inter_slice");
if (sps_max_mtt_hierarchy_depth_inter_slice != 0) {
gf_bs_read_ue_log(bs, "sps_log2_diff_max_bt_min_qt_inter_slice");
gf_bs_read_ue_log(bs, "sps_log2_diff_max_tt_min_qt_inter_slice");
}
//u8 sps_max_luma_transform_size_64_flag = 0;
if (CtbSizeY > 32) {
/*sps_max_luma_transform_size_64_flag = */gf_bs_read_int_log(bs, 1, "sps_max_luma_transform_size_64_flag");
}
u8 sps_transform_skip_enabled_flag = gf_bs_read_int_log(bs, 1, "sps_transform_skip_enabled_flag");
if (sps_transform_skip_enabled_flag) {
gf_bs_read_ue_log(bs, "sps_log2_transform_skip_max_size_minus2");
gf_bs_read_int_log(bs, 1, "sps_bdpcm_enabled_flag");
}
if (gf_bs_read_int_log(bs, 1, "sps_mts_enabled_flag")) {
gf_bs_read_int_log(bs, 1, "sps_explicit_mts_intra_enabled_flag");
gf_bs_read_int_log(bs, 1, "sps_explicit_mts_inter_enabled_flag");
}
gf_bs_read_int_log(bs, 1, "sps_lfnst_enabled_flag");
if (sps->chroma_format_idc) {
u8 sps_joint_cbcr_enabled_flag = gf_bs_read_int_log(bs, 1, "sps_joint_cbcr_enabled_flag");
u8 sps_same_qp_table_for_chroma_flag = gf_bs_read_int_log(bs, 1, "sps_same_qp_table_for_chroma_flag");
u32 numQpTables = sps_same_qp_table_for_chroma_flag ? 1 : (sps_joint_cbcr_enabled_flag ? 3 : 2);
for (i=0; i<numQpTables; i++) {
gf_bs_read_se_log_idx(bs, "sps_qp_table_start_minus26", i);
u32 j, sps_num_points_in_qp_table = 1 + gf_bs_read_ue_log_idx(bs, "sps_num_points_in_qp_table_minus1", i);
for (j=0; j<sps_num_points_in_qp_table; j++) {
gf_bs_read_ue_log_idx2(bs, "sps_delta_qp_in_val_minus1", i, j);
gf_bs_read_ue_log_idx2(bs, "sps_delta_qp_diff_val", i, j);
}
}
}
gf_bs_read_int_log(bs, 1, "sps_sao_enabled_flag");
sps->alf_enabled_flag = gf_bs_read_int_log(bs, 1, "sps_alf_enabled_flag");
if (sps->alf_enabled_flag && sps->chroma_format_idc) {
gf_bs_read_int_log(bs, 1, "sps_ccalf_enabled_flag");
}
/*! TODO parse the rest !*/
return sps_id;
} | 1494 | True | 1 |
CVE-2021-30014 | 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/gpac/gpac/issues/1721', 'name': 'https://github.com/gpac/gpac/issues/1721', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'name': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-190'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'There is a integer overflow in media_tools/av_parsers.c in the hevc_parse_slice_segment function in GPAC 1.0.1 which results in a crash.'}] | 2021-04-21T19:21Z | 2021-04-19T20:15Z | Integer Overflow or Wraparound | The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | An integer overflow or wraparound occurs when an integer value is incremented to a value that is too large to store in the associated representation. When this occurs, the value may wrap to become a very small or negative number. While this may be intended behavior in circumstances that rely on wrapping, it can have security consequences if the wrap is unexpected. This is especially the case if the integer overflow can be triggered using user-supplied inputs. This becomes security-critical when the result is used to control looping, make a security decision, or determine the offset or size in behaviors such as memory allocation, copying, concatenation, etc.
| https://cwe.mitre.org/data/definitions/190.html | 0 | jeanlf | 2021-03-29 09:34:02+02:00 | add safety in avc/hevc/vvc sps/pps/vps ID check - cf #1720 #1721 #1722 | 51cdb67ff7c5f1242ac58c5aa603ceaf1793b788 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_media_vvc_read_vps_bs_internal | gf_media_vvc_read_vps_bs_internal( GF_BitStream * bs , VVCState * vvc , Bool stop_at_vps_ext) | ['bs', 'vvc', 'stop_at_vps_ext'] | static s32 gf_media_vvc_read_vps_bs_internal(GF_BitStream *bs, VVCState *vvc, Bool stop_at_vps_ext)
{
u32 i, j;
s32 vps_id;
VVC_VPS *vps;
Bool vps_default_ptl_dpb_hrd_max_tid_flag=0;
//nalu header already parsed
vps_id = gf_bs_read_int_log(bs, 4, "vps_id");
if (vps_id >= 16) return -1;
if (!vps_id) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[VVC] VPS ID 0 is forbidden\n"));
return -1;
}
vps = &vvc->vps[vps_id];
if (!vps->state) {
vps->id = vps_id;
vps->state = 1;
}
vps->max_layers = 1 + gf_bs_read_int_log(bs, 6, "max_layers");
if (vps->max_layers > MAX_LHVC_LAYERS) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[VVC] sorry, %d layers in VPS but only %d supported\n", vps->max_layers, MAX_LHVC_LAYERS));
return -1;
}
vps->max_sub_layers = gf_bs_read_int_log(bs, 3, "max_sub_layers_minus1") + 1;
if ((vps->max_layers>1) && (vps->max_sub_layers>1))
vps_default_ptl_dpb_hrd_max_tid_flag = gf_bs_read_int_log(bs, 1, "vps_default_ptl_dpb_hrd_max_tid_flag");
if (vps->max_layers>1)
vps->all_layers_independent = gf_bs_read_int_log(bs, 1, "all_layers_independent");
for (i=0; i<vps->max_layers; i++) {
u32 layer_id = gf_bs_read_int_log_idx(bs, 6, "layer_id", i);
if (layer_id>vps->max_layer_id) vps->max_layer_id = layer_id;
if (i && !vps->all_layers_independent) {
Bool layer_indep = gf_bs_read_int_log_idx(bs, 1, "layer_independent", i);
if (!layer_indep) {
Bool vps_max_tid_ref_present_flag = gf_bs_read_int_log_idx(bs, 1, "vps_max_tid_ref_present_flag", i);
for (j=0; j<i; j++) {
Bool vps_direct_ref_layer_flag = gf_bs_read_int_log_idx2(bs, 1, "vps_direct_ref_layer_flag", i, j);
if (vps_max_tid_ref_present_flag && vps_direct_ref_layer_flag) {
gf_bs_read_int_log_idx2(bs, 3, "vps_max_tid_il_ref_pics_plus1", i, j);
}
}
}
}
}
vps->num_ptl = 1;
if (vps->max_layers > 1) {
if (vps->all_layers_independent) {
vps->each_layer_is_ols = gf_bs_read_int_log(bs, 1, "each_layer_is_ols");
}
if (!vps->each_layer_is_ols) {
u32 vps_ols_mode_idc = 2;
if (!vps->all_layers_independent) {
vps_ols_mode_idc = gf_bs_read_int_log(bs, 2, "vps_ols_mode_idc");
}
if (vps_ols_mode_idc==2) {
u8 vps_num_output_layer_sets = 2 + gf_bs_read_int_log(bs, 8, "vps_num_output_layer_sets_minus2");
for (i=0; i<vps_num_output_layer_sets; i++) {
for (j=0; j<vps->max_layers; j++) {
gf_bs_read_int_log_idx2(bs, 1, "vps_ols_output_layer_flag", i, j);
}
}
}
}
vps->num_ptl = 1 + gf_bs_read_int_log(bs, 8, "num_ptl_minus1");
}
vps->ptl[0].pt_present = 1;
for (i=0; i<vps->num_ptl; i++) {
if (i)
vps->ptl[i].pt_present = gf_bs_read_int_log_idx(bs, 1, "pt_present", i);
if (!vps_default_ptl_dpb_hrd_max_tid_flag)
vps->ptl[i].ptl_max_tid = gf_bs_read_int_log_idx(bs, 3, "ptl_max_tid", i);
else
vps->ptl[i].ptl_max_tid = vps->max_sub_layers - 1;;
}
//align
gf_bs_align(bs);
for (i=0; i<vps->num_ptl; i++) {
vvc_profile_tier_level(bs, &vps->ptl[i], i);
}
//TODO, parse multilayer stuff
return vps_id;
} | 647 | True | 1 |
CVE-2021-30020 | 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/gpac/gpac/issues/1722', 'name': 'https://github.com/gpac/gpac/issues/1722', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'name': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-787'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'In the function gf_hevc_read_pps_bs_internal function in media_tools/av_parsers.c in GPAC 1.0.1 there is a loop, which with crafted file, pps->num_tile_columns may be larger than sizeof(pps->column_width), which results in a heap overflow in the loop.'}] | 2021-04-21T19:02Z | 2021-04-19T20: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 | jeanlf | 2021-03-29 09:34:02+02:00 | add safety in avc/hevc/vvc sps/pps/vps ID check - cf #1720 #1721 #1722 | 51cdb67ff7c5f1242ac58c5aa603ceaf1793b788 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_media_vvc_read_vps_bs_internal | gf_media_vvc_read_vps_bs_internal( GF_BitStream * bs , VVCState * vvc , Bool stop_at_vps_ext) | ['bs', 'vvc', 'stop_at_vps_ext'] | static s32 gf_media_vvc_read_vps_bs_internal(GF_BitStream *bs, VVCState *vvc, Bool stop_at_vps_ext)
{
u32 i, j;
s32 vps_id;
VVC_VPS *vps;
Bool vps_default_ptl_dpb_hrd_max_tid_flag=0;
//nalu header already parsed
vps_id = gf_bs_read_int_log(bs, 4, "vps_id");
if (vps_id >= 16) return -1;
if (!vps_id) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[VVC] VPS ID 0 is forbidden\n"));
return -1;
}
vps = &vvc->vps[vps_id];
if (!vps->state) {
vps->id = vps_id;
vps->state = 1;
}
vps->max_layers = 1 + gf_bs_read_int_log(bs, 6, "max_layers");
if (vps->max_layers > MAX_LHVC_LAYERS) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[VVC] sorry, %d layers in VPS but only %d supported\n", vps->max_layers, MAX_LHVC_LAYERS));
return -1;
}
vps->max_sub_layers = gf_bs_read_int_log(bs, 3, "max_sub_layers_minus1") + 1;
if ((vps->max_layers>1) && (vps->max_sub_layers>1))
vps_default_ptl_dpb_hrd_max_tid_flag = gf_bs_read_int_log(bs, 1, "vps_default_ptl_dpb_hrd_max_tid_flag");
if (vps->max_layers>1)
vps->all_layers_independent = gf_bs_read_int_log(bs, 1, "all_layers_independent");
for (i=0; i<vps->max_layers; i++) {
u32 layer_id = gf_bs_read_int_log_idx(bs, 6, "layer_id", i);
if (layer_id>vps->max_layer_id) vps->max_layer_id = layer_id;
if (i && !vps->all_layers_independent) {
Bool layer_indep = gf_bs_read_int_log_idx(bs, 1, "layer_independent", i);
if (!layer_indep) {
Bool vps_max_tid_ref_present_flag = gf_bs_read_int_log_idx(bs, 1, "vps_max_tid_ref_present_flag", i);
for (j=0; j<i; j++) {
Bool vps_direct_ref_layer_flag = gf_bs_read_int_log_idx2(bs, 1, "vps_direct_ref_layer_flag", i, j);
if (vps_max_tid_ref_present_flag && vps_direct_ref_layer_flag) {
gf_bs_read_int_log_idx2(bs, 3, "vps_max_tid_il_ref_pics_plus1", i, j);
}
}
}
}
}
vps->num_ptl = 1;
if (vps->max_layers > 1) {
if (vps->all_layers_independent) {
vps->each_layer_is_ols = gf_bs_read_int_log(bs, 1, "each_layer_is_ols");
}
if (!vps->each_layer_is_ols) {
u32 vps_ols_mode_idc = 2;
if (!vps->all_layers_independent) {
vps_ols_mode_idc = gf_bs_read_int_log(bs, 2, "vps_ols_mode_idc");
}
if (vps_ols_mode_idc==2) {
u8 vps_num_output_layer_sets = 2 + gf_bs_read_int_log(bs, 8, "vps_num_output_layer_sets_minus2");
for (i=0; i<vps_num_output_layer_sets; i++) {
for (j=0; j<vps->max_layers; j++) {
gf_bs_read_int_log_idx2(bs, 1, "vps_ols_output_layer_flag", i, j);
}
}
}
}
vps->num_ptl = 1 + gf_bs_read_int_log(bs, 8, "num_ptl_minus1");
}
vps->ptl[0].pt_present = 1;
for (i=0; i<vps->num_ptl; i++) {
if (i)
vps->ptl[i].pt_present = gf_bs_read_int_log_idx(bs, 1, "pt_present", i);
if (!vps_default_ptl_dpb_hrd_max_tid_flag)
vps->ptl[i].ptl_max_tid = gf_bs_read_int_log_idx(bs, 3, "ptl_max_tid", i);
else
vps->ptl[i].ptl_max_tid = vps->max_sub_layers - 1;;
}
//align
gf_bs_align(bs);
for (i=0; i<vps->num_ptl; i++) {
vvc_profile_tier_level(bs, &vps->ptl[i], i);
}
//TODO, parse multilayer stuff
return vps_id;
} | 647 | True | 1 |
CVE-2021-30022 | 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/gpac/gpac/issues/1720', 'name': 'https://github.com/gpac/gpac/issues/1720', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'name': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-190'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'There is a integer overflow in media_tools/av_parsers.c in the gf_avc_read_pps_bs_internal in GPAC 1.0.1. pps_id may be a negative number, so it will not return. However, avc->pps only has 255 unit, so there is an overflow, which results a crash.'}] | 2021-04-21T19:03Z | 2021-04-19T20:15Z | Integer Overflow or Wraparound | The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | An integer overflow or wraparound occurs when an integer value is incremented to a value that is too large to store in the associated representation. When this occurs, the value may wrap to become a very small or negative number. While this may be intended behavior in circumstances that rely on wrapping, it can have security consequences if the wrap is unexpected. This is especially the case if the integer overflow can be triggered using user-supplied inputs. This becomes security-critical when the result is used to control looping, make a security decision, or determine the offset or size in behaviors such as memory allocation, copying, concatenation, etc.
| https://cwe.mitre.org/data/definitions/190.html | 0 | jeanlf | 2021-03-29 09:34:02+02:00 | add safety in avc/hevc/vvc sps/pps/vps ID check - cf #1720 #1721 #1722 | 51cdb67ff7c5f1242ac58c5aa603ceaf1793b788 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_media_vvc_read_vps_bs_internal | gf_media_vvc_read_vps_bs_internal( GF_BitStream * bs , VVCState * vvc , Bool stop_at_vps_ext) | ['bs', 'vvc', 'stop_at_vps_ext'] | static s32 gf_media_vvc_read_vps_bs_internal(GF_BitStream *bs, VVCState *vvc, Bool stop_at_vps_ext)
{
u32 i, j;
s32 vps_id;
VVC_VPS *vps;
Bool vps_default_ptl_dpb_hrd_max_tid_flag=0;
//nalu header already parsed
vps_id = gf_bs_read_int_log(bs, 4, "vps_id");
if (vps_id >= 16) return -1;
if (!vps_id) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[VVC] VPS ID 0 is forbidden\n"));
return -1;
}
vps = &vvc->vps[vps_id];
if (!vps->state) {
vps->id = vps_id;
vps->state = 1;
}
vps->max_layers = 1 + gf_bs_read_int_log(bs, 6, "max_layers");
if (vps->max_layers > MAX_LHVC_LAYERS) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CODING, ("[VVC] sorry, %d layers in VPS but only %d supported\n", vps->max_layers, MAX_LHVC_LAYERS));
return -1;
}
vps->max_sub_layers = gf_bs_read_int_log(bs, 3, "max_sub_layers_minus1") + 1;
if ((vps->max_layers>1) && (vps->max_sub_layers>1))
vps_default_ptl_dpb_hrd_max_tid_flag = gf_bs_read_int_log(bs, 1, "vps_default_ptl_dpb_hrd_max_tid_flag");
if (vps->max_layers>1)
vps->all_layers_independent = gf_bs_read_int_log(bs, 1, "all_layers_independent");
for (i=0; i<vps->max_layers; i++) {
u32 layer_id = gf_bs_read_int_log_idx(bs, 6, "layer_id", i);
if (layer_id>vps->max_layer_id) vps->max_layer_id = layer_id;
if (i && !vps->all_layers_independent) {
Bool layer_indep = gf_bs_read_int_log_idx(bs, 1, "layer_independent", i);
if (!layer_indep) {
Bool vps_max_tid_ref_present_flag = gf_bs_read_int_log_idx(bs, 1, "vps_max_tid_ref_present_flag", i);
for (j=0; j<i; j++) {
Bool vps_direct_ref_layer_flag = gf_bs_read_int_log_idx2(bs, 1, "vps_direct_ref_layer_flag", i, j);
if (vps_max_tid_ref_present_flag && vps_direct_ref_layer_flag) {
gf_bs_read_int_log_idx2(bs, 3, "vps_max_tid_il_ref_pics_plus1", i, j);
}
}
}
}
}
vps->num_ptl = 1;
if (vps->max_layers > 1) {
if (vps->all_layers_independent) {
vps->each_layer_is_ols = gf_bs_read_int_log(bs, 1, "each_layer_is_ols");
}
if (!vps->each_layer_is_ols) {
u32 vps_ols_mode_idc = 2;
if (!vps->all_layers_independent) {
vps_ols_mode_idc = gf_bs_read_int_log(bs, 2, "vps_ols_mode_idc");
}
if (vps_ols_mode_idc==2) {
u8 vps_num_output_layer_sets = 2 + gf_bs_read_int_log(bs, 8, "vps_num_output_layer_sets_minus2");
for (i=0; i<vps_num_output_layer_sets; i++) {
for (j=0; j<vps->max_layers; j++) {
gf_bs_read_int_log_idx2(bs, 1, "vps_ols_output_layer_flag", i, j);
}
}
}
}
vps->num_ptl = 1 + gf_bs_read_int_log(bs, 8, "num_ptl_minus1");
}
vps->ptl[0].pt_present = 1;
for (i=0; i<vps->num_ptl; i++) {
if (i)
vps->ptl[i].pt_present = gf_bs_read_int_log_idx(bs, 1, "pt_present", i);
if (!vps_default_ptl_dpb_hrd_max_tid_flag)
vps->ptl[i].ptl_max_tid = gf_bs_read_int_log_idx(bs, 3, "ptl_max_tid", i);
else
vps->ptl[i].ptl_max_tid = vps->max_sub_layers - 1;;
}
//align
gf_bs_align(bs);
for (i=0; i<vps->num_ptl; i++) {
vvc_profile_tier_level(bs, &vps->ptl[i], i);
}
//TODO, parse multilayer stuff
return vps_id;
} | 647 | True | 1 |
CVE-2021-30014 | 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/gpac/gpac/issues/1721', 'name': 'https://github.com/gpac/gpac/issues/1721', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'name': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-190'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'There is a integer overflow in media_tools/av_parsers.c in the hevc_parse_slice_segment function in GPAC 1.0.1 which results in a crash.'}] | 2021-04-21T19:21Z | 2021-04-19T20:15Z | Integer Overflow or Wraparound | The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | An integer overflow or wraparound occurs when an integer value is incremented to a value that is too large to store in the associated representation. When this occurs, the value may wrap to become a very small or negative number. While this may be intended behavior in circumstances that rely on wrapping, it can have security consequences if the wrap is unexpected. This is especially the case if the integer overflow can be triggered using user-supplied inputs. This becomes security-critical when the result is used to control looping, make a security decision, or determine the offset or size in behaviors such as memory allocation, copying, concatenation, etc.
| https://cwe.mitre.org/data/definitions/190.html | 0 | jeanlf | 2021-03-29 09:34:02+02:00 | add safety in avc/hevc/vvc sps/pps/vps ID check - cf #1720 #1721 #1722 | 51cdb67ff7c5f1242ac58c5aa603ceaf1793b788 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | hevc_parse_slice_segment | hevc_parse_slice_segment( GF_BitStream * bs , HEVCState * hevc , HEVCSliceInfo * si) | ['bs', 'hevc', 'si'] | s32 hevc_parse_slice_segment(GF_BitStream *bs, HEVCState *hevc, HEVCSliceInfo *si)
{
u32 i, j;
u32 num_ref_idx_l0_active = 0, num_ref_idx_l1_active = 0;
HEVC_PPS *pps;
HEVC_SPS *sps;
s32 pps_id;
Bool RapPicFlag = GF_FALSE;
Bool IDRPicFlag = GF_FALSE;
si->first_slice_segment_in_pic_flag = gf_bs_read_int_log(bs, 1, "first_slice_segment_in_pic_flag");
switch (si->nal_unit_type) {
case GF_HEVC_NALU_SLICE_IDR_W_DLP:
case GF_HEVC_NALU_SLICE_IDR_N_LP:
IDRPicFlag = GF_TRUE;
RapPicFlag = GF_TRUE;
break;
case GF_HEVC_NALU_SLICE_BLA_W_LP:
case GF_HEVC_NALU_SLICE_BLA_W_DLP:
case GF_HEVC_NALU_SLICE_BLA_N_LP:
case GF_HEVC_NALU_SLICE_CRA:
RapPicFlag = GF_TRUE;
break;
}
if (RapPicFlag) {
gf_bs_read_int_log(bs, 1, "no_output_of_prior_pics_flag");
}
pps_id = gf_bs_read_ue_log(bs, "pps_id");
if (pps_id >= 64)
return -1;
pps = &hevc->pps[pps_id];
sps = &hevc->sps[pps->sps_id];
si->sps = sps;
si->pps = pps;
if (!si->first_slice_segment_in_pic_flag && pps->dependent_slice_segments_enabled_flag) {
si->dependent_slice_segment_flag = gf_bs_read_int_log(bs, 1, "dependent_slice_segment_flag");
}
else {
si->dependent_slice_segment_flag = GF_FALSE;
}
if (!si->first_slice_segment_in_pic_flag) {
si->slice_segment_address = gf_bs_read_int_log(bs, sps->bitsSliceSegmentAddress, "slice_segment_address");
}
else {
si->slice_segment_address = 0;
}
if (!si->dependent_slice_segment_flag) {
Bool deblocking_filter_override_flag = 0;
Bool slice_temporal_mvp_enabled_flag = 0;
Bool slice_sao_luma_flag = 0;
Bool slice_sao_chroma_flag = 0;
Bool slice_deblocking_filter_disabled_flag = 0;
//"slice_reserved_undetermined_flag[]"
gf_bs_read_int_log(bs, pps->num_extra_slice_header_bits, "slice_reserved_undetermined_flag");
si->slice_type = gf_bs_read_ue_log(bs, "slice_type");
if (pps->output_flag_present_flag)
gf_bs_read_int_log(bs, 1, "pic_output_flag");
if (sps->separate_colour_plane_flag == 1)
gf_bs_read_int_log(bs, 2, "colour_plane_id");
if (IDRPicFlag) {
si->poc_lsb = 0;
//if not asked to parse full header, abort since we know the poc
if (!hevc->full_slice_header_parse) return 0;
}
else {
si->poc_lsb = gf_bs_read_int_log(bs, sps->log2_max_pic_order_cnt_lsb, "poc_lsb");
//if not asked to parse full header, abort once we have the poc
if (!hevc->full_slice_header_parse) return 0;
if (gf_bs_read_int_log(bs, 1, "short_term_ref_pic_set_sps_flag") == 0) {
Bool ret = hevc_parse_short_term_ref_pic_set(bs, sps, sps->num_short_term_ref_pic_sets);
if (!ret)
return -1;
}
else if (sps->num_short_term_ref_pic_sets > 1) {
u32 numbits = 0;
while ((u32)(1 << numbits) < sps->num_short_term_ref_pic_sets)
numbits++;
if (numbits > 0)
gf_bs_read_int_log(bs, numbits, "short_term_ref_pic_set_idx");
/*else
short_term_ref_pic_set_idx = 0;*/
}
if (sps->long_term_ref_pics_present_flag) {
u8 DeltaPocMsbCycleLt[32];
u32 num_long_term_sps = 0;
u32 num_long_term_pics = 0;
memset(DeltaPocMsbCycleLt, 0, sizeof(u8) * 32);
if (sps->num_long_term_ref_pic_sps > 0) {
num_long_term_sps = gf_bs_read_ue_log(bs, "num_long_term_sps");
}
num_long_term_pics = gf_bs_read_ue_log(bs, "num_long_term_pics");
for (i = 0; i < num_long_term_sps + num_long_term_pics; i++) {
if (i < num_long_term_sps) {
if (sps->num_long_term_ref_pic_sps > 1)
gf_bs_read_int_log_idx(bs, gf_get_bit_size(sps->num_long_term_ref_pic_sps), "lt_idx_sps", i);
}
else {
gf_bs_read_int_log_idx(bs, sps->log2_max_pic_order_cnt_lsb, "PocLsbLt", i);
gf_bs_read_int_log_idx(bs, 1, "UsedByCurrPicLt", i);
}
if (gf_bs_read_int_log_idx(bs, 1, "delta_poc_msb_present_flag", i)) {
if (i == 0 || i == num_long_term_sps)
DeltaPocMsbCycleLt[i] = gf_bs_read_ue_log_idx(bs, "DeltaPocMsbCycleLt", i);
else
DeltaPocMsbCycleLt[i] = gf_bs_read_ue_log_idx(bs, "DeltaPocMsbCycleLt", i) + DeltaPocMsbCycleLt[i - 1];
}
}
}
if (sps->temporal_mvp_enable_flag)
slice_temporal_mvp_enabled_flag = gf_bs_read_int_log(bs, 1, "slice_temporal_mvp_enabled_flag");
}
if (sps->sample_adaptive_offset_enabled_flag) {
u32 ChromaArrayType = sps->separate_colour_plane_flag ? 0 : sps->chroma_format_idc;
slice_sao_luma_flag = gf_bs_read_int_log(bs, 1, "slice_sao_luma_flag");
if (ChromaArrayType != 0)
slice_sao_chroma_flag = gf_bs_read_int_log(bs, 1, "slice_sao_chroma_flag");
}
if (si->slice_type == GF_HEVC_SLICE_TYPE_P || si->slice_type == GF_HEVC_SLICE_TYPE_B) {
//u32 NumPocTotalCurr;
num_ref_idx_l0_active = pps->num_ref_idx_l0_default_active;
num_ref_idx_l1_active = 0;
if (si->slice_type == GF_HEVC_SLICE_TYPE_B)
num_ref_idx_l1_active = pps->num_ref_idx_l1_default_active;
if (gf_bs_read_int_log(bs, 1, "num_ref_idx_active_override_flag")) {
num_ref_idx_l0_active = 1 + gf_bs_read_ue_log(bs, "num_ref_idx_l0_active");
if (si->slice_type == GF_HEVC_SLICE_TYPE_B)
num_ref_idx_l1_active = 1 + gf_bs_read_ue_log(bs, "num_ref_idx_l1_active");
}
if (pps->lists_modification_present_flag /*TODO: && NumPicTotalCurr > 1*/) {
if (!ref_pic_lists_modification(bs, si->slice_type, num_ref_idx_l0_active, num_ref_idx_l1_active)) {
GF_LOG(GF_LOG_WARNING, GF_LOG_CODING, ("[hevc] ref_pic_lists_modification( ) not implemented\n"));
return -1;
}
}
if (si->slice_type == GF_HEVC_SLICE_TYPE_B)
gf_bs_read_int_log(bs, 1, "mvd_l1_zero_flag");
if (pps->cabac_init_present_flag)
gf_bs_read_int_log(bs, 1, "cabac_init_flag");
if (slice_temporal_mvp_enabled_flag) {
// When collocated_from_l0_flag is not present, it is inferred to be equal to 1.
Bool collocated_from_l0_flag = 1;
if (si->slice_type == GF_HEVC_SLICE_TYPE_B)
collocated_from_l0_flag = gf_bs_read_int_log(bs, 1, "collocated_from_l0_flag");
if ((collocated_from_l0_flag && (num_ref_idx_l0_active > 1))
|| (!collocated_from_l0_flag && (num_ref_idx_l1_active > 1))
) {
gf_bs_read_ue_log(bs, "collocated_ref_idx");
}
}
if ((pps->weighted_pred_flag && si->slice_type == GF_HEVC_SLICE_TYPE_P)
|| (pps->weighted_bipred_flag && si->slice_type == GF_HEVC_SLICE_TYPE_B)
) {
hevc_pred_weight_table(bs, hevc, si, pps, sps, num_ref_idx_l0_active, num_ref_idx_l1_active);
}
gf_bs_read_ue_log(bs, "five_minus_max_num_merge_cand");
}
si->slice_qp_delta_start_bits = (s32) (gf_bs_get_position(bs) - 1) * 8 + gf_bs_get_bit_position(bs);
si->slice_qp_delta = gf_bs_read_se_log(bs, "slice_qp_delta");
if (pps->slice_chroma_qp_offsets_present_flag) {
gf_bs_read_se_log(bs, "slice_cb_qp_offset");
gf_bs_read_se_log(bs, "slice_cr_qp_offset");
}
if (pps->deblocking_filter_override_enabled_flag) {
deblocking_filter_override_flag = gf_bs_read_int_log(bs, 1, "deblocking_filter_override_flag");
}
if (deblocking_filter_override_flag) {
slice_deblocking_filter_disabled_flag = gf_bs_read_int_log(bs, 1, "slice_deblocking_filter_disabled_flag");
if (!slice_deblocking_filter_disabled_flag) {
gf_bs_read_se_log(bs, "slice_beta_offset_div2");
gf_bs_read_se_log(bs, "slice_tc_offset_div2");
}
}
if (pps->loop_filter_across_slices_enabled_flag
&& (slice_sao_luma_flag || slice_sao_chroma_flag || !slice_deblocking_filter_disabled_flag)
) {
gf_bs_read_int_log(bs, 1, "slice_loop_filter_across_slices_enabled_flag");
}
}
//dependent slice segment
else {
//if not asked to parse full header, abort
if (!hevc->full_slice_header_parse) return 0;
}
si->entry_point_start_bits = ((u32)gf_bs_get_position(bs) - 1) * 8 + gf_bs_get_bit_position(bs);
if (pps->tiles_enabled_flag || pps->entropy_coding_sync_enabled_flag) {
u32 num_entry_point_offsets = gf_bs_read_ue_log(bs, "num_entry_point_offsets");
if (num_entry_point_offsets > 0) {
u32 offset = gf_bs_read_ue_log(bs, "offset") + 1;
u32 segments = offset >> 4;
s32 remain = (offset & 15);
for (i = 0; i < num_entry_point_offsets; i++) {
//u32 res = 0;
for (j = 0; j < segments; j++) {
//res <<= 16;
/*res +=*/ gf_bs_read_int(bs, 16);
}
if (remain) {
//res <<= remain;
/* res += */ gf_bs_read_int(bs, remain);
}
// entry_point_offset = val + 1; // +1; // +1 to get the size
}
}
}
if (pps->slice_segment_header_extension_present_flag) {
u32 size_ext = gf_bs_read_ue_log(bs, "size_ext");
while (size_ext) {
gf_bs_read_int(bs, 8);
size_ext--;
}
}
si->header_size_bits = (gf_bs_get_position(bs) - 1) * 8 + gf_bs_get_bit_position(bs); // av_parser.c modified on 16 jan. 2019
if (gf_bs_read_int_log(bs, 1, "byte_align") == 0) {
GF_LOG(GF_LOG_WARNING, GF_LOG_CODING, ("Error parsing slice header: byte_align not found at end of header !\n"));
}
gf_bs_align(bs);
si->payload_start_offset = (s32)gf_bs_get_position(bs);
return 0;
} | 1391 | True | 1 |
CVE-2021-30020 | 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/gpac/gpac/issues/1722', 'name': 'https://github.com/gpac/gpac/issues/1722', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'name': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-787'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'In the function gf_hevc_read_pps_bs_internal function in media_tools/av_parsers.c in GPAC 1.0.1 there is a loop, which with crafted file, pps->num_tile_columns may be larger than sizeof(pps->column_width), which results in a heap overflow in the loop.'}] | 2021-04-21T19:02Z | 2021-04-19T20: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 | jeanlf | 2021-03-29 09:34:02+02:00 | add safety in avc/hevc/vvc sps/pps/vps ID check - cf #1720 #1721 #1722 | 51cdb67ff7c5f1242ac58c5aa603ceaf1793b788 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | hevc_parse_slice_segment | hevc_parse_slice_segment( GF_BitStream * bs , HEVCState * hevc , HEVCSliceInfo * si) | ['bs', 'hevc', 'si'] | s32 hevc_parse_slice_segment(GF_BitStream *bs, HEVCState *hevc, HEVCSliceInfo *si)
{
u32 i, j;
u32 num_ref_idx_l0_active = 0, num_ref_idx_l1_active = 0;
HEVC_PPS *pps;
HEVC_SPS *sps;
s32 pps_id;
Bool RapPicFlag = GF_FALSE;
Bool IDRPicFlag = GF_FALSE;
si->first_slice_segment_in_pic_flag = gf_bs_read_int_log(bs, 1, "first_slice_segment_in_pic_flag");
switch (si->nal_unit_type) {
case GF_HEVC_NALU_SLICE_IDR_W_DLP:
case GF_HEVC_NALU_SLICE_IDR_N_LP:
IDRPicFlag = GF_TRUE;
RapPicFlag = GF_TRUE;
break;
case GF_HEVC_NALU_SLICE_BLA_W_LP:
case GF_HEVC_NALU_SLICE_BLA_W_DLP:
case GF_HEVC_NALU_SLICE_BLA_N_LP:
case GF_HEVC_NALU_SLICE_CRA:
RapPicFlag = GF_TRUE;
break;
}
if (RapPicFlag) {
gf_bs_read_int_log(bs, 1, "no_output_of_prior_pics_flag");
}
pps_id = gf_bs_read_ue_log(bs, "pps_id");
if (pps_id >= 64)
return -1;
pps = &hevc->pps[pps_id];
sps = &hevc->sps[pps->sps_id];
si->sps = sps;
si->pps = pps;
if (!si->first_slice_segment_in_pic_flag && pps->dependent_slice_segments_enabled_flag) {
si->dependent_slice_segment_flag = gf_bs_read_int_log(bs, 1, "dependent_slice_segment_flag");
}
else {
si->dependent_slice_segment_flag = GF_FALSE;
}
if (!si->first_slice_segment_in_pic_flag) {
si->slice_segment_address = gf_bs_read_int_log(bs, sps->bitsSliceSegmentAddress, "slice_segment_address");
}
else {
si->slice_segment_address = 0;
}
if (!si->dependent_slice_segment_flag) {
Bool deblocking_filter_override_flag = 0;
Bool slice_temporal_mvp_enabled_flag = 0;
Bool slice_sao_luma_flag = 0;
Bool slice_sao_chroma_flag = 0;
Bool slice_deblocking_filter_disabled_flag = 0;
//"slice_reserved_undetermined_flag[]"
gf_bs_read_int_log(bs, pps->num_extra_slice_header_bits, "slice_reserved_undetermined_flag");
si->slice_type = gf_bs_read_ue_log(bs, "slice_type");
if (pps->output_flag_present_flag)
gf_bs_read_int_log(bs, 1, "pic_output_flag");
if (sps->separate_colour_plane_flag == 1)
gf_bs_read_int_log(bs, 2, "colour_plane_id");
if (IDRPicFlag) {
si->poc_lsb = 0;
//if not asked to parse full header, abort since we know the poc
if (!hevc->full_slice_header_parse) return 0;
}
else {
si->poc_lsb = gf_bs_read_int_log(bs, sps->log2_max_pic_order_cnt_lsb, "poc_lsb");
//if not asked to parse full header, abort once we have the poc
if (!hevc->full_slice_header_parse) return 0;
if (gf_bs_read_int_log(bs, 1, "short_term_ref_pic_set_sps_flag") == 0) {
Bool ret = hevc_parse_short_term_ref_pic_set(bs, sps, sps->num_short_term_ref_pic_sets);
if (!ret)
return -1;
}
else if (sps->num_short_term_ref_pic_sets > 1) {
u32 numbits = 0;
while ((u32)(1 << numbits) < sps->num_short_term_ref_pic_sets)
numbits++;
if (numbits > 0)
gf_bs_read_int_log(bs, numbits, "short_term_ref_pic_set_idx");
/*else
short_term_ref_pic_set_idx = 0;*/
}
if (sps->long_term_ref_pics_present_flag) {
u8 DeltaPocMsbCycleLt[32];
u32 num_long_term_sps = 0;
u32 num_long_term_pics = 0;
memset(DeltaPocMsbCycleLt, 0, sizeof(u8) * 32);
if (sps->num_long_term_ref_pic_sps > 0) {
num_long_term_sps = gf_bs_read_ue_log(bs, "num_long_term_sps");
}
num_long_term_pics = gf_bs_read_ue_log(bs, "num_long_term_pics");
for (i = 0; i < num_long_term_sps + num_long_term_pics; i++) {
if (i < num_long_term_sps) {
if (sps->num_long_term_ref_pic_sps > 1)
gf_bs_read_int_log_idx(bs, gf_get_bit_size(sps->num_long_term_ref_pic_sps), "lt_idx_sps", i);
}
else {
gf_bs_read_int_log_idx(bs, sps->log2_max_pic_order_cnt_lsb, "PocLsbLt", i);
gf_bs_read_int_log_idx(bs, 1, "UsedByCurrPicLt", i);
}
if (gf_bs_read_int_log_idx(bs, 1, "delta_poc_msb_present_flag", i)) {
if (i == 0 || i == num_long_term_sps)
DeltaPocMsbCycleLt[i] = gf_bs_read_ue_log_idx(bs, "DeltaPocMsbCycleLt", i);
else
DeltaPocMsbCycleLt[i] = gf_bs_read_ue_log_idx(bs, "DeltaPocMsbCycleLt", i) + DeltaPocMsbCycleLt[i - 1];
}
}
}
if (sps->temporal_mvp_enable_flag)
slice_temporal_mvp_enabled_flag = gf_bs_read_int_log(bs, 1, "slice_temporal_mvp_enabled_flag");
}
if (sps->sample_adaptive_offset_enabled_flag) {
u32 ChromaArrayType = sps->separate_colour_plane_flag ? 0 : sps->chroma_format_idc;
slice_sao_luma_flag = gf_bs_read_int_log(bs, 1, "slice_sao_luma_flag");
if (ChromaArrayType != 0)
slice_sao_chroma_flag = gf_bs_read_int_log(bs, 1, "slice_sao_chroma_flag");
}
if (si->slice_type == GF_HEVC_SLICE_TYPE_P || si->slice_type == GF_HEVC_SLICE_TYPE_B) {
//u32 NumPocTotalCurr;
num_ref_idx_l0_active = pps->num_ref_idx_l0_default_active;
num_ref_idx_l1_active = 0;
if (si->slice_type == GF_HEVC_SLICE_TYPE_B)
num_ref_idx_l1_active = pps->num_ref_idx_l1_default_active;
if (gf_bs_read_int_log(bs, 1, "num_ref_idx_active_override_flag")) {
num_ref_idx_l0_active = 1 + gf_bs_read_ue_log(bs, "num_ref_idx_l0_active");
if (si->slice_type == GF_HEVC_SLICE_TYPE_B)
num_ref_idx_l1_active = 1 + gf_bs_read_ue_log(bs, "num_ref_idx_l1_active");
}
if (pps->lists_modification_present_flag /*TODO: && NumPicTotalCurr > 1*/) {
if (!ref_pic_lists_modification(bs, si->slice_type, num_ref_idx_l0_active, num_ref_idx_l1_active)) {
GF_LOG(GF_LOG_WARNING, GF_LOG_CODING, ("[hevc] ref_pic_lists_modification( ) not implemented\n"));
return -1;
}
}
if (si->slice_type == GF_HEVC_SLICE_TYPE_B)
gf_bs_read_int_log(bs, 1, "mvd_l1_zero_flag");
if (pps->cabac_init_present_flag)
gf_bs_read_int_log(bs, 1, "cabac_init_flag");
if (slice_temporal_mvp_enabled_flag) {
// When collocated_from_l0_flag is not present, it is inferred to be equal to 1.
Bool collocated_from_l0_flag = 1;
if (si->slice_type == GF_HEVC_SLICE_TYPE_B)
collocated_from_l0_flag = gf_bs_read_int_log(bs, 1, "collocated_from_l0_flag");
if ((collocated_from_l0_flag && (num_ref_idx_l0_active > 1))
|| (!collocated_from_l0_flag && (num_ref_idx_l1_active > 1))
) {
gf_bs_read_ue_log(bs, "collocated_ref_idx");
}
}
if ((pps->weighted_pred_flag && si->slice_type == GF_HEVC_SLICE_TYPE_P)
|| (pps->weighted_bipred_flag && si->slice_type == GF_HEVC_SLICE_TYPE_B)
) {
hevc_pred_weight_table(bs, hevc, si, pps, sps, num_ref_idx_l0_active, num_ref_idx_l1_active);
}
gf_bs_read_ue_log(bs, "five_minus_max_num_merge_cand");
}
si->slice_qp_delta_start_bits = (s32) (gf_bs_get_position(bs) - 1) * 8 + gf_bs_get_bit_position(bs);
si->slice_qp_delta = gf_bs_read_se_log(bs, "slice_qp_delta");
if (pps->slice_chroma_qp_offsets_present_flag) {
gf_bs_read_se_log(bs, "slice_cb_qp_offset");
gf_bs_read_se_log(bs, "slice_cr_qp_offset");
}
if (pps->deblocking_filter_override_enabled_flag) {
deblocking_filter_override_flag = gf_bs_read_int_log(bs, 1, "deblocking_filter_override_flag");
}
if (deblocking_filter_override_flag) {
slice_deblocking_filter_disabled_flag = gf_bs_read_int_log(bs, 1, "slice_deblocking_filter_disabled_flag");
if (!slice_deblocking_filter_disabled_flag) {
gf_bs_read_se_log(bs, "slice_beta_offset_div2");
gf_bs_read_se_log(bs, "slice_tc_offset_div2");
}
}
if (pps->loop_filter_across_slices_enabled_flag
&& (slice_sao_luma_flag || slice_sao_chroma_flag || !slice_deblocking_filter_disabled_flag)
) {
gf_bs_read_int_log(bs, 1, "slice_loop_filter_across_slices_enabled_flag");
}
}
//dependent slice segment
else {
//if not asked to parse full header, abort
if (!hevc->full_slice_header_parse) return 0;
}
si->entry_point_start_bits = ((u32)gf_bs_get_position(bs) - 1) * 8 + gf_bs_get_bit_position(bs);
if (pps->tiles_enabled_flag || pps->entropy_coding_sync_enabled_flag) {
u32 num_entry_point_offsets = gf_bs_read_ue_log(bs, "num_entry_point_offsets");
if (num_entry_point_offsets > 0) {
u32 offset = gf_bs_read_ue_log(bs, "offset") + 1;
u32 segments = offset >> 4;
s32 remain = (offset & 15);
for (i = 0; i < num_entry_point_offsets; i++) {
//u32 res = 0;
for (j = 0; j < segments; j++) {
//res <<= 16;
/*res +=*/ gf_bs_read_int(bs, 16);
}
if (remain) {
//res <<= remain;
/* res += */ gf_bs_read_int(bs, remain);
}
// entry_point_offset = val + 1; // +1; // +1 to get the size
}
}
}
if (pps->slice_segment_header_extension_present_flag) {
u32 size_ext = gf_bs_read_ue_log(bs, "size_ext");
while (size_ext) {
gf_bs_read_int(bs, 8);
size_ext--;
}
}
si->header_size_bits = (gf_bs_get_position(bs) - 1) * 8 + gf_bs_get_bit_position(bs); // av_parser.c modified on 16 jan. 2019
if (gf_bs_read_int_log(bs, 1, "byte_align") == 0) {
GF_LOG(GF_LOG_WARNING, GF_LOG_CODING, ("Error parsing slice header: byte_align not found at end of header !\n"));
}
gf_bs_align(bs);
si->payload_start_offset = (s32)gf_bs_get_position(bs);
return 0;
} | 1391 | True | 1 |
CVE-2021-30022 | 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/gpac/gpac/issues/1720', 'name': 'https://github.com/gpac/gpac/issues/1720', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'name': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-190'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'There is a integer overflow in media_tools/av_parsers.c in the gf_avc_read_pps_bs_internal in GPAC 1.0.1. pps_id may be a negative number, so it will not return. However, avc->pps only has 255 unit, so there is an overflow, which results a crash.'}] | 2021-04-21T19:03Z | 2021-04-19T20:15Z | Integer Overflow or Wraparound | The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | An integer overflow or wraparound occurs when an integer value is incremented to a value that is too large to store in the associated representation. When this occurs, the value may wrap to become a very small or negative number. While this may be intended behavior in circumstances that rely on wrapping, it can have security consequences if the wrap is unexpected. This is especially the case if the integer overflow can be triggered using user-supplied inputs. This becomes security-critical when the result is used to control looping, make a security decision, or determine the offset or size in behaviors such as memory allocation, copying, concatenation, etc.
| https://cwe.mitre.org/data/definitions/190.html | 0 | jeanlf | 2021-03-29 09:34:02+02:00 | add safety in avc/hevc/vvc sps/pps/vps ID check - cf #1720 #1721 #1722 | 51cdb67ff7c5f1242ac58c5aa603ceaf1793b788 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | hevc_parse_slice_segment | hevc_parse_slice_segment( GF_BitStream * bs , HEVCState * hevc , HEVCSliceInfo * si) | ['bs', 'hevc', 'si'] | s32 hevc_parse_slice_segment(GF_BitStream *bs, HEVCState *hevc, HEVCSliceInfo *si)
{
u32 i, j;
u32 num_ref_idx_l0_active = 0, num_ref_idx_l1_active = 0;
HEVC_PPS *pps;
HEVC_SPS *sps;
s32 pps_id;
Bool RapPicFlag = GF_FALSE;
Bool IDRPicFlag = GF_FALSE;
si->first_slice_segment_in_pic_flag = gf_bs_read_int_log(bs, 1, "first_slice_segment_in_pic_flag");
switch (si->nal_unit_type) {
case GF_HEVC_NALU_SLICE_IDR_W_DLP:
case GF_HEVC_NALU_SLICE_IDR_N_LP:
IDRPicFlag = GF_TRUE;
RapPicFlag = GF_TRUE;
break;
case GF_HEVC_NALU_SLICE_BLA_W_LP:
case GF_HEVC_NALU_SLICE_BLA_W_DLP:
case GF_HEVC_NALU_SLICE_BLA_N_LP:
case GF_HEVC_NALU_SLICE_CRA:
RapPicFlag = GF_TRUE;
break;
}
if (RapPicFlag) {
gf_bs_read_int_log(bs, 1, "no_output_of_prior_pics_flag");
}
pps_id = gf_bs_read_ue_log(bs, "pps_id");
if (pps_id >= 64)
return -1;
pps = &hevc->pps[pps_id];
sps = &hevc->sps[pps->sps_id];
si->sps = sps;
si->pps = pps;
if (!si->first_slice_segment_in_pic_flag && pps->dependent_slice_segments_enabled_flag) {
si->dependent_slice_segment_flag = gf_bs_read_int_log(bs, 1, "dependent_slice_segment_flag");
}
else {
si->dependent_slice_segment_flag = GF_FALSE;
}
if (!si->first_slice_segment_in_pic_flag) {
si->slice_segment_address = gf_bs_read_int_log(bs, sps->bitsSliceSegmentAddress, "slice_segment_address");
}
else {
si->slice_segment_address = 0;
}
if (!si->dependent_slice_segment_flag) {
Bool deblocking_filter_override_flag = 0;
Bool slice_temporal_mvp_enabled_flag = 0;
Bool slice_sao_luma_flag = 0;
Bool slice_sao_chroma_flag = 0;
Bool slice_deblocking_filter_disabled_flag = 0;
//"slice_reserved_undetermined_flag[]"
gf_bs_read_int_log(bs, pps->num_extra_slice_header_bits, "slice_reserved_undetermined_flag");
si->slice_type = gf_bs_read_ue_log(bs, "slice_type");
if (pps->output_flag_present_flag)
gf_bs_read_int_log(bs, 1, "pic_output_flag");
if (sps->separate_colour_plane_flag == 1)
gf_bs_read_int_log(bs, 2, "colour_plane_id");
if (IDRPicFlag) {
si->poc_lsb = 0;
//if not asked to parse full header, abort since we know the poc
if (!hevc->full_slice_header_parse) return 0;
}
else {
si->poc_lsb = gf_bs_read_int_log(bs, sps->log2_max_pic_order_cnt_lsb, "poc_lsb");
//if not asked to parse full header, abort once we have the poc
if (!hevc->full_slice_header_parse) return 0;
if (gf_bs_read_int_log(bs, 1, "short_term_ref_pic_set_sps_flag") == 0) {
Bool ret = hevc_parse_short_term_ref_pic_set(bs, sps, sps->num_short_term_ref_pic_sets);
if (!ret)
return -1;
}
else if (sps->num_short_term_ref_pic_sets > 1) {
u32 numbits = 0;
while ((u32)(1 << numbits) < sps->num_short_term_ref_pic_sets)
numbits++;
if (numbits > 0)
gf_bs_read_int_log(bs, numbits, "short_term_ref_pic_set_idx");
/*else
short_term_ref_pic_set_idx = 0;*/
}
if (sps->long_term_ref_pics_present_flag) {
u8 DeltaPocMsbCycleLt[32];
u32 num_long_term_sps = 0;
u32 num_long_term_pics = 0;
memset(DeltaPocMsbCycleLt, 0, sizeof(u8) * 32);
if (sps->num_long_term_ref_pic_sps > 0) {
num_long_term_sps = gf_bs_read_ue_log(bs, "num_long_term_sps");
}
num_long_term_pics = gf_bs_read_ue_log(bs, "num_long_term_pics");
for (i = 0; i < num_long_term_sps + num_long_term_pics; i++) {
if (i < num_long_term_sps) {
if (sps->num_long_term_ref_pic_sps > 1)
gf_bs_read_int_log_idx(bs, gf_get_bit_size(sps->num_long_term_ref_pic_sps), "lt_idx_sps", i);
}
else {
gf_bs_read_int_log_idx(bs, sps->log2_max_pic_order_cnt_lsb, "PocLsbLt", i);
gf_bs_read_int_log_idx(bs, 1, "UsedByCurrPicLt", i);
}
if (gf_bs_read_int_log_idx(bs, 1, "delta_poc_msb_present_flag", i)) {
if (i == 0 || i == num_long_term_sps)
DeltaPocMsbCycleLt[i] = gf_bs_read_ue_log_idx(bs, "DeltaPocMsbCycleLt", i);
else
DeltaPocMsbCycleLt[i] = gf_bs_read_ue_log_idx(bs, "DeltaPocMsbCycleLt", i) + DeltaPocMsbCycleLt[i - 1];
}
}
}
if (sps->temporal_mvp_enable_flag)
slice_temporal_mvp_enabled_flag = gf_bs_read_int_log(bs, 1, "slice_temporal_mvp_enabled_flag");
}
if (sps->sample_adaptive_offset_enabled_flag) {
u32 ChromaArrayType = sps->separate_colour_plane_flag ? 0 : sps->chroma_format_idc;
slice_sao_luma_flag = gf_bs_read_int_log(bs, 1, "slice_sao_luma_flag");
if (ChromaArrayType != 0)
slice_sao_chroma_flag = gf_bs_read_int_log(bs, 1, "slice_sao_chroma_flag");
}
if (si->slice_type == GF_HEVC_SLICE_TYPE_P || si->slice_type == GF_HEVC_SLICE_TYPE_B) {
//u32 NumPocTotalCurr;
num_ref_idx_l0_active = pps->num_ref_idx_l0_default_active;
num_ref_idx_l1_active = 0;
if (si->slice_type == GF_HEVC_SLICE_TYPE_B)
num_ref_idx_l1_active = pps->num_ref_idx_l1_default_active;
if (gf_bs_read_int_log(bs, 1, "num_ref_idx_active_override_flag")) {
num_ref_idx_l0_active = 1 + gf_bs_read_ue_log(bs, "num_ref_idx_l0_active");
if (si->slice_type == GF_HEVC_SLICE_TYPE_B)
num_ref_idx_l1_active = 1 + gf_bs_read_ue_log(bs, "num_ref_idx_l1_active");
}
if (pps->lists_modification_present_flag /*TODO: && NumPicTotalCurr > 1*/) {
if (!ref_pic_lists_modification(bs, si->slice_type, num_ref_idx_l0_active, num_ref_idx_l1_active)) {
GF_LOG(GF_LOG_WARNING, GF_LOG_CODING, ("[hevc] ref_pic_lists_modification( ) not implemented\n"));
return -1;
}
}
if (si->slice_type == GF_HEVC_SLICE_TYPE_B)
gf_bs_read_int_log(bs, 1, "mvd_l1_zero_flag");
if (pps->cabac_init_present_flag)
gf_bs_read_int_log(bs, 1, "cabac_init_flag");
if (slice_temporal_mvp_enabled_flag) {
// When collocated_from_l0_flag is not present, it is inferred to be equal to 1.
Bool collocated_from_l0_flag = 1;
if (si->slice_type == GF_HEVC_SLICE_TYPE_B)
collocated_from_l0_flag = gf_bs_read_int_log(bs, 1, "collocated_from_l0_flag");
if ((collocated_from_l0_flag && (num_ref_idx_l0_active > 1))
|| (!collocated_from_l0_flag && (num_ref_idx_l1_active > 1))
) {
gf_bs_read_ue_log(bs, "collocated_ref_idx");
}
}
if ((pps->weighted_pred_flag && si->slice_type == GF_HEVC_SLICE_TYPE_P)
|| (pps->weighted_bipred_flag && si->slice_type == GF_HEVC_SLICE_TYPE_B)
) {
hevc_pred_weight_table(bs, hevc, si, pps, sps, num_ref_idx_l0_active, num_ref_idx_l1_active);
}
gf_bs_read_ue_log(bs, "five_minus_max_num_merge_cand");
}
si->slice_qp_delta_start_bits = (s32) (gf_bs_get_position(bs) - 1) * 8 + gf_bs_get_bit_position(bs);
si->slice_qp_delta = gf_bs_read_se_log(bs, "slice_qp_delta");
if (pps->slice_chroma_qp_offsets_present_flag) {
gf_bs_read_se_log(bs, "slice_cb_qp_offset");
gf_bs_read_se_log(bs, "slice_cr_qp_offset");
}
if (pps->deblocking_filter_override_enabled_flag) {
deblocking_filter_override_flag = gf_bs_read_int_log(bs, 1, "deblocking_filter_override_flag");
}
if (deblocking_filter_override_flag) {
slice_deblocking_filter_disabled_flag = gf_bs_read_int_log(bs, 1, "slice_deblocking_filter_disabled_flag");
if (!slice_deblocking_filter_disabled_flag) {
gf_bs_read_se_log(bs, "slice_beta_offset_div2");
gf_bs_read_se_log(bs, "slice_tc_offset_div2");
}
}
if (pps->loop_filter_across_slices_enabled_flag
&& (slice_sao_luma_flag || slice_sao_chroma_flag || !slice_deblocking_filter_disabled_flag)
) {
gf_bs_read_int_log(bs, 1, "slice_loop_filter_across_slices_enabled_flag");
}
}
//dependent slice segment
else {
//if not asked to parse full header, abort
if (!hevc->full_slice_header_parse) return 0;
}
si->entry_point_start_bits = ((u32)gf_bs_get_position(bs) - 1) * 8 + gf_bs_get_bit_position(bs);
if (pps->tiles_enabled_flag || pps->entropy_coding_sync_enabled_flag) {
u32 num_entry_point_offsets = gf_bs_read_ue_log(bs, "num_entry_point_offsets");
if (num_entry_point_offsets > 0) {
u32 offset = gf_bs_read_ue_log(bs, "offset") + 1;
u32 segments = offset >> 4;
s32 remain = (offset & 15);
for (i = 0; i < num_entry_point_offsets; i++) {
//u32 res = 0;
for (j = 0; j < segments; j++) {
//res <<= 16;
/*res +=*/ gf_bs_read_int(bs, 16);
}
if (remain) {
//res <<= remain;
/* res += */ gf_bs_read_int(bs, remain);
}
// entry_point_offset = val + 1; // +1; // +1 to get the size
}
}
}
if (pps->slice_segment_header_extension_present_flag) {
u32 size_ext = gf_bs_read_ue_log(bs, "size_ext");
while (size_ext) {
gf_bs_read_int(bs, 8);
size_ext--;
}
}
si->header_size_bits = (gf_bs_get_position(bs) - 1) * 8 + gf_bs_get_bit_position(bs); // av_parser.c modified on 16 jan. 2019
if (gf_bs_read_int_log(bs, 1, "byte_align") == 0) {
GF_LOG(GF_LOG_WARNING, GF_LOG_CODING, ("Error parsing slice header: byte_align not found at end of header !\n"));
}
gf_bs_align(bs);
si->payload_start_offset = (s32)gf_bs_get_position(bs);
return 0;
} | 1391 | True | 1 |
CVE-2021-30014 | 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/gpac/gpac/issues/1721', 'name': 'https://github.com/gpac/gpac/issues/1721', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'name': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-190'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'There is a integer overflow in media_tools/av_parsers.c in the hevc_parse_slice_segment function in GPAC 1.0.1 which results in a crash.'}] | 2021-04-21T19:21Z | 2021-04-19T20:15Z | Integer Overflow or Wraparound | The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | An integer overflow or wraparound occurs when an integer value is incremented to a value that is too large to store in the associated representation. When this occurs, the value may wrap to become a very small or negative number. While this may be intended behavior in circumstances that rely on wrapping, it can have security consequences if the wrap is unexpected. This is especially the case if the integer overflow can be triggered using user-supplied inputs. This becomes security-critical when the result is used to control looping, make a security decision, or determine the offset or size in behaviors such as memory allocation, copying, concatenation, etc.
| https://cwe.mitre.org/data/definitions/190.html | 0 | jeanlf | 2021-03-29 09:34:02+02:00 | add safety in avc/hevc/vvc sps/pps/vps ID check - cf #1720 #1721 #1722 | 51cdb67ff7c5f1242ac58c5aa603ceaf1793b788 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | vvc_parse_picture_header | vvc_parse_picture_header( GF_BitStream * bs , VVCState * vvc , VVCSliceInfo * si) | ['bs', 'vvc', 'si'] | s32 vvc_parse_picture_header(GF_BitStream *bs, VVCState *vvc, VVCSliceInfo *si)
{
u32 pps_id;
si->irap_or_gdr_pic = gf_bs_read_int_log(bs, 1, "irap_or_gdr_pic");
si->non_ref_pic = gf_bs_read_int_log(bs, 1, "non_ref_pic");
if (si->irap_or_gdr_pic)
si->gdr_pic = gf_bs_read_int_log(bs, 1, "gdr_pic");
if ((si->inter_slice_allowed_flag = gf_bs_read_int_log(bs, 1, "inter_slice_allowed_flag")))
si->intra_slice_allowed_flag = gf_bs_read_int_log(bs, 1, "intra_slice_allowed_flag");
pps_id = gf_bs_read_ue_log(bs, "pps_id");
if (pps_id >= 64)
return -1;
si->pps = &vvc->pps[pps_id];
si->sps = &vvc->sps[si->pps->sps_id];
si->poc_lsb = gf_bs_read_int_log(bs, si->sps->log2_max_poc_lsb, "poc_lsb");
si->recovery_point_valid = 0;
si->gdr_recovery_count = 0;
if (si->gdr_pic) {
si->recovery_point_valid = 1;
si->gdr_recovery_count = gf_bs_read_ue_log(bs, "gdr_recovery_count");
}
gf_bs_read_int_log(bs, si->sps->ph_num_extra_bits, "ph_extra_bits");
if (si->sps->poc_msb_cycle_flag) {
if ( (si->poc_msb_cycle_present_flag = gf_bs_read_int_log(bs, 1, "poc_msb_cycle_present_flag"))) {
si->poc_msb_cycle = gf_bs_read_int_log(bs, si->sps->poc_msb_cycle_len, "poc_msb_cycle");
}
}
return 0;
} | 257 | True | 1 |
CVE-2021-30020 | 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/gpac/gpac/issues/1722', 'name': 'https://github.com/gpac/gpac/issues/1722', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'name': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-787'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'In the function gf_hevc_read_pps_bs_internal function in media_tools/av_parsers.c in GPAC 1.0.1 there is a loop, which with crafted file, pps->num_tile_columns may be larger than sizeof(pps->column_width), which results in a heap overflow in the loop.'}] | 2021-04-21T19:02Z | 2021-04-19T20: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 | jeanlf | 2021-03-29 09:34:02+02:00 | add safety in avc/hevc/vvc sps/pps/vps ID check - cf #1720 #1721 #1722 | 51cdb67ff7c5f1242ac58c5aa603ceaf1793b788 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | vvc_parse_picture_header | vvc_parse_picture_header( GF_BitStream * bs , VVCState * vvc , VVCSliceInfo * si) | ['bs', 'vvc', 'si'] | s32 vvc_parse_picture_header(GF_BitStream *bs, VVCState *vvc, VVCSliceInfo *si)
{
u32 pps_id;
si->irap_or_gdr_pic = gf_bs_read_int_log(bs, 1, "irap_or_gdr_pic");
si->non_ref_pic = gf_bs_read_int_log(bs, 1, "non_ref_pic");
if (si->irap_or_gdr_pic)
si->gdr_pic = gf_bs_read_int_log(bs, 1, "gdr_pic");
if ((si->inter_slice_allowed_flag = gf_bs_read_int_log(bs, 1, "inter_slice_allowed_flag")))
si->intra_slice_allowed_flag = gf_bs_read_int_log(bs, 1, "intra_slice_allowed_flag");
pps_id = gf_bs_read_ue_log(bs, "pps_id");
if (pps_id >= 64)
return -1;
si->pps = &vvc->pps[pps_id];
si->sps = &vvc->sps[si->pps->sps_id];
si->poc_lsb = gf_bs_read_int_log(bs, si->sps->log2_max_poc_lsb, "poc_lsb");
si->recovery_point_valid = 0;
si->gdr_recovery_count = 0;
if (si->gdr_pic) {
si->recovery_point_valid = 1;
si->gdr_recovery_count = gf_bs_read_ue_log(bs, "gdr_recovery_count");
}
gf_bs_read_int_log(bs, si->sps->ph_num_extra_bits, "ph_extra_bits");
if (si->sps->poc_msb_cycle_flag) {
if ( (si->poc_msb_cycle_present_flag = gf_bs_read_int_log(bs, 1, "poc_msb_cycle_present_flag"))) {
si->poc_msb_cycle = gf_bs_read_int_log(bs, si->sps->poc_msb_cycle_len, "poc_msb_cycle");
}
}
return 0;
} | 257 | True | 1 |
CVE-2021-30022 | 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/gpac/gpac/issues/1720', 'name': 'https://github.com/gpac/gpac/issues/1720', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'name': 'https://github.com/gpac/gpac/commit/51cdb67ff7c5f1242ac58c5aa603ceaf1793b788', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-190'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'There is a integer overflow in media_tools/av_parsers.c in the gf_avc_read_pps_bs_internal in GPAC 1.0.1. pps_id may be a negative number, so it will not return. However, avc->pps only has 255 unit, so there is an overflow, which results a crash.'}] | 2021-04-21T19:03Z | 2021-04-19T20:15Z | Integer Overflow or Wraparound | The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control. | An integer overflow or wraparound occurs when an integer value is incremented to a value that is too large to store in the associated representation. When this occurs, the value may wrap to become a very small or negative number. While this may be intended behavior in circumstances that rely on wrapping, it can have security consequences if the wrap is unexpected. This is especially the case if the integer overflow can be triggered using user-supplied inputs. This becomes security-critical when the result is used to control looping, make a security decision, or determine the offset or size in behaviors such as memory allocation, copying, concatenation, etc.
| https://cwe.mitre.org/data/definitions/190.html | 0 | jeanlf | 2021-03-29 09:34:02+02:00 | add safety in avc/hevc/vvc sps/pps/vps ID check - cf #1720 #1721 #1722 | 51cdb67ff7c5f1242ac58c5aa603ceaf1793b788 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | vvc_parse_picture_header | vvc_parse_picture_header( GF_BitStream * bs , VVCState * vvc , VVCSliceInfo * si) | ['bs', 'vvc', 'si'] | s32 vvc_parse_picture_header(GF_BitStream *bs, VVCState *vvc, VVCSliceInfo *si)
{
u32 pps_id;
si->irap_or_gdr_pic = gf_bs_read_int_log(bs, 1, "irap_or_gdr_pic");
si->non_ref_pic = gf_bs_read_int_log(bs, 1, "non_ref_pic");
if (si->irap_or_gdr_pic)
si->gdr_pic = gf_bs_read_int_log(bs, 1, "gdr_pic");
if ((si->inter_slice_allowed_flag = gf_bs_read_int_log(bs, 1, "inter_slice_allowed_flag")))
si->intra_slice_allowed_flag = gf_bs_read_int_log(bs, 1, "intra_slice_allowed_flag");
pps_id = gf_bs_read_ue_log(bs, "pps_id");
if (pps_id >= 64)
return -1;
si->pps = &vvc->pps[pps_id];
si->sps = &vvc->sps[si->pps->sps_id];
si->poc_lsb = gf_bs_read_int_log(bs, si->sps->log2_max_poc_lsb, "poc_lsb");
si->recovery_point_valid = 0;
si->gdr_recovery_count = 0;
if (si->gdr_pic) {
si->recovery_point_valid = 1;
si->gdr_recovery_count = gf_bs_read_ue_log(bs, "gdr_recovery_count");
}
gf_bs_read_int_log(bs, si->sps->ph_num_extra_bits, "ph_extra_bits");
if (si->sps->poc_msb_cycle_flag) {
if ( (si->poc_msb_cycle_present_flag = gf_bs_read_int_log(bs, 1, "poc_msb_cycle_present_flag"))) {
si->poc_msb_cycle = gf_bs_read_int_log(bs, si->sps->poc_msb_cycle_len, "poc_msb_cycle");
}
}
return 0;
} | 257 | True | 1 |
CVE-2021-30199 | 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/gpac/gpac/commit/b2db2f99b4c30f96e17b9a14537c776da6cb5dca', 'name': 'https://github.com/gpac/gpac/commit/b2db2f99b4c30f96e17b9a14537c776da6cb5dca', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/issues/1728', 'name': 'https://github.com/gpac/gpac/issues/1728', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-476'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'In filters/reframe_latm.c in GPAC 1.0.1 there is a Null Pointer Dereference, when gf_filter_pck_get_data is called. The first arg pck may be null with a crafted mp4 file,which results in a crash.'}] | 2021-04-21T19:03Z | 2021-04-19T20: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 | jeanlf | 2021-04-08 09:29:42+02:00 | fixed #1728 | b2db2f99b4c30f96e17b9a14537c776da6cb5dca | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | latm_dmx_process | latm_dmx_process( GF_Filter * filter) | ['filter'] | GF_Err latm_dmx_process(GF_Filter *filter)
{
GF_LATMDmxCtx *ctx = gf_filter_get_udta(filter);
GF_FilterPacket *pck, *dst_pck;
u32 pos;
u8 *data, *output;
u32 pck_size, prev_pck_size;
u64 cts = GF_FILTER_NO_TS;
if (ctx->in_error)
return ctx->in_error;
//always reparse duration
if (!ctx->duration.num)
latm_dmx_check_dur(filter, ctx);
if (ctx->opid && !ctx->is_playing)
return GF_OK;
pck = gf_filter_pid_get_packet(ctx->ipid);
if (!pck) {
if (gf_filter_pid_is_eos(ctx->ipid)) {
if (!ctx->latm_buffer_size) {
if (ctx->opid)
gf_filter_pid_set_eos(ctx->opid);
if (ctx->src_pck) gf_filter_pck_unref(ctx->src_pck);
ctx->src_pck = NULL;
return GF_EOS;
}
} else {
return GF_OK;
}
}
data = (char *) gf_filter_pck_get_data(pck, &pck_size);
//input pid sets some timescale - we flushed pending data , update cts
if (ctx->timescale && pck) {
cts = gf_filter_pck_get_cts(pck);
}
prev_pck_size = ctx->latm_buffer_size;
if (pck && !ctx->resume_from) {
if (ctx->latm_buffer_size + pck_size > ctx->latm_buffer_alloc) {
ctx->latm_buffer_alloc = ctx->latm_buffer_size + pck_size;
ctx->latm_buffer = gf_realloc(ctx->latm_buffer, ctx->latm_buffer_alloc);
}
memcpy(ctx->latm_buffer + ctx->latm_buffer_size, data, pck_size);
ctx->latm_buffer_size += pck_size;
}
if (!ctx->bs) ctx->bs = gf_bs_new(ctx->latm_buffer, ctx->latm_buffer_size, GF_BITSTREAM_READ);
else gf_bs_reassign_buffer(ctx->bs, ctx->latm_buffer, ctx->latm_buffer_size);
if (ctx->resume_from) {
gf_bs_seek(ctx->bs, ctx->resume_from-1);
ctx->resume_from = 0;
}
if (cts == GF_FILTER_NO_TS)
prev_pck_size = 0;
while (1) {
pos = (u32) gf_bs_get_position(ctx->bs);
u8 latm_buffer[4096];
u32 latm_frame_size = 4096;
if (!latm_dmx_sync_frame_bs(ctx->bs,&ctx->acfg, &latm_frame_size, latm_buffer, NULL)) break;
if (ctx->in_seek) {
u64 nb_samples_at_seek = (u64) (ctx->start_range * GF_M4ASampleRates[ctx->sr_idx]);
if (ctx->cts + ctx->dts_inc >= nb_samples_at_seek) {
//u32 samples_to_discard = (ctx->cts + ctx->dts_inc) - nb_samples_at_seek;
ctx->in_seek = GF_FALSE;
}
}
latm_dmx_check_pid(filter, ctx);
if (!ctx->is_playing) {
ctx->resume_from = pos+1;
return GF_OK;
}
if (!ctx->in_seek) {
GF_FilterSAPType sap = GF_FILTER_SAP_1;
dst_pck = gf_filter_pck_new_alloc(ctx->opid, latm_frame_size, &output);
if (ctx->src_pck) gf_filter_pck_merge_properties(ctx->src_pck, dst_pck);
memcpy(output, latm_buffer, latm_frame_size);
gf_filter_pck_set_cts(dst_pck, ctx->cts);
gf_filter_pck_set_duration(dst_pck, ctx->dts_inc);
gf_filter_pck_set_framing(dst_pck, GF_TRUE, GF_TRUE);
/*xHE-AAC, check RAP*/
if (ctx->acfg.base_object_type==GF_CODECID_USAC) {
if (latm_frame_size && (output[0] & 0x80) && !ctx->prev_sap) {
sap = GF_FILTER_SAP_1;
ctx->prev_sap = GF_TRUE;
} else {
sap = GF_FILTER_SAP_NONE;
ctx->prev_sap = GF_FALSE;
}
}
gf_filter_pck_set_sap(dst_pck, sap);
gf_filter_pck_send(dst_pck);
}
latm_dmx_update_cts(ctx);
if (prev_pck_size) {
pos = (u32) gf_bs_get_position(ctx->bs);
if (prev_pck_size<=pos) {
prev_pck_size=0;
if (ctx->src_pck) gf_filter_pck_unref(ctx->src_pck);
ctx->src_pck = pck;
if (pck)
gf_filter_pck_ref_props(&ctx->src_pck);
}
}
}
if (pck) {
pos = (u32) gf_bs_get_position(ctx->bs);
assert(ctx->latm_buffer_size >= pos);
memmove(ctx->latm_buffer, ctx->latm_buffer+pos, ctx->latm_buffer_size - pos);
ctx->latm_buffer_size -= pos;
gf_filter_pid_drop_packet(ctx->ipid);
assert(!ctx->resume_from);
} else {
ctx->latm_buffer_size = 0;
return latm_dmx_process(filter);
}
return GF_OK;
} | 771 | True | 1 |
CVE-2021-31255 | 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/gpac/gpac/issues/1733', 'name': 'https://github.com/gpac/gpac/issues/1733', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/758135e91e623d7dfe7f6aaad7aeb3f791b7a4e5', 'name': 'https://github.com/gpac/gpac/commit/758135e91e623d7dfe7f6aaad7aeb3f791b7a4e5', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-120'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Buffer overflow in the abst_box_read function in MP4Box in GPAC 1.0.1 allows attackers to cause a denial of service or execute arbitrary code via a crafted file.'}] | 2021-04-21T19:34Z | 2021-04-19T19:15Z | Buffer Copy without Checking Size of Input ('Classic Buffer Overflow') | The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow. | A buffer overflow condition exists when a program attempts to put more data in a buffer than it can hold, or when a program attempts to put data in a memory area outside of the boundaries of a buffer. The simplest type of error, and the most common cause of buffer overflows, is the "classic" case in which the program copies the buffer without restricting how much is copied. Other variants exist, but the existence of a classic overflow strongly suggests that the programmer is not considering even the most basic of security protections.
| https://cwe.mitre.org/data/definitions/120.html | 0 | jeanlf | 2021-04-08 10:07:35+02:00 | fixed #1733 | 758135e91e623d7dfe7f6aaad7aeb3f791b7a4e5 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | abst_box_read | abst_box_read( GF_Box * s , GF_BitStream * bs) | ['s', 'bs'] | GF_Err abst_box_read(GF_Box *s, GF_BitStream *bs)
{
GF_AdobeBootstrapInfoBox *ptr = (GF_AdobeBootstrapInfoBox *)s;
int i;
u32 tmp_strsize;
char *tmp_str;
GF_Err e;
ISOM_DECREASE_SIZE(ptr, 25)
ptr->bootstrapinfo_version = gf_bs_read_u32(bs);
ptr->profile = gf_bs_read_int(bs, 2);
ptr->live = gf_bs_read_int(bs, 1);
ptr->update = gf_bs_read_int(bs, 1);
ptr->reserved = gf_bs_read_int(bs, 4);
ptr->time_scale = gf_bs_read_u32(bs);
ptr->current_media_time = gf_bs_read_u64(bs);
ptr->smpte_time_code_offset = gf_bs_read_u64(bs);
i=0;
if (ptr->size<8) return GF_ISOM_INVALID_FILE;
tmp_strsize =(u32)ptr->size;
tmp_str = gf_malloc(sizeof(char)*tmp_strsize);
if (!tmp_str) return GF_OUT_OF_MEM;
memset(tmp_str, 0, sizeof(char)*tmp_strsize);
while (tmp_strsize) {
ISOM_DECREASE_SIZE(ptr, 1)
tmp_str[i] = gf_bs_read_u8(bs);
tmp_strsize--;
if (!tmp_str[i])
break;
i++;
}
if (i) {
ptr->movie_identifier = gf_strdup(tmp_str);
}
ISOM_DECREASE_SIZE(ptr, 1)
ptr->server_entry_count = gf_bs_read_u8(bs);
for (i=0; i<ptr->server_entry_count; i++) {
int j=0;
tmp_strsize=(u32)ptr->size;
while (tmp_strsize) {
ISOM_DECREASE_SIZE(ptr, 1)
tmp_str[j] = gf_bs_read_u8(bs);
tmp_strsize--;
if (!tmp_str[j])
break;
j++;
}
if (j) {
gf_list_insert(ptr->server_entry_table, gf_strdup(tmp_str), i);
}
}
ISOM_DECREASE_SIZE(ptr, 1)
ptr->quality_entry_count = gf_bs_read_u8(bs);
for (i=0; i<ptr->quality_entry_count; i++) {
int j=0;
tmp_strsize=(u32)ptr->size;
while (tmp_strsize) {
ISOM_DECREASE_SIZE(ptr, 1)
tmp_str[j] = gf_bs_read_u8(bs);
tmp_strsize--;
if (!tmp_str[j])
break;
j++;
}
if (j) {
gf_list_insert(ptr->quality_entry_table, gf_strdup(tmp_str), i);
}
}
i=0;
tmp_strsize=(u32)ptr->size;
while (tmp_strsize) {
ISOM_DECREASE_SIZE(ptr, 1)
tmp_str[i] = gf_bs_read_u8(bs);
tmp_strsize--;
if (!tmp_str[i])
break;
i++;
}
if (i) {
ptr->drm_data = gf_strdup(tmp_str);
}
i=0;
tmp_strsize=(u32)ptr->size;
while (tmp_strsize) {
ISOM_DECREASE_SIZE(ptr, 1)
tmp_str[i] = gf_bs_read_u8(bs);
tmp_strsize--;
if (!tmp_str[i])
break;
i++;
}
if (i) {
ptr->meta_data = gf_strdup(tmp_str);
}
ISOM_DECREASE_SIZE(ptr, 1)
ptr->segment_run_table_count = gf_bs_read_u8(bs);
for (i=0; i<ptr->segment_run_table_count; i++) {
GF_AdobeSegmentRunTableBox *asrt = NULL;
e = gf_isom_box_parse((GF_Box **)&asrt, bs);
if (e) {
if (asrt) gf_isom_box_del((GF_Box*)asrt);
gf_free(tmp_str);
return e;
}
gf_list_add(ptr->segment_run_table_entries, asrt);
}
ISOM_DECREASE_SIZE(ptr, 1)
ptr->fragment_run_table_count = gf_bs_read_u8(bs);
for (i=0; i<ptr->fragment_run_table_count; i++) {
GF_AdobeFragmentRunTableBox *afrt = NULL;
e = gf_isom_box_parse((GF_Box **)&afrt, bs);
if (e) {
if (afrt) gf_isom_box_del((GF_Box*)afrt);
gf_free(tmp_str);
return e;
}
gf_list_add(ptr->fragment_run_table_entries, afrt);
}
gf_free(tmp_str);
return GF_OK;
} | 756 | True | 1 |
CVE-2021-31257 | 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/gpac/gpac/commit/87afe070cd6866df7fe80f11b26ef75161de85e0', 'name': 'https://github.com/gpac/gpac/commit/87afe070cd6866df7fe80f11b26ef75161de85e0', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/issues/1734', 'name': 'https://github.com/gpac/gpac/issues/1734', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-476'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'The HintFile function in GPAC 1.0.1 allows attackers to cause a denial of service (NULL pointer dereference) via a crafted file in the MP4Box command.'}] | 2021-04-21T19:42Z | 2021-04-19T19: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 | jeanlf | 2021-04-08 10:09:46+02:00 | fixed #1734 | 87afe070cd6866df7fe80f11b26ef75161de85e0 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | HintFile | HintFile( GF_ISOFile * file , u32 MTUSize , u32 max_ptime , u32 rtp_rate , u32 base_flags , Bool copy_data , Bool interleave , Bool regular_iod , Bool single_group , Bool hint_no_offset) | ['file', 'MTUSize', 'max_ptime', 'rtp_rate', 'base_flags', 'copy_data', 'interleave', 'regular_iod', 'single_group', 'hint_no_offset'] | GF_Err HintFile(GF_ISOFile *file, u32 MTUSize, u32 max_ptime, u32 rtp_rate, u32 base_flags, Bool copy_data, Bool interleave, Bool regular_iod, Bool single_group, Bool hint_no_offset)
{
GF_ESD *esd;
GF_InitialObjectDescriptor *iod;
u32 i, val, res, streamType;
u32 sl_mode, prev_ocr, single_ocr, nb_done, tot_bw, bw, flags, spec_type;
GF_Err e;
char szPayload[30];
GF_RTPHinter *hinter;
Bool copy, has_iod, single_av;
u8 init_payt = BASE_PAYT;
u32 mtype;
GF_SDP_IODProfile iod_mode = GF_SDP_IOD_NONE;
u32 media_group = 0;
u8 media_prio = 0;
tot_bw = 0;
prev_ocr = 0;
single_ocr = 1;
has_iod = 1;
iod = (GF_InitialObjectDescriptor *) gf_isom_get_root_od(file);
if (!iod) has_iod = 0;
else {
if (!gf_list_count(iod->ESDescriptors)) has_iod = 0;
gf_odf_desc_del((GF_Descriptor *) iod);
}
spec_type = gf_isom_guess_specification(file);
single_av = single_group ? 1 : gf_isom_is_single_av(file);
/*first make sure we use a systems track as base OCR*/
for (i=0; i<gf_isom_get_track_count(file); i++) {
res = gf_isom_get_media_type(file, i+1);
if ((res==GF_ISOM_MEDIA_SCENE) || (res==GF_ISOM_MEDIA_OD)) {
if (gf_isom_is_track_in_root_od(file, i+1)) {
gf_isom_set_default_sync_track(file, i+1);
break;
}
}
}
nb_done = 0;
for (i=0; i<gf_isom_get_track_count(file); i++) {
sl_mode = base_flags;
copy = copy_data;
/*skip emty tracks (mainly MPEG-4 interaction streams...*/
if (!gf_isom_get_sample_count(file, i+1)) continue;
if (!gf_isom_is_track_enabled(file, i+1)) {
M4_LOG(GF_LOG_INFO, ("Track ID %d disabled - skipping hint\n", gf_isom_get_track_id(file, i+1) ));
continue;
}
mtype = gf_isom_get_media_type(file, i+1);
switch (mtype) {
case GF_ISOM_MEDIA_VISUAL:
if (single_av) {
media_group = 2;
media_prio = 2;
}
break;
case GF_ISOM_MEDIA_AUXV:
if (single_av) {
media_group = 2;
media_prio = 3;
}
break;
case GF_ISOM_MEDIA_PICT:
if (single_av) {
media_group = 2;
media_prio = 4;
}
break;
case GF_ISOM_MEDIA_AUDIO:
if (single_av) {
media_group = 2;
media_prio = 1;
}
break;
case GF_ISOM_MEDIA_HINT:
continue;
default:
/*no hinting of systems track on isma*/
if (spec_type==GF_ISOM_BRAND_ISMA) continue;
}
mtype = gf_isom_get_media_subtype(file, i+1, 1);
if ((mtype==GF_ISOM_SUBTYPE_MPEG4) || (mtype==GF_ISOM_SUBTYPE_MPEG4_CRYP) ) mtype = gf_isom_get_mpeg4_subtype(file, i+1, 1);
if (!single_av) {
/*one media per group only (we should prompt user for group selection)*/
media_group ++;
media_prio = 1;
}
streamType = 0;
esd = gf_isom_get_esd(file, i+1, 1);
if (esd) {
streamType = esd->decoderConfig->streamType;
if (!prev_ocr) {
prev_ocr = esd->OCRESID;
if (!esd->OCRESID) prev_ocr = esd->ESID;
} else if (esd->OCRESID && prev_ocr != esd->OCRESID) {
single_ocr = 0;
}
/*OD MUST BE WITHOUT REFERENCES*/
if (streamType==1) copy = 1;
}
gf_odf_desc_del((GF_Descriptor *) esd);
if (!regular_iod && gf_isom_is_track_in_root_od(file, i+1)) {
/*single AU - check if base64 would fit in ESD (consider 33% overhead of base64), otherwise stream*/
if (gf_isom_get_sample_count(file, i+1)==1) {
GF_ISOSample *samp = gf_isom_get_sample(file, i+1, 1, &val);
if (streamType) {
res = gf_hinter_can_embbed_data(samp->data, samp->dataLength, streamType);
} else {
/*not a system track, we shall hint it*/
res = 0;
}
if (samp) gf_isom_sample_del(&samp);
if (res) continue;
}
}
if (interleave) sl_mode |= GP_RTP_PCK_USE_INTERLEAVING;
hinter = gf_hinter_track_new(file, i+1, MTUSize, max_ptime, rtp_rate, sl_mode, init_payt, copy, media_group, media_prio, &e);
if (!hinter) {
if (e) {
M4_LOG(nb_done ? GF_LOG_WARNING : GF_LOG_ERROR, ("Cannot create hinter (%s)\n", gf_error_to_string(e) ));
if (!nb_done) return e;
}
continue;
}
if (hint_no_offset)
gf_hinter_track_force_no_offsets(hinter);
bw = gf_hinter_track_get_bandwidth(hinter);
tot_bw += bw;
flags = gf_hinter_track_get_flags(hinter);
//set extraction mode for AVC/SVC
gf_isom_set_nalu_extract_mode(file, i+1, GF_ISOM_NALU_EXTRACT_LAYER_ONLY);
gf_hinter_track_get_payload_name(hinter, szPayload);
M4_LOG(GF_LOG_INFO, ("Hinting track ID %d - Type \"%s:%s\" (%s) - BW %d kbps\n", gf_isom_get_track_id(file, i+1), gf_4cc_to_str(mtype), gf_4cc_to_str(mtype), szPayload, bw));
if (flags & GP_RTP_PCK_SYSTEMS_CAROUSEL) M4_LOG(GF_LOG_INFO, ("\tMPEG-4 Systems stream carousel enabled\n"));
e = gf_hinter_track_process(hinter);
if (!e) e = gf_hinter_track_finalize(hinter, has_iod);
gf_hinter_track_del(hinter);
if (e) {
M4_LOG(GF_LOG_ERROR, ("Error while hinting (%s)\n", gf_error_to_string(e)));
if (!nb_done) return e;
}
init_payt++;
nb_done ++;
}
if (has_iod) {
iod_mode = GF_SDP_IOD_ISMA;
if (regular_iod) iod_mode = GF_SDP_IOD_REGULAR;
} else {
iod_mode = GF_SDP_IOD_NONE;
}
gf_hinter_finalize(file, iod_mode, tot_bw);
if (!single_ocr)
M4_LOG(GF_LOG_WARNING, ("Warning: at least 2 timelines found in the file\nThis may not be supported by servers/players\n\n"));
return GF_OK;
} | 971 | True | 1 |
CVE-2021-31259 | 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/gpac/gpac/commit/3b84ffcbacf144ce35650df958432f472b6483f8', 'name': 'https://github.com/gpac/gpac/commit/3b84ffcbacf144ce35650df958432f472b6483f8', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/issues/1735', 'name': 'https://github.com/gpac/gpac/issues/1735', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-476'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'The gf_isom_cenc_get_default_info_internal function in GPAC 1.0.1 allows attackers to cause a denial of service (NULL pointer dereference) via a crafted file in the MP4Box command.'}] | 2021-04-21T19:23Z | 2021-04-19T19: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 | jeanlf | 2021-04-08 10:13:35+02:00 | fixed #1735 | 3b84ffcbacf144ce35650df958432f472b6483f8 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_isom_cenc_get_default_info_internal | gf_isom_cenc_get_default_info_internal( GF_TrackBox * trak , u32 sampleDescriptionIndex , u32 * container_type , Bool * default_IsEncrypted , u8 * crypt_byte_block , u8 * skip_byte_block , const u8 ** key_info , u32 * key_info_size) | ['trak', 'sampleDescriptionIndex', 'container_type', 'default_IsEncrypted', 'crypt_byte_block', 'skip_byte_block', 'key_info', 'key_info_size'] | void gf_isom_cenc_get_default_info_internal(GF_TrackBox *trak, u32 sampleDescriptionIndex, u32 *container_type, Bool *default_IsEncrypted, u8 *crypt_byte_block, u8 *skip_byte_block, const u8 **key_info, u32 *key_info_size)
{
GF_ProtectionSchemeInfoBox *sinf;
//setup all default as not encrypted
if (default_IsEncrypted) *default_IsEncrypted = GF_FALSE;
if (crypt_byte_block) *crypt_byte_block = 0;
if (skip_byte_block) *skip_byte_block = 0;
if (container_type) *container_type = 0;
if (key_info) *key_info = NULL;
if (key_info_size) *key_info_size = 0;
sinf = isom_get_sinf_entry(trak, sampleDescriptionIndex, GF_ISOM_CENC_SCHEME, NULL);
if (!sinf) sinf = isom_get_sinf_entry(trak, sampleDescriptionIndex, GF_ISOM_CBC_SCHEME, NULL);
if (!sinf) sinf = isom_get_sinf_entry(trak, sampleDescriptionIndex, GF_ISOM_CENS_SCHEME, NULL);
if (!sinf) sinf = isom_get_sinf_entry(trak, sampleDescriptionIndex, GF_ISOM_CBCS_SCHEME, NULL);
if (!sinf) sinf = isom_get_sinf_entry(trak, sampleDescriptionIndex, GF_ISOM_PIFF_SCHEME, NULL);
if (!sinf) {
u32 i, nb_stsd = gf_list_count(trak->Media->information->sampleTable->SampleDescription->child_boxes);
for (i=0; i<nb_stsd; i++) {
GF_ProtectionSchemeInfoBox *a_sinf;
GF_SampleEntryBox *sentry=NULL;
if (i+1==sampleDescriptionIndex) continue;
sentry = gf_list_get(trak->Media->information->sampleTable->SampleDescription->child_boxes, i);
a_sinf = (GF_ProtectionSchemeInfoBox *) gf_isom_box_find_child(sentry->child_boxes, GF_ISOM_BOX_TYPE_SINF);
if (!a_sinf) continue;
//signal default (not encrypted)
return;
}
}
if (sinf && sinf->info && sinf->info->tenc) {
if (default_IsEncrypted) *default_IsEncrypted = sinf->info->tenc->isProtected;
if (crypt_byte_block) *crypt_byte_block = sinf->info->tenc->crypt_byte_block;
if (skip_byte_block) *skip_byte_block = sinf->info->tenc->skip_byte_block;
if (key_info) *key_info = sinf->info->tenc->key_info;
if (key_info_size) {
*key_info_size = 20;
if (!sinf->info->tenc->key_info[3])
*key_info_size += 1 + sinf->info->tenc->key_info[20];
}
//set default value, overwritten below
if (container_type) *container_type = GF_ISOM_BOX_TYPE_SENC;
} else if (sinf && sinf->info && sinf->info->piff_tenc) {
if (default_IsEncrypted) *default_IsEncrypted = GF_TRUE;
if (key_info) *key_info = sinf->info->piff_tenc->key_info;
if (key_info_size) *key_info_size = 19;
//set default value, overwritten below
if (container_type) *container_type = GF_ISOM_BOX_UUID_PSEC;
} else {
u32 i, count = 0;
GF_CENCSampleEncryptionGroupEntry *seig_entry = NULL;
if (!trak->moov->mov->is_smooth)
count = gf_list_count(trak->Media->information->sampleTable->sampleGroupsDescription);
for (i=0; i<count; i++) {
GF_SampleGroupDescriptionBox *sgdesc = (GF_SampleGroupDescriptionBox*)gf_list_get(trak->Media->information->sampleTable->sampleGroupsDescription, i);
if (sgdesc->grouping_type!=GF_ISOM_SAMPLE_GROUP_SEIG) continue;
if (sgdesc->default_description_index)
seig_entry = gf_list_get(sgdesc->group_descriptions, sgdesc->default_description_index-1);
else
seig_entry = gf_list_get(sgdesc->group_descriptions, 0);
if (!seig_entry->key_info[0])
seig_entry = NULL;
break;
}
if (seig_entry) {
if (default_IsEncrypted) *default_IsEncrypted = seig_entry->IsProtected;
if (crypt_byte_block) *crypt_byte_block = seig_entry->crypt_byte_block;
if (skip_byte_block) *skip_byte_block = seig_entry->skip_byte_block;
if (key_info) *key_info = seig_entry->key_info;
if (key_info_size) *key_info_size = seig_entry->key_info_size;
if (container_type) *container_type = GF_ISOM_BOX_TYPE_SENC;
} else {
if (! trak->moov->mov->is_smooth ) {
trak->moov->mov->is_smooth = GF_TRUE;
GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[iso file] senc box without tenc, assuming MS smooth+piff\n"));
}
if (default_IsEncrypted) *default_IsEncrypted = GF_TRUE;
//set default value, overwritten below
if (container_type) *container_type = GF_ISOM_BOX_UUID_PSEC;
}
}
if (container_type && trak->sample_encryption) {
if (trak->sample_encryption->type == GF_ISOM_BOX_TYPE_SENC) *container_type = GF_ISOM_BOX_TYPE_SENC;
else if (trak->sample_encryption->type == GF_ISOM_BOX_TYPE_UUID) *container_type = ((GF_UUIDBox*)trak->sample_encryption)->internal_4cc;
}
} | 784 | True | 1 |
CVE-2021-31260 | 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/gpac/gpac/commit/df8fffd839fe5ae9acd82d26fd48280a397411d9', 'name': 'https://github.com/gpac/gpac/commit/df8fffd839fe5ae9acd82d26fd48280a397411d9', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/issues/1736', 'name': 'https://github.com/gpac/gpac/issues/1736', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-476'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'The MergeTrack function in GPAC 1.0.1 allows attackers to cause a denial of service (NULL pointer dereference) via a crafted file in the MP4Box command.'}] | 2021-04-21T19:31Z | 2021-04-19T19: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 | jeanlf | 2021-04-08 10:21:26+02:00 | fixed #1736 | df8fffd839fe5ae9acd82d26fd48280a397411d9 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | MergeTrack | MergeTrack( GF_TrackBox * trak , GF_TrackFragmentBox * traf , GF_MovieFragmentBox * moof_box , u64 moof_offset , s32 compressed_diff , u64 * cumulated_offset , Bool is_first_merge) | ['trak', 'traf', 'moof_box', 'moof_offset', 'compressed_diff', 'cumulated_offset', 'is_first_merge'] | GF_Err MergeTrack(GF_TrackBox *trak, GF_TrackFragmentBox *traf, GF_MovieFragmentBox *moof_box, u64 moof_offset, s32 compressed_diff, u64 *cumulated_offset, Bool is_first_merge)
{
u32 i, j, chunk_size, track_num;
u64 base_offset, data_offset, traf_duration;
u32 def_duration, DescIndex, def_size, def_flags;
u32 duration, size, flags, prev_trun_data_offset, sample_index;
u8 pad, sync;
u16 degr;
Bool first_samp_in_traf=GF_TRUE;
Bool store_traf_map=GF_FALSE;
u8 *moof_template=NULL;
u32 moof_template_size=0;
Bool is_seg_start = GF_FALSE;
u64 seg_start=0, sidx_start=0, sidx_end=0, frag_start=0, last_dts=0;
GF_TrackFragmentRunBox *trun;
GF_TrunEntry *ent;
#ifdef GF_ENABLE_CTRN
GF_TrackFragmentBox *traf_ref = NULL;
#endif
GF_Err stbl_AppendTime(GF_SampleTableBox *stbl, u32 duration, u32 nb_pack);
GF_Err stbl_AppendSize(GF_SampleTableBox *stbl, u32 size, u32 nb_pack);
GF_Err stbl_AppendChunk(GF_SampleTableBox *stbl, u64 offset);
GF_Err stbl_AppendSampleToChunk(GF_SampleTableBox *stbl, u32 DescIndex, u32 samplesInChunk);
GF_Err stbl_AppendCTSOffset(GF_SampleTableBox *stbl, s32 CTSOffset);
GF_Err stbl_AppendRAP(GF_SampleTableBox *stbl, u8 isRap);
GF_Err stbl_AppendPadding(GF_SampleTableBox *stbl, u8 padding);
GF_Err stbl_AppendDegradation(GF_SampleTableBox *stbl, u16 DegradationPriority);
if (trak->Header->trackID != traf->tfhd->trackID) return GF_OK;
if (!trak->Media->information->sampleTable
|| !trak->Media->information->sampleTable->SampleSize
|| !trak->Media->information->sampleTable->TimeToSample
|| !trak->Media->information->sampleTable->SampleToChunk
|| !trak->Media->information->sampleTable->ChunkOffset
) {
return GF_ISOM_INVALID_FILE;
}
if (!traf->trex->track)
traf->trex->track = trak;
//setup all our defaults
DescIndex = (traf->tfhd->flags & GF_ISOM_TRAF_SAMPLE_DESC) ? traf->tfhd->sample_desc_index : traf->trex->def_sample_desc_index;
if (!DescIndex) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] default sample description set to 0, likely broken ! Fixing to 1\n" ));
DescIndex = 1;
} else if (DescIndex > gf_list_count(trak->Media->information->sampleTable->SampleDescription->child_boxes)) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] default sample description set to %d but only %d sample description(s), likely broken ! Fixing to 1\n", DescIndex, gf_list_count(trak->Media->information->sampleTable->SampleDescription->child_boxes)));
DescIndex = 1;
}
#ifdef GF_ENABLE_CTRN
if (traf->trex->inherit_from_traf_id) {
u32 traf_count = gf_list_count(moof_box->TrackList);
for (i=0; i<traf_count; i++) {
GF_TrackFragmentBox *atraf = gf_list_get(moof_box->TrackList, i);
if (atraf->tfhd && atraf->tfhd->trackID==traf->trex->inherit_from_traf_id) {
traf_ref = atraf;
break;
}
}
}
#endif
def_duration = (traf->tfhd->flags & GF_ISOM_TRAF_SAMPLE_DUR) ? traf->tfhd->def_sample_duration : traf->trex->def_sample_duration;
def_size = (traf->tfhd->flags & GF_ISOM_TRAF_SAMPLE_SIZE) ? traf->tfhd->def_sample_size : traf->trex->def_sample_size;
def_flags = (traf->tfhd->flags & GF_ISOM_TRAF_SAMPLE_FLAGS) ? traf->tfhd->def_sample_flags : traf->trex->def_sample_flags;
//locate base offset, by default use moof (dash-like)
base_offset = moof_offset;
//explicit base offset, use it
if (traf->tfhd->flags & GF_ISOM_TRAF_BASE_OFFSET)
base_offset = traf->tfhd->base_data_offset;
//no moof offset and no explicit offset, the offset is the end of the last written chunk of
//the previous traf. For the first traf, *cumulated_offset is actually moof offset
else if (!(traf->tfhd->flags & GF_ISOM_MOOF_BASE_OFFSET))
base_offset = *cumulated_offset;
chunk_size = 0;
prev_trun_data_offset = 0;
data_offset = 0;
traf_duration = 0;
/*in playback mode*/
if (traf->tfdt && is_first_merge) {
#ifndef GPAC_DISABLE_LOG
if (trak->moov->mov->NextMoofNumber && trak->present_in_scalable_segment && trak->sample_count_at_seg_start && (trak->dts_at_seg_start != traf->tfdt->baseMediaDecodeTime)) {
s32 drift = (s32) ((s64) traf->tfdt->baseMediaDecodeTime - (s64)trak->dts_at_seg_start);
if (drift<0) {
GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[iso file] Warning: TFDT timing "LLD" less than cumulated timing "LLD" - using tfdt\n", traf->tfdt->baseMediaDecodeTime, trak->dts_at_seg_start ));
} else {
GF_LOG(GF_LOG_INFO, GF_LOG_CONTAINER, ("[iso file] TFDT timing "LLD" higher than cumulated timing "LLD" (last sample got extended in duration)\n", traf->tfdt->baseMediaDecodeTime, trak->dts_at_seg_start ));
}
}
#endif
trak->dts_at_seg_start = traf->tfdt->baseMediaDecodeTime;
}
else if (traf->tfxd) {
trak->dts_at_seg_start = traf->tfxd->absolute_time_in_track_timescale;
}
if (traf->tfxd) {
trak->last_tfxd_value = traf->tfxd->absolute_time_in_track_timescale;
trak->last_tfxd_value += traf->tfxd->fragment_duration_in_track_timescale;
}
if (traf->tfrf) {
if (trak->tfrf) gf_isom_box_del_parent(&trak->child_boxes, (GF_Box *)trak->tfrf);
trak->tfrf = traf->tfrf;
gf_list_del_item(traf->child_boxes, traf->tfrf);
gf_list_add(trak->child_boxes, trak->tfrf);
}
if (trak->moov->mov->signal_frag_bounds) {
store_traf_map = GF_TRUE;
if (is_first_merge) {
GF_MovieFragmentBox *moof_clone = NULL;
gf_isom_box_freeze_order((GF_Box *)moof_box);
gf_isom_clone_box((GF_Box *)moof_box, (GF_Box **)&moof_clone);
if (moof_clone) {
GF_BitStream *bs;
for (i=0; i<gf_list_count(moof_clone->TrackList); i++) {
GF_TrackFragmentBox *traf_clone = gf_list_get(moof_clone->TrackList, i);
gf_isom_box_array_reset_parent(&traf_clone->child_boxes, traf_clone->TrackRuns);
gf_isom_box_array_reset_parent(&traf_clone->child_boxes, traf_clone->sampleGroups);
gf_isom_box_array_reset_parent(&traf_clone->child_boxes, traf_clone->sampleGroupsDescription);
gf_isom_box_array_reset_parent(&traf_clone->child_boxes, traf_clone->sub_samples);
gf_isom_box_array_reset_parent(&traf_clone->child_boxes, traf_clone->sai_offsets);
gf_isom_box_array_reset_parent(&traf_clone->child_boxes, traf_clone->sai_sizes);
if (traf_clone->sample_encryption) {
gf_isom_box_del_parent(&traf_clone->child_boxes, (GF_Box *) traf_clone->sample_encryption);
traf_clone->sample_encryption = NULL;
}
if (traf_clone->sdtp) {
gf_isom_box_del_parent(&traf_clone->child_boxes, (GF_Box *) traf_clone->sdtp);
traf_clone->sdtp = NULL;
}
}
gf_isom_box_size((GF_Box *)moof_clone);
bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE);
if (trak->moov->mov->seg_styp) {
gf_isom_box_size(trak->moov->mov->seg_styp);
gf_isom_box_write(trak->moov->mov->seg_styp, bs);
}
if (trak->moov->mov->root_sidx) {
gf_isom_box_size((GF_Box *)trak->moov->mov->root_sidx);
gf_isom_box_write((GF_Box *)trak->moov->mov->root_sidx, bs);
}
if (trak->moov->mov->seg_ssix) {
gf_isom_box_size(trak->moov->mov->seg_ssix);
gf_isom_box_write(trak->moov->mov->seg_ssix, bs);
}
gf_isom_box_write((GF_Box *)moof_clone, bs);
gf_isom_box_del((GF_Box*)moof_clone);
gf_bs_get_content(bs, &moof_template, &moof_template_size);
gf_bs_del(bs);
}
}
if (trak->moov->mov->seg_styp) {
is_seg_start = GF_TRUE;
seg_start = trak->moov->mov->styp_start_offset;
}
if (trak->moov->mov->root_sidx) {
is_seg_start = GF_TRUE;
sidx_start = trak->moov->mov->sidx_start_offset;
sidx_end = trak->moov->mov->sidx_end_offset;
if (! seg_start || (sidx_start<seg_start))
seg_start = sidx_start;
}
frag_start = trak->moov->mov->current_top_box_start;
}
else if (trak->moov->mov->store_traf_map) {
store_traf_map = GF_TRUE;
}
sample_index = 0;
i=0;
while ((trun = (GF_TrackFragmentRunBox *)gf_list_enum(traf->TrackRuns, &i))) {
//merge the run
for (j=0; j<trun->sample_count; j++) {
GF_Err e;
s32 cts_offset=0;
if (j<trun->nb_samples) {
ent = &trun->samples[j];
} else {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Track %d doesn't have enough trun entries (%d) compared to sample count (%d) in run\n", traf->trex->trackID, trun->nb_samples, trun->sample_count ));
break;
}
size = def_size;
duration = def_duration;
flags = def_flags;
//CTS - if flag not set (trun or ctrn) defaults to 0 which is the base value after alloc
//we just need to overrite its value if inherited
cts_offset = ent->CTS_Offset;
#ifdef GF_ENABLE_CTRN
if (trun->use_ctrn) {
if (!j && (trun->ctrn_flags & GF_ISOM_CTRN_FIRST_SAMPLE) ) {
if (trun->ctrn_first_dur) duration = ent->Duration;
if (trun->ctrn_first_size) size = ent->size;
if (trun->ctrn_first_ctts) flags = ent->flags;
} else {
if (trun->ctrn_dur) duration = ent->Duration;
if (trun->ctrn_size) size = ent->size;
if (trun->ctrn_sample_flags) flags = ent->flags;
}
/*re-override*/
if (trun->ctrn_flags & 0xF0) {
GF_TrunEntry *ref_entry;
if (!traf_ref) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Track %d use traf inheritance to track ID %d but reference traf not found\n", traf->trex->trackID, traf->trex->inherit_from_traf_id ));
break;
}
ref_entry = traf_get_sample_entry(traf_ref, sample_index);
if (!ref_entry) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Track %d use traf inheritance but sample %d not found in reference traf\n", traf->trex->trackID, sample_index+1 ));
break;
}
if (trun->ctrn_flags & GF_ISOM_CTRN_INHERIT_DUR)
duration = ref_entry->Duration;
if (trun->ctrn_flags & GF_ISOM_CTRN_INHERIT_SIZE)
size = ref_entry->size;
if (trun->ctrn_flags & GF_ISOM_CTRN_INHERIT_FLAGS)
flags = ref_entry->flags;
if (trun->ctrn_flags & GF_ISOM_CTRN_INHERIT_CTSO)
cts_offset = ref_entry->CTS_Offset;
}
} else
#endif
{
if (trun->flags & GF_ISOM_TRUN_DURATION) duration = ent->Duration;
if (trun->flags & GF_ISOM_TRUN_SIZE) size = ent->size;
if (trun->flags & GF_ISOM_TRUN_FLAGS) {
flags = ent->flags;
} else if (!j && (trun->flags & GF_ISOM_TRUN_FIRST_FLAG)) {
flags = trun->first_sample_flags;
}
}
sample_index++;
/*store the resolved value in case we have inheritance*/
ent->size = size;
ent->Duration = duration;
ent->flags = flags;
ent->CTS_Offset = cts_offset;
last_dts += duration;
//add size first
if (!trak->Media->information->sampleTable->SampleSize) {
trak->Media->information->sampleTable->SampleSize = (GF_SampleSizeBox *) gf_isom_box_new_parent(&trak->Media->information->sampleTable->child_boxes, GF_ISOM_BOX_TYPE_STSZ);
if (!trak->Media->information->sampleTable->SampleSize)
return GF_OUT_OF_MEM;
}
e = stbl_AppendSize(trak->Media->information->sampleTable, size, ent->nb_pack);
if (e) return e;
//then TS
if (!trak->Media->information->sampleTable->TimeToSample) {
trak->Media->information->sampleTable->TimeToSample = (GF_TimeToSampleBox *) gf_isom_box_new_parent(&trak->Media->information->sampleTable->child_boxes, GF_ISOM_BOX_TYPE_STTS);
if (!trak->Media->information->sampleTable->TimeToSample)
return GF_OUT_OF_MEM;
}
e = stbl_AppendTime(trak->Media->information->sampleTable, duration, ent->nb_pack);
if (e) return e;
//add chunk on first sample
if (!j) {
u64 final_offset;
data_offset = base_offset;
//we have an explicit data offset for this trun
if (trun->flags & GF_ISOM_TRUN_DATA_OFFSET) {
data_offset += trun->data_offset;
/*reset chunk size since data is now relative to this trun*/
chunk_size = 0;
/*remember this data offset for following trun*/
prev_trun_data_offset = trun->data_offset;
/*if mdat is located after the moof, and the moof was compressed, adjust offset
otherwise the offset does not need adjustment*/
if (trun->data_offset>=0) {
data_offset -= compressed_diff;
prev_trun_data_offset -= compressed_diff;
}
}
//we had an explicit data offset for the previous trun, use it + chunk size
else if (prev_trun_data_offset) {
/*data offset is previous chunk size plus previous offset of the trun*/
data_offset += prev_trun_data_offset + chunk_size;
}
//no explicit data offset, continuous data after last data in previous chunk
else {
data_offset += chunk_size;
//data offset of first trun in first traf, adjust if compressed moof
if ((i==1) && (trun->data_offset>=0)) {
data_offset -= compressed_diff;
}
}
final_offset = data_offset;
//adjust offset if moov was also compressed and we are still in the same file
//so that later call to gf_isom_get_sample properly adjust back the offset
if (trak->moov->compressed_diff) {
final_offset += trak->moov->compressed_diff;
}
if (!trak->Media->information->sampleTable->ChunkOffset) {
trak->Media->information->sampleTable->ChunkOffset = gf_isom_box_new_parent(&trak->Media->information->sampleTable->child_boxes, GF_ISOM_BOX_TYPE_STCO);
if (!trak->Media->information->sampleTable->ChunkOffset)
return GF_OUT_OF_MEM;
}
e = stbl_AppendChunk(trak->Media->information->sampleTable, final_offset);
if (e) return e;
//then sampleToChunk
if (!trak->Media->information->sampleTable->SampleToChunk) {
trak->Media->information->sampleTable->SampleToChunk = (GF_SampleToChunkBox *) gf_isom_box_new_parent(&trak->Media->information->sampleTable->child_boxes, GF_ISOM_BOX_TYPE_STSC);
if (!trak->Media->information->sampleTable->SampleToChunk)
return GF_OUT_OF_MEM;
}
e = stbl_AppendSampleToChunk(trak->Media->information->sampleTable,
DescIndex, trun->sample_count);
if (e) return e;
}
chunk_size += size;
if (store_traf_map && first_samp_in_traf) {
first_samp_in_traf = GF_FALSE;
e = stbl_AppendTrafMap(trak->Media->information->sampleTable, is_seg_start, seg_start, frag_start, moof_template, moof_template_size, sidx_start, sidx_end);
if (e) return e;
//do not deallocate, the memory is now owned by traf map
moof_template = NULL;
moof_template_size = 0;
}
if (ent->nb_pack>1) {
j+= ent->nb_pack-1;
traf_duration += ent->nb_pack*duration;
continue;
}
traf_duration += duration;
e = stbl_AppendCTSOffset(trak->Media->information->sampleTable, cts_offset);
if (e) return e;
//flags
sync = GF_ISOM_GET_FRAG_SYNC(flags);
if (trak->Media->information->sampleTable->no_sync_found && sync) {
trak->Media->information->sampleTable->no_sync_found = 0;
}
e = stbl_AppendRAP(trak->Media->information->sampleTable, sync);
if (e) return e;
pad = GF_ISOM_GET_FRAG_PAD(flags);
if (pad) {
e = stbl_AppendPadding(trak->Media->information->sampleTable, pad);
if (e) return e;
}
degr = GF_ISOM_GET_FRAG_DEG(flags);
if (degr) {
e = stbl_AppendDegradation(trak->Media->information->sampleTable, degr);
if (e) return e;
}
e = stbl_AppendDependencyType(trak->Media->information->sampleTable, GF_ISOM_GET_FRAG_LEAD(flags), GF_ISOM_GET_FRAG_DEPENDS(flags), GF_ISOM_GET_FRAG_DEPENDED(flags), GF_ISOM_GET_FRAG_REDUNDANT(flags));
if (e) return e;
}
}
if (trak->moov->mov->is_smooth && !traf->tfdt && !traf->tfxd) {
if (is_first_merge)
trak->dts_at_seg_start = trak->dts_at_next_seg_start;
trak->dts_at_next_seg_start += last_dts;
}
if (traf_duration && trak->editBox && trak->editBox->editList) {
for (i=0; i<gf_list_count(trak->editBox->editList->entryList); i++) {
GF_EdtsEntry *edts_e = gf_list_get(trak->editBox->editList->entryList, i);
if (edts_e->was_empty_dur) {
u64 extend_dur = traf_duration;
extend_dur *= trak->moov->mvhd->timeScale;
extend_dur /= trak->Media->mediaHeader->timeScale;
edts_e->segmentDuration += extend_dur;
}
else if (!edts_e->segmentDuration) {
edts_e->was_empty_dur = GF_TRUE;
if ((s64) traf_duration > edts_e->mediaTime)
traf_duration -= edts_e->mediaTime;
else
traf_duration = 0;
edts_e->segmentDuration = traf_duration;
edts_e->segmentDuration *= trak->moov->mvhd->timeScale;
edts_e->segmentDuration /= trak->Media->mediaHeader->timeScale;
}
}
}
//in any case, update the cumulated offset
//this will handle hypothetical files mixing MOOF offset and implicit non-moof offset
*cumulated_offset = data_offset + chunk_size;
/*merge sample groups*/
if (traf->sampleGroups) {
GF_List *groups;
GF_List *groupDescs;
Bool is_identical_sgpd = GF_TRUE;
u32 *new_idx = NULL, new_idx_count=0;
if (!trak->Media->information->sampleTable->sampleGroups)
trak->Media->information->sampleTable->sampleGroups = gf_list_new();
if (!trak->Media->information->sampleTable->sampleGroupsDescription)
trak->Media->information->sampleTable->sampleGroupsDescription = gf_list_new();
groupDescs = trak->Media->information->sampleTable->sampleGroupsDescription;
for (i=0; i<gf_list_count(traf->sampleGroupsDescription); i++) {
GF_SampleGroupDescriptionBox *new_sgdesc = NULL;
GF_SampleGroupDescriptionBox *sgdesc = gf_list_get(traf->sampleGroupsDescription, i);
for (j=0; j<gf_list_count(groupDescs); j++) {
new_sgdesc = gf_list_get(groupDescs, j);
if (new_sgdesc->grouping_type==sgdesc->grouping_type) break;
new_sgdesc = NULL;
}
/*new description, move it to our sample table*/
if (!new_sgdesc) {
gf_list_add(groupDescs, sgdesc);
gf_list_add(trak->Media->information->sampleTable->child_boxes, sgdesc);
gf_list_rem(traf->sampleGroupsDescription, i);
gf_list_del_item(traf->child_boxes, sgdesc);
i--;
}
/*merge descriptions*/
else {
u32 count;
is_identical_sgpd = gf_isom_is_identical_sgpd(new_sgdesc, sgdesc, 0);
if (is_identical_sgpd)
continue;
new_idx_count = gf_list_count(sgdesc->group_descriptions);
new_idx = (u32 *)gf_malloc(new_idx_count * sizeof(u32));
if (!new_idx) return GF_OUT_OF_MEM;
count = 0;
while (gf_list_count(sgdesc->group_descriptions)) {
void *sgpd_entry = gf_list_get(sgdesc->group_descriptions, 0);
Bool new_entry = GF_TRUE;
for (j = 0; j < gf_list_count(new_sgdesc->group_descriptions); j++) {
void *ptr = gf_list_get(new_sgdesc->group_descriptions, j);
if (gf_isom_is_identical_sgpd(sgpd_entry, ptr, new_sgdesc->grouping_type)) {
new_idx[count] = j + 1;
count ++;
new_entry = GF_FALSE;
gf_free(sgpd_entry);
break;
}
}
if (new_entry) {
gf_list_add(new_sgdesc->group_descriptions, sgpd_entry);
new_idx[count] = gf_list_count(new_sgdesc->group_descriptions);
count ++;
}
gf_list_rem(sgdesc->group_descriptions, 0);
}
}
}
groups = trak->Media->information->sampleTable->sampleGroups;
for (i=0; i<gf_list_count(traf->sampleGroups); i++) {
GF_SampleGroupBox *stbl_group = NULL;
GF_SampleGroupBox *frag_group = gf_list_get(traf->sampleGroups, i);
for (j=0; j<gf_list_count(groups); j++) {
stbl_group = gf_list_get(groups, j);
if ((frag_group->grouping_type==stbl_group->grouping_type) && (frag_group->grouping_type_parameter==stbl_group->grouping_type_parameter))
break;
stbl_group = NULL;
}
if (!stbl_group) {
stbl_group = (GF_SampleGroupBox *) gf_isom_box_new_parent(&trak->Media->information->sampleTable->child_boxes, GF_ISOM_BOX_TYPE_SBGP);
if (!stbl_group) return GF_OUT_OF_MEM;
stbl_group->grouping_type = frag_group->grouping_type;
stbl_group->grouping_type_parameter = frag_group->grouping_type_parameter;
stbl_group->version = frag_group->version;
gf_list_add(groups, stbl_group);
}
if (is_identical_sgpd) {
//adjust sgpd index: in traf index start at 0x1001
for (j = 0; j < frag_group->entry_count; j++)
frag_group->sample_entries[j].group_description_index &= 0x0FFFF;
if (frag_group->entry_count && stbl_group->entry_count &&
(frag_group->sample_entries[0].group_description_index==stbl_group->sample_entries[stbl_group->entry_count-1].group_description_index)
) {
stbl_group->sample_entries[stbl_group->entry_count - 1].sample_count += frag_group->sample_entries[0].sample_count;
if (frag_group->entry_count>1) {
stbl_group->sample_entries = gf_realloc(stbl_group->sample_entries, sizeof(GF_SampleGroupEntry) * (stbl_group->entry_count + frag_group->entry_count - 1));
memcpy(&stbl_group->sample_entries[stbl_group->entry_count], &frag_group->sample_entries[1], sizeof(GF_SampleGroupEntry) * (frag_group->entry_count - 1));
stbl_group->entry_count += frag_group->entry_count - 1;
}
} else {
stbl_group->sample_entries = gf_realloc(stbl_group->sample_entries, sizeof(GF_SampleGroupEntry) * (stbl_group->entry_count + frag_group->entry_count));
memcpy(&stbl_group->sample_entries[stbl_group->entry_count], &frag_group->sample_entries[0], sizeof(GF_SampleGroupEntry) * frag_group->entry_count);
stbl_group->entry_count += frag_group->entry_count;
}
} else {
stbl_group->sample_entries = gf_realloc(stbl_group->sample_entries, sizeof(GF_SampleGroupEntry) * (stbl_group->entry_count + frag_group->entry_count));
//adjust sgpd index
for (j = 0; j < frag_group->entry_count; j++) {
u32 sgidx = frag_group->sample_entries[j].group_description_index;
if (sgidx > 0x10000) {
sgidx -= 0x10001;
if (sgidx>=new_idx_count) {
GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[isobmf] corrupted sample group index in fragment %d but only %d group descriptions in fragment\n", sgidx, new_idx_count));
} else {
frag_group->sample_entries[j].group_description_index = new_idx[sgidx];
}
}
}
memcpy(&stbl_group->sample_entries[stbl_group->entry_count], &frag_group->sample_entries[0], sizeof(GF_SampleGroupEntry) * frag_group->entry_count);
stbl_group->entry_count += frag_group->entry_count;
}
}
if (new_idx) gf_free(new_idx);
}
/*content is encrypted*/
track_num = gf_isom_get_tracknum_from_id(trak->moov, trak->Header->trackID);
if (gf_isom_is_cenc_media(trak->moov->mov, track_num, DescIndex)
|| traf->sample_encryption) {
/*Merge sample auxiliary encryption information*/
GF_SampleEncryptionBox *senc = NULL;
u32 scheme_type;
gf_isom_get_cenc_info(trak->moov->mov, track_num, DescIndex, NULL, &scheme_type, NULL);
if (traf->sample_encryption) {
for (i = 0; i < gf_list_count(trak->Media->information->sampleTable->child_boxes); i++) {
GF_Box *a = (GF_Box *)gf_list_get(trak->Media->information->sampleTable->child_boxes, i);
if (a->type != traf->sample_encryption->type) continue;
if ((a->type ==GF_ISOM_BOX_TYPE_UUID) && (((GF_UUIDBox *)a)->internal_4cc == GF_ISOM_BOX_UUID_PSEC)) {
senc = (GF_SampleEncryptionBox *)a;
break;
}
else if (a->type ==GF_ISOM_BOX_TYPE_SENC) {
senc = (GF_SampleEncryptionBox *)a;
break;
}
}
if (!senc && trak->sample_encryption)
senc = trak->sample_encryption;
if (!senc) {
if (traf->sample_encryption->piff_type==1) {
senc = (GF_SampleEncryptionBox *)gf_isom_create_piff_psec_box(1, 0x2, 0, 0, NULL);
} else {
senc = gf_isom_create_samp_enc_box(1, 0x2);
}
if (!trak->Media->information->sampleTable->child_boxes) trak->Media->information->sampleTable->child_boxes = gf_list_new();
trak->sample_encryption = senc;
if (!trak->child_boxes) trak->child_boxes = gf_list_new();
gf_list_add(trak->child_boxes, senc);
}
}
/*get sample auxiliary information by saiz/saio rather than by parsing senc box*/
if (gf_isom_cenc_has_saiz_saio_traf(traf, scheme_type)) {
u32 nb_saio;
u32 aux_info_type;
u64 offset;
GF_Err e;
Bool is_encrypted;
GF_SampleAuxiliaryInfoOffsetBox *saio = NULL;
GF_SampleAuxiliaryInfoSizeBox *saiz = NULL;
offset = nb_saio = 0;
for (i = 0; i < gf_list_count(traf->sai_offsets); i++) {
saio = (GF_SampleAuxiliaryInfoOffsetBox *)gf_list_get(traf->sai_offsets, i);
aux_info_type = saio->aux_info_type;
if (!aux_info_type) aux_info_type = scheme_type;
/*if we have only 1 sai_offsets, assume that its type is cenc*/
if ((aux_info_type == GF_ISOM_CENC_SCHEME) || (aux_info_type == GF_ISOM_CBC_SCHEME) ||
(aux_info_type == GF_ISOM_CENS_SCHEME) || (aux_info_type == GF_ISOM_CBCS_SCHEME) ||
(gf_list_count(traf->sai_offsets) == 1)) {
offset = saio->offsets[0] + moof_offset;
nb_saio = saio->entry_count;
break;
}
}
for (i = 0; i < gf_list_count(traf->sai_sizes); i++) {
saiz = (GF_SampleAuxiliaryInfoSizeBox *)gf_list_get(traf->sai_sizes, i);
aux_info_type = saiz->aux_info_type;
if (!aux_info_type) aux_info_type = scheme_type;
/*if we have only 1 sai_sizes, assume that its type is cenc*/
if ((aux_info_type == GF_ISOM_CENC_SCHEME) || (aux_info_type == GF_ISOM_CBC_SCHEME) ||
(aux_info_type == GF_ISOM_CENS_SCHEME) || (aux_info_type == GF_ISOM_CBCS_SCHEME) ||
(gf_list_count(traf->sai_sizes) == 1)) {
break;
}
}
if (saiz && saio && senc) {
for (i = 0; i < saiz->sample_count; i++) {
GF_CENCSampleAuxInfo *sai;
const u8 *key_info=NULL;
u32 key_info_size;
u64 cur_position;
if (nb_saio != 1)
offset = saio->offsets[i] + moof_offset;
size = saiz->default_sample_info_size ? saiz->default_sample_info_size : saiz->sample_info_size[i];
cur_position = gf_bs_get_position(trak->moov->mov->movieFileMap->bs);
gf_bs_seek(trak->moov->mov->movieFileMap->bs, offset);
GF_SAFEALLOC(sai, GF_CENCSampleAuxInfo);
if (!sai) return GF_OUT_OF_MEM;
e = gf_isom_get_sample_cenc_info_internal(trak, traf, senc, i+1, &is_encrypted, NULL, NULL, &key_info, &key_info_size);
if (e) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[isobmf] could not get cenc info for sample %d: %s\n", i+1, gf_error_to_string(e) ));
return e;
}
if (is_encrypted) {
sai->cenc_data_size = size;
sai->cenc_data = gf_malloc(sizeof(u8)*size);
if (!sai->cenc_data) return GF_OUT_OF_MEM;
gf_bs_read_data(trak->moov->mov->movieFileMap->bs, sai->cenc_data, sai->cenc_data_size);
} else {
sai->isNotProtected=1;
}
if (key_info) {
//not multikey
if (!key_info[0]) {
//size greater than IV
if (size > key_info[3])
senc->flags = 0x00000002;
}
//multikey, always use subsamples
else {
senc->flags = 0x00000002;
}
}
gf_bs_seek(trak->moov->mov->movieFileMap->bs, cur_position);
gf_list_add(senc->samp_aux_info, sai);
e = gf_isom_cenc_merge_saiz_saio(senc, trak->Media->information->sampleTable, offset, size);
if (e) return e;
if (nb_saio == 1)
offset += size;
}
}
} else if (traf->sample_encryption) {
senc_Parse(trak->moov->mov->movieFileMap->bs, trak, traf, traf->sample_encryption);
trak->sample_encryption->AlgorithmID = traf->sample_encryption->AlgorithmID;
if (!trak->sample_encryption->IV_size)
trak->sample_encryption->IV_size = traf->sample_encryption->IV_size;
if (!trak->sample_encryption->samp_aux_info) trak->sample_encryption->samp_aux_info = gf_list_new();
gf_list_transfer(trak->sample_encryption->samp_aux_info, traf->sample_encryption->samp_aux_info);
if (traf->sample_encryption->flags & 0x00000002)
trak->sample_encryption->flags |= 0x00000002;
}
}
return GF_OK;
} | 4814 | True | 1 |
CVE-2021-31261 | 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/gpac/gpac/commit/cd3738dea038dbd12e603ad48cd7373ae0440f65', 'name': 'https://github.com/gpac/gpac/commit/cd3738dea038dbd12e603ad48cd7373ae0440f65', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/issues/1737', 'name': 'https://github.com/gpac/gpac/issues/1737', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-119'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'The gf_hinter_track_new function in GPAC 1.0.1 allows attackers to read memory via a crafted file in the MP4Box command.'}] | 2021-04-21T19:32Z | 2021-04-19T19:15Z | Improper Restriction of Operations within the Bounds of a Memory Buffer | The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer. |
Certain languages allow direct addressing of memory locations and do not automatically ensure that these locations are valid for the memory buffer that is being referenced. This can cause read or write operations to be performed on memory locations that may be associated with other variables, data structures, or internal program data.
As a result, an attacker may be able to execute arbitrary code, alter the intended control flow, read sensitive information, or cause the system to crash.
| https://cwe.mitre.org/data/definitions/119.html | 0 | jeanlf | 2021-04-09 11:12:47+02:00 | fixed #1737 | cd3738dea038dbd12e603ad48cd7373ae0440f65 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_hinter_track_new | gf_hinter_track_new( GF_ISOFile * file , u32 TrackNum , u32 Path_MTU , u32 max_ptime , u32 default_rtp_rate , u32 flags , u8 PayloadID , Bool copy_media , u32 InterleaveGroupID , u8 InterleaveGroupPriority , GF_Err * e) | ['file', 'TrackNum', 'Path_MTU', 'max_ptime', 'default_rtp_rate', 'flags', 'PayloadID', 'copy_media', 'InterleaveGroupID', 'InterleaveGroupPriority', 'e'] | GF_RTPHinter *gf_hinter_track_new(GF_ISOFile *file, u32 TrackNum,
u32 Path_MTU, u32 max_ptime, u32 default_rtp_rate, u32 flags, u8 PayloadID,
Bool copy_media, u32 InterleaveGroupID, u8 InterleaveGroupPriority, GF_Err *e)
{
GF_SLConfig my_sl;
u32 descIndex, MinSize, MaxSize, avgTS, streamType, codecid, const_dur, nb_ch, maxDTSDelta;
u8 OfficialPayloadID;
u32 TrackMediaSubType, TrackMediaType, hintType, nbEdts, required_rate, force_dts_delta, avc_nalu_size, PL_ID, bandwidth, IV_length, KI_length;
const char *url, *urn;
char *mpeg4mode;
Bool is_crypted, has_mpeg4_mapping;
GF_RTPHinter *tmp;
GF_ESD *esd;
*e = GF_BAD_PARAM;
if (!file || !TrackNum || !gf_isom_get_track_id(file, TrackNum)) return NULL;
if (!gf_isom_get_sample_count(file, TrackNum)) {
*e = GF_OK;
return NULL;
}
*e = GF_NOT_SUPPORTED;
nbEdts = gf_isom_get_edits_count(file, TrackNum);
if (nbEdts>1) {
u64 et, sd, mt;
GF_ISOEditType em;
gf_isom_get_edit(file, TrackNum, 1, &et, &sd, &mt, &em);
if ((nbEdts>2) || (em!=GF_ISOM_EDIT_EMPTY)) {
GF_LOG(GF_LOG_ERROR, GF_LOG_RTP, ("[rtp hinter] Cannot hint track whith EditList\n"));
return NULL;
}
}
if (nbEdts) gf_isom_remove_edits(file, TrackNum);
if (!gf_isom_is_track_enabled(file, TrackNum)) return NULL;
/*by default NO PL signaled*/
PL_ID = 0;
OfficialPayloadID = 0;
force_dts_delta = 0;
streamType = 0;
mpeg4mode = NULL;
required_rate = 0;
is_crypted = 0;
IV_length = KI_length = 0;
codecid = 0;
nb_ch = 0;
avc_nalu_size = 0;
has_mpeg4_mapping = 1;
const_dur = 0;
bandwidth=0;
TrackMediaType = gf_isom_get_media_type(file, TrackNum);
/*for max compatibility with QT*/
if (!default_rtp_rate) default_rtp_rate = 90000;
/*timed-text is a bit special, we support multiple stream descriptions & co*/
if ( (TrackMediaType==GF_ISOM_MEDIA_TEXT) || (TrackMediaType==GF_ISOM_MEDIA_SUBT)) {
hintType = GF_RTP_PAYT_3GPP_TEXT;
codecid = GF_CODECID_TEXT_MPEG4;
streamType = GF_STREAM_TEXT;
/*fixme - this works cos there's only one PL for text in mpeg4 at the current time*/
PL_ID = 0x10;
} else {
if (gf_isom_get_sample_description_count(file, TrackNum) > 1) return NULL;
TrackMediaSubType = gf_isom_get_media_subtype(file, TrackNum, 1);
switch (TrackMediaSubType) {
case GF_ISOM_SUBTYPE_MPEG4_CRYP:
is_crypted = 1;
case GF_ISOM_SUBTYPE_MPEG4:
esd = gf_isom_get_esd(file, TrackNum, 1);
hintType = GF_RTP_PAYT_MPEG4;
if (esd && esd->decoderConfig) {
streamType = esd->decoderConfig->streamType;
codecid = esd->decoderConfig->objectTypeIndication;
if (esd->URLString) hintType = 0;
/*AAC*/
if ((streamType==GF_STREAM_AUDIO)
&& esd->decoderConfig->decoderSpecificInfo && esd->decoderConfig->decoderSpecificInfo->data
/*(nb: we use mpeg4 for MPEG-2 AAC)*/
&& ((codecid==GF_CODECID_AAC_MPEG4) || (codecid==GF_CODECID_AAC_MPEG2_MP) || (codecid==GF_CODECID_AAC_MPEG2_LCP) || (codecid==GF_CODECID_AAC_MPEG2_SSRP)) ) {
u32 sample_rate;
GF_M4ADecSpecInfo a_cfg;
gf_m4a_get_config(esd->decoderConfig->decoderSpecificInfo->data, esd->decoderConfig->decoderSpecificInfo->dataLength, &a_cfg);
nb_ch = a_cfg.nb_chan;
sample_rate = a_cfg.base_sr;
PL_ID = a_cfg.audioPL;
switch (a_cfg.base_object_type) {
case GF_M4A_AAC_MAIN:
case GF_M4A_AAC_LC:
if (flags & GP_RTP_PCK_USE_LATM_AAC) {
hintType = GF_RTP_PAYT_LATM;
break;
}
case GF_M4A_AAC_SBR:
case GF_M4A_AAC_PS:
case GF_M4A_AAC_LTP:
case GF_M4A_AAC_SCALABLE:
case GF_M4A_ER_AAC_LC:
case GF_M4A_ER_AAC_LTP:
case GF_M4A_ER_AAC_SCALABLE:
mpeg4mode = "AAC";
break;
case GF_M4A_CELP:
case GF_M4A_ER_CELP:
mpeg4mode = "CELP";
break;
}
required_rate = sample_rate;
}
/*MPEG1/2 audio*/
else if ((streamType==GF_STREAM_AUDIO) && ((codecid==GF_CODECID_MPEG2_PART3) || (codecid==GF_CODECID_MPEG_AUDIO))) {
GF_ISOSample *samp = NULL;
if (!is_crypted)
samp = gf_isom_get_sample(file, TrackNum, 1, NULL);
if (samp && (samp->dataLength>3)) {
u32 hdr = GF_4CC((u32)samp->data[0], (u8)samp->data[1], (u8)samp->data[2], (u8)samp->data[3]);
nb_ch = gf_mp3_num_channels(hdr);
hintType = GF_RTP_PAYT_MPEG12_AUDIO;
/*use official RTP/AVP payload type*/
OfficialPayloadID = 14;
required_rate = 90000;
}
/*encrypted MP3 must be sent through MPEG-4 generic to signal all ISMACryp stuff*/
else {
u32 sample_rate;
gf_isom_get_audio_info(file, TrackNum, 1, &sample_rate, &nb_ch, NULL);
required_rate = sample_rate;
}
if (samp)
gf_isom_sample_del(&samp);
}
/*QCELP audio*/
else if ((streamType==GF_STREAM_AUDIO) && (codecid==GF_CODECID_QCELP)) {
hintType = GF_RTP_PAYT_QCELP;
OfficialPayloadID = 12;
required_rate = 8000;
streamType = GF_STREAM_AUDIO;
nb_ch = 1;
}
/*EVRC/SVM audio*/
else if ((streamType==GF_STREAM_AUDIO) && ((codecid==GF_CODECID_EVRC) || (codecid==GF_CODECID_SMV)) ) {
hintType = GF_RTP_PAYT_EVRC_SMV;
required_rate = 8000;
streamType = GF_STREAM_AUDIO;
nb_ch = 1;
}
/*visual streams*/
else if (streamType==GF_STREAM_VISUAL) {
if ((codecid==GF_CODECID_MPEG4_PART2) && esd->decoderConfig->decoderSpecificInfo) {
GF_M4VDecSpecInfo dsi;
gf_m4v_get_config(esd->decoderConfig->decoderSpecificInfo->data, esd->decoderConfig->decoderSpecificInfo->dataLength, &dsi);
PL_ID = dsi.VideoPL;
}
/*MPEG1/2 video*/
if ( ((codecid>=GF_CODECID_MPEG2_SIMPLE) && (codecid<=GF_CODECID_MPEG2_422)) || (codecid==GF_CODECID_MPEG1)) {
if (!is_crypted) {
hintType = GF_RTP_PAYT_MPEG12_VIDEO;
OfficialPayloadID = 32;
}
}
/*for ISMA*/
if (is_crypted) {
/*that's another pain with ISMACryp, even if no B-frames the DTS is signaled...*/
if (codecid==GF_CODECID_MPEG4_PART2) force_dts_delta = 22;
else if ((codecid==GF_CODECID_AVC) || (codecid==GF_CODECID_SVC)) {
flags &= ~GP_RTP_PCK_USE_MULTI;
force_dts_delta = 22;
}
flags |= GP_RTP_PCK_SIGNAL_RAP | GP_RTP_PCK_SIGNAL_TS;
}
required_rate = default_rtp_rate;
}
/*systems streams*/
else if (gf_isom_has_sync_shadows(file, TrackNum) || gf_isom_has_sample_dependency(file, TrackNum)) {
flags |= GP_RTP_PCK_SYSTEMS_CAROUSEL;
}
gf_odf_desc_del((GF_Descriptor*)esd);
}
break;
case GF_ISOM_SUBTYPE_3GP_H263:
hintType = GF_RTP_PAYT_H263;
required_rate = 90000;
streamType = GF_STREAM_VISUAL;
OfficialPayloadID = 34;
/*not 100% compliant (short header is missing) but should still work*/
codecid = GF_CODECID_MPEG4_PART2;
PL_ID = 0x01;
break;
case GF_ISOM_SUBTYPE_3GP_AMR:
required_rate = 8000;
hintType = GF_RTP_PAYT_AMR;
streamType = GF_STREAM_AUDIO;
has_mpeg4_mapping = 0;
nb_ch = 1;
break;
case GF_ISOM_SUBTYPE_3GP_AMR_WB:
required_rate = 16000;
hintType = GF_RTP_PAYT_AMR_WB;
streamType = GF_STREAM_AUDIO;
has_mpeg4_mapping = 0;
nb_ch = 1;
break;
case GF_ISOM_SUBTYPE_AVC_H264:
case GF_ISOM_SUBTYPE_AVC2_H264:
case GF_ISOM_SUBTYPE_AVC3_H264:
case GF_ISOM_SUBTYPE_AVC4_H264:
case GF_ISOM_SUBTYPE_SVC_H264:
case GF_ISOM_SUBTYPE_MVC_H264:
{
GF_AVCConfig *avcc = gf_isom_avc_config_get(file, TrackNum, 1);
GF_AVCConfig *svcc = gf_isom_svc_config_get(file, TrackNum, 1);
GF_AVCConfig *mvcc = gf_isom_mvc_config_get(file, TrackNum, 1);
if (!avcc && !svcc && !mvcc) {
*e = GF_NON_COMPLIANT_BITSTREAM;
return NULL;
}
required_rate = 90000; /* "90 kHz clock rate MUST be used"*/
hintType = GF_RTP_PAYT_H264_AVC;
if (TrackMediaSubType==GF_ISOM_SUBTYPE_SVC_H264)
hintType = GF_RTP_PAYT_H264_SVC;
else if (TrackMediaSubType==GF_ISOM_SUBTYPE_MVC_H264)
hintType = GF_RTP_PAYT_H264_SVC;
streamType = GF_STREAM_VISUAL;
avc_nalu_size = avcc ? avcc->nal_unit_size : svcc ? svcc->nal_unit_size : mvcc->nal_unit_size;
codecid = GF_CODECID_AVC;
PL_ID = 0x0F;
gf_odf_avc_cfg_del(avcc);
gf_odf_avc_cfg_del(svcc);
}
break;
case GF_ISOM_SUBTYPE_HVC1:
case GF_ISOM_SUBTYPE_HEV1:
case GF_ISOM_SUBTYPE_HVC2:
case GF_ISOM_SUBTYPE_HEV2:
{
GF_HEVCConfig *hevcc = gf_isom_hevc_config_get(file, TrackNum, 1);
if (!hevcc) {
*e = GF_NON_COMPLIANT_BITSTREAM;
return NULL;
}
required_rate = 90000; /* "90 kHz clock rate MUST be used"*/
hintType = GF_RTP_PAYT_HEVC;
streamType = GF_STREAM_VISUAL;
avc_nalu_size = hevcc->nal_unit_size;
codecid = GF_CODECID_HEVC;
PL_ID = 0x0F;
flags |= GP_RTP_PCK_USE_MULTI;
gf_odf_hevc_cfg_del(hevcc);
break;
}
break;
case GF_ISOM_SUBTYPE_3GP_QCELP:
required_rate = 8000;
hintType = GF_RTP_PAYT_QCELP;
streamType = GF_STREAM_AUDIO;
codecid = GF_CODECID_QCELP;
OfficialPayloadID = 12;
nb_ch = 1;
break;
case GF_ISOM_SUBTYPE_3GP_EVRC:
case GF_ISOM_SUBTYPE_3GP_SMV:
required_rate = 8000;
hintType = GF_RTP_PAYT_EVRC_SMV;
streamType = GF_STREAM_AUDIO;
codecid = (TrackMediaSubType==GF_ISOM_SUBTYPE_3GP_EVRC) ? GF_CODECID_EVRC : GF_CODECID_SMV;
nb_ch = 1;
break;
case GF_ISOM_SUBTYPE_3GP_DIMS:
#if GPAC_ENABLE_3GPP_DIMS_RTP
hintType = GF_RTP_PAYT_3GPP_DIMS;
streamType = GF_STREAM_SCENE;
#else
hintType = 0;
GF_LOG(GF_LOG_ERROR, GF_LOG_RTP, ("[RTP Packetizer] 3GPP DIMS over RTP disabled in build\n", streamType));
#endif
break;
case GF_ISOM_SUBTYPE_AC3:
hintType = GF_RTP_PAYT_AC3;
streamType = GF_STREAM_AUDIO;
gf_isom_get_audio_info(file, TrackNum, 1, NULL, &nb_ch, NULL);
break;
case GF_ISOM_SUBTYPE_MP3:
{
GF_ISOSample *samp = gf_isom_get_sample(file, TrackNum, 1, NULL);
if (samp && (samp->dataLength>3)) {
u32 hdr = GF_4CC((u32)samp->data[0], (u8)samp->data[1], (u8)samp->data[2], (u8)samp->data[3]);
nb_ch = gf_mp3_num_channels(hdr);
} else {
u32 bps;
gf_isom_get_audio_info(file, TrackNum, 1, &required_rate, &nb_ch, &bps);
}
hintType = GF_RTP_PAYT_MPEG12_AUDIO;
/*use official RTP/AVP payload type*/
OfficialPayloadID = 14;
required_rate = 90000;
if (samp)
gf_isom_sample_del(&samp);
}
break;
default:
/*ERROR*/
hintType = 0;
break;
}
}
/*not hintable*/
if (!hintType) return NULL;
/*we only support self-contained files for hinting*/
gf_isom_get_data_reference(file, TrackNum, 1, &url, &urn);
if (url || urn) return NULL;
*e = GF_OUT_OF_MEM;
GF_SAFEALLOC(tmp, GF_RTPHinter);
if (!tmp) return NULL;
/*override hinter type if requested and possible*/
if (has_mpeg4_mapping && (flags & GP_RTP_PCK_FORCE_MPEG4)) {
hintType = GF_RTP_PAYT_MPEG4;
avc_nalu_size = 0;
}
/*use static payload ID if enabled*/
else if (OfficialPayloadID && (flags & GP_RTP_PCK_USE_STATIC_ID) ) {
PayloadID = OfficialPayloadID;
}
tmp->file = file;
tmp->TrackNum = TrackNum;
tmp->avc_nalu_size = avc_nalu_size;
tmp->nb_chan = nb_ch;
/*spatial scalability check*/
tmp->has_ctts = gf_isom_has_time_offset(file, TrackNum);
/*get sample info*/
gf_media_get_sample_average_infos(file, TrackNum, &MinSize, &MaxSize, &avgTS, &maxDTSDelta, &const_dur, &bandwidth);
/*systems carousel: we need at least IDX and RAP signaling*/
if (flags & GP_RTP_PCK_SYSTEMS_CAROUSEL) {
flags |= GP_RTP_PCK_SIGNAL_RAP;
}
/*update flags in MultiSL*/
if (flags & GP_RTP_PCK_USE_MULTI) {
if (MinSize != MaxSize) flags |= GP_RTP_PCK_SIGNAL_SIZE;
if (!const_dur) flags |= GP_RTP_PCK_SIGNAL_TS;
}
if (tmp->has_ctts) flags |= GP_RTP_PCK_SIGNAL_TS;
/*default SL for RTP */
InitSL_RTP(&my_sl);
my_sl.timestampResolution = gf_isom_get_media_timescale(file, TrackNum);
/*override clockrate if set*/
if (required_rate) {
Double sc = required_rate;
sc /= my_sl.timestampResolution;
maxDTSDelta = (u32) (maxDTSDelta*sc);
my_sl.timestampResolution = required_rate;
}
/*switch to RTP TS*/
max_ptime = (u32) (max_ptime * my_sl.timestampResolution / 1000);
my_sl.AUSeqNumLength = gf_get_bit_size(gf_isom_get_sample_count(file, TrackNum));
if (my_sl.AUSeqNumLength>16) my_sl.AUSeqNumLength=16;
my_sl.CUDuration = const_dur;
if (gf_isom_has_sync_points(file, TrackNum)) {
my_sl.useRandomAccessPointFlag = 1;
} else {
my_sl.useRandomAccessPointFlag = 0;
my_sl.hasRandomAccessUnitsOnlyFlag = 1;
}
if (is_crypted) {
Bool use_sel_enc;
gf_isom_get_ismacryp_info(file, TrackNum, 1, NULL, NULL, NULL, NULL, NULL, &use_sel_enc, &IV_length, &KI_length);
if (use_sel_enc) flags |= GP_RTP_PCK_SELECTIVE_ENCRYPTION;
}
// in case a different timescale was provided
tmp->OrigTimeScale = gf_isom_get_media_timescale(file, TrackNum);
tmp->rtp_p = gf_rtp_builder_new(hintType, &my_sl, flags, tmp,
MP4T_OnNewPacket, MP4T_OnPacketDone,
/*if copy, no data ref*/
copy_media ? NULL : MP4T_OnDataRef,
MP4T_OnData);
//init the builder
gf_rtp_builder_init(tmp->rtp_p, PayloadID, Path_MTU, max_ptime,
streamType, codecid, PL_ID, MinSize, MaxSize, avgTS, maxDTSDelta, IV_length, KI_length, mpeg4mode);
/*ISMA compliance is a pain...*/
if (force_dts_delta) tmp->rtp_p->slMap.DTSDeltaLength = force_dts_delta;
/* Hint Track Setup */
tmp->TrackID = gf_isom_get_track_id(file, TrackNum);
tmp->HintID = tmp->TrackID + 65535;
while (gf_isom_get_track_by_id(file, tmp->HintID)) tmp->HintID++;
tmp->HintTrack = gf_isom_new_track(file, tmp->HintID, GF_ISOM_MEDIA_HINT, my_sl.timestampResolution);
gf_isom_setup_hint_track(file, tmp->HintTrack, GF_ISOM_HINT_RTP);
/*create a hint description*/
gf_isom_new_hint_description(file, tmp->HintTrack, -1, -1, 0, &descIndex);
gf_isom_rtp_set_timescale(file, tmp->HintTrack, descIndex, my_sl.timestampResolution);
if (hintType==GF_RTP_PAYT_MPEG4) {
tmp->rtp_p->slMap.CodecID = codecid;
/*set this SL for extraction.*/
*e = gf_isom_set_extraction_slc(file, TrackNum, 1, &my_sl);
if (*e) {
gf_hinter_track_del(tmp);
return NULL;
}
}
tmp->bandwidth = bandwidth;
/*set interleaving*/
gf_isom_set_track_interleaving_group(file, TrackNum, InterleaveGroupID);
if (!copy_media) {
/*if we don't copy data set hint track and media track in the same group*/
gf_isom_set_track_interleaving_group(file, tmp->HintTrack, InterleaveGroupID);
} else {
gf_isom_set_track_interleaving_group(file, tmp->HintTrack, InterleaveGroupID + OFFSET_HINT_GROUP_ID);
}
/*use user-secified priority*/
InterleaveGroupPriority*=2;
gf_isom_set_track_priority_in_group(file, TrackNum, InterleaveGroupPriority+1);
gf_isom_set_track_priority_in_group(file, tmp->HintTrack, InterleaveGroupPriority);
*e = GF_OK;
return tmp;
} | 2330 | True | 1 |
CVE-2021-31262 | 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/gpac/gpac/commit/b2eab95e07cb5819375a50358d4806a8813b6e50', 'name': 'https://github.com/gpac/gpac/commit/b2eab95e07cb5819375a50358d4806a8813b6e50', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/issues/1738', 'name': 'https://github.com/gpac/gpac/issues/1738', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-476'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'The AV1_DuplicateConfig function in GPAC 1.0.1 allows attackers to cause a denial of service (NULL pointer dereference) via a crafted file in the MP4Box command.'}] | 2021-04-21T19:05Z | 2021-04-19T19: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 | jeanlf | 2021-04-09 11:17:40+02:00 | fixed #1738 | b2eab95e07cb5819375a50358d4806a8813b6e50 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | AV1_DuplicateConfig | AV1_DuplicateConfig( GF_AV1Config const * const cfg) | ['cfg'] | static GF_AV1Config* AV1_DuplicateConfig(GF_AV1Config const * const cfg) {
u32 i = 0;
GF_AV1Config *out = gf_malloc(sizeof(GF_AV1Config));
out->marker = cfg->marker;
out->version = cfg->version;
out->seq_profile = cfg->seq_profile;
out->seq_level_idx_0 = cfg->seq_level_idx_0;
out->seq_tier_0 = cfg->seq_tier_0;
out->high_bitdepth = cfg->high_bitdepth;
out->twelve_bit = cfg->twelve_bit;
out->monochrome = cfg->monochrome;
out->chroma_subsampling_x = cfg->chroma_subsampling_x;
out->chroma_subsampling_y = cfg->chroma_subsampling_y;
out->chroma_sample_position = cfg->chroma_sample_position;
out->initial_presentation_delay_present = cfg->initial_presentation_delay_present;
out->initial_presentation_delay_minus_one = cfg->initial_presentation_delay_minus_one;
out->obu_array = gf_list_new();
for (i = 0; i<gf_list_count(cfg->obu_array); ++i) {
GF_AV1_OBUArrayEntry *dst = gf_malloc(sizeof(GF_AV1_OBUArrayEntry)), *src = gf_list_get(cfg->obu_array, i);
dst->obu_length = src->obu_length;
dst->obu_type = src->obu_type;
dst->obu = gf_malloc((size_t)dst->obu_length);
memcpy(dst->obu, src->obu, (size_t)src->obu_length);
gf_list_add(out->obu_array, dst);
}
return out;
} | 243 | True | 1 |
CVE-2021-31262 | 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/gpac/gpac/commit/b2eab95e07cb5819375a50358d4806a8813b6e50', 'name': 'https://github.com/gpac/gpac/commit/b2eab95e07cb5819375a50358d4806a8813b6e50', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/issues/1738', 'name': 'https://github.com/gpac/gpac/issues/1738', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-476'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'The AV1_DuplicateConfig function in GPAC 1.0.1 allows attackers to cause a denial of service (NULL pointer dereference) via a crafted file in the MP4Box command.'}] | 2021-04-21T19:05Z | 2021-04-19T19: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 | jeanlf | 2021-04-09 11:17:40+02:00 | fixed #1738 | b2eab95e07cb5819375a50358d4806a8813b6e50 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | AV1_RewriteESDescriptorEx | AV1_RewriteESDescriptorEx( GF_MPEGVisualSampleEntryBox * av1 , GF_MediaBox * mdia) | ['av1', 'mdia'] | void AV1_RewriteESDescriptorEx(GF_MPEGVisualSampleEntryBox *av1, GF_MediaBox *mdia)
{
GF_BitRateBox *btrt = gf_isom_sample_entry_get_bitrate((GF_SampleEntryBox *)av1, GF_FALSE);
if (av1->emul_esd) gf_odf_desc_del((GF_Descriptor *)av1->emul_esd);
av1->emul_esd = gf_odf_desc_esd_new(2);
av1->emul_esd->decoderConfig->streamType = GF_STREAM_VISUAL;
av1->emul_esd->decoderConfig->objectTypeIndication = GF_CODECID_AV1;
if (btrt) {
av1->emul_esd->decoderConfig->bufferSizeDB = btrt->bufferSizeDB;
av1->emul_esd->decoderConfig->avgBitrate = btrt->avgBitrate;
av1->emul_esd->decoderConfig->maxBitrate = btrt->maxBitrate;
}
if (av1->av1_config) {
GF_AV1Config *av1_cfg = AV1_DuplicateConfig(av1->av1_config->config);
if (av1_cfg) {
gf_odf_av1_cfg_write(av1_cfg, &av1->emul_esd->decoderConfig->decoderSpecificInfo->data, &av1->emul_esd->decoderConfig->decoderSpecificInfo->dataLength);
gf_odf_av1_cfg_del(av1_cfg);
}
}
} | 174 | True | 1 |
CVE-2021-31262 | 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/gpac/gpac/commit/b2eab95e07cb5819375a50358d4806a8813b6e50', 'name': 'https://github.com/gpac/gpac/commit/b2eab95e07cb5819375a50358d4806a8813b6e50', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/issues/1738', 'name': 'https://github.com/gpac/gpac/issues/1738', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-476'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'The AV1_DuplicateConfig function in GPAC 1.0.1 allows attackers to cause a denial of service (NULL pointer dereference) via a crafted file in the MP4Box command.'}] | 2021-04-21T19:05Z | 2021-04-19T19: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 | jeanlf | 2021-04-09 11:17:40+02:00 | fixed #1738 | b2eab95e07cb5819375a50358d4806a8813b6e50 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_isom_av1_config_get | gf_isom_av1_config_get( GF_ISOFile * the_file , u32 trackNumber , u32 DescriptionIndex) | ['the_file', 'trackNumber', 'DescriptionIndex'] | GF_AV1Config *gf_isom_av1_config_get(GF_ISOFile *the_file, u32 trackNumber, u32 DescriptionIndex)
{
GF_TrackBox *trak;
GF_MPEGVisualSampleEntryBox *entry;
if (gf_isom_get_reference_count(the_file, trackNumber, GF_ISOM_REF_TBAS)) {
u32 ref_track;
GF_Err e = gf_isom_get_reference(the_file, trackNumber, GF_ISOM_REF_TBAS, 1, &ref_track);
if (e == GF_OK) {
trackNumber = ref_track;
}
}
trak = gf_isom_get_track_from_file(the_file, trackNumber);
if (!trak || !trak->Media || !DescriptionIndex) return NULL;
entry = (GF_MPEGVisualSampleEntryBox*)gf_list_get(trak->Media->information->sampleTable->SampleDescription->child_boxes, DescriptionIndex - 1);
if (!entry || !entry->av1_config) return NULL;
return AV1_DuplicateConfig(entry->av1_config->config);
} | 140 | True | 1 |
CVE-2021-32132 | 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/gpac/gpac/issues/1753', 'name': 'https://github.com/gpac/gpac/issues/1753', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/e74be5976a6fee059c638050a237893f7e9a3b23', 'name': 'https://github.com/gpac/gpac/commit/e74be5976a6fee059c638050a237893f7e9a3b23', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-476'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'The abst_box_size function in GPAC 1.0.1 allows attackers to cause a denial of service (NULL pointer dereference) via a crafted file in the MP4Box command.'}] | 2021-09-22T18:56Z | 2021-09-13T15: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 | jeanlf | 2021-04-22 10:59:53+02:00 | fixed #1753 | e74be5976a6fee059c638050a237893f7e9a3b23 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | abst_box_read | abst_box_read( GF_Box * s , GF_BitStream * bs) | ['s', 'bs'] | GF_Err abst_box_read(GF_Box *s, GF_BitStream *bs)
{
GF_AdobeBootstrapInfoBox *ptr = (GF_AdobeBootstrapInfoBox *)s;
int i;
u32 tmp_strsize;
char *tmp_str;
Bool zfound=GF_FALSE;
GF_Err e;
ISOM_DECREASE_SIZE(ptr, 25)
ptr->bootstrapinfo_version = gf_bs_read_u32(bs);
ptr->profile = gf_bs_read_int(bs, 2);
ptr->live = gf_bs_read_int(bs, 1);
ptr->update = gf_bs_read_int(bs, 1);
ptr->reserved = gf_bs_read_int(bs, 4);
ptr->time_scale = gf_bs_read_u32(bs);
ptr->current_media_time = gf_bs_read_u64(bs);
ptr->smpte_time_code_offset = gf_bs_read_u64(bs);
i=0;
if (ptr->size<8) return GF_ISOM_INVALID_FILE;
tmp_strsize =(u32)ptr->size;
tmp_str = gf_malloc(sizeof(char)*tmp_strsize);
if (!tmp_str) return GF_OUT_OF_MEM;
memset(tmp_str, 0, sizeof(char)*tmp_strsize);
while (tmp_strsize) {
ISOM_DECREASE_SIZE(ptr, 1)
tmp_str[i] = gf_bs_read_u8(bs);
tmp_strsize--;
if (!tmp_str[i]) {
zfound = GF_TRUE;
break;
}
i++;
}
if (!zfound)
return GF_ISOM_INVALID_FILE;
if (i) {
ptr->movie_identifier = gf_strdup(tmp_str);
}
ISOM_DECREASE_SIZE(ptr, 1)
ptr->server_entry_count = gf_bs_read_u8(bs);
for (i=0; i<ptr->server_entry_count; i++) {
int j=0;
zfound = GF_FALSE;
tmp_strsize=(u32)ptr->size;
while (tmp_strsize) {
ISOM_DECREASE_SIZE(ptr, 1)
tmp_str[j] = gf_bs_read_u8(bs);
tmp_strsize--;
if (!tmp_str[j]) {
zfound = GF_TRUE;
break;
}
j++;
}
if (!zfound)
return GF_ISOM_INVALID_FILE;
if (j) {
gf_list_insert(ptr->server_entry_table, gf_strdup(tmp_str), i);
}
}
ISOM_DECREASE_SIZE(ptr, 1)
ptr->quality_entry_count = gf_bs_read_u8(bs);
for (i=0; i<ptr->quality_entry_count; i++) {
int j=0;
zfound = GF_FALSE;
tmp_strsize=(u32)ptr->size;
while (tmp_strsize) {
ISOM_DECREASE_SIZE(ptr, 1)
tmp_str[j] = gf_bs_read_u8(bs);
tmp_strsize--;
if (!tmp_str[j]) {
zfound = GF_TRUE;
break;
}
j++;
}
if (!zfound)
return GF_ISOM_INVALID_FILE;
if (j) {
gf_list_insert(ptr->quality_entry_table, gf_strdup(tmp_str), i);
}
}
i=0;
tmp_strsize=(u32)ptr->size;
zfound = GF_FALSE;
while (tmp_strsize) {
ISOM_DECREASE_SIZE(ptr, 1)
tmp_str[i] = gf_bs_read_u8(bs);
tmp_strsize--;
if (!tmp_str[i]) {
zfound = GF_TRUE;
break;
}
i++;
}
if (!zfound)
return GF_ISOM_INVALID_FILE;
if (i) {
ptr->drm_data = gf_strdup(tmp_str);
}
i=0;
tmp_strsize=(u32)ptr->size;
zfound = GF_FALSE;
while (tmp_strsize) {
ISOM_DECREASE_SIZE(ptr, 1)
tmp_str[i] = gf_bs_read_u8(bs);
tmp_strsize--;
if (!tmp_str[i]) {
zfound = GF_TRUE;
break;
}
i++;
}
if (!zfound)
return GF_ISOM_INVALID_FILE;
if (i) {
ptr->meta_data = gf_strdup(tmp_str);
}
ISOM_DECREASE_SIZE(ptr, 1)
ptr->segment_run_table_count = gf_bs_read_u8(bs);
for (i=0; i<ptr->segment_run_table_count; i++) {
GF_AdobeSegmentRunTableBox *asrt = NULL;
e = gf_isom_box_parse((GF_Box **)&asrt, bs);
if (e) {
if (asrt) gf_isom_box_del((GF_Box*)asrt);
gf_free(tmp_str);
return e;
}
gf_list_add(ptr->segment_run_table_entries, asrt);
}
ISOM_DECREASE_SIZE(ptr, 1)
ptr->fragment_run_table_count = gf_bs_read_u8(bs);
for (i=0; i<ptr->fragment_run_table_count; i++) {
GF_AdobeFragmentRunTableBox *afrt = NULL;
e = gf_isom_box_parse((GF_Box **)&afrt, bs);
if (e) {
if (afrt) gf_isom_box_del((GF_Box*)afrt);
gf_free(tmp_str);
return e;
}
gf_list_add(ptr->fragment_run_table_entries, afrt);
}
gf_free(tmp_str);
return GF_OK;
} | 847 | True | 1 |
CVE-2021-32134 | 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/gpac/gpac/commit/328c6d682698fdb9878dbb4f282963d42c538c01', 'name': 'https://github.com/gpac/gpac/commit/328c6d682698fdb9878dbb4f282963d42c538c01', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/issues/1756', 'name': 'https://github.com/gpac/gpac/issues/1756', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-476'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'The gf_odf_desc_copy function in GPAC 1.0.1 allows attackers to cause a denial of service (NULL pointer dereference) via a crafted file in the MP4Box command.'}] | 2021-09-22T19:05Z | 2021-09-13T14: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 | jeanlf | 2021-04-23 14:35:56+02:00 | fixed #1756 | 328c6d682698fdb9878dbb4f282963d42c538c01 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | encs_box_new | encs_box_new() | [] | GF_Box *encs_box_new()
{
ISOM_DECL_BOX_ALLOC(GF_MPEGSampleEntryBox, GF_ISOM_BOX_TYPE_ENCS);
gf_isom_sample_entry_init((GF_SampleEntryBox*)tmp);
tmp->internal_type = GF_ISOM_SAMPLE_ENTRY_MP4S;
return (GF_Box *)tmp;
} | 34 | True | 1 |
CVE-2021-32134 | 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/gpac/gpac/commit/328c6d682698fdb9878dbb4f282963d42c538c01', 'name': 'https://github.com/gpac/gpac/commit/328c6d682698fdb9878dbb4f282963d42c538c01', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/issues/1756', 'name': 'https://github.com/gpac/gpac/issues/1756', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-476'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'The gf_odf_desc_copy function in GPAC 1.0.1 allows attackers to cause a denial of service (NULL pointer dereference) via a crafted file in the MP4Box command.'}] | 2021-09-22T19:05Z | 2021-09-13T14: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 | jeanlf | 2021-04-23 14:35:56+02:00 | fixed #1756 | 328c6d682698fdb9878dbb4f282963d42c538c01 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | mp4s_box_new | mp4s_box_new() | [] | GF_Box *mp4s_box_new()
{
ISOM_DECL_BOX_ALLOC(GF_MPEGSampleEntryBox, GF_ISOM_BOX_TYPE_MP4S);
gf_isom_sample_entry_init((GF_SampleEntryBox*)tmp);
tmp->internal_type = GF_ISOM_SAMPLE_ENTRY_MP4S;
return (GF_Box *)tmp;
} | 34 | True | 1 |
CVE-2021-32134 | 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/gpac/gpac/commit/328c6d682698fdb9878dbb4f282963d42c538c01', 'name': 'https://github.com/gpac/gpac/commit/328c6d682698fdb9878dbb4f282963d42c538c01', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/issues/1756', 'name': 'https://github.com/gpac/gpac/issues/1756', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-476'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'The gf_odf_desc_copy function in GPAC 1.0.1 allows attackers to cause a denial of service (NULL pointer dereference) via a crafted file in the MP4Box command.'}] | 2021-09-22T19:05Z | 2021-09-13T14: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 | jeanlf | 2021-04-23 14:35:56+02:00 | fixed #1756 | 328c6d682698fdb9878dbb4f282963d42c538c01 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | Media_GetESD | Media_GetESD( GF_MediaBox * mdia , u32 sampleDescIndex , GF_ESD ** out_esd , Bool true_desc_only) | ['mdia', 'sampleDescIndex', 'out_esd', 'true_desc_only'] | GF_Err Media_GetESD(GF_MediaBox *mdia, u32 sampleDescIndex, GF_ESD **out_esd, Bool true_desc_only)
{
u32 type;
GF_ESD *esd;
GF_MPEGSampleEntryBox *entry = NULL;
GF_ESDBox *ESDa;
GF_ProtectionSchemeInfoBox *sinf;
GF_SampleDescriptionBox *stsd = mdia->information->sampleTable->SampleDescription;
*out_esd = NULL;
if (!stsd || !stsd->child_boxes || !sampleDescIndex || (sampleDescIndex > gf_list_count(stsd->child_boxes)) )
return GF_BAD_PARAM;
esd = NULL;
entry = (GF_MPEGSampleEntryBox*)gf_list_get(stsd->child_boxes, sampleDescIndex - 1);
if (! entry) return GF_ISOM_INVALID_MEDIA;
*out_esd = NULL;
ESDa = NULL;
type = entry->type;
switch (type) {
case GF_ISOM_BOX_TYPE_ENCV:
case GF_ISOM_BOX_TYPE_ENCA:
case GF_ISOM_BOX_TYPE_ENCS:
case GF_ISOM_BOX_TYPE_ENCF:
case GF_ISOM_BOX_TYPE_ENCM:
case GF_ISOM_BOX_TYPE_ENCT:
sinf = (GF_ProtectionSchemeInfoBox *) gf_isom_box_find_child(entry->child_boxes, GF_ISOM_BOX_TYPE_SINF);
if (sinf && sinf->original_format) {
type = sinf->original_format->data_format;
}
break;
case GF_ISOM_BOX_TYPE_RESV:
sinf = (GF_ProtectionSchemeInfoBox *) gf_isom_box_find_child(entry->child_boxes, GF_ISOM_BOX_TYPE_RINF);
if (sinf && sinf->original_format) {
type = sinf->original_format->data_format;
}
break;
}
switch (type) {
case GF_ISOM_BOX_TYPE_MP4V:
ESDa = ((GF_MPEGVisualSampleEntryBox*)entry)->esd;
if (ESDa) esd = (GF_ESD *) ESDa->desc;
/*avc1 encrypted*/
else esd = ((GF_MPEGVisualSampleEntryBox*) entry)->emul_esd;
break;
case GF_ISOM_BOX_TYPE_AVC1:
case GF_ISOM_BOX_TYPE_AVC2:
case GF_ISOM_BOX_TYPE_AVC3:
case GF_ISOM_BOX_TYPE_AVC4:
case GF_ISOM_BOX_TYPE_HVC1:
case GF_ISOM_BOX_TYPE_HEV1:
case GF_ISOM_BOX_TYPE_HVC2:
case GF_ISOM_BOX_TYPE_HEV2:
case GF_ISOM_BOX_TYPE_HVT1:
case GF_ISOM_BOX_TYPE_264B:
case GF_ISOM_BOX_TYPE_265B:
case GF_ISOM_BOX_TYPE_DVHE:
case GF_ISOM_BOX_TYPE_VVC1:
case GF_ISOM_BOX_TYPE_VVI1:
esd = ((GF_MPEGVisualSampleEntryBox*) entry)->emul_esd;
break;
case GF_ISOM_BOX_TYPE_SVC1:
case GF_ISOM_BOX_TYPE_MVC1:
if ((mdia->mediaTrack->extractor_mode & 0x0000FFFF) != GF_ISOM_NALU_EXTRACT_INSPECT)
AVC_RewriteESDescriptorEx((GF_MPEGVisualSampleEntryBox*) entry, mdia);
else
AVC_RewriteESDescriptorEx((GF_MPEGVisualSampleEntryBox*) entry, NULL);
esd = ((GF_MPEGVisualSampleEntryBox*) entry)->emul_esd;
break;
case GF_ISOM_BOX_TYPE_LHE1:
case GF_ISOM_BOX_TYPE_LHV1:
if ((mdia->mediaTrack->extractor_mode & 0x0000FFFF) != GF_ISOM_NALU_EXTRACT_INSPECT)
HEVC_RewriteESDescriptorEx((GF_MPEGVisualSampleEntryBox*) entry, mdia);
else
HEVC_RewriteESDescriptorEx((GF_MPEGVisualSampleEntryBox*) entry, NULL);
esd = ((GF_MPEGVisualSampleEntryBox*) entry)->emul_esd;
break;
case GF_ISOM_BOX_TYPE_AV01:
AV1_RewriteESDescriptorEx((GF_MPEGVisualSampleEntryBox*)entry, mdia);
esd = ((GF_MPEGVisualSampleEntryBox*)entry)->emul_esd;
break;
case GF_ISOM_BOX_TYPE_VP08:
case GF_ISOM_BOX_TYPE_VP09:
VP9_RewriteESDescriptorEx((GF_MPEGVisualSampleEntryBox*)entry, mdia);
esd = ((GF_MPEGVisualSampleEntryBox*)entry)->emul_esd;
break;
case GF_ISOM_BOX_TYPE_MP4A:
{
GF_MPEGAudioSampleEntryBox *ase = (GF_MPEGAudioSampleEntryBox*)entry;
ESDa = ase->esd;
if (ESDa) {
esd = (GF_ESD *) ESDa->desc;
} else if (!true_desc_only) {
Bool make_mp4a = GF_FALSE;
sinf = (GF_ProtectionSchemeInfoBox *) gf_isom_box_find_child(entry->child_boxes, GF_ISOM_BOX_TYPE_SINF);
if (sinf && sinf->original_format) {
if (sinf->original_format->data_format==GF_ISOM_BOX_TYPE_MP4A) {
make_mp4a = GF_TRUE;
}
} else {
// Assuming that if no ESD is provided the stream is Basic MPEG-4 AAC LC
make_mp4a = GF_TRUE;
}
if (make_mp4a) {
GF_M4ADecSpecInfo aacinfo;
memset(&aacinfo, 0, sizeof(GF_M4ADecSpecInfo));
aacinfo.nb_chan = ase->channel_count;
aacinfo.base_object_type = GF_M4A_AAC_LC;
aacinfo.base_sr = ase->samplerate_hi;
*out_esd = gf_odf_desc_esd_new(0);
(*out_esd)->decoderConfig->streamType = GF_STREAM_AUDIO;
(*out_esd)->decoderConfig->objectTypeIndication = GF_CODECID_AAC_MPEG4;
gf_m4a_write_config(&aacinfo, &(*out_esd)->decoderConfig->decoderSpecificInfo->data, &(*out_esd)->decoderConfig->decoderSpecificInfo->dataLength);
}
}
}
break;
case GF_ISOM_BOX_TYPE_MP4S:
if (entry->internal_type==GF_ISOM_SAMPLE_ENTRY_MP4S) {
ESDa = entry->esd;
if (ESDa) esd = (GF_ESD *) ESDa->desc;
}
break;
#ifndef GPAC_DISABLE_TTXT
case GF_ISOM_BOX_TYPE_TX3G:
case GF_ISOM_BOX_TYPE_TEXT:
if (!true_desc_only && mdia->mediaTrack->moov->mov->convert_streaming_text) {
GF_Err e = gf_isom_get_ttxt_esd(mdia, out_esd);
if (e) return e;
break;
}
else
return GF_ISOM_INVALID_MEDIA;
#endif
#ifndef GPAC_DISABLE_VTT
case GF_ISOM_BOX_TYPE_WVTT:
{
GF_WebVTTSampleEntryBox*vtte = (GF_WebVTTSampleEntryBox*)entry;
esd = gf_odf_desc_esd_new(2);
*out_esd = esd;
esd->decoderConfig->streamType = GF_STREAM_TEXT;
esd->decoderConfig->objectTypeIndication = GF_CODECID_WEBVTT;
if (vtte->config) {
esd->decoderConfig->decoderSpecificInfo->dataLength = (u32) strlen(vtte->config->string);
esd->decoderConfig->decoderSpecificInfo->data = gf_malloc(sizeof(char)*esd->decoderConfig->decoderSpecificInfo->dataLength);
memcpy(esd->decoderConfig->decoderSpecificInfo->data, vtte->config->string, esd->decoderConfig->decoderSpecificInfo->dataLength);
}
}
break;
case GF_ISOM_BOX_TYPE_STPP:
case GF_ISOM_BOX_TYPE_SBTT:
case GF_ISOM_BOX_TYPE_STXT:
break;
#endif
case GF_ISOM_SUBTYPE_3GP_AMR:
case GF_ISOM_SUBTYPE_3GP_AMR_WB:
case GF_ISOM_SUBTYPE_3GP_EVRC:
case GF_ISOM_SUBTYPE_3GP_QCELP:
case GF_ISOM_SUBTYPE_3GP_SMV:
if (!true_desc_only) {
GF_Err e = gf_isom_get_3gpp_audio_esd(mdia->information->sampleTable, type, (GF_GenericAudioSampleEntryBox*)entry, out_esd);
if (e) return e;
break;
} else return GF_ISOM_INVALID_MEDIA;
case GF_ISOM_SUBTYPE_OPUS: {
GF_OpusSpecificBox *e = ((GF_MPEGAudioSampleEntryBox*)entry)->cfg_opus;
GF_BitStream *bs_out;
if (!e) {
GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("ESD not found for Opus\n)"));
break;
}
*out_esd = gf_odf_desc_esd_new(2);
(*out_esd)->decoderConfig->streamType = GF_STREAM_AUDIO;
(*out_esd)->decoderConfig->objectTypeIndication = GF_CODECID_OPUS;
//serialize box with header - compatibility with ffmpeg
bs_out = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE);
gf_isom_box_size((GF_Box *) e);
gf_isom_box_write((GF_Box *) e, bs_out);
gf_bs_get_content(bs_out, & (*out_esd)->decoderConfig->decoderSpecificInfo->data, & (*out_esd)->decoderConfig->decoderSpecificInfo->dataLength);
gf_bs_del(bs_out);
break;
}
case GF_ISOM_SUBTYPE_3GP_H263:
if (true_desc_only) {
return GF_ISOM_INVALID_MEDIA;
} else {
esd = gf_odf_desc_esd_new(2);
*out_esd = esd;
esd->decoderConfig->streamType = GF_STREAM_VISUAL;
esd->decoderConfig->objectTypeIndication = GF_CODECID_H263;
break;
}
case GF_ISOM_SUBTYPE_MP3:
if (true_desc_only) {
return GF_ISOM_INVALID_MEDIA;
} else {
esd = gf_odf_desc_esd_new(2);
*out_esd = esd;
esd->decoderConfig->streamType = GF_STREAM_AUDIO;
esd->decoderConfig->objectTypeIndication = GF_CODECID_MPEG_AUDIO;
break;
}
case GF_ISOM_SUBTYPE_LSR1:
if (true_desc_only) {
return GF_ISOM_INVALID_MEDIA;
} else {
GF_LASeRSampleEntryBox*ptr = (GF_LASeRSampleEntryBox*)entry;
esd = gf_odf_desc_esd_new(2);
*out_esd = esd;
esd->decoderConfig->streamType = GF_STREAM_SCENE;
esd->decoderConfig->objectTypeIndication = GF_CODECID_LASER;
esd->decoderConfig->decoderSpecificInfo->dataLength = ptr->lsr_config->hdr_size;
esd->decoderConfig->decoderSpecificInfo->data = gf_malloc(sizeof(char)*ptr->lsr_config->hdr_size);
if (!esd->decoderConfig->decoderSpecificInfo->data) return GF_OUT_OF_MEM;
memcpy(esd->decoderConfig->decoderSpecificInfo->data, ptr->lsr_config->hdr, sizeof(char)*ptr->lsr_config->hdr_size);
break;
}
case GF_ISOM_SUBTYPE_MH3D_MHA1:
case GF_ISOM_SUBTYPE_MH3D_MHA2:
case GF_ISOM_SUBTYPE_MH3D_MHM1:
case GF_ISOM_SUBTYPE_MH3D_MHM2:
if (true_desc_only) {
return GF_ISOM_INVALID_MEDIA;
} else {
GF_MPEGAudioSampleEntryBox*ptr = (GF_MPEGAudioSampleEntryBox*)entry;
esd = gf_odf_desc_esd_new(2);
*out_esd = esd;
esd->decoderConfig->streamType = GF_STREAM_AUDIO;
if ((type==GF_ISOM_SUBTYPE_MH3D_MHA1) || (type==GF_ISOM_SUBTYPE_MH3D_MHA2))
esd->decoderConfig->objectTypeIndication = GF_CODECID_MPHA;
else
esd->decoderConfig->objectTypeIndication = GF_CODECID_MHAS;
if (ptr->cfg_mha) {
GF_BitStream *bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE);
gf_bs_write_u8(bs, ptr->cfg_mha->configuration_version);
gf_bs_write_u8(bs, ptr->cfg_mha->mha_pl_indication);
gf_bs_write_u8(bs, ptr->cfg_mha->reference_channel_layout);
gf_bs_write_u16(bs, ptr->cfg_mha->mha_config ? ptr->cfg_mha->mha_config_size : 0);
if (ptr->cfg_mha->mha_config && ptr->cfg_mha->mha_config_size)
gf_bs_write_data(bs, ptr->cfg_mha->mha_config, ptr->cfg_mha->mha_config_size);
gf_bs_get_content(bs, &esd->decoderConfig->decoderSpecificInfo->data, &esd->decoderConfig->decoderSpecificInfo->dataLength);
gf_bs_del(bs);
}
}
break;
default:
return GF_ISOM_INVALID_MEDIA;
}
if (true_desc_only) {
if (!esd) return GF_ISOM_INVALID_MEDIA;
*out_esd = esd;
return GF_OK;
} else {
if (!esd && !*out_esd) return GF_ISOM_INVALID_MEDIA;
if (*out_esd == NULL) return gf_odf_desc_copy((GF_Descriptor *)esd, (GF_Descriptor **)out_esd);
}
return GF_OK;
} | 1628 | True | 1 |
CVE-2021-32139 | 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/gpac/gpac/commit/d527325a9b72218612455a534a508f9e1753f76e', 'name': 'https://github.com/gpac/gpac/commit/d527325a9b72218612455a534a508f9e1753f76e', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/issues/1768', 'name': 'https://github.com/gpac/gpac/issues/1768', 'refsource': 'MISC', 'tags': ['Exploit', 'Issue Tracking', 'Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-476'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'The gf_isom_vp_config_get function in GPAC 1.0.1 allows attackers to cause a denial of service (NULL pointer dereference) via a crafted file in the MP4Box command.'}] | 2021-09-23T20:12Z | 2021-09-13T20: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 | jeanlf | 2021-04-30 10:13:24+02:00 | fixed #1768 | d527325a9b72218612455a534a508f9e1753f76e | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | text_box_read | text_box_read( GF_Box * s , GF_BitStream * bs) | ['s', 'bs'] | GF_Err text_box_read(GF_Box *s, GF_BitStream *bs)
{
GF_Err e;
u16 pSize;
GF_TextSampleEntryBox *ptr = (GF_TextSampleEntryBox*)s;
ISOM_DECREASE_SIZE(ptr, 51);
e = gf_isom_base_sample_entry_read((GF_SampleEntryBox *)ptr, bs);
if (e) return e;
ptr->displayFlags = gf_bs_read_u32(bs); /*Display flags*/
ptr->textJustification = gf_bs_read_u32(bs); /*Text justification*/
gf_bs_read_data(bs, ptr->background_color, 6); /*Background color*/
gpp_read_box(bs, &ptr->default_box); /*Default text box*/
gf_bs_read_data(bs, ptr->reserved1, 8); /*Reserved*/
ptr->fontNumber = gf_bs_read_u16(bs); /*Font number*/
ptr->fontFace = gf_bs_read_u16(bs); /*Font face*/
ptr->reserved2 = gf_bs_read_u8(bs); /*Reserved*/
ptr->reserved3 = gf_bs_read_u16(bs); /*Reserved*/
gf_bs_read_data(bs, ptr->foreground_color, 6); /*Foreground color*/
/*ffmpeg compatibility with iPod streams: no pascal string*/
if (!ptr->size)
return GF_OK;
ISOM_DECREASE_SIZE(ptr, 1);
pSize = gf_bs_read_u8(bs); /*a Pascal string begins with its size: get textName size*/
if (ptr->size < pSize) {
u32 b_size = pSize;
size_t i = 0;
GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[iso file] text box doesn't use a Pascal string: trying to decode anyway.\n"));
ptr->textName = (char*)gf_malloc((size_t)ptr->size + 1 + 1);
if (!ptr->textName) return GF_OUT_OF_MEM;
do {
char c = (char)b_size;
if (c == '\0') {
break;
} else if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {
ptr->textName[i] = c;
} else {
gf_free(ptr->textName);
ptr->textName = NULL;
GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[iso file] text box doesn't use a Pascal string and contains non-chars. Abort.\n"));
return GF_ISOM_INVALID_FILE;
}
i++;
if (!ptr->size)
break;
ptr->size--;
b_size = gf_bs_read_u8(bs);
} while (b_size);
ptr->textName[i] = '\0'; /*Font name*/
GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[iso file] text box doesn't use a Pascal string: \"%s\" detected.\n", ptr->textName));
return GF_OK;
}
if (pSize) {
ptr->textName = (char*) gf_malloc(pSize+1 * sizeof(char));
if (!ptr->textName) return GF_OUT_OF_MEM;
if (gf_bs_read_data(bs, ptr->textName, pSize) != pSize) {
gf_free(ptr->textName);
ptr->textName = NULL;
return GF_ISOM_INVALID_FILE;
}
ptr->textName[pSize] = '\0'; /*Font name*/
}
ISOM_DECREASE_SIZE(ptr, pSize);
return gf_isom_box_array_read(s, bs);
} | 473 | True | 1 |
CVE-2021-32139 | 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/gpac/gpac/commit/d527325a9b72218612455a534a508f9e1753f76e', 'name': 'https://github.com/gpac/gpac/commit/d527325a9b72218612455a534a508f9e1753f76e', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/issues/1768', 'name': 'https://github.com/gpac/gpac/issues/1768', 'refsource': 'MISC', 'tags': ['Exploit', 'Issue Tracking', 'Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-476'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'The gf_isom_vp_config_get function in GPAC 1.0.1 allows attackers to cause a denial of service (NULL pointer dereference) via a crafted file in the MP4Box command.'}] | 2021-09-23T20:12Z | 2021-09-13T20: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 | jeanlf | 2021-04-30 10:13:24+02:00 | fixed #1768 | d527325a9b72218612455a534a508f9e1753f76e | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | text_box_size | text_box_size( GF_Box * s) | ['s'] | GF_Err text_box_size(GF_Box *s)
{
GF_TextSampleEntryBox *ptr = (GF_TextSampleEntryBox*)s;
/*base + this + string length*/
s->size += 51 + 1;
if (ptr->textName)
s->size += strlen(ptr->textName);
return GF_OK;
} | 46 | True | 1 |
CVE-2021-32139 | 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/gpac/gpac/commit/d527325a9b72218612455a534a508f9e1753f76e', 'name': 'https://github.com/gpac/gpac/commit/d527325a9b72218612455a534a508f9e1753f76e', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/issues/1768', 'name': 'https://github.com/gpac/gpac/issues/1768', 'refsource': 'MISC', 'tags': ['Exploit', 'Issue Tracking', 'Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-476'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'The gf_isom_vp_config_get function in GPAC 1.0.1 allows attackers to cause a denial of service (NULL pointer dereference) via a crafted file in the MP4Box command.'}] | 2021-09-23T20:12Z | 2021-09-13T20: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 | jeanlf | 2021-04-30 10:13:24+02:00 | fixed #1768 | d527325a9b72218612455a534a508f9e1753f76e | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_isom_box_parse_ex | gf_isom_box_parse_ex( GF_Box ** outBox , GF_BitStream * bs , u32 parent_type , Bool is_root_box) | ['outBox', 'bs', 'parent_type', 'is_root_box'] | GF_Err gf_isom_box_parse_ex(GF_Box **outBox, GF_BitStream *bs, u32 parent_type, Bool is_root_box)
{
u32 type, uuid_type, hdr_size, restore_type;
u64 size, start, comp_start, payload_start, end;
char uuid[16];
GF_Err e;
GF_BitStream *uncomp_bs = NULL;
u8 *uncomp_data = NULL;
u32 compressed_size=0;
GF_Box *newBox;
Bool skip_logs = (gf_bs_get_cookie(bs) & GF_ISOM_BS_COOKIE_NO_LOGS ) ? GF_TRUE : GF_FALSE;
Bool is_special = GF_TRUE;
if ((bs == NULL) || (outBox == NULL) ) return GF_BAD_PARAM;
*outBox = NULL;
if (gf_bs_available(bs) < 8) {
return GF_ISOM_INCOMPLETE_FILE;
}
comp_start = start = gf_bs_get_position(bs);
uuid_type = 0;
size = (u64) gf_bs_read_u32(bs);
hdr_size = 4;
/*fix for some boxes found in some old hinted files*/
if ((size >= 2) && (size <= 4)) {
size = 4;
type = GF_ISOM_BOX_TYPE_VOID;
} else {
type = gf_bs_read_u32(bs);
hdr_size += 4;
/*no size means till end of file - EXCEPT FOR some old QuickTime boxes...*/
if (type == GF_ISOM_BOX_TYPE_TOTL)
size = 12;
if (!size) {
if (is_root_box) {
if (!skip_logs) {
GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[iso file] Warning Read Box type %s (0x%08X) size 0 reading till the end of file\n", gf_4cc_to_str(type), type));
}
size = gf_bs_available(bs) + 8;
} else {
if (!skip_logs) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Read Box type %s (0x%08X) at position "LLU" has size 0 but is not at root/file level, skipping\n", gf_4cc_to_str(type), type, start));
}
return GF_OK;
}
}
if (is_root_box && (size>=8)) {
Bool do_uncompress = GF_FALSE;
u8 *compb = NULL;
u32 osize = 0;
u32 otype = type;
if (type==GF_4CC('!', 'm', 'o', 'f')) {
do_uncompress = GF_TRUE;
type = GF_ISOM_BOX_TYPE_MOOF;
}
else if (type==GF_4CC('!', 'm', 'o', 'v')) {
do_uncompress = GF_TRUE;
type = GF_ISOM_BOX_TYPE_MOOV;
}
else if (type==GF_4CC('!', 's', 'i', 'x')) {
do_uncompress = GF_TRUE;
type = GF_ISOM_BOX_TYPE_SIDX;
}
else if (type==GF_4CC('!', 's', 's', 'x')) {
do_uncompress = GF_TRUE;
type = GF_ISOM_BOX_TYPE_SSIX;
}
if (do_uncompress) {
compb = gf_malloc((u32) (size-8));
compressed_size = (u32) (size - 8);
gf_bs_read_data(bs, compb, compressed_size);
e = gf_gz_decompress_payload(compb, compressed_size, &uncomp_data, &osize);
if (e) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Failed to uncompress payload for box type %s (0x%08X)\n", gf_4cc_to_str(otype), otype));
return e;
}
//keep size as complete box size for tests below
size = osize + 8;
uncomp_bs = gf_bs_new(uncomp_data, osize, GF_BITSTREAM_READ);
bs = uncomp_bs;
start = 0;
gf_free(compb);
}
}
}
/*handle uuid*/
memset(uuid, 0, 16);
if (type == GF_ISOM_BOX_TYPE_UUID ) {
if (gf_bs_available(bs) < 16) {
return GF_ISOM_INCOMPLETE_FILE;
}
gf_bs_read_data(bs, uuid, 16);
hdr_size += 16;
uuid_type = gf_isom_solve_uuid_box(uuid);
}
//handle large box
if (size == 1) {
if (gf_bs_available(bs) < 8) {
return GF_ISOM_INCOMPLETE_FILE;
}
size = gf_bs_read_u64(bs);
hdr_size += 8;
}
if (!skip_logs)
GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[iso file] Read Box type %s size "LLD" start "LLD"\n", gf_4cc_to_str(type), size, start));
if ( size < hdr_size ) {
GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[iso file] Box size "LLD" less than box header size %d\n", size, hdr_size));
return GF_ISOM_INVALID_FILE;
}
restore_type = 0;
if ((parent_type==GF_ISOM_BOX_TYPE_STSD) && (type==GF_QT_SUBTYPE_RAW) ) {
u64 cookie = gf_bs_get_cookie(bs);
restore_type = type;
if (cookie & GF_ISOM_BS_COOKIE_VISUAL_TRACK)
type = GF_QT_SUBTYPE_RAW_VID;
else
type = GF_QT_SUBTYPE_RAW_AUD;
}
//some special boxes (references and track groups) are handled by a single generic box with an associated ref/group type
if (parent_type && (parent_type == GF_ISOM_BOX_TYPE_TREF)) {
newBox = gf_isom_box_new(GF_ISOM_BOX_TYPE_REFT);
if (!newBox) return GF_OUT_OF_MEM;
((GF_TrackReferenceTypeBox*)newBox)->reference_type = type;
} else if (parent_type && (parent_type == GF_ISOM_BOX_TYPE_IREF)) {
newBox = gf_isom_box_new(GF_ISOM_BOX_TYPE_REFI);
if (!newBox) return GF_OUT_OF_MEM;
((GF_ItemReferenceTypeBox*)newBox)->reference_type = type;
} else if (parent_type && (parent_type == GF_ISOM_BOX_TYPE_TRGR)) {
newBox = gf_isom_box_new(GF_ISOM_BOX_TYPE_TRGT);
if (!newBox) return GF_OUT_OF_MEM;
((GF_TrackGroupTypeBox*)newBox)->group_type = type;
} else if (parent_type && (parent_type == GF_ISOM_BOX_TYPE_GRPL)) {
newBox = gf_isom_box_new(GF_ISOM_BOX_TYPE_GRPT);
if (!newBox) return GF_OUT_OF_MEM;
((GF_EntityToGroupTypeBox*)newBox)->grouping_type = type;
} else {
//OK, create the box based on the type
is_special = GF_FALSE;
newBox = gf_isom_box_new_ex(uuid_type ? uuid_type : type, parent_type, skip_logs, is_root_box);
if (!newBox) return GF_OUT_OF_MEM;
}
//OK, init and read this box
if (type==GF_ISOM_BOX_TYPE_UUID && !is_special) {
memcpy(((GF_UUIDBox *)newBox)->uuid, uuid, 16);
((GF_UUIDBox *)newBox)->internal_4cc = uuid_type;
}
if (!newBox->type) newBox->type = type;
if (restore_type)
newBox->type = restore_type;
payload_start = gf_bs_get_position(bs);
retry_unknown_box:
end = gf_bs_available(bs);
if (size - hdr_size > end ) {
newBox->size = size - hdr_size - end;
*outBox = newBox;
return GF_ISOM_INCOMPLETE_FILE;
}
newBox->size = size - hdr_size;
e = gf_isom_full_box_read(newBox, bs);
if (!e) e = gf_isom_box_read(newBox, bs);
if (e) {
if (gf_opts_get_bool("core", "no-check"))
e = GF_OK;
}
newBox->size = size;
end = gf_bs_get_position(bs);
if (uncomp_bs) {
gf_free(uncomp_data);
gf_bs_del(uncomp_bs);
if (e) {
gf_isom_box_del(newBox);
*outBox = NULL;
return e;
}
//move size to real bitstream offsets for tests below
size -= 8;
//remember compressed vs real size info for moof in order to properly recompute data_offset/base_data_offset
if (type==GF_ISOM_BOX_TYPE_MOOF) {
((GF_MovieFragmentBox *)newBox)->compressed_diff = (s32)size - (s32)compressed_size;
}
//remember compressed vs real size info for moov in order to properly recompute chunk offset
else if (type==GF_ISOM_BOX_TYPE_MOOV) {
((GF_MovieBox *)newBox)->compressed_diff = (s32)size - (s32)compressed_size;
((GF_MovieBox *)newBox)->file_offset = comp_start;
}
//remember compressed vs real size info for dump
else if (type==GF_ISOM_BOX_TYPE_SIDX) {
((GF_SegmentIndexBox *)newBox)->compressed_diff = (s32)size - (s32)compressed_size;
}
//remember compressed vs real size info for dump
else if (type==GF_ISOM_BOX_TYPE_SSIX) {
((GF_SubsegmentIndexBox *)newBox)->compressed_diff = (s32)size - (s32)compressed_size;
}
newBox->internal_flags = GF_ISOM_BOX_COMPRESSED;
}
if (e && (e != GF_ISOM_INCOMPLETE_FILE)) {
gf_isom_box_del(newBox);
*outBox = NULL;
if (parent_type==GF_ISOM_BOX_TYPE_STSD) {
newBox = gf_isom_box_new(GF_ISOM_BOX_TYPE_UNKNOWN);
if (!newBox) return GF_OUT_OF_MEM;
((GF_UnknownBox *)newBox)->original_4cc = type;
newBox->size = size;
gf_bs_seek(bs, payload_start);
goto retry_unknown_box;
}
if (!skip_logs) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Read Box \"%s\" (start "LLU") failed (%s) - skipping\n", gf_4cc_to_str(type), start, gf_error_to_string(e)));
}
//we don't try to reparse known boxes that have been failing (too dangerous)
return e;
}
if (end-start > size) {
if (!skip_logs) {
GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[iso file] Box \"%s\" size "LLU" (start "LLU") invalid (read "LLU")\n", gf_4cc_to_str(type), size, start, (end-start) ));
}
/*let's still try to load the file since no error was notified*/
gf_bs_seek(bs, start+size);
} else if (end-start < size) {
u32 to_skip = (u32) (size-(end-start));
if (!skip_logs) {
if ((to_skip!=4) || gf_bs_peek_bits(bs, 32, 0)) {
GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[iso file] Box \"%s\" (start "LLU") has %u extra bytes\n", gf_4cc_to_str(type), start, to_skip));
}
}
gf_bs_skip_bytes(bs, to_skip);
}
*outBox = newBox;
return e;
} | 1507 | True | 1 |
CVE-2021-32139 | 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/gpac/gpac/commit/d527325a9b72218612455a534a508f9e1753f76e', 'name': 'https://github.com/gpac/gpac/commit/d527325a9b72218612455a534a508f9e1753f76e', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/issues/1768', 'name': 'https://github.com/gpac/gpac/issues/1768', 'refsource': 'MISC', 'tags': ['Exploit', 'Issue Tracking', 'Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-476'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'The gf_isom_vp_config_get function in GPAC 1.0.1 allows attackers to cause a denial of service (NULL pointer dereference) via a crafted file in the MP4Box command.'}] | 2021-09-23T20:12Z | 2021-09-13T20: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 | jeanlf | 2021-04-30 10:13:24+02:00 | fixed #1768 | d527325a9b72218612455a534a508f9e1753f76e | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_isom_get_text_description | gf_isom_get_text_description( GF_ISOFile * movie , u32 trackNumber , u32 descriptionIndex , GF_TextSampleDescriptor ** out_desc) | ['movie', 'trackNumber', 'descriptionIndex', 'out_desc'] | GF_Err gf_isom_get_text_description(GF_ISOFile *movie, u32 trackNumber, u32 descriptionIndex, GF_TextSampleDescriptor **out_desc)
{
GF_TrackBox *trak;
u32 i;
Bool is_qt_text = GF_FALSE;
GF_Tx3gSampleEntryBox *txt;
if (!descriptionIndex || !out_desc) return GF_BAD_PARAM;
trak = gf_isom_get_track_from_file(movie, trackNumber);
if (!trak || !trak->Media) return GF_BAD_PARAM;
switch (trak->Media->handler->handlerType) {
case GF_ISOM_MEDIA_TEXT:
case GF_ISOM_MEDIA_SUBT:
break;
default:
return GF_BAD_PARAM;
}
txt = (GF_Tx3gSampleEntryBox*)gf_list_get(trak->Media->information->sampleTable->SampleDescription->child_boxes, descriptionIndex - 1);
if (!txt) return GF_BAD_PARAM;
switch (txt->type) {
case GF_ISOM_BOX_TYPE_TX3G:
break;
case GF_ISOM_BOX_TYPE_TEXT:
is_qt_text = GF_TRUE;
break;
default:
return GF_BAD_PARAM;
}
(*out_desc) = (GF_TextSampleDescriptor *) gf_odf_desc_new(GF_ODF_TX3G_TAG);
if (! (*out_desc) ) return GF_OUT_OF_MEM;
(*out_desc)->back_color = txt->back_color;
(*out_desc)->default_pos = txt->default_box;
(*out_desc)->default_style = txt->default_style;
(*out_desc)->displayFlags = txt->displayFlags;
(*out_desc)->vert_justif = txt->vertical_justification;
(*out_desc)->horiz_justif = txt->horizontal_justification;
if (is_qt_text) {
GF_TextSampleEntryBox *qt_txt = (GF_TextSampleEntryBox *) txt;
if (qt_txt->textName) {
(*out_desc)->font_count = 1;
(*out_desc)->fonts = (GF_FontRecord *) gf_malloc(sizeof(GF_FontRecord));
(*out_desc)->fonts[0].fontName = gf_strdup(qt_txt->textName);
}
} else {
(*out_desc)->font_count = txt->font_table->entry_count;
(*out_desc)->fonts = (GF_FontRecord *) gf_malloc(sizeof(GF_FontRecord) * txt->font_table->entry_count);
for (i=0; i<txt->font_table->entry_count; i++) {
(*out_desc)->fonts[i].fontID = txt->font_table->fonts[i].fontID;
if (txt->font_table->fonts[i].fontName)
(*out_desc)->fonts[i].fontName = gf_strdup(txt->font_table->fonts[i].fontName);
}
}
return GF_OK;
} | 439 | True | 1 |
CVE-2021-32139 | 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/gpac/gpac/commit/d527325a9b72218612455a534a508f9e1753f76e', 'name': 'https://github.com/gpac/gpac/commit/d527325a9b72218612455a534a508f9e1753f76e', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/issues/1768', 'name': 'https://github.com/gpac/gpac/issues/1768', 'refsource': 'MISC', 'tags': ['Exploit', 'Issue Tracking', 'Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-476'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'The gf_isom_vp_config_get function in GPAC 1.0.1 allows attackers to cause a denial of service (NULL pointer dereference) via a crafted file in the MP4Box command.'}] | 2021-09-23T20:12Z | 2021-09-13T20: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 | jeanlf | 2021-04-30 10:13:24+02:00 | fixed #1768 | d527325a9b72218612455a534a508f9e1753f76e | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_isom_write_tx3g | gf_isom_write_tx3g( GF_Tx3gSampleEntryBox * a , GF_BitStream * bs , u32 sidx , u32 sidx_offset) | ['a', 'bs', 'sidx', 'sidx_offset'] | static void gf_isom_write_tx3g(GF_Tx3gSampleEntryBox *a, GF_BitStream *bs, u32 sidx, u32 sidx_offset)
{
u32 size, j, fount_count;
Bool is_qt_text = (a->type==GF_ISOM_BOX_TYPE_TEXT) ? GF_TRUE : GF_FALSE;
const char *qt_fontname = NULL;
void gpp_write_rgba(GF_BitStream *bs, u32 col);
void gpp_write_box(GF_BitStream *bs, GF_BoxRecord *rec);
void gpp_write_style(GF_BitStream *bs, GF_StyleRecord *rec);
if (sidx_offset) gf_bs_write_u8(bs, sidx + sidx_offset);
/*SINCE WINCE HAS A READONLY VERSION OF MP4 WE MUST DO IT BY HAND*/
size = 8 + 18 + 8 + 12;
size += 8 + 2;
fount_count = 0;
if (is_qt_text) {
GF_TextSampleEntryBox *qt = (GF_TextSampleEntryBox *)a;
if (qt->textName) {
qt_fontname = qt->textName;
fount_count = 1;
}
} else {
if (a->font_table) {
fount_count = a->font_table->entry_count;
for (j=0; j<fount_count; j++) {
size += 3;
if (a->font_table->fonts[j].fontName) size += (u32) strlen(a->font_table->fonts[j].fontName);
}
}
}
/*write TextSampleEntry box*/
gf_bs_write_u32(bs, size);
gf_bs_write_u32(bs, a->type);
gf_bs_write_data(bs, a->reserved, 6);
gf_bs_write_u16(bs, a->dataReferenceIndex);
gf_bs_write_u32(bs, a->displayFlags);
gf_bs_write_u8(bs, a->horizontal_justification);
gf_bs_write_u8(bs, a->vertical_justification);
gpp_write_rgba(bs, a->back_color);
gpp_write_box(bs, &a->default_box);
gpp_write_style(bs, &a->default_style);
/*write font table box*/
size -= (8 + 18 + 8 + 12);
gf_bs_write_u32(bs, size);
gf_bs_write_u32(bs, GF_ISOM_BOX_TYPE_FTAB);
gf_bs_write_u16(bs, fount_count);
for (j=0; j<fount_count; j++) {
if (is_qt_text) {
gf_bs_write_u16(bs, 0);
if (qt_fontname) {
u32 len = (u32) strlen(qt_fontname);
gf_bs_write_u8(bs, len);
gf_bs_write_data(bs, qt_fontname, len);
} else {
gf_bs_write_u8(bs, 0);
}
} else {
gf_bs_write_u16(bs, a->font_table->fonts[j].fontID);
if (a->font_table->fonts[j].fontName) {
u32 len = (u32) strlen(a->font_table->fonts[j].fontName);
gf_bs_write_u8(bs, len);
gf_bs_write_data(bs, a->font_table->fonts[j].fontName, len);
} else {
gf_bs_write_u8(bs, 0);
}
}
}
} | 504 | True | 1 |
CVE-2021-32136 | 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/gpac/gpac/issues/1765', 'name': 'https://github.com/gpac/gpac/issues/1765', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/eb71812fcc10e9c5348a5d1c61bd25b6fa06eaed', 'name': 'https://github.com/gpac/gpac/commit/eb71812fcc10e9c5348a5d1c61bd25b6fa06eaed', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-787'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Heap buffer overflow in the print_udta function in MP4Box in GPAC 1.0.1 allows attackers to cause a denial of service or execute arbitrary code via a crafted file.'}] | 2021-09-22T19:05Z | 2021-09-13T13: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 | jeanlf | 2021-04-30 10:37:24+02:00 | fixed #1765 | eb71812fcc10e9c5348a5d1c61bd25b6fa06eaed | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | print_udta | print_udta( GF_ISOFile * file , u32 track_number , Bool has_itags) | ['file', 'track_number', 'has_itags'] | }
void print_udta(GF_ISOFile *file, u32 track_number, Bool has_itags)
{
u32 i, count;
count = gf_isom_get_udta_count(file, track_number);
if (!count) return;
if (has_itags) {
for (i=0; i<count; i++) {
u32 type;
bin128 uuid;
gf_isom_get_udta_type(file, track_number, i+1, &type, &uuid);
if (type == GF_ISOM_BOX_TYPE_META) {
count--;
break;
}
}
if (!count) return;
}
fprintf(stderr, "%d UDTA types: ", count);
for (i=0; i<count; i++) {
u32 j, type, nb_items, first=GF_TRUE;
bin128 uuid;
gf_isom_get_udta_type(file, track_number, i+1, &type, &uuid);
nb_items = gf_isom_get_user_data_count(file, track_number, type, uuid);
fprintf(stderr, "%s (%d) ", gf_4cc_to_str(type), nb_items);
for (j=0; j<nb_items; j++) {
u8 *udta=NULL;
u32 udta_size;
gf_isom_get_user_data(file, track_number, type, uuid, j+1, &udta, &udta_size);
if (!udta) continue;
if (gf_utf8_is_legal(udta, udta_size)) {
if (first) {
fprintf(stderr, "\n");
first = GF_FALSE;
}
fprintf(stderr, "\t%s\n", (char *) udta);
}
gf_free(udta);
}
} | 286 | True | 1 |
CVE-2021-32137 | 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/gpac/gpac/issues/1766', 'name': 'https://github.com/gpac/gpac/issues/1766', 'refsource': 'MISC', 'tags': ['Exploit', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/328def7d3b93847d64ecb6e9e0399684e57c3eca', 'name': 'https://github.com/gpac/gpac/commit/328def7d3b93847d64ecb6e9e0399684e57c3eca', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-787'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Heap buffer overflow in the URL_GetProtocolType function in MP4Box in GPAC 1.0.1 allows attackers to cause a denial of service or execute arbitrary code via a crafted file.'}] | 2021-09-22T19:05Z | 2021-09-13T14: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 | jeanlf | 2021-04-30 10:43:32+02:00 | fixed #1766 (fuzz) | 328def7d3b93847d64ecb6e9e0399684e57c3eca | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | Media_CheckDataEntry | Media_CheckDataEntry( GF_MediaBox * mdia , u32 dataEntryIndex) | ['mdia', 'dataEntryIndex'] | GF_Err Media_CheckDataEntry(GF_MediaBox *mdia, u32 dataEntryIndex)
{
GF_DataEntryURLBox *entry;
GF_DataMap *map;
GF_Err e;
if (!mdia || !dataEntryIndex || dataEntryIndex > gf_list_count(mdia->information->dataInformation->dref->child_boxes)) return GF_BAD_PARAM;
entry = (GF_DataEntryURLBox*)gf_list_get(mdia->information->dataInformation->dref->child_boxes, dataEntryIndex - 1);
if (!entry) return GF_ISOM_INVALID_FILE;
if (entry->flags == 1) return GF_OK;
//ok, not self contained, let's go for it...
//we don't know what's a URN yet
if (entry->type == GF_ISOM_BOX_TYPE_URN) return GF_NOT_SUPPORTED;
if (mdia->mediaTrack->moov->mov->openMode == GF_ISOM_OPEN_WRITE) {
e = gf_isom_datamap_new(entry->location, NULL, GF_ISOM_DATA_MAP_READ, &map);
} else {
e = gf_isom_datamap_new(entry->location, mdia->mediaTrack->moov->mov->fileName, GF_ISOM_DATA_MAP_READ, &map);
}
if (e) return e;
gf_isom_datamap_del(map);
return GF_OK;
} | 175 | True | 1 |
CVE-2021-32138 | 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/gpac/gpac/commit/289ffce3e0d224d314f5f92a744d5fe35999f20b', 'name': 'https://github.com/gpac/gpac/commit/289ffce3e0d224d314f5f92a744d5fe35999f20b', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/issues/1767', 'name': 'https://github.com/gpac/gpac/issues/1767', 'refsource': 'MISC', 'tags': ['Exploit', 'Issue Tracking', 'Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-476'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'The DumpTrackInfo function in GPAC 1.0.1 allows attackers to cause a denial of service (NULL pointer dereference) via a crafted file in the MP4Box command.'}] | 2021-09-23T20:11Z | 2021-09-13T20: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 | jeanlf | 2021-04-30 10:47:35+02:00 | fixed #1767 (fuzz) | 289ffce3e0d224d314f5f92a744d5fe35999f20b | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | DumpTrackInfo | DumpTrackInfo( GF_ISOFile * file , GF_ISOTrackID trackID , Bool full_dump , Bool is_track_num , Bool dump_m4sys) | ['file', 'trackID', 'full_dump', 'is_track_num', 'dump_m4sys'] | void gf_inspect_format_timecode(const u8 *data, u32 size, u32 tmcd_flags, u32 tc_num, u32 tc_den, u32 tmcd_fpt, char szFmt[100]);
void DumpTrackInfo(GF_ISOFile *file, GF_ISOTrackID trackID, Bool full_dump, Bool is_track_num, Bool dump_m4sys)
{
char szCodec[RFC6381_CODEC_NAME_SIZE_MAX];
Double scale, max_rate, rate;
Bool is_od_track = 0;
u32 trackNum, i, j, ts, mtype, msub_type, timescale, sr, nb_ch, count, alt_group, nb_groups, nb_edits, cdur, csize, bps, pfmt, codecid;
u64 time_slice, dur, size;
s32 cts_shift;
GF_ESD *esd;
char szDur[50];
char *lang;
if (!is_track_num) {
trackNum = gf_isom_get_track_by_id(file, trackID);
} else {
trackNum = trackID;
trackID = gf_isom_get_track_id(file, trackNum);
}
if (!trackNum) {
M4_LOG(GF_LOG_ERROR, ("No track with ID %d found\n", trackID));
return;
}
timescale = gf_isom_get_media_timescale(file, trackNum);
fprintf(stderr, "# Track %d Info - ID %d - TimeScale %d\n", trackNum, trackID, timescale);
dur = gf_isom_get_media_original_duration(file, trackNum);
size = gf_isom_get_media_duration(file, trackNum);
fprintf(stderr, "Media Duration %s ", format_duration(dur, timescale, szDur));
if (dur != size)
fprintf(stderr, " (recomputed %s)", format_duration(size, timescale, szDur));
fprintf(stderr, "\n");
if (gf_isom_check_data_reference(file, trackNum, 1) != GF_OK) {
M4_LOG(GF_LOG_WARNING, ("Track uses external data reference not supported by GPAC!\n"));
}
nb_edits = gf_isom_get_edits_count(file, trackNum);
if (nb_edits)
fprintf(stderr, "Track has %d edits: track duration is %s\n", nb_edits, format_duration(gf_isom_get_track_duration(file, trackNum), gf_isom_get_timescale(file), szDur));
cts_shift = gf_isom_get_composition_offset_shift(file, trackNum);
if (cts_shift)
fprintf(stderr, "Track composition offset shift (negative CTS offset): %d\n", cts_shift);
if (gf_isom_is_track_in_root_od(file, trackNum) ) fprintf(stderr, "Track is present in Root OD\n");
if (!gf_isom_is_track_enabled(file, trackNum)) fprintf(stderr, "Track is disabled\n");
gf_isom_get_media_language(file, trackNum, &lang);
fprintf(stderr, "Media Info: Language \"%s (%s)\" - ", GetLanguage(lang), lang );
gf_free(lang);
mtype = gf_isom_get_media_type(file, trackNum);
fprintf(stderr, "Type \"%s:", gf_4cc_to_str(mtype));
msub_type = gf_isom_get_mpeg4_subtype(file, trackNum, 1);
if (!msub_type) msub_type = gf_isom_get_media_subtype(file, trackNum, 1);
fprintf(stderr, "%s\" - %d samples\n", gf_4cc_to_str(msub_type), gf_isom_get_sample_count(file, trackNum));
pfmt = gf_pixel_fmt_from_qt_type(msub_type);
codecid = gf_codec_id_from_isobmf(msub_type);
count = gf_isom_get_track_kind_count(file, trackNum);
for (i = 0; i < count; i++) {
char *kind_scheme, *kind_value;
gf_isom_get_track_kind(file, trackNum, i, &kind_scheme, &kind_value);
fprintf(stderr, "Kind: %s - %s\n", kind_scheme ? kind_scheme : "null", kind_value ? kind_value : "null");
if (kind_scheme) gf_free(kind_scheme);
if (kind_value) gf_free(kind_value);
}
if (gf_isom_is_track_fragmented(file, trackID) ) {
u32 defaultDuration, defaultSize, defaultDescriptionIndex, defaultRandomAccess;
u8 defaultPadding;
u16 defaultDegradationPriority;
u32 frag_samples;
u64 frag_duration;
gf_isom_get_fragmented_samples_info(file, trackID, &frag_samples, &frag_duration);
fprintf(stderr, "Fragmented track: %d samples - Media Duration %s\n", frag_samples, format_duration(frag_duration, timescale, szDur));
gf_isom_get_fragment_defaults(file, trackNum, &defaultDuration, &defaultSize, &defaultDescriptionIndex, &defaultRandomAccess, &defaultPadding, &defaultDegradationPriority);
fprintf(stderr, "Fragment sample defaults: duration %d size %d stsd %d sync %d padding %d degradation_priority %d\n",
defaultDuration, defaultSize, defaultDescriptionIndex, defaultRandomAccess,
(u32) defaultPadding, (u32) defaultDegradationPriority
);
}
if (!gf_isom_is_self_contained(file, trackNum, 1)) {
const char *url, *urn;
gf_isom_get_data_reference(file, trackNum, 1, &url, &urn);
fprintf(stderr, "Media Data Location: %s\n", url ? url : urn);
}
if (full_dump) {
const char *handler_name;
gf_isom_get_handler_name(file, trackNum, &handler_name);
fprintf(stderr, "Handler name: %s\n", handler_name);
}
print_udta(file, trackNum, GF_FALSE);
if (gf_isom_is_video_handler_type(mtype) ) {
s32 tx, ty;
u32 w, h;
u16 bit_depth;
gf_isom_get_visual_info(file, trackNum, 1, &w, &h);
gf_isom_get_visual_bit_depth(file, trackNum, 1, &bit_depth);
fprintf(stderr, "Visual Sample Entry Info: width=%d height=%d (depth=%d bits)\n", w, h, (int)bit_depth);
gf_isom_get_track_layout_info(file, trackNum, &w, &h, &tx, &ty, NULL);
fprintf(stderr, "Visual Track layout: x=%d y=%d width=%d height=%d\n", tx, ty, w, h);
}
gf_isom_get_audio_info(file, trackNum, 1, &sr, &nb_ch, &bps);
gf_isom_set_nalu_extract_mode(file, trackNum, GF_ISOM_NALU_EXTRACT_INSPECT);
msub_type = gf_isom_get_media_subtype(file, trackNum, 1);
if (msub_type==GF_ISOM_SUBTYPE_MPEG4_CRYP)
gf_isom_get_original_format_type(file, trackNum, 1, &msub_type);
if ((msub_type==GF_ISOM_SUBTYPE_MPEG4)
|| (msub_type==GF_ISOM_SUBTYPE_AVC_H264)
|| (msub_type==GF_ISOM_SUBTYPE_AVC2_H264)
|| (msub_type==GF_ISOM_SUBTYPE_AVC3_H264)
|| (msub_type==GF_ISOM_SUBTYPE_AVC4_H264)
|| (msub_type==GF_ISOM_SUBTYPE_SVC_H264)
|| (msub_type==GF_ISOM_SUBTYPE_MVC_H264)
|| (msub_type==GF_ISOM_SUBTYPE_LSR1)
|| (msub_type==GF_ISOM_SUBTYPE_HVC1)
|| (msub_type==GF_ISOM_SUBTYPE_HEV1)
|| (msub_type==GF_ISOM_SUBTYPE_HVC2)
|| (msub_type==GF_ISOM_SUBTYPE_HEV2)
|| (msub_type==GF_ISOM_SUBTYPE_LHV1)
|| (msub_type==GF_ISOM_SUBTYPE_LHE1)
|| (msub_type==GF_ISOM_SUBTYPE_HVT1)
) {
esd = gf_isom_get_esd(file, trackNum, 1);
if (!esd || !esd->decoderConfig) {
M4_LOG(GF_LOG_WARNING, ("WARNING: Broken MPEG-4 Track\n"));
if (esd) gf_odf_desc_del((GF_Descriptor *)esd);
} else {
const char *st = gf_stream_type_name(esd->decoderConfig->streamType);
if (dump_m4sys) {
if (st) {
fprintf(stderr, "MPEG-4 Config%s%s Stream - ObjectTypeIndication 0x%02x\n",
full_dump ? "\n\t" : ": ", st, esd->decoderConfig->objectTypeIndication);
} else {
fprintf(stderr, "MPEG-4 Config%sStream Type 0x%02x - ObjectTypeIndication 0x%02x\n",
full_dump ? "\n\t" : ": ", esd->decoderConfig->streamType, esd->decoderConfig->objectTypeIndication);
}
}
if (esd->decoderConfig->streamType==GF_STREAM_OD)
is_od_track=1;
if (esd->decoderConfig->streamType==GF_STREAM_VISUAL) {
u32 w, h;
u16 rvc_predef;
w = h = 0;
if (esd->decoderConfig->objectTypeIndication==GF_CODECID_MPEG4_PART2) {
#ifndef GPAC_DISABLE_AV_PARSERS
if (!esd->decoderConfig->decoderSpecificInfo) {
#else
gf_isom_get_visual_info(file, trackNum, 1, &w, &h);
fprintf(stderr, "MPEG-4 Visual Size %d x %d\n", w, h);
#endif
M4_LOG(GF_LOG_WARNING, ("Non-compliant MPEG-4 Visual track: video_object_layer infos not found in sample description\n"));
#ifndef GPAC_DISABLE_AV_PARSERS
} else {
GF_M4VDecSpecInfo dsi;
gf_m4v_get_config(esd->decoderConfig->decoderSpecificInfo->data, esd->decoderConfig->decoderSpecificInfo->dataLength, &dsi);
if (full_dump) fprintf(stderr, "\t");
w = dsi.width;
h = dsi.height;
fprintf(stderr, "MPEG-4 Visual Size %d x %d - %s\n", w, h, gf_m4v_get_profile_name(dsi.VideoPL));
if (dsi.par_den && dsi.par_num) {
u32 tw, th;
gf_isom_get_track_layout_info(file, trackNum, &tw, &th, NULL, NULL, NULL);
fprintf(stderr, "Pixel Aspect Ratio %d:%d - Indicated track size %d x %d\n", dsi.par_num, dsi.par_den, tw, th);
}
}
#endif
} else if (gf_isom_get_avc_svc_type(file, trackNum, 1) != GF_ISOM_AVCTYPE_NONE) {
GF_AVCConfig *avccfg, *svccfg, *mvccfg;
gf_isom_get_visual_info(file, trackNum, 1, &w, &h);
if (full_dump) fprintf(stderr, "\t");
fprintf(stderr, "AVC/H264 Video - Visual Size %d x %d\n", w, h);
avccfg = gf_isom_avc_config_get(file, trackNum, 1);
svccfg = gf_isom_svc_config_get(file, trackNum, 1);
mvccfg = gf_isom_mvc_config_get(file, trackNum, 1);
if (!avccfg && !svccfg && !mvccfg) {
M4_LOG(GF_LOG_ERROR, ("\tNon-compliant AVC track: SPS/PPS not found in sample description\n"));
} else if (avccfg) {
fprintf(stderr, "\tAVC Info: %d SPS - %d PPS", gf_list_count(avccfg->sequenceParameterSets) , gf_list_count(avccfg->pictureParameterSets) );
fprintf(stderr, " - Profile %s @ Level %g\n", gf_avc_get_profile_name(avccfg->AVCProfileIndication), ((Double)avccfg->AVCLevelIndication)/10.0 );
fprintf(stderr, "\tNAL Unit length bits: %d\n", 8*avccfg->nal_unit_size);
#ifndef GPAC_DISABLE_AV_PARSERS
for (i=0; i<gf_list_count(avccfg->sequenceParameterSets); i++) {
s32 par_n, par_d;
GF_NALUFFParam *slc = gf_list_get(avccfg->sequenceParameterSets, i);
gf_avc_get_sps_info(slc->data, slc->size, NULL, NULL, NULL, &par_n, &par_d);
if ((par_n>0) && (par_d>0)) {
u32 tw, th;
gf_isom_get_track_layout_info(file, trackNum, &tw, &th, NULL, NULL, NULL);
fprintf(stderr, "\tPixel Aspect Ratio %d:%d - Indicated track size %d x %d\n", par_n, par_d, tw, th);
}
if (!full_dump) break;
}
#endif
if (avccfg->chroma_bit_depth) {
fprintf(stderr, "\tChroma format %s - Luma bit depth %d - chroma bit depth %d\n", gf_avc_hevc_get_chroma_format_name(avccfg->chroma_format), avccfg->luma_bit_depth, avccfg->chroma_bit_depth);
}
print_config_hash(avccfg->sequenceParameterSets, "SPS");
print_config_hash(avccfg->pictureParameterSets, "PPS");
gf_odf_avc_cfg_del(avccfg);
}
if (svccfg) {
fprintf(stderr, "\n\tSVC Info: %d SPS - %d PPS - Profile %s @ Level %g\n", gf_list_count(svccfg->sequenceParameterSets) , gf_list_count(svccfg->pictureParameterSets), gf_avc_get_profile_name(svccfg->AVCProfileIndication), ((Double)svccfg->AVCLevelIndication)/10.0 );
fprintf(stderr, "\tSVC NAL Unit length bits: %d\n", 8*svccfg->nal_unit_size);
#ifndef GPAC_DISABLE_AV_PARSERS
for (i=0; i<gf_list_count(svccfg->sequenceParameterSets); i++) {
GF_NALUFFParam *slc = gf_list_get(svccfg->sequenceParameterSets, i);
if (slc) {
s32 par_n, par_d;
u32 s_w, s_h, sps_id;
gf_avc_get_sps_info(slc->data, slc->size, &sps_id, &s_w, &s_h, &par_n, &par_d);
fprintf(stderr, "\t\tSPS ID %d - Visual Size %d x %d\n", sps_id, s_w, s_h);
if ((par_n>0) && (par_d>0)) {
u32 tw, th;
gf_isom_get_track_layout_info(file, trackNum, &tw, &th, NULL, NULL, NULL);
fprintf(stderr, "\tPixel Aspect Ratio %d:%d - Indicated track size %d x %d\n", par_n, par_d, tw, th);
}
}
}
#endif
print_config_hash(svccfg->sequenceParameterSets, "SPS");
print_config_hash(svccfg->pictureParameterSets, "PPS");
print_config_hash(svccfg->sequenceParameterSetExtensions, "SPSEx");
gf_odf_avc_cfg_del(svccfg);
}
if (mvccfg) {
fprintf(stderr, "\n\tMVC Info: %d SPS - %d PPS - Profile %s @ Level %g\n", gf_list_count(mvccfg->sequenceParameterSets) , gf_list_count(mvccfg->pictureParameterSets), gf_avc_get_profile_name(mvccfg->AVCProfileIndication), ((Double)mvccfg->AVCLevelIndication)/10.0 );
fprintf(stderr, "\tMVC NAL Unit length bits: %d\n", 8*mvccfg->nal_unit_size);
#ifndef GPAC_DISABLE_AV_PARSERS
for (i=0; i<gf_list_count(mvccfg->sequenceParameterSets); i++) {
GF_NALUFFParam *slc = gf_list_get(mvccfg->sequenceParameterSets, i);
if (slc) {
u32 s_w, s_h, sps_id;
s32 par_n, par_d;
gf_avc_get_sps_info(slc->data, slc->size, &sps_id, &s_w, &s_h, &par_n, &par_d);
fprintf(stderr, "\t\tSPS ID %d - Visual Size %d x %d\n", sps_id, s_w, s_h);
if ((par_n>0) && (par_d>0)) {
u32 tw, th;
gf_isom_get_track_layout_info(file, trackNum, &tw, &th, NULL, NULL, NULL);
fprintf(stderr, "\tPixel Aspect Ratio %d:%d - Indicated track size %d x %d\n", par_n, par_d, tw, th);
}
}
}
#endif
print_config_hash(mvccfg->sequenceParameterSets, "SPS");
print_config_hash(mvccfg->pictureParameterSets, "PPS");
gf_odf_avc_cfg_del(mvccfg);
}
} else if ((esd->decoderConfig->objectTypeIndication==GF_CODECID_HEVC)
|| (esd->decoderConfig->objectTypeIndication==GF_CODECID_LHVC)
) {
GF_HEVCConfig *hevccfg, *lhvccfg;
GF_OperatingPointsInformation *oinf;
#if !defined(GPAC_DISABLE_AV_PARSERS) && !defined(GPAC_DISABLE_HEVC)
HEVCState hevc_state;
memset(&hevc_state, 0, sizeof(HEVCState));
hevc_state.sps_active_idx = -1;
#endif
gf_isom_get_visual_info(file, trackNum, 1, &w, &h);
if (full_dump) fprintf(stderr, "\t");
fprintf(stderr, "HEVC Video - Visual Size %d x %d\n", w, h);
hevccfg = gf_isom_hevc_config_get(file, trackNum, 1);
lhvccfg = gf_isom_lhvc_config_get(file, trackNum, 1);
if (msub_type==GF_ISOM_SUBTYPE_HVT1) {
const u8 *data;
u32 tsize;
u32 is_default, tx,ty,tw,th, id, independent;
Bool full_frame;
if (gf_isom_get_tile_info(file, trackNum, 1, &is_default, &id, &independent, &full_frame, &tx, &ty, &tw, &th)) {
fprintf(stderr, "\tHEVC Tile - ID %d independent %d (x,y,w,h)=%d,%d,%d,%d \n", id, independent, tx, ty, tw, th);
} else if (gf_isom_get_sample_group_info(file, trackNum, 1, GF_ISOM_SAMPLE_GROUP_TRIF, &is_default, &data, &tsize)) {
fprintf(stderr, "\tHEVC Tile track containing a tile set\n");
} else {
fprintf(stderr, "\tHEVC Tile track without tiling info\n");
}
} else if (!hevccfg && !lhvccfg) {
M4_LOG(GF_LOG_ERROR, ("\tNon-compliant HEVC track: No hvcC or shcC found in sample description\n"));
}
if (gf_isom_get_reference_count(file, trackNum, GF_ISOM_REF_SABT)) {
fprintf(stderr, "\tHEVC Tile base track\n");
}
if (hevccfg) {
dump_hevc_track_info(file, trackNum, hevccfg
#if !defined(GPAC_DISABLE_AV_PARSERS) && !defined(GPAC_DISABLE_HEVC)
, &hevc_state
#endif
);
gf_odf_hevc_cfg_del(hevccfg);
fprintf(stderr, "\n");
}
if (lhvccfg) {
dump_hevc_track_info(file, trackNum, lhvccfg
#if !defined(GPAC_DISABLE_AV_PARSERS) && !defined(GPAC_DISABLE_HEVC)
, &hevc_state
#endif
);
gf_odf_hevc_cfg_del(lhvccfg);
}
if (gf_isom_get_oinf_info(file, trackNum, &oinf)) {
fprintf(stderr, "\n\tOperating Points Information -");
fprintf(stderr, " scalability_mask %d (", oinf->scalability_mask);
switch (oinf->scalability_mask) {
case 2:
fprintf(stderr, "Multiview");
break;
case 4:
fprintf(stderr, "Spatial scalability");
break;
case 8:
fprintf(stderr, "Auxilary");
break;
default:
fprintf(stderr, "unknown");
}
//TODO: need to dump more info ?
fprintf(stderr, ") num_profile_tier_level %d ", gf_list_count(oinf->profile_tier_levels) );
fprintf(stderr, " num_operating_points %d dependency layers %d \n", gf_list_count(oinf->operating_points), gf_list_count(oinf->dependency_layers) );
}
}
/*OGG media*/
else if (esd->decoderConfig->objectTypeIndication==GF_CODECID_THEORA) {
char *szName;
gf_isom_get_visual_info(file, trackNum, 1, &w, &h);
if (full_dump) fprintf(stderr, "\t");
if (!strnicmp((char *) &esd->decoderConfig->decoderSpecificInfo->data[3], "theora", 6)) szName = "Theora";
else szName = "Unknown";
fprintf(stderr, "Ogg/%s video / GPAC Mux - Visual Size %d x %d\n", szName, w, h);
}
else {
//check if we know this codec from its OTI
u32 codec_id = gf_codecid_from_oti(GF_STREAM_VISUAL, esd->decoderConfig->objectTypeIndication);
if (codec_id) {
gf_isom_get_visual_info(file, trackNum, 1, &w, &h);
fprintf(stderr, "%s - Visual Size %d x %d\n", gf_codecid_name(codec_id), w, h);
}
}
if (!w || !h) {
gf_isom_get_visual_info(file, trackNum, 1, &w, &h);
if (full_dump) fprintf(stderr, "\t");
fprintf(stderr, "Visual Size %d x %d\n", w, h);
}
if (gf_isom_get_rvc_config(file, trackNum, 1, &rvc_predef, NULL, NULL, NULL)==GF_OK) {
fprintf(stderr, "Has RVC signaled - Predefined configuration %d\n", rvc_predef);
}
} else if (esd->decoderConfig->streamType==GF_STREAM_AUDIO) {
#ifndef GPAC_DISABLE_AV_PARSERS
GF_M4ADecSpecInfo a_cfg;
GF_Err e;
u32 oti;
#endif
u32 codec_id;
Bool is_mp2 = GF_FALSE;
switch (esd->decoderConfig->objectTypeIndication) {
case GF_CODECID_AAC_MPEG2_MP:
case GF_CODECID_AAC_MPEG2_LCP:
case GF_CODECID_AAC_MPEG2_SSRP:
is_mp2 = GF_TRUE;
case GF_CODECID_AAC_MPEG4:
#ifndef GPAC_DISABLE_AV_PARSERS
if (!esd->decoderConfig->decoderSpecificInfo)
e = GF_NON_COMPLIANT_BITSTREAM;
else
e = gf_m4a_get_config(esd->decoderConfig->decoderSpecificInfo->data, esd->decoderConfig->decoderSpecificInfo->dataLength, &a_cfg);
if (full_dump) fprintf(stderr, "\t");
if (e) {
M4_LOG(GF_LOG_ERROR, ("Corrupted AAC Config\n"));
} else {
char *signaling = "implicit";
char *heaac = "";
if (!is_mp2 && a_cfg.has_sbr) {
if (a_cfg.has_ps) heaac = "(HE-AAC v2) ";
else heaac = "(HE-AAC v1) ";
}
if (a_cfg.base_object_type==2) {
if (a_cfg.has_ps || a_cfg.has_sbr)
signaling = "backward compatible";
} else {
signaling = "hierarchical";
}
fprintf(stderr, "%s (AOT=%d %s) %s- %d Channel(s) - SampleRate %d", gf_m4a_object_type_name(a_cfg.base_object_type), a_cfg.base_object_type, signaling, heaac, a_cfg.nb_chan, a_cfg.base_sr);
if (is_mp2) fprintf(stderr, " (MPEG-2 Signaling)");
if (a_cfg.has_sbr) fprintf(stderr, " - SBR: SampleRate %d Type %s", a_cfg.sbr_sr, gf_m4a_object_type_name(a_cfg.sbr_object_type));
if (a_cfg.has_ps) fprintf(stderr, " - PS");
fprintf(stderr, "\n");
}
#else
fprintf(stderr, "MPEG-2/4 Audio - %d Channels - SampleRate %d\n", nb_ch, sr);
#endif
break;
case GF_CODECID_MPEG2_PART3:
case GF_CODECID_MPEG_AUDIO:
if (msub_type == GF_ISOM_SUBTYPE_MPEG4_CRYP) {
fprintf(stderr, "MPEG-1/2 Audio - %d Channels - SampleRate %d\n", nb_ch, sr);
} else {
#ifndef GPAC_DISABLE_AV_PARSERS
GF_ISOSample *samp = gf_isom_get_sample(file, trackNum, 1, &oti);
if (samp) {
u32 mhdr = GF_4CC((u8)samp->data[0], (u8)samp->data[1], (u8)samp->data[2], (u8)samp->data[3]);
if (full_dump) fprintf(stderr, "\t");
fprintf(stderr, "%s Audio - %d Channel(s) - SampleRate %d - Layer %d\n",
gf_mp3_version_name(mhdr),
gf_mp3_num_channels(mhdr),
gf_mp3_sampling_rate(mhdr),
gf_mp3_layer(mhdr)
);
gf_isom_sample_del(&samp);
} else {
M4_LOG(GF_LOG_ERROR, ("Error fetching sample: %s\n", gf_error_to_string(gf_isom_last_error(file)) ));
}
#else
fprintf(stderr, "MPEG-1/2 Audio - %d Channels - SampleRate %d\n", nb_ch, sr);
#endif
}
break;
case GF_CODECID_EVRC:
fprintf(stderr, "EVRC Audio - Sample Rate 8000 - 1 channel\n");
break;
case GF_CODECID_SMV:
fprintf(stderr, "SMV Audio - Sample Rate 8000 - 1 channel\n");
break;
case GF_CODECID_QCELP:
fprintf(stderr, "QCELP Audio - Sample Rate 8000 - 1 channel\n");
break;
/*packetVideo hack for EVRC...*/
case GF_CODECID_EVRC_PV:
if (esd->decoderConfig->decoderSpecificInfo && (esd->decoderConfig->decoderSpecificInfo->dataLength==8)
&& !strnicmp((char *)esd->decoderConfig->decoderSpecificInfo->data, "pvmm", 4)) {
if (full_dump) fprintf(stderr, "\t");
fprintf(stderr, "EVRC Audio (PacketVideo Mux) - Sample Rate 8000 - 1 channel\n");
}
break;
default:
codec_id = gf_codecid_from_oti(GF_STREAM_AUDIO, esd->decoderConfig->objectTypeIndication);
if (codec_id) {
fprintf(stderr, "%s - Sample Rate %d - %d channel(s)\n", gf_codecid_name(codec_id), sr, nb_ch);
}
break;
}
}
else if (esd->decoderConfig->streamType==GF_STREAM_SCENE) {
if (esd->decoderConfig->objectTypeIndication<=4) {
GF_BIFSConfig *b_cfg = gf_odf_get_bifs_config(esd->decoderConfig->decoderSpecificInfo, esd->decoderConfig->objectTypeIndication);
fprintf(stderr, "BIFS Scene description - %s stream\n", b_cfg->elementaryMasks ? "Animation" : "Command");
if (full_dump && !b_cfg->elementaryMasks) {
fprintf(stderr, "\tWidth %d Height %d Pixel Metrics %s\n", b_cfg->pixelWidth, b_cfg->pixelHeight, b_cfg->pixelMetrics ? "yes" : "no");
}
gf_odf_desc_del((GF_Descriptor *)b_cfg);
} else if (esd->decoderConfig->objectTypeIndication==GF_CODECID_AFX) {
u8 tag = esd->decoderConfig->decoderSpecificInfo ? esd->decoderConfig->decoderSpecificInfo->data[0] : 0xFF;
const char *afxtype = gf_stream_type_afx_name(tag);
fprintf(stderr, "AFX Stream - type %s (%d)\n", afxtype, tag);
} else if (esd->decoderConfig->objectTypeIndication==GF_CODECID_FONT) {
fprintf(stderr, "Font Data stream\n");
} else if (esd->decoderConfig->objectTypeIndication==GF_CODECID_LASER) {
GF_LASERConfig l_cfg;
gf_odf_get_laser_config(esd->decoderConfig->decoderSpecificInfo, &l_cfg);
fprintf(stderr, "LASER Stream - %s\n", l_cfg.newSceneIndicator ? "Full Scene" : "Scene Segment");
} else if (esd->decoderConfig->objectTypeIndication==GF_CODECID_TEXT_MPEG4) {
fprintf(stderr, "MPEG-4 Streaming Text stream\n");
} else if (esd->decoderConfig->objectTypeIndication==GF_CODECID_SYNTHESIZED_TEXTURE) {
fprintf(stderr, "Synthetized Texture stream stream\n");
} else {
M4_LOG(GF_LOG_WARNING, ("Unknown Systems stream OTI %d\n", esd->decoderConfig->objectTypeIndication));
}
}
/*sync is only valid if we open all tracks to take care of default MP4 sync..*/
if (!full_dump) {
if (dump_m4sys) {
if (!esd->OCRESID || (esd->OCRESID == esd->ESID))
fprintf(stderr, "Self-synchronized\n");
else
fprintf(stderr, "Synchronized on stream %d\n", esd->OCRESID);
}
} else {
fprintf(stderr, "\tDecoding Buffer size %d - Bitrate: avg %d - max %d kbps\n", esd->decoderConfig->bufferSizeDB, esd->decoderConfig->avgBitrate/1000, esd->decoderConfig->maxBitrate/1000);
if (esd->dependsOnESID)
fprintf(stderr, "\tDepends on stream %d for decoding\n", esd->dependsOnESID);
else
fprintf(stderr, "\tNo stream dependencies for decoding\n");
fprintf(stderr, "\tStreamPriority %d\n", esd->streamPriority);
if (esd->URLString) fprintf(stderr, "\tRemote Data Source %s\n", esd->URLString);
}
gf_odf_desc_del((GF_Descriptor *) esd);
}
} else if (msub_type == GF_ISOM_SUBTYPE_AV01) {
GF_AV1Config *av1c;
u32 w, h;
gf_isom_get_visual_info(file, trackNum, 1, &w, &h);
fprintf(stderr, "\tAOM AV1 stream - Resolution %d x %d\n", w, h);
av1c = gf_isom_av1_config_get(file, trackNum, 1);
fprintf(stderr, "\tversion=%u, profile=%u, level_idx0=%u, tier=%u\n", (u32)av1c->version, (u32)av1c->seq_profile, (u32)av1c->seq_level_idx_0, (u32)av1c->seq_tier_0);
fprintf(stderr, "\thigh_bitdepth=%u, twelve_bit=%u, monochrome=%u\n", (u32)av1c->high_bitdepth, (u32)av1c->twelve_bit, (u32)av1c->monochrome);
fprintf(stderr, "\tchroma: subsampling_x=%u, subsampling_y=%u, sample_position=%u\n", (u32)av1c->chroma_subsampling_x, (u32)av1c->chroma_subsampling_y, (u32)av1c->chroma_sample_position);
if (av1c->initial_presentation_delay_present)
fprintf(stderr, "\tInitial presentation delay %u\n", (u32) av1c->initial_presentation_delay_minus_one+1);
count = gf_list_count(av1c->obu_array);
for (i=0; i<count; i++) {
u8 hash[20];
GF_AV1_OBUArrayEntry *obu = gf_list_get(av1c->obu_array, i);
gf_sha1_csum((u8*)obu->obu, (u32)obu->obu_length, hash);
fprintf(stderr, "\tOBU#%d %s hash: ", i+1, gf_av1_get_obu_name(obu->obu_type) );
for (j=0; j<20; j++) fprintf(stderr, "%02X", hash[j]);
fprintf(stderr, "\n");
}
gf_odf_av1_cfg_del(av1c);
} else if (msub_type == GF_ISOM_SUBTYPE_3GP_H263) {
u32 w, h;
gf_isom_get_visual_info(file, trackNum, 1, &w, &h);
fprintf(stderr, "\t3GPP H263 stream - Resolution %d x %d\n", w, h);
} else if (msub_type == GF_ISOM_SUBTYPE_MJP2) {
u32 w, h;
gf_isom_get_visual_info(file, trackNum, 1, &w, &h);
fprintf(stderr, "\tMotionJPEG2000 stream - Resolution %d x %d\n", w, h);
} else if ((msub_type == GF_ISOM_SUBTYPE_3GP_AMR) || (msub_type == GF_ISOM_SUBTYPE_3GP_AMR_WB)) {
fprintf(stderr, "\t3GPP AMR%s stream - Sample Rate %d - %d channel(s) %d bps\n", (msub_type == GF_ISOM_SUBTYPE_3GP_AMR_WB) ? " Wide Band" : "", sr, nb_ch, (u32) bps);
} else if (msub_type == GF_ISOM_SUBTYPE_3GP_EVRC) {
fprintf(stderr, "\t3GPP EVRC stream - Sample Rate %d - %d channel(s) %d bps\n", sr, nb_ch, (u32) bps);
} else if (msub_type == GF_ISOM_SUBTYPE_3GP_QCELP) {
fprintf(stderr, "\t3GPP QCELP stream - Sample Rate %d - %d channel(s) %d bps\n", sr, nb_ch, (u32) bps);
} else if (msub_type == GF_ISOM_SUBTYPE_MP3) {
fprintf(stderr, "\tMPEG 1/2 Audio stream - Sample Rate %d - %d channel(s) %d bps\n", sr, nb_ch, (u32) bps);
} else if ((msub_type == GF_ISOM_SUBTYPE_AC3) || (msub_type == GF_ISOM_SUBTYPE_EC3)) {
u32 br = 0;
const char *lfe = "";
Bool is_ec3 = (msub_type == GF_ISOM_SUBTYPE_EC3) ? GF_TRUE : GF_FALSE;
#ifndef GPAC_DISABLE_AV_PARSERS
GF_AC3Config *ac3 = gf_isom_ac3_config_get(file, trackNum, 1);
if (ac3) {
nb_ch = gf_ac3_get_channels(ac3->streams[0].acmod);
for (i=0; i<ac3->streams[0].nb_dep_sub; ++i) {
assert(ac3->streams[0].nb_dep_sub == 1);
nb_ch += gf_ac3_get_channels(ac3->streams[0].chan_loc);
}
if (ac3->streams[0].lfon) lfe = ".1";
br = ac3->is_ec3 ? ac3->brcode : gf_ac3_get_bitrate(ac3->brcode);
is_ec3 = ac3->is_ec3;
gf_free(ac3);
}
#endif
fprintf(stderr, "\t%s stream - Sample Rate %d - %d%s channel(s) - bitrate %d\n", is_ec3 ? "EC-3" : "AC-3", sr, nb_ch, lfe, br);
} else if (msub_type == GF_ISOM_SUBTYPE_3GP_SMV) {
fprintf(stderr, "\t3GPP SMV stream - Sample Rate %d - %d channel(s) %d bits per samples\n", sr, nb_ch, (u32) bps);
} else if (msub_type == GF_ISOM_SUBTYPE_3GP_DIMS) {
u32 w, h;
GF_DIMSDescription dims;
gf_isom_get_visual_info(file, trackNum, 1, &w, &h);
gf_isom_get_dims_description(file, trackNum, 1, &dims);
fprintf(stderr, "\t3GPP DIMS stream - size %d x %d - Profile %d - Level %d\n", w, h, dims.profile, dims.level);
fprintf(stderr, "\tpathComponents: %d - useFullRequestHost: %s\n", dims.pathComponents, dims.fullRequestHost ? "yes" : "no");
fprintf(stderr, "\tstream type: %s - redundant: %s\n", dims.streamType ? "primary" : "secondary", (dims.containsRedundant==1) ? "main" : ((dims.containsRedundant==2) ? "redundant" : "main+redundant") );
if (dims.textEncoding[0]) fprintf(stderr, "\ttext encoding %s\n", dims.textEncoding);
if (dims.contentEncoding[0]) fprintf(stderr, "\tcontent encoding %s\n", dims.contentEncoding);
if (dims.content_script_types) fprintf(stderr, "\tscript languages %s\n", dims.content_script_types);
} else if (mtype==GF_ISOM_MEDIA_HINT) {
u32 refTrack;
s32 refCount = gf_isom_get_reference_count(file, trackNum, GF_ISOM_REF_HINT);
if (refCount>0) {
fprintf(stderr, "Streaming Hint Track for track%s ", (refCount>1) ? "s" :"");
for (i=0; i<(u32) refCount; i++) {
gf_isom_get_reference(file, trackNum, GF_ISOM_REF_HINT, i+1, &refTrack);
if (i) fprintf(stderr, " - ");
fprintf(stderr, "ID %d", gf_isom_get_track_id(file, refTrack));
}
fprintf(stderr, "\n");
} else {
fprintf(stderr, "Streaming Hint Track (no refs)\n");
}
#ifndef GPAC_DISABLE_ISOM_HINTING
refCount = gf_isom_get_payt_count(file, trackNum);
if (refCount>0) {
for (i=0; i<(u32) refCount; i++) {
const char *name = gf_isom_get_payt_info(file, trackNum, i+1, &refTrack);
fprintf(stderr, "\tPayload ID %d: type %s\n", refTrack, name);
}
}
#endif
} else if (mtype==GF_ISOM_MEDIA_FLASH) {
fprintf(stderr, "Macromedia Flash Movie\n");
} else if ((mtype==GF_ISOM_MEDIA_TEXT) || (mtype==GF_ISOM_MEDIA_SUBT) || (mtype==GF_ISOM_MEDIA_MPEG_SUBT)) {
u32 w, h;
s16 l;
s32 tx, ty;
const char *content_encoding = NULL;
const char *mime = NULL;
const char *config = NULL;
const char *_namespace = NULL;
const char *schema_loc = NULL;
const char *auxiliary_mimes = NULL;
gf_isom_get_track_layout_info(file, trackNum, &w, &h, &tx, &ty, &l);
if (msub_type == GF_ISOM_SUBTYPE_SBTT) {
gf_isom_stxt_get_description(file, trackNum, 1, &mime, &content_encoding, &config);
fprintf(stderr, "Textual Subtitle Stream ");
fprintf(stderr, "- mime %s", mime);
if (content_encoding != NULL) {
fprintf(stderr, " - encoding %s", content_encoding);
}
if (config != NULL) {
fprintf(stderr, " - %d bytes config", (u32) strlen(config));
}
} else if (msub_type == GF_ISOM_SUBTYPE_STXT) {
gf_isom_stxt_get_description(file, trackNum, 1, &mime, &content_encoding, &config);
fprintf(stderr, "Simple Timed Text Stream ");
fprintf(stderr, "- mime %s", mime);
if (content_encoding != NULL) {
fprintf(stderr, " - encoding %s", content_encoding);
}
if (config != NULL) {
fprintf(stderr, " - %d bytes config", (u32) strlen(config));
}
} else if (msub_type == GF_ISOM_SUBTYPE_STPP) {
gf_isom_xml_subtitle_get_description(file, trackNum, 1, &_namespace, &schema_loc, &auxiliary_mimes);
fprintf(stderr, "XML Subtitle Stream ");
fprintf(stderr, "- namespace %s", _namespace);
if (schema_loc != NULL) {
fprintf(stderr, " - schema-location %s", schema_loc);
}
if (auxiliary_mimes != NULL) {
fprintf(stderr, " - auxiliary-mime-types %s", auxiliary_mimes);
}
} else {
fprintf(stderr, "Unknown Text Stream");
}
fprintf(stderr, "\n Size %d x %d - Translation X=%d Y=%d - Layer %d\n", w, h, tx, ty, l);
} else if (mtype == GF_ISOM_MEDIA_META) {
const char *content_encoding = NULL;
if (msub_type == GF_ISOM_SUBTYPE_METT) {
const char *mime = NULL;
const char *config = NULL;
gf_isom_stxt_get_description(file, trackNum, 1, &mime, &content_encoding, &config);
fprintf(stderr, "Textual Metadata Stream - mime %s", mime);
if (content_encoding != NULL) {
fprintf(stderr, " - encoding %s", content_encoding);
}
if (config != NULL) {
fprintf(stderr, " - %d bytes config", (u32) strlen(config));
}
fprintf(stderr, "\n");
} else if (msub_type == GF_ISOM_SUBTYPE_METX) {
const char *_namespace = NULL;
const char *schema_loc = NULL;
gf_isom_get_xml_metadata_description(file, trackNum, 1, &_namespace, &schema_loc, &content_encoding);
fprintf(stderr, "XML Metadata Stream - namespace %s", _namespace);
if (content_encoding != NULL) {
fprintf(stderr, " - encoding %s", content_encoding);
}
if (schema_loc != NULL) {
fprintf(stderr, " - schema-location %s", schema_loc);
}
fprintf(stderr, "\n");
} else {
fprintf(stderr, "Unknown Metadata Stream\n");
}
} else if ((msub_type==GF_ISOM_SUBTYPE_VVC1) || (msub_type==GF_ISOM_SUBTYPE_VVI1)) {
GF_VVCConfig *vvccfg;
u32 w, h;
#if !defined(GPAC_DISABLE_AV_PARSERS)
VVCState *vvc_state;
GF_SAFEALLOC(vvc_state, VVCState);
if (vvc_state) vvc_state->sps_active_idx = -1;
#endif
gf_isom_get_visual_info(file, trackNum, 1, &w, &h);
if (full_dump) fprintf(stderr, "\t");
fprintf(stderr, "VVC Video - Visual Size %d x %d\n", w, h);
vvccfg = gf_isom_vvc_config_get(file, trackNum, 1);
if (!vvccfg) {
M4_LOG(GF_LOG_ERROR, ("Non-compliant VVC track: No vvcC found in sample description\n"));
} else {
dump_vvc_track_info(file, trackNum, vvccfg
#if !defined(GPAC_DISABLE_AV_PARSERS)
, vvc_state
#endif
);
gf_odf_vvc_cfg_del(vvccfg);
fprintf(stderr, "\n");
}
#if !defined(GPAC_DISABLE_AV_PARSERS)
if (vvc_state) gf_free(vvc_state);
#endif
} else if ((msub_type == GF_ISOM_SUBTYPE_MH3D_MHA1) || (msub_type == GF_ISOM_SUBTYPE_MH3D_MHA2)
|| (msub_type == GF_ISOM_SUBTYPE_MH3D_MHM1) || (msub_type == GF_ISOM_SUBTYPE_MH3D_MHM2)
) {
const u8 *compat_profiles;
u32 nb_compat_profiles;
Bool valid = GF_FALSE;
Bool allow_inband = GF_FALSE;
if ( (msub_type == GF_ISOM_SUBTYPE_MH3D_MHM1) || (msub_type == GF_ISOM_SUBTYPE_MH3D_MHM2))
allow_inband = GF_TRUE;
fprintf(stderr, "\tMPEG-H Audio stream - Sample Rate %d\n", sr);
esd = gf_media_map_esd(file, trackNum, 1);
if (!esd || !esd->decoderConfig || !esd->decoderConfig->decoderSpecificInfo
|| !esd->decoderConfig->decoderSpecificInfo->data
) {
if (allow_inband) {
GF_ISOSample *samp = gf_isom_get_sample(file, trackNum, 1, NULL);
if (samp) {
u64 ch_layout=0;
s32 PL = gf_mpegh_get_mhas_pl(samp->data, samp->dataLength, &ch_layout);
if (PL>=0) {
fprintf(stderr, "\tProfileLevelIndication: 0x%02X", PL);
if (ch_layout)
fprintf(stderr, " - Reference Channel Layout %s", gf_audio_fmt_get_layout_name(ch_layout) );
fprintf(stderr, "\n");
}
gf_isom_sample_del(&samp);
}
valid = GF_TRUE;
}
} else if (esd->decoderConfig->decoderSpecificInfo->dataLength>=5) {
fprintf(stderr, "\tProfileLevelIndication: 0x%02X - Reference Channel Layout %s\n", esd->decoderConfig->decoderSpecificInfo->data[1]
, gf_audio_fmt_get_layout_name_from_cicp(esd->decoderConfig->decoderSpecificInfo->data[2])
);
valid = GF_TRUE;
}
if (!valid) {
M4_LOG(GF_LOG_ERROR, ("Invalid MPEG-H audio config\n"));
}
if (esd) gf_odf_desc_del((GF_Descriptor *)esd);
compat_profiles = gf_isom_get_mpegh_compatible_profiles(file, trackNum, 1, &nb_compat_profiles);
for (i=0; i<nb_compat_profiles; i++) {
if (!i)
fprintf(stderr, "\tCompatible profiles:");
fprintf(stderr, " 0x%02X", compat_profiles[i]);
}
if (i) fprintf(stderr, "\n");
} else if (msub_type==GF_ISOM_SUBTYPE_MLPA) {
u32 fmt, prate;
if (gf_isom_truehd_config_get(file, trackNum, 1, &fmt, &prate) != GF_OK) {
fprintf(stderr, "\tInvalid TrueHD audio config\n");
}
fprintf(stderr, "TrueHD Audio stream - Sample Rate %u - channels %u - format %u peak rate %u\n", sr, nb_ch, fmt, prate);
} else if (codecid) {
if (gf_isom_is_video_handler_type(mtype) ) {
u32 w, h;
gf_isom_get_visual_info(file, trackNum, 1, &w, &h);
fprintf(stderr, "%s - Resolution %d x %d\n", gf_codecid_name(codecid), w, h);
} else if (mtype==GF_ISOM_MEDIA_AUDIO) {
gf_isom_get_audio_info(file, trackNum, 1, &sr, &nb_ch, NULL);
fprintf(stderr, "%s - Sample Rate %d - %d channel(s)\n", gf_codecid_name(codecid), sr, nb_ch);
} else {
fprintf(stderr, "%s\n", gf_codecid_name(codecid) );
}
} else if (pfmt) {
u32 w, h;
gf_isom_get_visual_info(file, trackNum, 1, &w, &h);
fprintf(stderr, "Raw video %s - Resolution %d x %d\n", gf_pixel_fmt_name(pfmt), w, h);
} else if (msub_type==GF_QT_SUBTYPE_TMCD) {
u32 stsd_idx;
GF_ISOSample *sample = gf_isom_get_sample(file, trackNum, 1, &stsd_idx);
fprintf(stderr, "Time Code stream\n");
if (sample) {
char szTimecode[100];
u32 tmcd_flags, tmcd_num, tmcd_den, tmcd_fpt;
gf_isom_get_tmcd_config(file, trackNum, stsd_idx, &tmcd_flags, &tmcd_num, &tmcd_den, &tmcd_fpt);
gf_inspect_format_timecode(sample->data, sample->dataLength, tmcd_flags, tmcd_num, tmcd_den, tmcd_fpt, szTimecode);
gf_isom_sample_del(&sample);
fprintf(stderr, "\tFirst timecode: %s\n", szTimecode);
}
} else {
GF_GenericSampleDescription *udesc;
udesc = gf_isom_get_generic_sample_description(file, trackNum, 1);
if (udesc) {
if (gf_isom_is_video_handler_type(mtype) ) {
fprintf(stderr, "%s - Compressor \"%s\" - Resolution %d x %d\n",
( (mtype == GF_ISOM_MEDIA_VISUAL ? "Visual" : "Auxiliary Video") ),
udesc->compressor_name, udesc->width, udesc->height);
} else if (mtype==GF_ISOM_MEDIA_AUDIO) {
fprintf(stderr, "Audio - Sample Rate %d - %d channel(s)\n", udesc->samplerate, udesc->nb_channels);
} else {
fprintf(stderr, "Unknown media type\n");
}
if (udesc->vendor_code)
fprintf(stderr, "\tVendor code \"%s\" - Version %d - revision %d\n", gf_4cc_to_str(udesc->vendor_code), udesc->version, udesc->revision);
if (udesc->extension_buf) {
fprintf(stderr, "\tCodec configuration data size: %d bytes\n", udesc->extension_buf_size);
gf_free(udesc->extension_buf);
}
gf_free(udesc);
} else {
fprintf(stderr, "Unknown track type\n");
}
}
/*Crypto info*/
if (gf_isom_is_track_encrypted(file, trackNum)) {
const char *scheme_URI, *KMS_URI;
u32 scheme_type, version;
u32 IV_size;
Bool use_sel_enc;
if (gf_isom_is_ismacryp_media(file, trackNum, 1)) {
gf_isom_get_ismacryp_info(file, trackNum, 1, NULL, &scheme_type, &version, &scheme_URI, &KMS_URI, &use_sel_enc, &IV_size, NULL);
fprintf(stderr, "\n\tProtected by ISMA E&A scheme %s (version %d)\n", gf_4cc_to_str(scheme_type), version);
if (scheme_URI) fprintf(stderr, "scheme location: %s\n", scheme_URI);
if (KMS_URI) {
if (!strnicmp(KMS_URI, "(key)", 5)) fprintf(stderr, "\tKMS location: key in file\n");
else fprintf(stderr, "\tKMS location: %s\n", KMS_URI);
}
fprintf(stderr, "\tSelective Encryption: %s\n", use_sel_enc ? "Yes" : "No");
if (IV_size) fprintf(stderr, "\tInitialization Vector size: %d bits\n", IV_size*8);
} else if (gf_isom_is_omadrm_media(file, trackNum, 1)) {
const char *textHdrs;
u32 enc_type, hdr_len;
u64 orig_len;
gf_isom_get_omadrm_info(file, trackNum, 1, NULL, &scheme_type, &version, &scheme_URI, &KMS_URI, &textHdrs, &hdr_len, &orig_len, &enc_type, &use_sel_enc, &IV_size, NULL);
fprintf(stderr, "\n\tProtected by OMA DRM scheme %s (version %d)\n", gf_4cc_to_str(scheme_type), version);
fprintf(stderr, "\tRights Issuer: %s\n", KMS_URI);
fprintf(stderr, "\tContent ID: %s\n", scheme_URI);
if (textHdrs) {
u32 offset;
const char *start = textHdrs;
fprintf(stderr, "\tOMA Textual Headers:\n");
i=0;
offset=0;
while (i<hdr_len) {
if (start[i]==0) {
fprintf(stderr, "\t\t%s\n", start+offset);
offset=i+1;
}
i++;
}
fprintf(stderr, "\\tt%s\n", start+offset);
}
if (orig_len) fprintf(stderr, "\tOriginal media size "LLD"\n", orig_len);
fprintf(stderr, "\tEncryption algorithm %s\n", (enc_type==1) ? "AEA 128 CBC" : (enc_type ? "AEA 128 CTR" : "None"));
fprintf(stderr, "\tSelective Encryption: %s\n", use_sel_enc ? "Yes" : "No");
if (IV_size) fprintf(stderr, "\tInitialization Vector size: %d bits\n", IV_size*8);
} else if(gf_isom_is_cenc_media(file, trackNum, 1)) {
const u8 *def_key;
u32 def_key_size;
Bool IsEncrypted;
u8 crypt_byte_block, skip_byte_block;
IV_size = 0;
gf_isom_get_cenc_info(file, trackNum, 1, NULL, &scheme_type, &version);
gf_isom_cenc_get_default_info(file, trackNum, 1, NULL, &IsEncrypted, &crypt_byte_block, &skip_byte_block, &def_key, &def_key_size);
fprintf(stderr, "\n\tProtected by CENC scheme %s version 0x%08X", gf_4cc_to_str(scheme_type), version);
if (crypt_byte_block && skip_byte_block)
fprintf(stderr, " - Pattern %d:%d", (u32) skip_byte_block, (u32) crypt_byte_block);
if (def_key && def_key[0])
fprintf(stderr, " - MultiKey");
fprintf(stderr, "\n");
dump_key_info(def_key, def_key_size, IsEncrypted);
} else if(gf_isom_is_adobe_protection_media(file, trackNum, 1)) {
gf_isom_get_adobe_protection_info(file, trackNum, 1, NULL, &scheme_type, &version, NULL);
fprintf(stderr, "\nProtected by Adobe scheme %s (version %d)\n", gf_4cc_to_str(scheme_type), version);
} else {
fprintf(stderr, "\nProtected by unknown scheme %s\n", gf_4cc_to_str(gf_isom_is_media_encrypted(file, trackNum, 0) ));
}
fprintf(stderr, "\n");
}
if ( gf_media_get_rfc_6381_codec_name(file, trackNum, szCodec, GF_FALSE, GF_FALSE) == GF_OK) {
fprintf(stderr, "\tRFC6381 Codec Parameters: %s\n", szCodec);
}
DumpMetaItem(file, 0, trackNum, "\tTrack Meta");
gf_isom_get_track_switch_group_count(file, trackNum, &alt_group, &nb_groups);
if (alt_group) {
fprintf(stderr, "Alternate Group ID %d\n", alt_group);
for (i=0; i<nb_groups; i++) {
u32 nb_crit, switchGroupID;
const u32 *criterias = gf_isom_get_track_switch_parameter(file, trackNum, i+1, &switchGroupID, &nb_crit);
if (!nb_crit) {
fprintf(stderr, "\tNo criteria in %s group\n", switchGroupID ? "switch" : "alternate");
} else {
if (switchGroupID) {
fprintf(stderr, "\tSwitchGroup ID %d criterias: ", switchGroupID);
} else {
fprintf(stderr, "\tAlternate Group criterias: ");
}
for (j=0; j<nb_crit; j++) {
if (j) fprintf(stderr, " ");
fprintf(stderr, "%s", gf_4cc_to_str(criterias[j]) );
}
fprintf(stderr, "\n");
}
}
}
switch (gf_isom_has_sync_points(file, trackNum)) {
case 0:
fprintf(stderr, "\tAll samples are sync\n");
break;
case 1:
{
u32 nb_sync = gf_isom_get_sync_point_count(file, trackNum) - 1;
if (! nb_sync) {
fprintf(stderr, "\tOnly one sync sample\n");
} else {
fprintf(stderr, "\tAverage GOP length: %d samples\n", gf_isom_get_sample_count(file, trackNum) / nb_sync);
}
}
break;
case 2:
fprintf(stderr, "\tNo sync sample found\n");
break;
}
fprintf(stderr, "\tMax sample duration: %d / %d\n", gf_isom_get_max_sample_delta(file, trackNum), timescale);
if (!full_dump) {
fprintf(stderr, "\n");
return;
}
dur = size = 0;
max_rate = rate = 0;
time_slice = 0;
ts = gf_isom_get_media_timescale(file, trackNum);
csize = gf_isom_get_constant_sample_size(file, trackNum);
cdur = gf_isom_get_constant_sample_duration(file, trackNum);
count = gf_isom_get_sample_count(file, trackNum);
if (csize && cdur) {
size = count * csize;
dur = cdur * count;
} else {
for (j=0; j<count; j++) {
GF_ISOSample *samp;
if (is_od_track) {
samp = gf_isom_get_sample(file, trackNum, j+1, NULL);
} else {
samp = gf_isom_get_sample_info(file, trackNum, j+1, NULL, NULL);
}
if (!samp) {
M4_LOG(GF_LOG_ERROR, ("Failed to fetch sample %d\n", j+1));
return;
}
dur = samp->DTS+samp->CTS_Offset;
size += samp->dataLength;
rate += samp->dataLength;
if (samp->DTS - time_slice > ts) {
Double max_tmp = rate * ts / (samp->DTS - time_slice);
if (max_rate < max_tmp )
max_rate = max_tmp;
rate = 0;
time_slice = samp->DTS;
}
gf_isom_sample_del(&samp);
}
}
fprintf(stderr, "\nComputed info from media:\n");
if (csize && cdur) {
fprintf(stderr, "\tConstant sample size %d bytes and dur %d / %d\n", csize, cdur, ts);
}
scale = 1000.0 / ts;
dur = (u64) (scale * dur);
fprintf(stderr, "\tTotal size "LLU" bytes - Total samples duration "LLU" ms\n", size, dur);
if (!dur) {
fprintf(stderr, "\n");
return;
}
/*rate in byte, dur is in ms*/
rate = 8000.0 * size / dur;
if (!max_rate)
max_rate = rate;
else
max_rate *= 8.0;
if (rate >= 1500) {
fprintf(stderr, "\tAverage rate %.2f kbps - Max Rate %.2f kbps\n", rate/1000, max_rate/1000);
} else {
fprintf(stderr, "\tAverage rate %.2f bps - Max Rate %.2f bps\n", rate, max_rate);
}
{
u32 dmin, dmax, davg, smin, smax, savg;
gf_isom_get_chunks_infos(file, trackNum, &dmin, &davg, &dmax, &smin, &savg, &smax);
fprintf(stderr, "\tChunk durations: min %d ms - max %d ms - average %d ms\n", (1000*dmin)/ts, (1000*dmax)/ts, (1000*davg)/ts);
fprintf(stderr, "\tChunk sizes (bytes): min %d - max %d - average %d\n", smin, smax, savg);
}
fprintf(stderr, "\n");
count = gf_isom_get_chapter_count(file, trackNum);
if (count) {
const char *name;
u64 time;
fprintf(stderr, "\nChapters:\n");
for (j=0; j<count; j++) {
gf_isom_get_chapter(file, trackNum, j+1, &time, &name);
fprintf(stderr, "\tChapter #%d - %s - \"%s\"\n", j+1, format_duration(time, 1000, szDur), name);
} | 8049 | True | 1 |
CVE-2021-32438 | 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/gpac/gpac/commit/00194f5fe462123f70b0bae7987317b52898b868', 'name': 'https://github.com/gpac/gpac/commit/00194f5fe462123f70b0bae7987317b52898b868', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/issues/1769', 'name': 'https://github.com/gpac/gpac/issues/1769', 'refsource': 'MISC', 'tags': ['Exploit', 'Issue Tracking', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-476'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'The gf_media_export_filters function in GPAC 1.0.1 allows attackers to cause a denial of service (NULL pointer dereference) via a crafted file in the MP4Box command.'}] | 2021-08-16T17:34Z | 2021-08-11T20: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 | jeanlf | 2021-04-30 10:50:38+02:00 | fixed #1769 (fuzz) | 00194f5fe462123f70b0bae7987317b52898b868 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_media_export_filters | gf_media_export_filters( GF_MediaExporter * dumper) | ['dumper'] | static GF_Err gf_media_export_filters(GF_MediaExporter *dumper)
{
char *args, szSubArgs[1024], szExt[30];
GF_Filter *file_out, *reframer, *remux=NULL, *src_filter;
GF_FilterSession *fsess;
GF_Err e = GF_OK;
u32 codec_id=0;
u32 sample_count=0;
Bool skip_write_filter = GF_FALSE;
Bool ext_forced = GF_FALSE;
Bool use_dynext = GF_FALSE;
args = NULL;
strcpy(szExt, "");
if (dumper->trackID && dumper->file) {
u32 msubtype = 0;
u32 mtype = 0;
u32 afmt = 0;
GF_PixelFormat pfmt = 0;
GF_ESD *esd;
const char *export_ext = dumper->out_name ? gf_file_ext_start(dumper->out_name) : NULL;
u32 track_num = gf_isom_get_track_by_id(dumper->file, dumper->trackID);
if (!track_num) {
GF_LOG(GF_LOG_ERROR, GF_LOG_AUTHOR, ("[Exporter] No tracks with ID %d in file\n", dumper->trackID));
return GF_BAD_PARAM;
}
esd = gf_media_map_esd(dumper->file, track_num, 0);
sample_count = gf_isom_get_sample_count(dumper->file, dumper->trackID);
if (esd) {
if (esd->decoderConfig->objectTypeIndication<GF_CODECID_LAST_MPEG4_MAPPING) {
codec_id = gf_codecid_from_oti(esd->decoderConfig->streamType, esd->decoderConfig->objectTypeIndication);
#ifndef GPAC_DISABLE_AV_PARSERS
if (esd->decoderConfig->decoderSpecificInfo && (codec_id==GF_CODECID_AAC_MPEG4)) {
GF_M4ADecSpecInfo acfg;
gf_m4a_get_config(esd->decoderConfig->decoderSpecificInfo->data, esd->decoderConfig->decoderSpecificInfo->dataLength, &acfg);
if (acfg.base_object_type == GF_M4A_USAC)
codec_id = GF_CODECID_USAC;
}
#endif
} else {
codec_id = esd->decoderConfig->objectTypeIndication;
}
}
if (!codec_id) {
msubtype = gf_isom_get_media_subtype(dumper->file, track_num, 1);
codec_id = gf_codec_id_from_isobmf(msubtype);
}
mtype = gf_isom_get_media_type(dumper->file, track_num);
if (!codec_id) {
pfmt = gf_pixel_fmt_from_qt_type(msubtype);
if (pfmt) codec_id = GF_CODECID_RAW;
}
if (!codec_id) {
strcpy(szExt, gf_4cc_to_str(msubtype));
ext_forced = GF_TRUE;
} else if (codec_id==GF_CODECID_RAW) {
switch (mtype) {
case GF_ISOM_MEDIA_VISUAL:
case GF_ISOM_MEDIA_AUXV:
case GF_ISOM_MEDIA_PICT:
if (pfmt)
strcpy(szExt, gf_pixel_fmt_sname(pfmt));
break;
case GF_ISOM_MEDIA_AUDIO:
afmt = gf_audio_fmt_from_isobmf(msubtype);
if (afmt)
strcpy(szExt, gf_audio_fmt_name(afmt));
break;
default:
strcpy(szExt, gf_4cc_to_str(msubtype));
break;
}
} else {
const char *sname = gf_codecid_file_ext(codec_id);
if (export_ext && strstr(sname, export_ext+1)) {
szExt[0]=0;
} else {
char *sep;
strncpy(szExt, sname, 29);
szExt[29]=0;
sep = strchr(szExt, '|');
if (sep) sep[0] = 0;
}
}
switch (mtype) {
case GF_ISOM_MEDIA_VISUAL:
case GF_ISOM_MEDIA_AUXV:
case GF_ISOM_MEDIA_PICT:
case GF_ISOM_MEDIA_AUDIO:
skip_write_filter = codec_id ? GF_TRUE : GF_FALSE;
break;
default:
switch (codec_id) {
case GF_CODECID_WEBVTT:
skip_write_filter = GF_TRUE;
break;
case GF_CODECID_META_TEXT:
case GF_CODECID_META_XML:
case GF_CODECID_SUBS_TEXT:
case GF_CODECID_SUBS_XML:
case GF_CODECID_SIMPLE_TEXT:
//use dynamic extension
szExt[0] = 0;
use_dynext = GF_TRUE;
break;
}
break;
}
//TODO, move these two to filters one of these days
if ((codec_id==GF_CODECID_VORBIS) || (codec_id==GF_CODECID_THEORA) || (codec_id==GF_CODECID_OPUS)) {
char *outname = dumper->out_name;
if (outname && !strcmp(outname, "std")) outname=NULL;
if (esd) gf_odf_desc_del((GF_Descriptor *) esd);
#ifndef GPAC_DISABLE_AV_PARSERS
return gf_dump_to_ogg(dumper, outname, track_num);
#else
return GF_NOT_SUPPORTED;
#endif
}
if (codec_id==GF_CODECID_SUBPIC) {
#ifndef GPAC_DISABLE_AV_PARSERS
char *dsi = NULL;
u32 dsi_size = 0;
if (esd && esd->decoderConfig && esd->decoderConfig->decoderSpecificInfo) {
dsi = esd->decoderConfig->decoderSpecificInfo->data;
dsi_size = esd->decoderConfig->decoderSpecificInfo->dataLength;
}
e = gf_dump_to_vobsub(dumper, dumper->out_name, track_num, dsi, dsi_size);
#else
e = GF_NOT_SUPPORTED;
#endif
if (esd) gf_odf_desc_del((GF_Descriptor *) esd);
return e;
}
if (esd) gf_odf_desc_del((GF_Descriptor *) esd);
} else {
const char *export_ext = dumper->out_name ? gf_file_ext_start(dumper->out_name) : NULL;
skip_write_filter = GF_TRUE;
if (!export_ext)
use_dynext = GF_TRUE;
}
fsess = gf_fs_new_defaults(0);
if (!fsess) {
GF_LOG(GF_LOG_ERROR, GF_LOG_AUTHOR, ("[Exporter] Failed to create filter session\n"));
return GF_OUT_OF_MEM;
}
file_out = NULL;
args = NULL;
if (dumper->flags & GF_EXPORT_REMUX) {
file_out = gf_fs_load_destination(fsess, dumper->out_name, NULL, NULL, &e);
if (!file_out) {
gf_fs_del(fsess);
GF_LOG(GF_LOG_ERROR, GF_LOG_AUTHOR, ("[Exporter] Cannot open destination %s\n", dumper->out_name));
return e;
}
}
//except in nhml inband file dump, create a sink filter
else if (!dumper->dump_file) {
Bool no_ext = (dumper->flags & GF_EXPORT_NO_FILE_EXT) ? GF_TRUE : GF_FALSE;
char *ext = gf_file_ext_start(dumper->out_name);
//mux args, for now we only dump to file
e = gf_dynstrcat(&args, "fout:dst=", NULL);
e |= gf_dynstrcat(&args, dumper->out_name, NULL);
if (dumper->flags & GF_EXPORT_NHNT) {
strcpy(szExt, "nhnt");
e |= gf_dynstrcat(&args, ":clone", NULL);
no_ext = GF_TRUE;
if (!ext)
e |= gf_dynstrcat(&args, ":dynext", NULL);
} else if (dumper->flags & GF_EXPORT_NHML) {
strcpy(szExt, "nhml");
e |= gf_dynstrcat(&args, ":clone", NULL);
no_ext = GF_TRUE;
if (!ext)
e |= gf_dynstrcat(&args, ":dynext", NULL);
}
if (dumper->flags & GF_EXPORT_RAW_SAMPLES) {
if (!dumper->sample_num) {
ext = gf_file_ext_start(args);
if (ext) ext[0] = 0;
if (sample_count>=1000) {
e |= gf_dynstrcat(&args, "_$num%08d$", NULL);
} else if (sample_count) {
e |= gf_dynstrcat(&args, "_$num%03d$", NULL);
} else {
e |= gf_dynstrcat(&args, "_$num$", NULL);
}
ext = gf_file_ext_start(dumper->out_name);
if (ext) e |= gf_dynstrcat(&args, ext, NULL);
}
e |= gf_dynstrcat(&args, ":dynext", NULL);
} else if (dumper->trackID && strlen(szExt) ) {
if (!no_ext && !gf_file_ext_start(dumper->out_name)) {
if (args) gf_free(args);
args=NULL;
e = gf_dynstrcat(&args, "fout:dst=", NULL);
e |= gf_dynstrcat(&args, dumper->out_name, NULL);
e |= gf_dynstrcat(&args, szExt, ".");
} else {
e |= gf_dynstrcat(&args, ":ext=", NULL);
e |= gf_dynstrcat(&args, szExt, NULL);
}
} else if ((dumper->trackID || dumper->track_type) && use_dynext) {
e |= gf_dynstrcat(&args, ":dynext", NULL);
}
if (e) {
GF_LOG(GF_LOG_ERROR, GF_LOG_AUTHOR, ("[Exporter] Cannot load arguments for output file dumper\n"));
if (args) gf_free(args);
gf_fs_del(fsess);
return e;
}
file_out = gf_fs_load_filter(fsess, args, &e);
if (!file_out) {
gf_fs_del(fsess);
if (args) gf_free(args);
GF_LOG(GF_LOG_ERROR, GF_LOG_AUTHOR, ("[Exporter] Cannot load output file dumper\n"));
return e;
}
}
if (args) gf_free(args);
args = NULL;
//raw sample frame, force loading filter generic write in frame mode
if (dumper->flags & GF_EXPORT_RAW_SAMPLES) {
e = gf_dynstrcat(&args, "writegen:frame", NULL);
if (dumper->sample_num) {
sprintf(szSubArgs, ":sstart=%d:send=%d", dumper->sample_num, dumper->sample_num);
e |= gf_dynstrcat(&args, szSubArgs, NULL);
}
remux = e ? NULL : gf_fs_load_filter(fsess, args, &e);
if (!remux || e) {
gf_fs_del(fsess);
GF_LOG(GF_LOG_ERROR, GF_LOG_AUTHOR, ("[Exporter] Cannot load stream->file filter\n"));
if (args) gf_free(args);
return e ? e : GF_FILTER_NOT_FOUND;
}
}
else if (dumper->flags & GF_EXPORT_NHNT) {
remux = gf_fs_load_filter(fsess, "nhntw:exporter", &e);
if (!remux) {
gf_fs_del(fsess);
GF_LOG(GF_LOG_ERROR, GF_LOG_AUTHOR, ("[Exporter] Cannot load NHNT write filter\n"));
return e;
}
}
else if (dumper->flags & GF_EXPORT_NHML) {
e = gf_dynstrcat(&args, "nhmlw:exporter:name=", NULL);
e |= gf_dynstrcat(&args, dumper->out_name, NULL);
if (dumper->flags & GF_EXPORT_NHML_FULL)
e |= gf_dynstrcat(&args, ":pckp", NULL);
if (dumper->dump_file) {
sprintf(szSubArgs, ":nhmlonly:filep=%p", dumper->dump_file);
e |= gf_dynstrcat(&args, szSubArgs, NULL);
}
remux = e ? NULL : gf_fs_load_filter(fsess, args, &e);
if (!remux || e) {
gf_fs_del(fsess);
if (args) gf_free(args);
GF_LOG(GF_LOG_ERROR, GF_LOG_AUTHOR, ("[Exporter] Cannot load NHML write filter\n"));
return e ? e : GF_FILTER_NOT_FOUND;
}
} else if (!skip_write_filter) {
e = gf_dynstrcat(&args, "writegen:exporter", NULL);
//extension has been forced, override ext at output of writegen
if (ext_forced) {
e |= gf_dynstrcat(&args, ":#Extension=", NULL);
e |= gf_dynstrcat(&args, szExt, NULL);
}
remux = e ? NULL : gf_fs_load_filter(fsess, args, &e);
if (!remux) {
gf_fs_del(fsess);
if (args) gf_free(args);
GF_LOG(GF_LOG_ERROR, GF_LOG_AUTHOR, ("[Exporter] Cannot load stream->file filter\n"));
return e;
}
}
if (args) gf_free(args);
args = NULL;
//force a reframer filter, connected to our input
e = gf_dynstrcat(&args, "reframer:SID=1", NULL);
if (dumper->trackID) {
sprintf(szSubArgs, "#PID=%d", dumper->trackID);
e |= gf_dynstrcat(&args, szSubArgs, NULL);
}
e |= gf_dynstrcat(&args, ":exporter", NULL);
if (dumper->flags & GF_EXPORT_SVC_LAYER)
e |= gf_dynstrcat(&args, ":extract=layer", NULL);
if (dumper->flags & GF_EXPORT_WEBVTT_NOMERGE)
e |= gf_dynstrcat(&args, ":merge", NULL);
reframer = gf_fs_load_filter(fsess, args, &e);
if (!reframer || e) {
gf_fs_del(fsess);
if (args) gf_free(args);
GF_LOG(GF_LOG_ERROR, GF_LOG_AUTHOR, ("[Exporter] Cannot load reframer filter\n"));
return e ? e : GF_FILTER_NOT_FOUND;
}
if (args) gf_free(args);
args = NULL;
//we already have the file loaded, directly load the mp4dmx filter with this file
if (dumper->file) {
//we want to expose every track
e = gf_dynstrcat(&args, "mp4dmx:FID=1:noedit:alltk:allt", NULL);
if (!e) {
sprintf(szSubArgs, ":mov=%p", dumper->file);
e = gf_dynstrcat(&args, szSubArgs, NULL);
}
//we want to expose every track
src_filter = gf_fs_load_filter(fsess, args, &e);
gf_free(args);
args = NULL;
} else {
//we want to expose every track
src_filter = gf_fs_load_source(fsess, dumper->in_name, "FID=1:noedit:alltk:allt", NULL, &e);
}
if (!src_filter || e) {
gf_fs_del(fsess);
GF_LOG(GF_LOG_ERROR, GF_LOG_AUTHOR, ("[Exporter] Cannot load filter for input file \"%s\": %s\n", dumper->in_name, gf_error_to_string(e) ));
return e;
}
if (dumper->track_type) {
const char *mtype = (dumper->track_type==1) ? "video" : "audio";
if (dumper->trackID) {
sprintf(szSubArgs, "%s%d", mtype, dumper->trackID);
} else {
sprintf(szSubArgs, "%s", mtype);
}
}
else if (dumper->trackID) {
sprintf(szSubArgs, "PID=%d", dumper->trackID);
}
if (remux) {
gf_filter_set_source(file_out, remux, (dumper->trackID || dumper->track_type) ? szSubArgs : NULL);
gf_filter_set_source(remux, reframer, (dumper->trackID || dumper->track_type) ? szSubArgs : NULL);
} else {
gf_filter_set_source(file_out, reframer, (dumper->trackID || dumper->track_type) ? szSubArgs : NULL);
}
e = gf_fs_run(fsess);
if (e>GF_OK) e = GF_OK;
if (!e) e = gf_fs_get_last_connect_error(fsess);
if (!e) e = gf_fs_get_last_process_error(fsess);
if (!e) {
if (dumper->file)
gf_fs_print_unused_args(fsess, NULL);
else
gf_fs_print_unused_args(fsess, "alltk,allt,noedit");
}
gf_fs_print_non_connected(fsess);
if (dumper->print_stats_graph & 1) gf_fs_print_stats(fsess);
if (dumper->print_stats_graph & 2) gf_fs_print_connections(fsess);
gf_fs_del(fsess);
return e;
} | 2410 | True | 1 |
CVE-2021-32437 | 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/gpac/gpac/issues/1770', 'name': 'https://github.com/gpac/gpac/issues/1770', 'refsource': 'MISC', 'tags': ['Exploit', 'Issue Tracking', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/1653f31cf874eb6df964bea88d58d8e9b98b485e', 'name': 'https://github.com/gpac/gpac/commit/1653f31cf874eb6df964bea88d58d8e9b98b485e', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-476'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'The gf_hinter_finalize function in GPAC 1.0.1 allows attackers to cause a denial of service (NULL pointer dereference) via a crafted file in the MP4Box command.'}] | 2021-08-16T17:27Z | 2021-08-11T20: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 | jeanlf | 2021-04-30 10:53:53+02:00 | fixed #1770 (fuzz) | 1653f31cf874eb6df964bea88d58d8e9b98b485e | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_hinter_finalize | gf_hinter_finalize( GF_ISOFile * file , GF_SDP_IODProfile IOD_Profile , u32 bandwidth) | ['file', 'IOD_Profile', 'bandwidth'] | GF_Err gf_hinter_finalize(GF_ISOFile *file, GF_SDP_IODProfile IOD_Profile, u32 bandwidth)
{
u32 i, sceneT, odT, descIndex, size, size64;
GF_InitialObjectDescriptor *iod;
GF_SLConfig slc;
GF_ISOSample *samp;
Bool remove_ocr;
u8 *buffer;
char buf64[5000], sdpLine[5100];
gf_isom_sdp_clean(file);
if (bandwidth) {
sprintf(buf64, "b=AS:%d", bandwidth);
gf_isom_sdp_add_line(file, buf64);
}
//xtended attribute for copyright
if (gf_sys_is_test_mode()) {
sprintf(buf64, "a=x-copyright: %s", "MP4/3GP File hinted with GPAC - (c) Telecom ParisTech (http://gpac.io)");
} else {
sprintf(buf64, "a=x-copyright: MP4/3GP File hinted with GPAC %s - %s", gf_gpac_version(), gf_gpac_copyright() );
}
gf_isom_sdp_add_line(file, buf64);
if (IOD_Profile == GF_SDP_IOD_NONE) return GF_OK;
odT = sceneT = 0;
for (i=0; i<gf_isom_get_track_count(file); i++) {
if (!gf_isom_is_track_in_root_od(file, i+1)) continue;
switch (gf_isom_get_media_type(file,i+1)) {
case GF_ISOM_MEDIA_OD:
odT = i+1;
break;
case GF_ISOM_MEDIA_SCENE:
sceneT = i+1;
break;
}
}
remove_ocr = 0;
if (IOD_Profile == GF_SDP_IOD_ISMA_STRICT) {
IOD_Profile = GF_SDP_IOD_ISMA;
remove_ocr = 1;
}
/*if we want ISMA like iods, we need at least BIFS */
if ( (IOD_Profile == GF_SDP_IOD_ISMA) && !sceneT ) return GF_BAD_PARAM;
/*do NOT change PLs, we assume they are correct*/
iod = (GF_InitialObjectDescriptor *) gf_isom_get_root_od(file);
if (!iod) return GF_NOT_SUPPORTED;
/*rewrite an IOD with good SL config - embbed data if possible*/
if (IOD_Profile == GF_SDP_IOD_ISMA) {
GF_ESD *esd;
Bool is_ok = 1;
while (gf_list_count(iod->ESDescriptors)) {
esd = (GF_ESD*)gf_list_get(iod->ESDescriptors, 0);
gf_odf_desc_del((GF_Descriptor *) esd);
gf_list_rem(iod->ESDescriptors, 0);
}
/*get OD esd, and embbed stream data if possible*/
if (odT) {
esd = gf_isom_get_esd(file, odT, 1);
if (gf_isom_get_sample_count(file, odT)==1) {
samp = gf_isom_get_sample(file, odT, 1, &descIndex);
if (samp && gf_hinter_can_embbed_data(samp->data, samp->dataLength, GF_STREAM_OD)) {
InitSL_NULL(&slc);
slc.predefined = 0;
slc.hasRandomAccessUnitsOnlyFlag = 1;
slc.timeScale = slc.timestampResolution = gf_isom_get_media_timescale(file, odT);
slc.OCRResolution = 1000;
slc.startCTS = samp->DTS+samp->CTS_Offset;
slc.startDTS = samp->DTS;
//set the SL for future extraction
gf_isom_set_extraction_slc(file, odT, 1, &slc);
size64 = gf_base64_encode(samp->data, samp->dataLength, buf64, 2000);
buf64[size64] = 0;
sprintf(sdpLine, "data:application/mpeg4-od-au;base64,%s", buf64);
esd->decoderConfig->avgBitrate = 0;
esd->decoderConfig->bufferSizeDB = samp->dataLength;
esd->decoderConfig->maxBitrate = 0;
size64 = (u32) strlen(sdpLine)+1;
esd->URLString = (char*)gf_malloc(sizeof(char) * size64);
strcpy(esd->URLString, sdpLine);
} else {
GF_LOG(GF_LOG_WARNING, GF_LOG_RTP, ("[rtp hinter] OD sample too large to be embedded in IOD - ISMA disabled\n"));
is_ok = 0;
}
gf_isom_sample_del(&samp);
}
if (remove_ocr) esd->OCRESID = 0;
else if (esd->OCRESID == esd->ESID) esd->OCRESID = 0;
//OK, add this to our IOD
gf_list_add(iod->ESDescriptors, esd);
}
esd = gf_isom_get_esd(file, sceneT, 1);
if (gf_isom_get_sample_count(file, sceneT)==1) {
samp = gf_isom_get_sample(file, sceneT, 1, &descIndex);
if (gf_hinter_can_embbed_data(samp->data, samp->dataLength, GF_STREAM_SCENE)) {
slc.timeScale = slc.timestampResolution = gf_isom_get_media_timescale(file, sceneT);
slc.OCRResolution = 1000;
slc.startCTS = samp->DTS+samp->CTS_Offset;
slc.startDTS = samp->DTS;
//set the SL for future extraction
gf_isom_set_extraction_slc(file, sceneT, 1, &slc);
//encode in Base64 the sample
size64 = gf_base64_encode(samp->data, samp->dataLength, buf64, 2000);
buf64[size64] = 0;
sprintf(sdpLine, "data:application/mpeg4-bifs-au;base64,%s", buf64);
esd->decoderConfig->avgBitrate = 0;
esd->decoderConfig->bufferSizeDB = samp->dataLength;
esd->decoderConfig->maxBitrate = 0;
esd->URLString = (char*)gf_malloc(sizeof(char) * (strlen(sdpLine)+1));
strcpy(esd->URLString, sdpLine);
} else {
GF_LOG(GF_LOG_ERROR, GF_LOG_RTP, ("[rtp hinter] Scene description sample too large to be embedded in IOD - ISMA disabled\n"));
is_ok = 0;
}
gf_isom_sample_del(&samp);
}
if (remove_ocr) esd->OCRESID = 0;
else if (esd->OCRESID == esd->ESID) esd->OCRESID = 0;
gf_list_add(iod->ESDescriptors, esd);
if (is_ok) {
u32 has_a, has_v, has_i_a, has_i_v;
has_a = has_v = has_i_a = has_i_v = 0;
for (i=0; i<gf_isom_get_track_count(file); i++) {
esd = gf_isom_get_esd(file, i+1, 1);
if (!esd) continue;
if (esd->decoderConfig->streamType==GF_STREAM_VISUAL) {
if (esd->decoderConfig->objectTypeIndication==GF_CODECID_MPEG4_PART2) has_i_v ++;
else has_v++;
} else if (esd->decoderConfig->streamType==GF_STREAM_AUDIO) {
if (esd->decoderConfig->objectTypeIndication==GF_CODECID_AAC_MPEG4) has_i_a ++;
else has_a++;
}
gf_odf_desc_del((GF_Descriptor *)esd);
}
/*only 1 MPEG-4 visual max and 1 MPEG-4 audio max for ISMA compliancy*/
if (!has_v && !has_a && (has_i_v<=1) && (has_i_a<=1)) {
sprintf(sdpLine, "a=isma-compliance:1,1.0,1");
gf_isom_sdp_add_line(file, sdpLine);
}
}
}
//encode the IOD
buffer = NULL;
size = 0;
gf_odf_desc_write((GF_Descriptor *) iod, &buffer, &size);
gf_odf_desc_del((GF_Descriptor *)iod);
//encode in Base64 the iod
size64 = gf_base64_encode(buffer, size, buf64, 2000);
buf64[size64] = 0;
gf_free(buffer);
sprintf(sdpLine, "a=mpeg4-iod:\"data:application/mpeg4-iod;base64,%s\"", buf64);
gf_isom_sdp_add_line(file, sdpLine);
return GF_OK;
} | 1117 | True | 1 |
CVE-2021-32440 | 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/gpac/gpac/issues/1772', 'name': 'https://github.com/gpac/gpac/issues/1772', 'refsource': 'MISC', 'tags': ['Exploit', 'Issue Tracking', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/f0ba83717b6e4d7a15a1676d1fe06152e199b011', 'name': 'https://github.com/gpac/gpac/commit/f0ba83717b6e4d7a15a1676d1fe06152e199b011', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-476'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'The Media_RewriteODFrame function in GPAC 1.0.1 allows attackers to cause a denial of service (NULL pointer dereference) via a crafted file in the MP4Box command.'}] | 2021-08-16T17:32Z | 2021-08-11T20: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 | jeanlf | 2021-04-30 11:05:11+02:00 | fixed #1772 (fuzz) | f0ba83717b6e4d7a15a1676d1fe06152e199b011 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | Media_RewriteODFrame | Media_RewriteODFrame( GF_MediaBox * mdia , GF_ISOSample * sample) | ['mdia', 'sample'] | GF_Err Media_RewriteODFrame(GF_MediaBox *mdia, GF_ISOSample *sample)
{
GF_Err e;
GF_ODCodec *ODdecode;
GF_ODCodec *ODencode;
GF_ODCom *com;
//the commands we proceed
GF_ESDUpdate *esdU, *esdU2;
GF_ESDRemove *esdR, *esdR2;
GF_ODUpdate *odU, *odU2;
//the desc they contain
GF_ObjectDescriptor *od;
GF_IsomObjectDescriptor *isom_od;
GF_ESD *esd;
GF_ES_ID_Ref *ref;
GF_Descriptor *desc;
GF_TrackReferenceTypeBox *mpod;
u32 i, j, skipped;
if (!mdia || !sample || !sample->data || !sample->dataLength) return GF_BAD_PARAM;
mpod = NULL;
e = Track_FindRef(mdia->mediaTrack, GF_ISOM_BOX_TYPE_MPOD, &mpod);
if (e) return e;
//no references, nothing to do...
if (!mpod || !mpod->trackIDs) return GF_OK;
ODdecode = gf_odf_codec_new();
if (!ODdecode) return GF_OUT_OF_MEM;
ODencode = gf_odf_codec_new();
if (!ODencode) {
gf_odf_codec_del(ODdecode);
return GF_OUT_OF_MEM;
}
e = gf_odf_codec_set_au(ODdecode, sample->data, sample->dataLength);
if (e) goto err_exit;
e = gf_odf_codec_decode(ODdecode);
if (e) goto err_exit;
while (1) {
com = gf_odf_codec_get_com(ODdecode);
if (!com) break;
//we only need to rewrite commands with ESDs inside: ESDUpdate and ODUpdate
switch (com->tag) {
case GF_ODF_OD_UPDATE_TAG:
odU = (GF_ODUpdate *) com;
odU2 = (GF_ODUpdate *) gf_odf_com_new(GF_ODF_OD_UPDATE_TAG);
i=0;
while ((desc = (GF_Descriptor*)gf_list_enum(odU->objectDescriptors, &i))) {
switch (desc->tag) {
case GF_ODF_OD_TAG:
case GF_ODF_ISOM_OD_TAG:
//IOD can be used in OD streams
case GF_ODF_ISOM_IOD_TAG:
break;
default:
return GF_ISOM_INVALID_FILE;
}
e = gf_odf_desc_copy(desc, (GF_Descriptor **)&isom_od);
if (e) goto err_exit;
//create our OD...
if (desc->tag == GF_ODF_ISOM_IOD_TAG) {
od = (GF_ObjectDescriptor *) gf_malloc(sizeof(GF_InitialObjectDescriptor));
} else {
od = (GF_ObjectDescriptor *) gf_malloc(sizeof(GF_ObjectDescriptor));
}
if (!od) {
e = GF_OUT_OF_MEM;
goto err_exit;
}
od->ESDescriptors = gf_list_new();
//and duplicate...
od->objectDescriptorID = isom_od->objectDescriptorID;
od->tag = GF_ODF_OD_TAG;
od->URLString = isom_od->URLString;
isom_od->URLString = NULL;
od->extensionDescriptors = isom_od->extensionDescriptors;
isom_od->extensionDescriptors = NULL;
od->IPMP_Descriptors = isom_od->IPMP_Descriptors;
isom_od->IPMP_Descriptors = NULL;
od->OCIDescriptors = isom_od->OCIDescriptors;
isom_od->OCIDescriptors = NULL;
//init as IOD
if (isom_od->tag == GF_ODF_ISOM_IOD_TAG) {
((GF_InitialObjectDescriptor *)od)->audio_profileAndLevel = ((GF_IsomInitialObjectDescriptor *)isom_od)->audio_profileAndLevel;
((GF_InitialObjectDescriptor *)od)->inlineProfileFlag = ((GF_IsomInitialObjectDescriptor *)isom_od)->inlineProfileFlag;
((GF_InitialObjectDescriptor *)od)->graphics_profileAndLevel = ((GF_IsomInitialObjectDescriptor *)isom_od)->graphics_profileAndLevel;
((GF_InitialObjectDescriptor *)od)->OD_profileAndLevel = ((GF_IsomInitialObjectDescriptor *)isom_od)->OD_profileAndLevel;
((GF_InitialObjectDescriptor *)od)->scene_profileAndLevel = ((GF_IsomInitialObjectDescriptor *)isom_od)->scene_profileAndLevel;
((GF_InitialObjectDescriptor *)od)->visual_profileAndLevel = ((GF_IsomInitialObjectDescriptor *)isom_od)->visual_profileAndLevel;
((GF_InitialObjectDescriptor *)od)->IPMPToolList = ((GF_IsomInitialObjectDescriptor *)isom_od)->IPMPToolList;
((GF_IsomInitialObjectDescriptor *)isom_od)->IPMPToolList = NULL;
}
//then rewrite the ESDesc
j=0;
while ((ref = (GF_ES_ID_Ref*)gf_list_enum(isom_od->ES_ID_RefDescriptors, &j))) {
//if the ref index is not valid, skip this desc...
if (!mpod->trackIDs || gf_isom_get_track_from_id(mdia->mediaTrack->moov, mpod->trackIDs[ref->trackRef - 1]) == NULL) continue;
//OK, get the esd
e = GetESDForTime(mdia->mediaTrack->moov, mpod->trackIDs[ref->trackRef - 1], sample->DTS, &esd);
if (!e) e = gf_odf_desc_add_desc((GF_Descriptor *) od, (GF_Descriptor *) esd);
if (e) {
gf_odf_desc_del((GF_Descriptor *)od);
gf_odf_com_del((GF_ODCom **)&odU2);
gf_odf_desc_del((GF_Descriptor *)isom_od);
gf_odf_com_del((GF_ODCom **)&odU);
goto err_exit;
}
}
//delete our desc
gf_odf_desc_del((GF_Descriptor *)isom_od);
gf_list_add(odU2->objectDescriptors, od);
}
//clean a bit
gf_odf_com_del((GF_ODCom **)&odU);
gf_odf_codec_add_com(ODencode, (GF_ODCom *)odU2);
break;
case GF_ODF_ESD_UPDATE_TAG:
esdU = (GF_ESDUpdate *) com;
esdU2 = (GF_ESDUpdate *) gf_odf_com_new(GF_ODF_ESD_UPDATE_TAG);
esdU2->ODID = esdU->ODID;
i=0;
while ((ref = (GF_ES_ID_Ref*)gf_list_enum(esdU->ESDescriptors, &i))) {
//if the ref index is not valid, skip this desc...
if (gf_isom_get_track_from_id(mdia->mediaTrack->moov, mpod->trackIDs[ref->trackRef - 1]) == NULL) continue;
//OK, get the esd
e = GetESDForTime(mdia->mediaTrack->moov, mpod->trackIDs[ref->trackRef - 1], sample->DTS, &esd);
if (e) goto err_exit;
gf_list_add(esdU2->ESDescriptors, esd);
}
gf_odf_com_del((GF_ODCom **)&esdU);
gf_odf_codec_add_com(ODencode, (GF_ODCom *)esdU2);
break;
//brand new case: the ESRemove follows the same principle according to the spec...
case GF_ODF_ESD_REMOVE_REF_TAG:
//both commands have the same structure, only the tags change
esdR = (GF_ESDRemove *) com;
esdR2 = (GF_ESDRemove *) gf_odf_com_new(GF_ODF_ESD_REMOVE_TAG);
esdR2->ODID = esdR->ODID;
esdR2->NbESDs = esdR->NbESDs;
//alloc our stuff
esdR2->ES_ID = (unsigned short*)gf_malloc(sizeof(u32) * esdR->NbESDs);
if (!esdR2->ES_ID) {
e = GF_OUT_OF_MEM;
goto err_exit;
}
skipped = 0;
//get the ES_ID in the mpod indicated in the ES_ID[]
for (i = 0; i < esdR->NbESDs; i++) {
//if the ref index is not valid, remove this desc...
if (gf_isom_get_track_from_id(mdia->mediaTrack->moov, mpod->trackIDs[esdR->ES_ID[i] - 1]) == NULL) {
skipped ++;
} else {
//the command in the file has the ref index of the trackID in the mpod
esdR2->ES_ID[i - skipped] = mpod->trackIDs[esdR->ES_ID[i] - 1];
}
}
//gf_realloc...
if (skipped && (skipped != esdR2->NbESDs) ) {
esdR2->NbESDs -= skipped;
esdR2->ES_ID = (unsigned short*)gf_realloc(esdR2->ES_ID, sizeof(u32) * esdR2->NbESDs);
}
gf_odf_com_del((GF_ODCom **)&esdR);
gf_odf_codec_add_com(ODencode, (GF_ODCom *)esdR2);
break;
default:
e = gf_odf_codec_add_com(ODencode, com);
if (e) goto err_exit;
}
}
//encode our new AU
e = gf_odf_codec_encode(ODencode, 1);
if (e) goto err_exit;
//and set the buffer in the sample
gf_free(sample->data);
sample->data = NULL;
sample->dataLength = 0;
e = gf_odf_codec_get_au(ODencode, &sample->data, &sample->dataLength);
err_exit:
gf_odf_codec_del(ODdecode);
gf_odf_codec_del(ODencode);
return e;
} | 1278 | True | 1 |
CVE-2021-32439 | 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/gpac/gpac/issues/1774', 'name': 'https://github.com/gpac/gpac/issues/1774', 'refsource': 'MISC', 'tags': ['Exploit', 'Issue Tracking', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/77ed81c069e10b3861d88f72e1c6be1277ee7eae', 'name': 'https://github.com/gpac/gpac/commit/77ed81c069e10b3861d88f72e1c6be1277ee7eae', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-120'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Buffer overflow in the stbl_AppendSize function in MP4Box in GPAC 1.0.1 allows attackers to cause a denial of service or execute arbitrary code via a crafted file.'}] | 2021-08-16T17:32Z | 2021-08-11T20:15Z | Buffer Copy without Checking Size of Input ('Classic Buffer Overflow') | The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow. | A buffer overflow condition exists when a program attempts to put more data in a buffer than it can hold, or when a program attempts to put data in a memory area outside of the boundaries of a buffer. The simplest type of error, and the most common cause of buffer overflows, is the "classic" case in which the program copies the buffer without restricting how much is copied. Other variants exist, but the existence of a classic overflow strongly suggests that the programmer is not considering even the most basic of security protections.
| https://cwe.mitre.org/data/definitions/120.html | 0 | jeanlf | 2021-04-30 11:30:41+02:00 | fixed #1774 (fuzz) | 77ed81c069e10b3861d88f72e1c6be1277ee7eae | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | stbl_AddChunkOffset | stbl_AddChunkOffset( GF_MediaBox * mdia , u32 sampleNumber , u32 StreamDescIndex , u64 offset , u32 nb_pack_samples) | ['mdia', 'sampleNumber', 'StreamDescIndex', 'offset', 'nb_pack_samples'] | GF_Err stbl_AddChunkOffset(GF_MediaBox *mdia, u32 sampleNumber, u32 StreamDescIndex, u64 offset, u32 nb_pack_samples)
{
GF_SampleTableBox *stbl;
GF_ChunkOffsetBox *stco;
GF_SampleToChunkBox *stsc;
GF_ChunkLargeOffsetBox *co64;
GF_StscEntry *ent;
u32 i, k, *newOff, new_chunk_idx=0;
u64 *newLarge;
s32 insert_idx = -1;
stbl = mdia->information->sampleTable;
stsc = stbl->SampleToChunk;
// if (stsc->w_lastSampleNumber + 1 < sampleNumber ) return GF_BAD_PARAM;
if (!nb_pack_samples)
nb_pack_samples = 1;
if (!stsc->nb_entries || (stsc->nb_entries + 2 >= stsc->alloc_size)) {
if (!stsc->alloc_size) stsc->alloc_size = 1;
ALLOC_INC(stsc->alloc_size);
stsc->entries = gf_realloc(stsc->entries, sizeof(GF_StscEntry)*stsc->alloc_size);
if (!stsc->entries) return GF_OUT_OF_MEM;
memset(&stsc->entries[stsc->nb_entries], 0, sizeof(GF_StscEntry)*(stsc->alloc_size-stsc->nb_entries) );
}
if (sampleNumber == stsc->w_lastSampleNumber + 1) {
ent = &stsc->entries[stsc->nb_entries];
stsc->w_lastChunkNumber ++;
ent->firstChunk = stsc->w_lastChunkNumber;
if (stsc->nb_entries) stsc->entries[stsc->nb_entries-1].nextChunk = stsc->w_lastChunkNumber;
new_chunk_idx = stsc->w_lastChunkNumber;
stsc->w_lastSampleNumber = sampleNumber + nb_pack_samples-1;
stsc->nb_entries += 1;
} else {
u32 cur_samp = 1;
u32 samples_in_next_entry = 0;
u32 next_entry_first_chunk = 1;
for (i=0; i<stsc->nb_entries; i++) {
u32 nb_chunks = 1;
ent = &stsc->entries[i];
if (i+1<stsc->nb_entries) nb_chunks = stsc->entries[i+1].firstChunk - ent->firstChunk;
for (k=0; k<nb_chunks; k++) {
if ((cur_samp <= sampleNumber) && (ent->samplesPerChunk + cur_samp > sampleNumber)) {
insert_idx = i;
//stsc entry has samples before inserted sample, split
if (sampleNumber>cur_samp) {
samples_in_next_entry = ent->samplesPerChunk - (sampleNumber-cur_samp);
ent->samplesPerChunk = sampleNumber-cur_samp;
}
break;
}
cur_samp += ent->samplesPerChunk;
next_entry_first_chunk++;
}
if (insert_idx>=0) break;
}
//we need to split the entry
if (samples_in_next_entry) {
memmove(&stsc->entries[insert_idx+3], &stsc->entries[insert_idx+1], sizeof(GF_StscEntry)*(stsc->nb_entries - insert_idx - 1));
//copy over original entry
ent = &stsc->entries[insert_idx];
stsc->entries[insert_idx+2] = *ent;
stsc->entries[insert_idx+2].samplesPerChunk = samples_in_next_entry;
stsc->entries[insert_idx+2].firstChunk = next_entry_first_chunk + 1;
//setup new entry
ent = &stsc->entries[insert_idx+1];
ent->firstChunk = next_entry_first_chunk;
stsc->nb_entries += 2;
} else {
if (insert_idx<0) {
ent = &stsc->entries[stsc->nb_entries];
insert_idx = stsc->nb_entries;
} else {
memmove(&stsc->entries[insert_idx+1], &stsc->entries[insert_idx], sizeof(GF_StscEntry)*(stsc->nb_entries+1-insert_idx));
ent = &stsc->entries[insert_idx+1];
}
ent->firstChunk = next_entry_first_chunk;
stsc->nb_entries += 1;
}
new_chunk_idx = next_entry_first_chunk;
}
ent->isEdited = (Media_IsSelfContained(mdia, StreamDescIndex)) ? 1 : 0;
ent->sampleDescriptionIndex = StreamDescIndex;
ent->samplesPerChunk = nb_pack_samples;
ent->nextChunk = ent->firstChunk+1;
//OK, now if we've inserted a chunk, update the sample to chunk info...
if (sampleNumber + nb_pack_samples - 1 == stsc->w_lastSampleNumber) {
if (stsc->nb_entries)
stsc->entries[stsc->nb_entries-1].nextChunk = ent->firstChunk;
stbl->SampleToChunk->currentIndex = stsc->nb_entries-1;
stbl->SampleToChunk->firstSampleInCurrentChunk = sampleNumber;
//write - edit mode: sample number = chunk number
stbl->SampleToChunk->currentChunk = stsc->w_lastChunkNumber;
stbl->SampleToChunk->ghostNumber = 1;
} else {
/*offset remaining entries*/
for (i = insert_idx+1; i<stsc->nb_entries+1; i++) {
stsc->entries[i].firstChunk++;
if (i+1<stsc->nb_entries)
stsc->entries[i-1].nextChunk = stsc->entries[i].firstChunk;
}
}
//add the offset to the chunk...
//and we change our offset
if (stbl->ChunkOffset->type == GF_ISOM_BOX_TYPE_STCO) {
stco = (GF_ChunkOffsetBox *)stbl->ChunkOffset;
//if the new offset is a large one, we have to rewrite our table entry by entry (32->64 bit conv)...
if (offset > 0xFFFFFFFF) {
co64 = (GF_ChunkLargeOffsetBox *) gf_isom_box_new_parent(&stbl->child_boxes, GF_ISOM_BOX_TYPE_CO64);
if (!co64) return GF_OUT_OF_MEM;
co64->nb_entries = stco->nb_entries + 1;
co64->alloc_size = co64->nb_entries;
co64->offsets = (u64*)gf_malloc(sizeof(u64) * co64->nb_entries);
if (!co64->offsets) return GF_OUT_OF_MEM;
k = 0;
for (i=0; i<stco->nb_entries; i++) {
if (i + 1 == new_chunk_idx) {
co64->offsets[i] = offset;
k = 1;
}
co64->offsets[i+k] = (u64) stco->offsets[i];
}
if (!k) co64->offsets[co64->nb_entries - 1] = offset;
gf_isom_box_del_parent(&stbl->child_boxes, stbl->ChunkOffset);
stbl->ChunkOffset = (GF_Box *) co64;
} else {
//no, we can use this one.
if (new_chunk_idx > stco->nb_entries) {
if (!stco->alloc_size) stco->alloc_size = stco->nb_entries;
if (stco->nb_entries == stco->alloc_size) {
ALLOC_INC(stco->alloc_size);
stco->offsets = (u32*)gf_realloc(stco->offsets, sizeof(u32) * stco->alloc_size);
if (!stco->offsets) return GF_OUT_OF_MEM;
memset(&stco->offsets[stco->nb_entries], 0, sizeof(u32) * (stco->alloc_size-stco->nb_entries) );
}
stco->offsets[stco->nb_entries] = (u32) offset;
stco->nb_entries += 1;
} else {
//nope. we're inserting
newOff = (u32*)gf_malloc(sizeof(u32) * (stco->nb_entries + 1));
if (!newOff) return GF_OUT_OF_MEM;
k=0;
for (i=0; i<stco->nb_entries; i++) {
if (i+1 == new_chunk_idx) {
newOff[i] = (u32) offset;
k=1;
}
newOff[i+k] = stco->offsets[i];
}
gf_free(stco->offsets);
stco->offsets = newOff;
stco->nb_entries ++;
stco->alloc_size = stco->nb_entries;
}
}
} else {
//use large offset...
co64 = (GF_ChunkLargeOffsetBox *)stbl->ChunkOffset;
if (sampleNumber > co64->nb_entries) {
if (!co64->alloc_size) co64->alloc_size = co64->nb_entries;
if (co64->nb_entries == co64->alloc_size) {
ALLOC_INC(co64->alloc_size);
co64->offsets = (u64*)gf_realloc(co64->offsets, sizeof(u64) * co64->alloc_size);
if (!co64->offsets) return GF_OUT_OF_MEM;
memset(&co64->offsets[co64->nb_entries], 0, sizeof(u64) * (co64->alloc_size - co64->nb_entries) );
}
co64->offsets[co64->nb_entries] = offset;
co64->nb_entries += 1;
} else {
//nope. we're inserting
newLarge = (u64*)gf_malloc(sizeof(u64) * (co64->nb_entries + 1));
if (!newLarge) return GF_OUT_OF_MEM;
k=0;
for (i=0; i<co64->nb_entries; i++) {
if (i+1 == new_chunk_idx) {
newLarge[i] = offset;
k=1;
}
newLarge[i+k] = co64->offsets[i];
}
gf_free(co64->offsets);
co64->offsets = newLarge;
co64->nb_entries++;
co64->alloc_size++;
}
}
return GF_OK;
} | 1530 | True | 1 |
CVE-2021-32439 | 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/gpac/gpac/issues/1774', 'name': 'https://github.com/gpac/gpac/issues/1774', 'refsource': 'MISC', 'tags': ['Exploit', 'Issue Tracking', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/77ed81c069e10b3861d88f72e1c6be1277ee7eae', 'name': 'https://github.com/gpac/gpac/commit/77ed81c069e10b3861d88f72e1c6be1277ee7eae', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-120'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Buffer overflow in the stbl_AppendSize function in MP4Box in GPAC 1.0.1 allows attackers to cause a denial of service or execute arbitrary code via a crafted file.'}] | 2021-08-16T17:32Z | 2021-08-11T20:15Z | Buffer Copy without Checking Size of Input ('Classic Buffer Overflow') | The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow. | A buffer overflow condition exists when a program attempts to put more data in a buffer than it can hold, or when a program attempts to put data in a memory area outside of the boundaries of a buffer. The simplest type of error, and the most common cause of buffer overflows, is the "classic" case in which the program copies the buffer without restricting how much is copied. Other variants exist, but the existence of a classic overflow strongly suggests that the programmer is not considering even the most basic of security protections.
| https://cwe.mitre.org/data/definitions/120.html | 0 | jeanlf | 2021-04-30 11:30:41+02:00 | fixed #1774 (fuzz) | 77ed81c069e10b3861d88f72e1c6be1277ee7eae | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | stbl_AddDTS | stbl_AddDTS( GF_SampleTableBox * stbl , u64 DTS , u32 * sampleNumber , u32 LastAUDefDuration , u32 nb_packed_samples) | ['stbl', 'DTS', 'sampleNumber', 'LastAUDefDuration', 'nb_packed_samples'] | GF_Err stbl_AddDTS(GF_SampleTableBox *stbl, u64 DTS, u32 *sampleNumber, u32 LastAUDefDuration, u32 nb_packed_samples)
{
u32 i, j, sampNum;
u64 *DTSs, curDTS;
Bool inserted;
GF_SttsEntry *ent;
GF_TimeToSampleBox *stts = stbl->TimeToSample;
//reset the reading cache when adding a sample
stts->r_FirstSampleInEntry = 0;
*sampleNumber = 0;
if (!nb_packed_samples)
nb_packed_samples=1;
//if we don't have an entry, that's the first one...
if (!stts->nb_entries) {
//assert the first DTS is 0. If not, that will break the whole file
if (DTS) return GF_BAD_PARAM;
stts->alloc_size = 1;
stts->nb_entries = 1;
stts->entries = gf_malloc(sizeof(GF_SttsEntry));
if (!stts->entries) return GF_OUT_OF_MEM;
stts->entries[0].sampleCount = nb_packed_samples;
stts->entries[0].sampleDelta = (nb_packed_samples>1) ? 0 : LastAUDefDuration;
(*sampleNumber) = 1;
stts->w_currentSampleNum = nb_packed_samples;
return GF_OK;
}
//check the last DTS - we allow 0-duration samples (same DTS)
if (DTS >= stts->w_LastDTS) {
u32 nb_extra = 0;
ent = &stts->entries[stts->nb_entries-1];
if (!ent->sampleDelta && (ent->sampleCount>1)) {
ent->sampleDelta = (u32) ( DTS / ent->sampleCount);
stts->w_LastDTS = DTS - ent->sampleDelta;
}
//OK, we're adding at the end
if ((DTS == stts->w_LastDTS + ent->sampleDelta)
//for raw audio, consider (dts==last_dts) and (dts==last_dts+2*delta) as sample append to cope with
//timescale vs samplerate precision
|| ((nb_packed_samples>1) && ((DTS == stts->w_LastDTS) || (DTS == stts->w_LastDTS + 2*ent->sampleDelta) ))
) {
(*sampleNumber) = stts->w_currentSampleNum + 1;
ent->sampleCount += nb_packed_samples;
stts->w_currentSampleNum += nb_packed_samples;
stts->w_LastDTS = DTS + ent->sampleDelta * (nb_packed_samples-1);
return GF_OK;
}
//we need to split the entry
if (ent->sampleCount == 1) {
//FIXME - we need more tests with timed text
#if 0
if (stts->w_LastDTS)
ent->sampleDelta += (u32) (DTS - stts->w_LastDTS);
else
ent->sampleDelta = (u32) DTS;
#else
//use this one and adjust...
ent->sampleDelta = (u32) (DTS - stts->w_LastDTS);
#endif
ent->sampleCount ++;
//little opt, merge last entry with previous one if same delta
if ((stts->nb_entries>=2) && (ent->sampleDelta== stts->entries[stts->nb_entries-2].sampleDelta)) {
stts->entries[stts->nb_entries-2].sampleCount += ent->sampleCount;
stts->nb_entries--;
}
stts->w_currentSampleNum ++;
stts->w_LastDTS = DTS;
(*sampleNumber) = stts->w_currentSampleNum;
return GF_OK;
}
//we definitely need to split the entry ;)
ent->sampleCount --;
if (nb_packed_samples>1)
nb_extra = 1;
if (stts->alloc_size <= stts->nb_entries + nb_extra) {
ALLOC_INC(stts->alloc_size);
stts->entries = gf_realloc(stts->entries, sizeof(GF_SttsEntry)*stts->alloc_size);
if (!stts->entries) return GF_OUT_OF_MEM;
memset(&stts->entries[stts->nb_entries], 0, sizeof(GF_SttsEntry)*(stts->alloc_size-stts->nb_entries) );
}
if (nb_extra)
nb_extra = stts->entries[stts->nb_entries-1].sampleDelta;
ent = &stts->entries[stts->nb_entries];
stts->nb_entries++;
if (nb_packed_samples==1) {
ent->sampleCount = 2;
ent->sampleDelta = (u32) (DTS - stts->w_LastDTS);
stts->w_LastDTS = DTS;
(*sampleNumber) = stts->w_currentSampleNum+1;
stts->w_currentSampleNum += 1;
return GF_OK;
}
ent->sampleCount = 1;
ent->sampleDelta = (u32) (DTS - stts->w_LastDTS);
ent = &stts->entries[stts->nb_entries];
stts->nb_entries++;
ent->sampleCount = nb_packed_samples;
ent->sampleDelta = nb_extra;
stts->w_LastDTS = DTS;
(*sampleNumber) = stts->w_currentSampleNum + 1;
stts->w_currentSampleNum += nb_packed_samples;
return GF_OK;
}
//unpack the DTSs and locate new sample...
DTSs = (u64*)gf_malloc(sizeof(u64) * (stbl->SampleSize->sampleCount+2) );
if (!DTSs) return GF_OUT_OF_MEM;
curDTS = 0;
sampNum = 0;
ent = NULL;
inserted = 0;
for (i=0; i<stts->nb_entries; i++) {
ent = & stts->entries[i];
for (j = 0; j<ent->sampleCount; j++) {
if (!inserted && (curDTS > DTS)) {
DTSs[sampNum] = DTS;
sampNum++;
*sampleNumber = sampNum;
inserted = 1;
}
DTSs[sampNum] = curDTS;
curDTS += ent->sampleDelta;
sampNum ++;
}
}
if (!inserted) {
gf_free(DTSs);
return GF_BAD_PARAM;
}
/*we will at most insert 3 new entries*/
if (stts->nb_entries+3 >= stts->alloc_size) {
stts->alloc_size += 3;
stts->entries = gf_realloc(stts->entries, sizeof(GF_SttsEntry)*stts->alloc_size);
if (!stts->entries) return GF_OUT_OF_MEM;
memset(&stts->entries[stts->nb_entries], 0, sizeof(GF_SttsEntry)*(stts->alloc_size - stts->nb_entries) );
}
/*repack the DTSs*/
j=0;
stts->nb_entries = 1;
stts->entries[0].sampleCount = 1;
stts->entries[0].sampleDelta = (u32) DTSs[1] /* - (DTS[0] which is 0)*/;
for (i=1; i<stbl->SampleSize->sampleCount+1; i++) {
if (i == stbl->SampleSize->sampleCount) {
//and by default, our last sample has the same delta as the prev
stts->entries[j].sampleCount++;
} else if (stts->entries[j].sampleDelta == (u32) ( DTSs[i+1] - DTSs[i]) ) {
stts->entries[j].sampleCount ++;
} else {
stts->nb_entries ++;
j++;
stts->entries[j].sampleCount = 1;
stts->entries[j].sampleDelta = (u32) (DTSs[i+1] - DTSs[i]);
}
}
gf_free(DTSs);
//reset the cache to the end
stts->w_currentSampleNum = stbl->SampleSize->sampleCount + 1;
return GF_OK;
} | 1151 | True | 1 |
CVE-2021-32439 | 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/gpac/gpac/issues/1774', 'name': 'https://github.com/gpac/gpac/issues/1774', 'refsource': 'MISC', 'tags': ['Exploit', 'Issue Tracking', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/77ed81c069e10b3861d88f72e1c6be1277ee7eae', 'name': 'https://github.com/gpac/gpac/commit/77ed81c069e10b3861d88f72e1c6be1277ee7eae', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-120'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Buffer overflow in the stbl_AppendSize function in MP4Box in GPAC 1.0.1 allows attackers to cause a denial of service or execute arbitrary code via a crafted file.'}] | 2021-08-16T17:32Z | 2021-08-11T20:15Z | Buffer Copy without Checking Size of Input ('Classic Buffer Overflow') | The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow. | A buffer overflow condition exists when a program attempts to put more data in a buffer than it can hold, or when a program attempts to put data in a memory area outside of the boundaries of a buffer. The simplest type of error, and the most common cause of buffer overflows, is the "classic" case in which the program copies the buffer without restricting how much is copied. Other variants exist, but the existence of a classic overflow strongly suggests that the programmer is not considering even the most basic of security protections.
| https://cwe.mitre.org/data/definitions/120.html | 0 | jeanlf | 2021-04-30 11:30:41+02:00 | fixed #1774 (fuzz) | 77ed81c069e10b3861d88f72e1c6be1277ee7eae | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | stbl_AddSize | stbl_AddSize( GF_SampleSizeBox * stsz , u32 sampleNumber , u32 size , u32 nb_pack_samples) | ['stsz', 'sampleNumber', 'size', 'nb_pack_samples'] | GF_Err stbl_AddSize(GF_SampleSizeBox *stsz, u32 sampleNumber, u32 size, u32 nb_pack_samples)
{
u32 i, k;
u32 *newSizes;
if (!stsz /*|| !size */ || !sampleNumber) return GF_BAD_PARAM;
if (sampleNumber > stsz->sampleCount + 1) return GF_BAD_PARAM;
if (!nb_pack_samples) nb_pack_samples = 1;
else if (nb_pack_samples>1)
size /= nb_pack_samples;
//all samples have the same size
if (stsz->sizes == NULL) {
//1 first sample added in NON COMPACT MODE
if (! stsz->sampleCount && (stsz->type != GF_ISOM_BOX_TYPE_STZ2) ) {
stsz->sampleCount = nb_pack_samples;
stsz->sampleSize = size;
return GF_OK;
}
//2- sample has the same size
if (stsz->sampleSize == size) {
stsz->sampleCount += nb_pack_samples;
return GF_OK;
}
if (nb_pack_samples>1) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Inserting packed samples with different sizes is not yet supported\n" ));
return GF_NOT_SUPPORTED;
}
//3- no, need to alloc a size table
stsz->sizes = (u32*)gf_malloc(sizeof(u32) * (stsz->sampleCount + 1));
if (!stsz->sizes) return GF_OUT_OF_MEM;
stsz->alloc_size = stsz->sampleCount + 1;
k = 0;
for (i = 0 ; i < stsz->sampleCount; i++) {
if (i + 1 == sampleNumber) {
stsz->sizes[i + k] = size;
k = 1;
}
stsz->sizes[i+k] = stsz->sampleSize;
}
//this if we append a new sample
if (stsz->sampleCount + 1 == sampleNumber) {
stsz->sizes[stsz->sampleCount] = size;
}
stsz->sampleSize = 0;
stsz->sampleCount++;
return GF_OK;
}
/*append*/
if (stsz->sampleCount + 1 == sampleNumber) {
if (!stsz->alloc_size) stsz->alloc_size = stsz->sampleCount;
if (stsz->sampleCount == stsz->alloc_size) {
ALLOC_INC(stsz->alloc_size);
stsz->sizes = gf_realloc(stsz->sizes, sizeof(u32)*(stsz->alloc_size) );
if (!stsz->sizes) return GF_OUT_OF_MEM;
memset(&stsz->sizes[stsz->sampleCount], 0, sizeof(u32)*(stsz->alloc_size - stsz->sampleCount) );
}
stsz->sizes[stsz->sampleCount] = size;
} else {
newSizes = (u32*)gf_malloc(sizeof(u32)*(1 + stsz->sampleCount) );
if (!newSizes) return GF_OUT_OF_MEM;
k = 0;
for (i = 0; i < stsz->sampleCount; i++) {
if (i + 1 == sampleNumber) {
newSizes[i + k] = size;
k = 1;
}
newSizes[i + k] = stsz->sizes[i];
}
gf_free(stsz->sizes);
stsz->sizes = newSizes;
stsz->alloc_size = 1 + stsz->sampleCount;
}
stsz->sampleCount++;
return GF_OK;
} | 535 | True | 1 |
CVE-2021-32439 | 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/gpac/gpac/issues/1774', 'name': 'https://github.com/gpac/gpac/issues/1774', 'refsource': 'MISC', 'tags': ['Exploit', 'Issue Tracking', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/77ed81c069e10b3861d88f72e1c6be1277ee7eae', 'name': 'https://github.com/gpac/gpac/commit/77ed81c069e10b3861d88f72e1c6be1277ee7eae', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-120'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Buffer overflow in the stbl_AppendSize function in MP4Box in GPAC 1.0.1 allows attackers to cause a denial of service or execute arbitrary code via a crafted file.'}] | 2021-08-16T17:32Z | 2021-08-11T20:15Z | Buffer Copy without Checking Size of Input ('Classic Buffer Overflow') | The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow. | A buffer overflow condition exists when a program attempts to put more data in a buffer than it can hold, or when a program attempts to put data in a memory area outside of the boundaries of a buffer. The simplest type of error, and the most common cause of buffer overflows, is the "classic" case in which the program copies the buffer without restricting how much is copied. Other variants exist, but the existence of a classic overflow strongly suggests that the programmer is not considering even the most basic of security protections.
| https://cwe.mitre.org/data/definitions/120.html | 0 | jeanlf | 2021-04-30 11:30:41+02:00 | fixed #1774 (fuzz) | 77ed81c069e10b3861d88f72e1c6be1277ee7eae | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | stbl_AppendSize | stbl_AppendSize( GF_SampleTableBox * stbl , u32 size , u32 nb_pack) | ['stbl', 'size', 'nb_pack'] | GF_Err stbl_AppendSize(GF_SampleTableBox *stbl, u32 size, u32 nb_pack)
{
u32 i;
if (!nb_pack) nb_pack = 1;
if (!stbl->SampleSize->sampleCount) {
stbl->SampleSize->sampleSize = size;
stbl->SampleSize->sampleCount += nb_pack;
return GF_OK;
}
if (stbl->SampleSize->sampleSize && (stbl->SampleSize->sampleSize==size)) {
stbl->SampleSize->sampleCount += nb_pack;
return GF_OK;
}
if (!stbl->SampleSize->sizes || (stbl->SampleSize->sampleCount+nb_pack > stbl->SampleSize->alloc_size)) {
Bool init_table = (stbl->SampleSize->sizes==NULL) ? 1 : 0;
ALLOC_INC(stbl->SampleSize->alloc_size);
if (stbl->SampleSize->sampleCount+nb_pack > stbl->SampleSize->alloc_size)
stbl->SampleSize->alloc_size = stbl->SampleSize->sampleCount+nb_pack;
stbl->SampleSize->sizes = (u32 *)gf_realloc(stbl->SampleSize->sizes, sizeof(u32)*stbl->SampleSize->alloc_size);
if (!stbl->SampleSize->sizes) return GF_OUT_OF_MEM;
memset(&stbl->SampleSize->sizes[stbl->SampleSize->sampleCount], 0, sizeof(u32) * (stbl->SampleSize->alloc_size - stbl->SampleSize->sampleCount) );
if (init_table) {
for (i=0; i<stbl->SampleSize->sampleCount; i++)
stbl->SampleSize->sizes[i] = stbl->SampleSize->sampleSize;
}
}
stbl->SampleSize->sampleSize = 0;
for (i=0; i<nb_pack; i++) {
stbl->SampleSize->sizes[stbl->SampleSize->sampleCount+i] = size;
}
stbl->SampleSize->sampleCount += nb_pack;
if (size > stbl->SampleSize->max_size)
stbl->SampleSize->max_size = size;
stbl->SampleSize->total_size += size;
stbl->SampleSize->total_samples += nb_pack;
return GF_OK;
} | 373 | True | 1 |
CVE-2021-32439 | 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/gpac/gpac/issues/1774', 'name': 'https://github.com/gpac/gpac/issues/1774', 'refsource': 'MISC', 'tags': ['Exploit', 'Issue Tracking', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/77ed81c069e10b3861d88f72e1c6be1277ee7eae', 'name': 'https://github.com/gpac/gpac/commit/77ed81c069e10b3861d88f72e1c6be1277ee7eae', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-120'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Buffer overflow in the stbl_AppendSize function in MP4Box in GPAC 1.0.1 allows attackers to cause a denial of service or execute arbitrary code via a crafted file.'}] | 2021-08-16T17:32Z | 2021-08-11T20:15Z | Buffer Copy without Checking Size of Input ('Classic Buffer Overflow') | The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow. | A buffer overflow condition exists when a program attempts to put more data in a buffer than it can hold, or when a program attempts to put data in a memory area outside of the boundaries of a buffer. The simplest type of error, and the most common cause of buffer overflows, is the "classic" case in which the program copies the buffer without restricting how much is copied. Other variants exist, but the existence of a classic overflow strongly suggests that the programmer is not considering even the most basic of security protections.
| https://cwe.mitre.org/data/definitions/120.html | 0 | jeanlf | 2021-04-30 11:30:41+02:00 | fixed #1774 (fuzz) | 77ed81c069e10b3861d88f72e1c6be1277ee7eae | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | stbl_AppendTime | stbl_AppendTime( GF_SampleTableBox * stbl , u32 duration , u32 nb_pack) | ['stbl', 'duration', 'nb_pack'] | GF_Err stbl_AppendTime(GF_SampleTableBox *stbl, u32 duration, u32 nb_pack)
{
GF_TimeToSampleBox *stts = stbl->TimeToSample;
if (!nb_pack) nb_pack = 1;
if (stts->nb_entries) {
if (stts->entries[stts->nb_entries-1].sampleDelta == duration) {
stts->entries[stts->nb_entries-1].sampleCount += nb_pack;
return GF_OK;
}
}
if (stts->nb_entries==stts->alloc_size) {
ALLOC_INC(stts->alloc_size);
stts->entries = gf_realloc(stts->entries, sizeof(GF_SttsEntry)*stts->alloc_size);
if (!stts->entries) return GF_OUT_OF_MEM;
memset(&stts->entries[stts->nb_entries], 0, sizeof(GF_SttsEntry)*(stts->alloc_size-stts->nb_entries) );
}
stts->entries[stts->nb_entries].sampleCount = nb_pack;
stts->entries[stts->nb_entries].sampleDelta = duration;
stts->nb_entries++;
if (stts->max_ts_delta < duration ) stts->max_ts_delta = duration;
return GF_OK;
} | 203 | True | 1 |
CVE-2021-33361 | 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/gpac/gpac/issues/1782', 'name': 'https://github.com/gpac/gpac/issues/1782', 'refsource': 'MISC', 'tags': ['Exploit', 'Issue Tracking', 'Patch', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/a51f951b878c2b73c1d8e2f1518c7cdc5fb82c3f', 'name': 'https://github.com/gpac/gpac/commit/a51f951b878c2b73c1d8e2f1518c7cdc5fb82c3f', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-401'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Memory leak in the afra_box_read function in MP4Box in GPAC 1.0.1 allows attackers to read memory via a crafted file.'}] | 2022-05-03T16:04Z | 2021-09-13T20:15Z | Missing Release of Memory after Effective Lifetime | The software does not sufficiently track and release allocated memory after it has been used, which slowly consumes remaining memory. | This is often triggered by improper handling of malformed data or unexpectedly interrupted sessions. In some languages, developers are responsible for tracking memory allocation and releasing the memory. If there are no more pointers or references to the memory, then it can no longer be tracked and identified for release.
| https://cwe.mitre.org/data/definitions/401.html | 0 | jeanlf | 2021-05-10 11:14:03+02:00 | fixed #1782 (fuzz) | a51f951b878c2b73c1d8e2f1518c7cdc5fb82c3f | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | afra_box_read | afra_box_read( GF_Box * s , GF_BitStream * bs) | ['s', 'bs'] | GF_Err afra_box_read(GF_Box *s, GF_BitStream *bs)
{
unsigned int i;
GF_AdobeFragRandomAccessBox *ptr = (GF_AdobeFragRandomAccessBox *)s;
ISOM_DECREASE_SIZE(ptr, 9)
ptr->long_ids = gf_bs_read_int(bs, 1);
ptr->long_offsets = gf_bs_read_int(bs, 1);
ptr->global_entries = gf_bs_read_int(bs, 1);
ptr->reserved = gf_bs_read_int(bs, 5);
ptr->time_scale = gf_bs_read_u32(bs);
ptr->entry_count = gf_bs_read_u32(bs);
if (ptr->size / ( (ptr->long_offsets ? 16 : 12) ) < ptr->entry_count)
return GF_ISOM_INVALID_FILE;
for (i=0; i<ptr->entry_count; i++) {
GF_AfraEntry *ae = gf_malloc(sizeof(GF_AfraEntry));
if (!ae) return GF_OUT_OF_MEM;
ISOM_DECREASE_SIZE(ptr, 8)
ae->time = gf_bs_read_u64(bs);
if (ptr->long_offsets) {
ISOM_DECREASE_SIZE(ptr, 8)
ae->offset = gf_bs_read_u64(bs);
} else {
ISOM_DECREASE_SIZE(ptr, 4)
ae->offset = gf_bs_read_u32(bs);
}
gf_list_insert(ptr->local_access_entries, ae, i);
}
if (ptr->global_entries) {
ISOM_DECREASE_SIZE(ptr, 4)
ptr->global_entry_count = gf_bs_read_u32(bs);
for (i=0; i<ptr->global_entry_count; i++) {
GF_GlobalAfraEntry *ae = gf_malloc(sizeof(GF_GlobalAfraEntry));
if (!ae) return GF_OUT_OF_MEM;
ISOM_DECREASE_SIZE(ptr, 8)
ae->time = gf_bs_read_u64(bs);
if (ptr->long_ids) {
ISOM_DECREASE_SIZE(ptr, 8)
ae->segment = gf_bs_read_u32(bs);
ae->fragment = gf_bs_read_u32(bs);
} else {
ISOM_DECREASE_SIZE(ptr, 4)
ae->segment = gf_bs_read_u16(bs);
ae->fragment = gf_bs_read_u16(bs);
}
if (ptr->long_offsets) {
ISOM_DECREASE_SIZE(ptr, 16)
ae->afra_offset = gf_bs_read_u64(bs);
ae->offset_from_afra = gf_bs_read_u64(bs);
} else {
ISOM_DECREASE_SIZE(ptr, 8)
ae->afra_offset = gf_bs_read_u32(bs);
ae->offset_from_afra = gf_bs_read_u32(bs);
}
gf_list_insert(ptr->global_access_entries, ae, i);
}
}
return GF_OK;
} | 430 | True | 1 |
CVE-2021-33365 | 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/gpac/gpac/issues/1784', 'name': 'https://github.com/gpac/gpac/issues/1784', 'refsource': 'MISC', 'tags': ['Issue Tracking', 'Patch', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/984787de3d414a5f7d43d0b4584d9469dff2a5a5', 'name': 'https://github.com/gpac/gpac/commit/984787de3d414a5f7d43d0b4584d9469dff2a5a5', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-401'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Memory leak in the gf_isom_get_root_od function in MP4Box in GPAC 1.0.1 allows attackers to read memory via a crafted file.'}] | 2022-05-03T16:04Z | 2021-09-13T20:15Z | Missing Release of Memory after Effective Lifetime | The software does not sufficiently track and release allocated memory after it has been used, which slowly consumes remaining memory. | This is often triggered by improper handling of malformed data or unexpectedly interrupted sessions. In some languages, developers are responsible for tracking memory allocation and releasing the memory. If there are no more pointers or references to the memory, then it can no longer be tracked and identified for release.
| https://cwe.mitre.org/data/definitions/401.html | 0 | jeanlf | 2021-05-10 11:24:17+02:00 | fixed #1784 (fuzz) | 984787de3d414a5f7d43d0b4584d9469dff2a5a5 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_isom_get_root_od | gf_isom_get_root_od( GF_ISOFile * movie) | ['movie'] | GF_Descriptor *gf_isom_get_root_od(GF_ISOFile *movie)
{
GF_Descriptor *desc;
GF_ObjectDescriptor *od;
GF_InitialObjectDescriptor *iod;
GF_IsomObjectDescriptor *isom_od;
GF_IsomInitialObjectDescriptor *isom_iod;
GF_ESD *esd;
GF_ES_ID_Inc *inc;
u32 i;
u8 useIOD;
if (!movie || !movie->moov) return NULL;
if (!movie->moov->iods) return NULL;
if (movie->disable_odf_translate) {
//duplicate our descriptor
movie->LastError = gf_odf_desc_copy((GF_Descriptor *) movie->moov->iods->descriptor, &desc);
if (movie->LastError) return NULL;
return desc;
}
od = NULL;
iod = NULL;
switch (movie->moov->iods->descriptor->tag) {
case GF_ODF_ISOM_OD_TAG:
od = (GF_ObjectDescriptor*)gf_malloc(sizeof(GF_ObjectDescriptor));
if (!od) return NULL;
memset(od, 0, sizeof(GF_ObjectDescriptor));
od->ESDescriptors = gf_list_new();
useIOD = 0;
break;
case GF_ODF_ISOM_IOD_TAG:
iod = (GF_InitialObjectDescriptor*)gf_malloc(sizeof(GF_InitialObjectDescriptor));
if (!iod) return NULL;
memset(iod, 0, sizeof(GF_InitialObjectDescriptor));
iod->ESDescriptors = gf_list_new();
useIOD = 1;
break;
default:
return NULL;
}
//duplicate our descriptor
movie->LastError = gf_odf_desc_copy((GF_Descriptor *) movie->moov->iods->descriptor, &desc);
if (movie->LastError) return NULL;
if (!useIOD) {
isom_od = (GF_IsomObjectDescriptor *)desc;
od->objectDescriptorID = isom_od->objectDescriptorID;
od->extensionDescriptors = isom_od->extensionDescriptors;
isom_od->extensionDescriptors = NULL;
od->IPMP_Descriptors = isom_od->IPMP_Descriptors;
isom_od->IPMP_Descriptors = NULL;
od->OCIDescriptors = isom_od->OCIDescriptors;
isom_od->OCIDescriptors = NULL;
od->URLString = isom_od->URLString;
isom_od->URLString = NULL;
od->tag = GF_ODF_OD_TAG;
//then recreate the desc in Inc
i=0;
while ((inc = (GF_ES_ID_Inc*)gf_list_enum(isom_od->ES_ID_IncDescriptors, &i))) {
movie->LastError = GetESDForTime(movie->moov, inc->trackID, 0, &esd);
if (!movie->LastError) movie->LastError = gf_list_add(od->ESDescriptors, esd);
if (movie->LastError) {
gf_odf_desc_del(desc);
gf_odf_desc_del((GF_Descriptor *) od);
return NULL;
}
}
gf_odf_desc_del(desc);
return (GF_Descriptor *)od;
} else {
isom_iod = (GF_IsomInitialObjectDescriptor *)desc;
iod->objectDescriptorID = isom_iod->objectDescriptorID;
iod->extensionDescriptors = isom_iod->extensionDescriptors;
isom_iod->extensionDescriptors = NULL;
iod->IPMP_Descriptors = isom_iod->IPMP_Descriptors;
isom_iod->IPMP_Descriptors = NULL;
iod->OCIDescriptors = isom_iod->OCIDescriptors;
isom_iod->OCIDescriptors = NULL;
iod->URLString = isom_iod->URLString;
isom_iod->URLString = NULL;
iod->tag = GF_ODF_IOD_TAG;
iod->audio_profileAndLevel = isom_iod->audio_profileAndLevel;
iod->graphics_profileAndLevel = isom_iod->graphics_profileAndLevel;
iod->inlineProfileFlag = isom_iod->inlineProfileFlag;
iod->OD_profileAndLevel = isom_iod->OD_profileAndLevel;
iod->scene_profileAndLevel = isom_iod->scene_profileAndLevel;
iod->visual_profileAndLevel = isom_iod->visual_profileAndLevel;
iod->IPMPToolList = isom_iod->IPMPToolList;
isom_iod->IPMPToolList = NULL;
//then recreate the desc in Inc
i=0;
while ((inc = (GF_ES_ID_Inc*)gf_list_enum(isom_iod->ES_ID_IncDescriptors, &i))) {
movie->LastError = GetESDForTime(movie->moov, inc->trackID, 0, &esd);
if (!movie->LastError) movie->LastError = gf_list_add(iod->ESDescriptors, esd);
if (movie->LastError) {
gf_odf_desc_del(desc);
gf_odf_desc_del((GF_Descriptor *) iod);
return NULL;
}
}
gf_odf_desc_del(desc);
return (GF_Descriptor *)iod;
}
} | 703 | True | 1 |
CVE-2021-33366 | 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/gpac/gpac/issues/1785', 'name': 'https://github.com/gpac/gpac/issues/1785', 'refsource': 'MISC', 'tags': ['Exploit', 'Issue Tracking', 'Patch', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/0a85029d694f992f3631e2f249e4999daee15cbf', 'name': 'https://github.com/gpac/gpac/commit/0a85029d694f992f3631e2f249e4999daee15cbf', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-401'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Memory leak in the gf_isom_oinf_read_entry function in MP4Box in GPAC 1.0.1 allows attackers to read memory via a crafted file.'}] | 2021-09-23T19:01Z | 2021-09-13T19:15Z | Missing Release of Memory after Effective Lifetime | The software does not sufficiently track and release allocated memory after it has been used, which slowly consumes remaining memory. | This is often triggered by improper handling of malformed data or unexpectedly interrupted sessions. In some languages, developers are responsible for tracking memory allocation and releasing the memory. If there are no more pointers or references to the memory, then it can no longer be tracked and identified for release.
| https://cwe.mitre.org/data/definitions/401.html | 0 | jeanlf | 2021-05-10 11:26:57+02:00 | fixed #1785 (fuzz) | 0a85029d694f992f3631e2f249e4999daee15cbf | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_isom_oinf_read_entry | gf_isom_oinf_read_entry( void * entry , GF_BitStream * bs) | ['entry', 'bs'] | GF_Err gf_isom_oinf_read_entry(void *entry, GF_BitStream *bs)
{
GF_OperatingPointsInformation* ptr = (GF_OperatingPointsInformation *)entry;
u32 i, j, count;
if (!ptr) return GF_BAD_PARAM;
ptr->scalability_mask = gf_bs_read_u16(bs);
gf_bs_read_int(bs, 2);//reserved
count = gf_bs_read_int(bs, 6);
for (i = 0; i < count; i++) {
LHEVC_ProfileTierLevel *ptl;
GF_SAFEALLOC(ptl, LHEVC_ProfileTierLevel);
if (!ptl) return GF_OUT_OF_MEM;
ptl->general_profile_space = gf_bs_read_int(bs, 2);
ptl->general_tier_flag= gf_bs_read_int(bs, 1);
ptl->general_profile_idc = gf_bs_read_int(bs, 5);
ptl->general_profile_compatibility_flags = gf_bs_read_u32(bs);
ptl->general_constraint_indicator_flags = gf_bs_read_long_int(bs, 48);
ptl->general_level_idc = gf_bs_read_u8(bs);
gf_list_add(ptr->profile_tier_levels, ptl);
}
count = gf_bs_read_u16(bs);
for (i = 0; i < count; i++) {
LHEVC_OperatingPoint *op;
GF_SAFEALLOC(op, LHEVC_OperatingPoint);
if (!op) return GF_OUT_OF_MEM;
op->output_layer_set_idx = gf_bs_read_u16(bs);
op->max_temporal_id = gf_bs_read_u8(bs);
op->layer_count = gf_bs_read_u8(bs);
if (op->layer_count > GF_ARRAY_LENGTH(op->layers_info))
return GF_NON_COMPLIANT_BITSTREAM;
for (j = 0; j < op->layer_count; j++) {
op->layers_info[j].ptl_idx = gf_bs_read_u8(bs);
op->layers_info[j].layer_id = gf_bs_read_int(bs, 6);
op->layers_info[j].is_outputlayer = gf_bs_read_int(bs, 1) ? GF_TRUE : GF_FALSE;
op->layers_info[j].is_alternate_outputlayer = gf_bs_read_int(bs, 1) ? GF_TRUE : GF_FALSE;
}
op->minPicWidth = gf_bs_read_u16(bs);
op->minPicHeight = gf_bs_read_u16(bs);
op->maxPicWidth = gf_bs_read_u16(bs);
op->maxPicHeight = gf_bs_read_u16(bs);
op->maxChromaFormat = gf_bs_read_int(bs, 2);
op->maxBitDepth = gf_bs_read_int(bs, 3) + 8;
gf_bs_read_int(bs, 1);//reserved
op->frame_rate_info_flag = gf_bs_read_int(bs, 1) ? GF_TRUE : GF_FALSE;
op->bit_rate_info_flag = gf_bs_read_int(bs, 1) ? GF_TRUE : GF_FALSE;
if (op->frame_rate_info_flag) {
op->avgFrameRate = gf_bs_read_u16(bs);
gf_bs_read_int(bs, 6); //reserved
op->constantFrameRate = gf_bs_read_int(bs, 2);
}
if (op->bit_rate_info_flag) {
op->maxBitRate = gf_bs_read_u32(bs);
op->avgBitRate = gf_bs_read_u32(bs);
}
gf_list_add(ptr->operating_points, op);
}
count = gf_bs_read_u8(bs);
for (i = 0; i < count; i++) {
LHEVC_DependentLayer *dep;
GF_SAFEALLOC(dep, LHEVC_DependentLayer);
if (!dep) return GF_OUT_OF_MEM;
dep->dependent_layerID = gf_bs_read_u8(bs);
dep->num_layers_dependent_on = gf_bs_read_u8(bs);
if (dep->num_layers_dependent_on > GF_ARRAY_LENGTH(dep->dependent_on_layerID)) {
gf_free(dep);
return GF_NON_COMPLIANT_BITSTREAM;
}
for (j = 0; j < dep->num_layers_dependent_on; j++)
dep->dependent_on_layerID[j] = gf_bs_read_u8(bs);
for (j = 0; j < 16; j++) {
if (ptr->scalability_mask & (1 << j))
dep->dimension_identifier[j] = gf_bs_read_u8(bs);
}
gf_list_add(ptr->dependency_layers, dep);
}
return GF_OK;
} | 666 | True | 1 |
CVE-2021-33363 | 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/gpac/gpac/issues/1786', 'name': 'https://github.com/gpac/gpac/issues/1786', 'refsource': 'MISC', 'tags': ['Issue Tracking', 'Patch', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/commit/ec64c7b8966d7e4642d12debb888be5acf18efb9', 'name': 'https://github.com/gpac/gpac/commit/ec64c7b8966d7e4642d12debb888be5acf18efb9', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'CWE-401'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:1.0.1:*:*:*:*:*:*:*', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Memory leak in the infe_box_read function in MP4Box in GPAC 1.0.1 allows attackers to read memory via a crafted file.'}] | 2022-05-03T16:04Z | 2021-09-13T20:15Z | Missing Release of Memory after Effective Lifetime | The software does not sufficiently track and release allocated memory after it has been used, which slowly consumes remaining memory. | This is often triggered by improper handling of malformed data or unexpectedly interrupted sessions. In some languages, developers are responsible for tracking memory allocation and releasing the memory. If there are no more pointers or references to the memory, then it can no longer be tracked and identified for release.
| https://cwe.mitre.org/data/definitions/401.html | 0 | jeanlf | 2021-05-10 11:31:19+02:00 | fixed #1786 (fuzz) | ec64c7b8966d7e4642d12debb888be5acf18efb9 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | infe_box_read | infe_box_read( GF_Box * s , GF_BitStream * bs) | ['s', 'bs'] | GF_Err infe_box_read(GF_Box *s, GF_BitStream *bs)
{
char *buf;
u32 buf_len, i, string_len, string_start;
GF_ItemInfoEntryBox *ptr = (GF_ItemInfoEntryBox *)s;
ISOM_DECREASE_SIZE(ptr, 4);
ptr->item_ID = gf_bs_read_u16(bs);
ptr->item_protection_index = gf_bs_read_u16(bs);
if (ptr->version == 2) {
ISOM_DECREASE_SIZE(ptr, 4);
ptr->item_type = gf_bs_read_u32(bs);
}
buf_len = (u32) (ptr->size);
buf = (char*)gf_malloc(buf_len);
if (!buf) return GF_OUT_OF_MEM;
if (buf_len != gf_bs_read_data(bs, buf, buf_len)) {
gf_free(buf);
return GF_ISOM_INVALID_FILE;
}
string_len = 1;
string_start = 0;
for (i = 0; i < buf_len; i++) {
if (buf[i] == 0) {
if (!ptr->item_name) {
ptr->item_name = (char*)gf_malloc(sizeof(char)*string_len);
if (!ptr->item_name) return GF_OUT_OF_MEM;
memcpy(ptr->item_name, buf+string_start, string_len);
} else if (!ptr->content_type) {
ptr->content_type = (char*)gf_malloc(sizeof(char)*string_len);
if (!ptr->content_type) return GF_OUT_OF_MEM;
memcpy(ptr->content_type, buf+string_start, string_len);
} else {
ptr->content_encoding = (char*)gf_malloc(sizeof(char)*string_len);
if (!ptr->content_encoding) return GF_OUT_OF_MEM;
memcpy(ptr->content_encoding, buf+string_start, string_len);
}
string_start += string_len;
string_len = 0;
if (ptr->content_encoding && ptr->version == 1) {
break;
}
}
string_len++;
}
gf_free(buf);
if (!ptr->item_name || (!ptr->content_type && ptr->version < 2)) {
GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[isoff] Infe without name or content type !\n"));
}
return GF_OK;
} | 386 | True | 1 |
CVE-2021-40567 | 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/gpac/gpac/commit/f5a038e6893019ee471b6a57490cf7a495673816', 'name': 'https://github.com/gpac/gpac/commit/f5a038e6893019ee471b6a57490cf7a495673816', 'refsource': 'MISC', 'tags': ['Patch', 'Third Party Advisory']}, {'url': 'https://github.com/gpac/gpac/issues/1889', 'name': 'https://github.com/gpac/gpac/issues/1889', 'refsource': 'MISC', 'tags': ['Exploit', 'Issue Tracking', 'Third Party Advisory']}] | [{'description': [{'lang': 'en', 'value': 'NVD-CWE-noinfo'}]}] | MEDIUM | [{'operator': 'OR', 'children': [], 'cpe_match': [{'vulnerable': True, 'cpe23Uri': 'cpe:2.3:a:gpac:gpac:*:*:*:*:*:*:*:*', 'versionEndIncluding': '1.0.1', 'cpe_name': []}]}] | [{'lang': 'en', 'value': 'Segmentation fault vulnerability exists in Gpac through 1.0.1 via the gf_odf_size_descriptor function in desc_private.c when using mp4box, which causes a denial of service.'}] | 2022-01-14T16:30Z | 2022-01-13T18:15Z | Insufficient Information | There is insufficient information about the issue to classify it; details are unkown or unspecified. | Insufficient Information | https://nvd.nist.gov/vuln/categories | 0 | jeanlf | 2021-08-30 14:53:51+02:00 | fixed #1885 | f5a038e6893019ee471b6a57490cf7a495673816 | False | gpac/gpac | Modular Multimedia framework for packaging, streaming and playing your favorite content. | 2014-05-03 11:29:57 | 2022-08-01 15:00:31 | http://gpac.io | gpac | 1911.0 | 427.0 | gf_hinter_finalize | gf_hinter_finalize( GF_ISOFile * file , GF_SDP_IODProfile IOD_Profile , u32 bandwidth) | ['file', 'IOD_Profile', 'bandwidth'] | GF_Err gf_hinter_finalize(GF_ISOFile *file, GF_SDP_IODProfile IOD_Profile, u32 bandwidth)
{
u32 i, sceneT, odT, descIndex, size, size64;
GF_InitialObjectDescriptor *iod;
GF_SLConfig slc;
GF_ISOSample *samp;
Bool remove_ocr;
u8 *buffer;
char buf64[5000], sdpLine[5100];
gf_isom_sdp_clean(file);
if (bandwidth) {
sprintf(buf64, "b=AS:%d", bandwidth);
gf_isom_sdp_add_line(file, buf64);
}
//xtended attribute for copyright
if (gf_sys_is_test_mode()) {
sprintf(buf64, "a=x-copyright: %s", "MP4/3GP File hinted with GPAC - (c) Telecom ParisTech (http://gpac.io)");
} else {
sprintf(buf64, "a=x-copyright: MP4/3GP File hinted with GPAC %s - %s", gf_gpac_version(), gf_gpac_copyright() );
}
gf_isom_sdp_add_line(file, buf64);
if (IOD_Profile == GF_SDP_IOD_NONE) return GF_OK;
odT = sceneT = 0;
for (i=0; i<gf_isom_get_track_count(file); i++) {
if (!gf_isom_is_track_in_root_od(file, i+1)) continue;
switch (gf_isom_get_media_type(file,i+1)) {
case GF_ISOM_MEDIA_OD:
odT = i+1;
break;
case GF_ISOM_MEDIA_SCENE:
sceneT = i+1;
break;
}
}
remove_ocr = 0;
if (IOD_Profile == GF_SDP_IOD_ISMA_STRICT) {
IOD_Profile = GF_SDP_IOD_ISMA;
remove_ocr = 1;
}
/*if we want ISMA like iods, we need at least BIFS */
if ( (IOD_Profile == GF_SDP_IOD_ISMA) && !sceneT ) return GF_BAD_PARAM;
/*do NOT change PLs, we assume they are correct*/
iod = (GF_InitialObjectDescriptor *) gf_isom_get_root_od(file);
if (!iod) return GF_NOT_SUPPORTED;
/*rewrite an IOD with good SL config - embbed data if possible*/
if (IOD_Profile == GF_SDP_IOD_ISMA) {
GF_ESD *esd;
Bool is_ok = 1;
while (gf_list_count(iod->ESDescriptors)) {
esd = (GF_ESD*)gf_list_get(iod->ESDescriptors, 0);
gf_odf_desc_del((GF_Descriptor *) esd);
gf_list_rem(iod->ESDescriptors, 0);
}
/*get OD esd, and embbed stream data if possible*/
if (odT) {
esd = gf_isom_get_esd(file, odT, 1);
if (gf_isom_get_sample_count(file, odT)==1) {
samp = gf_isom_get_sample(file, odT, 1, &descIndex);
if (samp && gf_hinter_can_embbed_data(samp->data, samp->dataLength, GF_STREAM_OD)) {
InitSL_NULL(&slc);
slc.predefined = 0;
slc.hasRandomAccessUnitsOnlyFlag = 1;
slc.timeScale = slc.timestampResolution = gf_isom_get_media_timescale(file, odT);
slc.OCRResolution = 1000;
slc.startCTS = samp->DTS+samp->CTS_Offset;
slc.startDTS = samp->DTS;
//set the SL for future extraction
gf_isom_set_extraction_slc(file, odT, 1, &slc);
size64 = gf_base64_encode(samp->data, samp->dataLength, buf64, 2000);
buf64[size64] = 0;
sprintf(sdpLine, "data:application/mpeg4-od-au;base64,%s", buf64);
if (esd->decoderConfig) {
esd->decoderConfig->avgBitrate = 0;
esd->decoderConfig->bufferSizeDB = samp->dataLength;
esd->decoderConfig->maxBitrate = 0;
}
size64 = (u32) strlen(sdpLine)+1;
esd->URLString = (char*)gf_malloc(sizeof(char) * size64);
strcpy(esd->URLString, sdpLine);
} else {
GF_LOG(GF_LOG_WARNING, GF_LOG_RTP, ("[rtp hinter] OD sample too large to be embedded in IOD - ISMA disabled\n"));
is_ok = 0;
}
gf_isom_sample_del(&samp);
}
if (remove_ocr) esd->OCRESID = 0;
else if (esd->OCRESID == esd->ESID) esd->OCRESID = 0;
//OK, add this to our IOD
gf_list_add(iod->ESDescriptors, esd);
}
esd = gf_isom_get_esd(file, sceneT, 1);
if (gf_isom_get_sample_count(file, sceneT)==1) {
samp = gf_isom_get_sample(file, sceneT, 1, &descIndex);
if (samp && gf_hinter_can_embbed_data(samp->data, samp->dataLength, GF_STREAM_SCENE)) {
slc.timeScale = slc.timestampResolution = gf_isom_get_media_timescale(file, sceneT);
slc.OCRResolution = 1000;
slc.startCTS = samp->DTS+samp->CTS_Offset;
slc.startDTS = samp->DTS;
//set the SL for future extraction
gf_isom_set_extraction_slc(file, sceneT, 1, &slc);
//encode in Base64 the sample
size64 = gf_base64_encode(samp->data, samp->dataLength, buf64, 2000);
buf64[size64] = 0;
sprintf(sdpLine, "data:application/mpeg4-bifs-au;base64,%s", buf64);
if (esd->decoderConfig) {
esd->decoderConfig->avgBitrate = 0;
esd->decoderConfig->bufferSizeDB = samp->dataLength;
esd->decoderConfig->maxBitrate = 0;
}
esd->URLString = (char*)gf_malloc(sizeof(char) * (strlen(sdpLine)+1));
strcpy(esd->URLString, sdpLine);
} else {
GF_LOG(GF_LOG_ERROR, GF_LOG_RTP, ("[rtp hinter] Scene description sample too large to be embedded in IOD - ISMA disabled\n"));
is_ok = 0;
}
gf_isom_sample_del(&samp);
}
if (remove_ocr) esd->OCRESID = 0;
else if (esd->OCRESID == esd->ESID) esd->OCRESID = 0;
gf_list_add(iod->ESDescriptors, esd);
if (is_ok) {
u32 has_a, has_v, has_i_a, has_i_v;
has_a = has_v = has_i_a = has_i_v = 0;
for (i=0; i<gf_isom_get_track_count(file); i++) {
esd = gf_isom_get_esd(file, i+1, 1);
if (!esd) continue;
if (esd->decoderConfig) {
if (esd->decoderConfig->streamType==GF_STREAM_VISUAL) {
if (esd->decoderConfig->objectTypeIndication==GF_CODECID_MPEG4_PART2) has_i_v ++;
else has_v++;
} else if (esd->decoderConfig->streamType==GF_STREAM_AUDIO) {
if (esd->decoderConfig->objectTypeIndication==GF_CODECID_AAC_MPEG4) has_i_a ++;
else has_a++;
}
}
gf_odf_desc_del((GF_Descriptor *)esd);
}
/*only 1 MPEG-4 visual max and 1 MPEG-4 audio max for ISMA compliancy*/
if (!has_v && !has_a && (has_i_v<=1) && (has_i_a<=1)) {
sprintf(sdpLine, "a=isma-compliance:1,1.0,1");
gf_isom_sdp_add_line(file, sdpLine);
}
}
}
//encode the IOD
buffer = NULL;
size = 0;
gf_odf_desc_write((GF_Descriptor *) iod, &buffer, &size);
gf_odf_desc_del((GF_Descriptor *)iod);
//encode in Base64 the iod
size64 = gf_base64_encode(buffer, size, buf64, 2000);
buf64[size64] = 0;
gf_free(buffer);
sprintf(sdpLine, "a=mpeg4-iod:\"data:application/mpeg4-iod;base64,%s\"", buf64);
gf_isom_sdp_add_line(file, sdpLine);
return GF_OK;
} | 1143 | True | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.