- if (size == 0) {
- needed_size = 0;
- for (i = 0; i < inode->i_num_ads; i++)
- needed_size += inode->i_ads_entries[i].stream_name_utf8_len + 6;
- return needed_size;
- } else {
- p = list;
- for (i = 0; i < inode->i_num_ads; i++) {
- needed_size = inode->i_ads_entries[i].stream_name_utf8_len + 6;
- if (needed_size > size)
+ p = list;
+ for (i = 0; i < inode->i_num_ads; i++) {
+ mbchar *stream_name_mbs;
+ size_t stream_name_mbs_nbytes;
+ int ret;
+
+ ret = utf16le_to_mbs(inode->i_ads_entries[i].stream_name,
+ inode->i_ads_entries[i].stream_name_nbytes,
+ &stream_name_mbs,
+ &stream_name_mbs_nbytes);
+ if (ret) {
+ if (ret == WIMLIB_ERR_NOMEM)
+ return -ENOMEM;
+ else
+ return -EIO;
+ }
+
+ needed_size = stream_name_mbs_nbytes + 6;
+ if (!size_only) {
+ if (needed_size > size) {
+ FREE(stream_name_mbs);