memcmp(is->escape_sequences, "%/C", 3) == 0||
memcmp(is->escape_sequences, "%/E", 3) == 0) {
dbg("Joliet extension found");
- volume_id_set_unicode16((char *)svd_label, sizeof(svd_label), is->volume_id, BE, 32);
+ volume_id_set_unicode16(svd_label, sizeof(svd_label), is->volume_id, BE, 32);
if (memcmp(id->label, svd_label, 16) == 0) {
dbg("SVD label is identical, use the possibly longer PVD one");
break;
return len;
}
-void volume_id_set_unicode16(char *str, size_t len, const uint8_t *buf, enum endian endianess, size_t count)
+size_t volume_id_set_unicode16(uint8_t *str, size_t len, const uint8_t *buf, enum endian endianess, size_t count)
{
- unsigned int i, j;
+ size_t i, j;
uint16_t c;
j = 0;
}
}
str[j] = '\0';
+ return j;
}
static char *usage_to_string(enum volume_id_usage usage_id)
void volume_id_set_label_raw(struct volume_id *id, const uint8_t *buf, size_t count)
{
+ if (count > sizeof(id->label))
+ count = sizeof(id->label);
+
memcpy(id->label_raw, buf, count);
id->label_raw_len = count;
}
void volume_id_set_label_string(struct volume_id *id, const uint8_t *buf, size_t count)
{
- unsigned int i;
+ size_t i;
+
+ if (count >= sizeof(id->label))
+ count = sizeof(id->label)-1;
memcpy(id->label, buf, count);
+ id->label[count] = '\0';
/* remove trailing whitespace */
i = strnlen(id->label, count);
void volume_id_set_label_unicode16(struct volume_id *id, const uint8_t *buf, enum endian endianess, size_t count)
{
- volume_id_set_unicode16(id->label, sizeof(id->label), buf, endianess, count);
+ if (count >= sizeof(id->label))
+ count = sizeof(id->label)-1;
+
+ volume_id_set_unicode16((uint8_t *)id->label, sizeof(id->label), buf, endianess, count);
}
void volume_id_set_uuid(struct volume_id *id, const uint8_t *buf, size_t len, enum uuid_format format)
};
extern int volume_id_utf8_encoded_valid_unichar(const char *str);
-extern void volume_id_set_unicode16(char *str, size_t len, const uint8_t *buf, enum endian endianess, size_t count);
+extern size_t volume_id_set_unicode16(uint8_t *str, size_t len, const uint8_t *buf, enum endian endianess, size_t count);
extern void volume_id_set_usage(struct volume_id *id, enum volume_id_usage usage_id);
extern void volume_id_set_label_raw(struct volume_id *id, const uint8_t *buf, size_t count);
extern void volume_id_set_label_string(struct volume_id *id, const uint8_t *buf, size_t count);