Changeset 6d0e133 in mainline


Ignore:
Timestamp:
2025-04-14T08:30:07Z (4 days ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
master
Children:
6120b7b
Parents:
f5e1692
Message:

Improve handling of invalid data in str_decode()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • common/str.c

    rf5e1692 r6d0e133  
    226226        unsigned int b0_bits = 6 - cbytes;  /* Data bits in first byte */
    227227
    228         if (*offset + cbytes > size)
     228        if (cbytes < 0 || *offset + cbytes > size)
    229229                return U_SPECIAL;
    230230
     
    233233        /* Decode continuation bytes */
    234234        while (cbytes > 0) {
    235                 uint8_t b = (uint8_t) str[(*offset)++];
     235                uint8_t b = (uint8_t) str[*offset];
    236236
    237237                if (!_is_continuation_byte(b))
    238238                        return U_SPECIAL;
     239
     240                (*offset)++;
    239241
    240242                /* Shift data bits to ch */
Note: See TracChangeset for help on using the changeset viewer.