* Check if the variable name corresponds to its data type. * * @param s the EXRContext * @param value_name name of the variable to check * @param value_type type of the variable to check * @param minimum_length minimum length of the variable data * * @return bytes to read containing variable data * -1 if variable is not found * 0 if buffer ended premat
| 1570 | * 0 if buffer ended prematurely |
| 1571 | */ |
| 1572 | static int check_header_variable(EXRContext *s, |
| 1573 | const char *value_name, |
| 1574 | const char *value_type, |
| 1575 | unsigned int minimum_length) |
| 1576 | { |
| 1577 | GetByteContext *gb = &s->gb; |
| 1578 | int var_size = -1; |
| 1579 | |
| 1580 | if (bytestream2_get_bytes_left(gb) >= minimum_length && |
| 1581 | !strcmp(gb->buffer, value_name)) { |
| 1582 | // found value_name, jump to value_type (null terminated strings) |
| 1583 | gb->buffer += strlen(value_name) + 1; |
| 1584 | if (!strcmp(gb->buffer, value_type)) { |
| 1585 | gb->buffer += strlen(value_type) + 1; |
| 1586 | var_size = bytestream2_get_le32(gb); |
| 1587 | // don't go read past boundaries |
| 1588 | if (var_size > bytestream2_get_bytes_left(gb)) |
| 1589 | var_size = 0; |
| 1590 | } else { |
| 1591 | // value_type not found, reset the buffer |
| 1592 | gb->buffer -= strlen(value_name) + 1; |
| 1593 | av_log(s->avctx, AV_LOG_WARNING, |
| 1594 | "Unknown data type %s for header variable %s.\n", |
| 1595 | value_type, value_name); |
| 1596 | } |
| 1597 | } |
| 1598 | |
| 1599 | return var_size; |
| 1600 | } |
| 1601 | |
| 1602 | static int decode_header(EXRContext *s, AVFrame *frame) |
| 1603 | { |
no test coverage detected