udf: Make udf_get_filename() return error instead of 0 length file name
authorFabian Frederick <fabf@skynet.be>
Wed, 8 Apr 2015 19:23:57 +0000 (21:23 +0200)
committerJan Kara <jack@suse.cz>
Mon, 18 May 2015 09:23:06 +0000 (11:23 +0200)
Zero length file name isn't really valid. So check the length of the
final file name generated by udf_translate_to_linux() and return -EINVAL
instead of zero length file name. Update caller of udf_get_filename() to
not check for 0 return value.

Signed-off-by: Fabian Frederick <fabf@skynet.be>
Signed-off-by: Jan Kara <jack@suse.cz>
fs/udf/dir.c
fs/udf/unicode.c

index fcf227e..541d9c6 100644 (file)
@@ -168,7 +168,7 @@ static int udf_readdir(struct file *file, struct dir_context *ctx)
                }
 
                flen = udf_get_filename(sb, nameptr, lfi, fname, UDF_NAME_LEN);
-               if (flen <= 0)
+               if (flen < 0)
                        continue;
 
                tloc = lelb_to_cpu(cfi.icb.extLocation);
index 97b23b0..ab478e6 100644 (file)
@@ -333,7 +333,7 @@ int udf_get_filename(struct super_block *sb, uint8_t *sname, int slen,
                     uint8_t *dname, int dlen)
 {
        struct ustr *filename, *unifilename;
-       int ret = 0;
+       int ret;
 
        if (!slen)
                return -EIO;
@@ -370,6 +370,9 @@ int udf_get_filename(struct super_block *sb, uint8_t *sname, int slen,
        ret = udf_translate_to_linux(dname, dlen,
                                     filename->u_name, filename->u_len,
                                     unifilename->u_name, unifilename->u_len);
+       /* Zero length filename isn't valid... */
+       if (ret == 0)
+               ret = -EINVAL;
 out2:
        kfree(unifilename);
 out1: