summaryrefslogtreecommitdiffstats
path: root/fs/ext4/ext4_common.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ext4/ext4_common.c')
-rw-r--r--fs/ext4/ext4_common.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
index cab5465b9d..727a2f753d 100644
--- a/fs/ext4/ext4_common.c
+++ b/fs/ext4/ext4_common.c
@@ -24,6 +24,7 @@
#include <ext4fs.h>
#include <inttypes.h>
#include <malloc.h>
+#include <memalign.h>
#include <stddef.h>
#include <linux/stat.h>
#include <linux/time.h>
@@ -614,8 +615,7 @@ static int parse_path(char **arr, char *dirname)
arr[i] = zalloc(strlen("/") + 1);
if (!arr[i])
return -ENOMEM;
-
- arr[i++] = "/";
+ memcpy(arr[i++], "/", strlen("/"));
/* add each path entry after root */
while (token != NULL) {
@@ -745,6 +745,11 @@ end:
fail:
free(depth_dirname);
free(parse_dirname);
+ for (i = 0; i < depth; i++) {
+ if (!ptr[i])
+ break;
+ free(ptr[i]);
+ }
free(ptr);
free(parent_inode);
free(first_inode);
@@ -765,6 +770,7 @@ static int check_filename(char *filename, unsigned int blknr)
struct ext2_dirent *previous_dir = NULL;
char *ptr = NULL;
struct ext_filesystem *fs = get_fs();
+ int ret = -1;
/* get the first block of root */
first_block_no_of_root = blknr;
@@ -818,12 +824,12 @@ static int check_filename(char *filename, unsigned int blknr)
if (ext4fs_put_metadata(root_first_block_addr,
first_block_no_of_root))
goto fail;
- return inodeno;
+ ret = inodeno;
}
fail:
free(root_first_block_buffer);
- return -1;
+ return ret;
}
int ext4fs_filename_check(char *filename)
@@ -2040,7 +2046,7 @@ static char *ext4fs_read_symlink(struct ext2fs_node *node)
status = ext4fs_read_file(diro, 0,
__le32_to_cpu(diro->inode.size),
symlink, &actread);
- if (status == 0) {
+ if ((status < 0) || (actread == 0)) {
free(symlink);
return 0;
}
OpenPOWER on IntegriCloud