Whamcloud - gitweb
debugfs: fix printing of xattrs with ea_in_inode values
[tools/e2fsprogs.git] / debugfs / util.c
index bd5de79..759bb39 100644 (file)
@@ -119,7 +119,7 @@ ext2_ino_t string_to_inode(char *str)
         */
        if ((len > 2) && (str[0] == '<') && (str[len-1] == '>')) {
                ino = strtoul(str+1, &end, 0);
-               if (*end=='>')
+               if (*end=='>' && (ino <= current_fs->super->s_inodes_count))
                        return ino;
        }
 
@@ -128,6 +128,11 @@ ext2_ino_t string_to_inode(char *str)
                com_err(str, retval, 0);
                return 0;
        }
+       if (ino > current_fs->super->s_inodes_count) {
+               com_err(str, 0, "resolves to an illegal inode number: %u\n",
+                       ino);
+               return 0;
+       }
        return ino;
 }
 
@@ -205,7 +210,7 @@ char *time_to_string(__s64 cl)
        const char      *tz;
 
        if (do_gmt == -1) {
-               /* The diet libc doesn't respect the TZ environemnt variable */
+               /* The diet libc doesn't respect the TZ environment variable */
                tz = ss_safe_getenv("TZ");
                if (!tz)
                        tz = "";
@@ -415,12 +420,12 @@ int common_block_args_process(int argc, char *argv[],
        return 0;
 }
 
-int debugfs_read_inode_full(ext2_ino_t ino, struct ext2_inode * inode,
-                       const char *cmd, int bufsize)
+int debugfs_read_inode2(ext2_ino_t ino, struct ext2_inode * inode,
+                       const char *cmd, int bufsize, int flags)
 {
        int retval;
 
-       retval = ext2fs_read_inode_full(current_fs, ino, inode, bufsize);
+       retval = ext2fs_read_inode2(current_fs, ino, inode, bufsize, flags);
        if (retval) {
                com_err(cmd, retval, "while reading inode %u", ino);
                return 1;
@@ -441,15 +446,14 @@ int debugfs_read_inode(ext2_ino_t ino, struct ext2_inode * inode,
        return 0;
 }
 
-int debugfs_write_inode_full(ext2_ino_t ino,
-                            struct ext2_inode *inode,
-                            const char *cmd,
-                            int bufsize)
+int debugfs_write_inode2(ext2_ino_t ino,
+                        struct ext2_inode *inode,
+                        const char *cmd,
+                        int bufsize, int flags)
 {
        int retval;
 
-       retval = ext2fs_write_inode_full(current_fs, ino,
-                                        inode, bufsize);
+       retval = ext2fs_write_inode2(current_fs, ino, inode, bufsize, flags);
        if (retval) {
                com_err(cmd, retval, "while writing inode %u", ino);
                return 1;