summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bin/gensquashfs/filemap_xattr.c18
-rw-r--r--bin/gensquashfs/mkfs.h2
2 files changed, 11 insertions, 9 deletions
diff --git a/bin/gensquashfs/filemap_xattr.c b/bin/gensquashfs/filemap_xattr.c
index e5a16be..a6919b6 100644
--- a/bin/gensquashfs/filemap_xattr.c
+++ b/bin/gensquashfs/filemap_xattr.c
@@ -11,16 +11,17 @@
#define NEW_FILE_START "# file: "
// Taken from attr-2.5.1/tools/setfattr.c
-static char *
-decode(const char *value, size_t *size) {
- char *decoded = NULL;
+static sqfs_u8 *decode(const char *value, size_t *size)
+{
+ sqfs_u8 *decoded = NULL;
if (*size == 0)
- return strdup("");
+ return (sqfs_u8 *)strdup("");
+
if (value[0] == '0' && (value[1] == 'x' || value[1] == 'X')) {
*size = ((*size) - 2) / 2;
- decoded = realloc(decoded, *size);
+ decoded = calloc(1, (*size) + 1);
if (decoded == NULL) {
return NULL;
}
@@ -35,7 +36,7 @@ decode(const char *value, size_t *size) {
*size = (input_len / 4) * 3;
- decoded = realloc(decoded, *size);
+ decoded = calloc(1, (*size) + 1);
if (decoded == NULL) {
return NULL;
}
@@ -47,17 +48,18 @@ decode(const char *value, size_t *size) {
}
} else {
const char *v = value, *end = value + *size;
- char *d;
+ sqfs_u8 *d;
if (end > v + 1 && *v == '"' && *(end - 1) == '"') {
v++;
end--;
}
- decoded = realloc(decoded, *size);
+ decoded = calloc(1, (*size) + 1);
if (decoded == NULL) {
return NULL;
}
+
d = decoded;
while (v < end) {
diff --git a/bin/gensquashfs/mkfs.h b/bin/gensquashfs/mkfs.h
index 960a31c..33ba707 100644
--- a/bin/gensquashfs/mkfs.h
+++ b/bin/gensquashfs/mkfs.h
@@ -64,7 +64,7 @@ typedef struct {
struct XattrMapEntry {
char *key;
- char *value;
+ sqfs_u8 *value;
size_t value_len;
struct XattrMapEntry *next;
};