X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Fsymlink.c;h=3b8ed4351fc282c45b78262c1c2c59f14198fd5f;hb=35dd893208119869db6a90b1d1663f9aea88a3f7;hp=3773fb053012f63db8dee41ed0460fcfb9098895;hpb=c6127ff151b2963c5b90e4018f08f53051a97dfd;p=wimlib diff --git a/src/symlink.c b/src/symlink.c index 3773fb05..3b8ed435 100644 --- a/src/symlink.c +++ b/src/symlink.c @@ -10,16 +10,16 @@ * This file is part of wimlib, a library for working with WIM files. * * wimlib is free software; you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 2.1 of the License, or (at your option) + * terms of the GNU General Public License as published by the Free + * Software Foundation; either version 3 of the License, or (at your option) * any later version. * * wimlib is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * - * You should have received a copy of the GNU Lesser General Public License + * You should have received a copy of the GNU General Public License * along with wimlib; if not, see http://www.gnu.org/licenses/. */ @@ -80,7 +80,7 @@ static ssize_t get_symlink_name(const u8 *resource, size_t resource_len, } if (header_size + substitute_name_offset + substitute_name_len > resource_len) return -EIO; - link_target = utf16_to_utf8(p + substitute_name_offset, + link_target = utf16_to_utf8((const char *)p + substitute_name_offset, substitute_name_len, &link_target_len); @@ -135,20 +135,22 @@ void *make_symlink_reparse_data_buf(const char *symlink_target, size_t *len_ret) for (size_t i = 0; i < utf16_len / 2; i++) if (((u16*)name_utf16)[i] == to_le16('/')) ((u16*)name_utf16)[i] = to_le16('\\'); - size_t len = 12 + utf16_len * 2; + size_t len = 12 + utf16_len * 2 + 4; void *buf = MALLOC(len); if (!buf) goto out; /* XXX Fix absolute paths */ u8 *p = buf; - p = put_u16(p, utf16_len); /* Substitute name offset */ + p = put_u16(p, utf16_len + 2); /* Substitute name offset */ p = put_u16(p, utf16_len); /* Substitute name length */ p = put_u16(p, 0); /* Print name offset */ p = put_u16(p, utf16_len); /* Print name length */ p = put_u32(p, 1); - p = put_bytes(p, utf16_len, name_utf16); - p = put_bytes(p, utf16_len, name_utf16); + p = put_bytes(p, utf16_len, (const u8*)name_utf16); + p = put_u16(p, 0); + p = put_bytes(p, utf16_len, (const u8*)name_utf16); + p = put_u16(p, 0); /*DEBUG("utf16_len = %zu, len = %zu", utf16_len, len);*/ *len_ret = len; out: @@ -175,7 +177,7 @@ ssize_t dentry_readlink(const struct dentry *dentry, char *buf, size_t buf_len, if (wim_resource_size(lte) > 10000) return -EIO; - char res_buf[wim_resource_size(lte)]; + u8 res_buf[wim_resource_size(lte)]; ret = read_full_wim_resource(lte, res_buf); if (ret != 0) return -EIO;