Ignore:
Timestamp:
Jan 1, 2014, 12:47:38 AM (10 years ago)
Author:
Bruno Cornec
Message:
  • Update mindi-busybox to 1.21.1
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2/mindi-busybox/util-linux/volume_id/util.c

    r2725 r3232  
    3232        else
    3333            c = (buf[i] << 8) | buf[i+1];
    34         if (c == 0) {
    35             str[j] = '\0';
     34        if (c == 0)
    3635            break;
    37         } else if (c < 0x80) {
    38             if (j+1 >= len)
    39                 break;
    40             str[j++] = (uint8_t) c;
    41         } else if (c < 0x800) {
     36        if (j+1 >= len)
     37            break;
     38        if (c < 0x80) {
     39            /* 0xxxxxxx */
     40        } else {
     41            uint8_t topbits = 0xc0;
    4242            if (j+2 >= len)
    4343                break;
    44             str[j++] = (uint8_t) (0xc0 | (c >> 6));
    45             str[j++] = (uint8_t) (0x80 | (c & 0x3f));
    46         } else {
    47             if (j+3 >= len)
    48                 break;
    49             str[j++] = (uint8_t) (0xe0 | (c >> 12));
    50             str[j++] = (uint8_t) (0x80 | ((c >> 6) & 0x3f));
    51             str[j++] = (uint8_t) (0x80 | (c & 0x3f));
     44            if (c < 0x800) {
     45                /* 110yyyxx 10xxxxxx */
     46            } else {
     47                if (j+3 >= len)
     48                    break;
     49                /* 1110yyyy 10yyyyxx 10xxxxxx */
     50                str[j++] = (uint8_t) (0xe0 | (c >> 12));
     51                topbits = 0x80;
     52            }
     53            str[j++] = (uint8_t) (topbits | ((c >> 6) & 0x3f));
     54            c = 0x80 | (c & 0x3f);
    5255        }
     56        str[j++] = (uint8_t) c;
    5357    }
    5458    str[j] = '\0';
     
    126130void volume_id_set_label_unicode16(struct volume_id *id, const uint8_t *buf, enum endian endianess, size_t count)
    127131{
    128      volume_id_set_unicode16(id->label, sizeof(id->label), buf, endianess, count);
     132    volume_id_set_unicode16(id->label, sizeof(id->label), buf, endianess, count);
    129133}
    130134
     
    132136{
    133137    unsigned i;
    134     unsigned count = 0;
    135 
    136     switch (format) {
    137     case UUID_DOS:
    138         count = 4;
    139         break;
    140     case UUID_NTFS:
    141     case UUID_HFS:
    142         count = 8;
    143         break;
    144     case UUID_DCE:
    145         count = 16;
    146         break;
    147     case UUID_DCE_STRING:
    148         /* 36 is ok, id->uuid has one extra byte for NUL */
    149         count = VOLUME_ID_UUID_SIZE;
    150         break;
    151     }
     138    unsigned count = (format == UUID_DCE_STRING ? VOLUME_ID_UUID_SIZE : 4 << format);
     139
    152140//  memcpy(id->uuid_raw, buf, count);
    153141//  id->uuid_raw_len = count;
     
    169157            buf[7], buf[6], buf[5], buf[4],
    170158            buf[3], buf[2], buf[1], buf[0]);
    171         break;
    172     case UUID_HFS:
    173         sprintf(id->uuid, "%02X%02X%02X%02X%02X%02X%02X%02X",
    174             buf[0], buf[1], buf[2], buf[3],
    175             buf[4], buf[5], buf[6], buf[7]);
    176159        break;
    177160    case UUID_DCE:
Note: See TracChangeset for help on using the changeset viewer.