]> git.sur5r.net Git - u-boot/blobdiff - fs/ext4/ext4_common.c
tools: gen_eth_addr: add getpid() to time(0) to avoid duplicated seed
[u-boot] / fs / ext4 / ext4_common.c
index cab5465b9d4f9e99158dbdc8cd2f704e090c9b4b..727a2f753df391457010925aa237a46330b5cf5f 100644 (file)
@@ -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;
                }